ReportModule.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <div>
  3. <div class="bigBox">
  4. <div class="settingBox">
  5. <h2>报告模板管理</h2>
  6. </div>
  7. <div>
  8. <div class="moduleBox">
  9. <div class="litBox">
  10. <el-button type="primary" plain @click="openAdd(0)">
  11. <el-icon>
  12. <Plus />
  13. </el-icon>新建报告模板</el-button>
  14. </div>
  15. <div class="litBox">
  16. <span>模板名称</span>
  17. <el-input style="width: 260px;" v-model="moduleName" placeholder="请输入模板名称"></el-input>
  18. </div>
  19. <div class="litBox">
  20. <span>日期范围</span>
  21. <el-date-picker v-model="getTime" @change="timeChange" type="datetimerange" start-placeholder="开始时间"
  22. end-placeholder="结束时间" format="YYYY-MM-DD HH:mm:ss" date-format="YYYY/MM/DD ddd"
  23. time-format="A hh:mm:ss" />
  24. </div>
  25. <div class="litBox">
  26. <el-button type="primary" plain><el-icon>
  27. <Search />
  28. </el-icon>查询</el-button>
  29. <el-button @click="searchReport"><el-icon>
  30. <RefreshLeft />
  31. </el-icon>重置</el-button>
  32. </div>
  33. </div>
  34. <div class="tableBox">
  35. <el-table ref="multipleTableRef" :data="reportList" style="width: 100%;height: calc(100vh - 240px);"
  36. @selection-change="handleSelectionChange">
  37. <el-table-column type="selection" width="55" />
  38. <el-table-column label="编号" width="auto">
  39. <template #default="scope">
  40. {{ scope.$index + 1 }}
  41. </template>
  42. </el-table-column>
  43. <el-table-column property="name" label="模板名称" width="auto" show-overflow-tooltip />
  44. <el-table-column property="memo" label="模板描述" width="auto" show-overflow-tooltip />
  45. <el-table-column property="ct" label="上传时间" width="auto" show-overflow-tooltip />
  46. <el-table-column fixed="right" label="操作" width="180">
  47. <template #default="scope">
  48. <el-button link type="primary" size="small" @click="openAdd(1, scope.row)">
  49. <el-icon>
  50. <EditPen />
  51. </el-icon>编辑</el-button>
  52. <el-button link type="primary" size="small">
  53. <el-icon>
  54. <Download />
  55. </el-icon>下载</el-button>
  56. <el-button style="color: red;" link type="primary" size="small" @click="openDel(scope.row)">
  57. <el-icon style="color: red;">
  58. <Delete />
  59. </el-icon>删除</el-button>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. </div>
  64. </div>
  65. <div class="pageBox">
  66. <Pagination :tLength="totals"></Pagination>
  67. </div>
  68. <div class="modalBox">
  69. <Addrm v-if="addModal" :addModal="addModal" :addOrEdit="addOrEdit" :editRow="editRow" :searchReport="searchReport" @armBack="armBack">
  70. </Addrm>
  71. <Delrm v-if="delModal" :delModal="delModal" :delId="delId" :searchReport="searchReport" @delrmBack="delrmBack"></Delrm>
  72. </div>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import { ref, onMounted, toRefs } from 'vue'
  78. import report from '@/api/report';
  79. import moment from 'moment';
  80. import Addrm from '../modalComp/Addrm.vue'
  81. import Delrm from '../modalComp/Delrm.vue'
  82. import Pagination from './Pagination.vue';
  83. export default {
  84. setup() {
  85. let reportList = ref([])//报告模板列表
  86. let moduleName = ref('')//搜索报告模型
  87. let getTime = ref("")//选择的时间范围
  88. let addModal = ref(false)//新增,修改的模态框状态
  89. let delModal = ref(false)//删除确认模态框状态
  90. let pages = ref(0)//页数
  91. let sizes = ref(0)//条数
  92. let totals = ref(0)//总条数
  93. let addOrEdit = ref(0)//0为新增,1为修改
  94. let editRow = ref({})//需要回显的对象
  95. let delId = ref('')//需要删除的id
  96. function searchReport() {//查询所有报告模板
  97. report.getReport({ pageno: 1, pagesize: 20 }).then(res => {
  98. console.log(res, 'sss');
  99. reportList.value = res.data
  100. totals.value = res.count
  101. })
  102. }
  103. function handleSelectionChange(val) {//表格多选事件
  104. console.log(val, 'val');
  105. }
  106. function timeChange(e) {//时间选择器change事件
  107. let a = moment(e[0]).format("YYYY-MM-DD HH:mm:ss")//开始时间
  108. let b = moment(e[1]).format("YYYY-MM-DD HH:mm:ss")//结束时间
  109. }
  110. function openAdd(num, row) {//打开,新增编辑模态框
  111. addOrEdit.value = num
  112. editRow.value = row
  113. addModal.value = true
  114. }
  115. function openDel(row) {
  116. delModal.value = true
  117. delId.value = row.id
  118. }
  119. function armBack(data) {//新增编辑模态框返回数据
  120. addModal.value = data
  121. }
  122. function delrmBack(data) {
  123. delModal.value = data
  124. }
  125. onMounted(() => {
  126. searchReport()
  127. })
  128. return {
  129. reportList,//报告模板列表
  130. searchReport,//查询所有报告模板
  131. moduleName,//搜索报告模板
  132. getTime,//时间选择器
  133. timeChange,//时间选择器change事件
  134. handleSelectionChange,//表格多选事件
  135. addModal,//新增,修改的模态框状态
  136. delModal,//删除确认模态框状态
  137. pages,
  138. sizes,
  139. totals,
  140. armBack,//新增编辑模态框返回数据
  141. openAdd,//打开新增编辑模态框
  142. addOrEdit,//0新增,1修改
  143. editRow,//需要回显的对象
  144. openDel,//打开删除模态框
  145. delId,//需要删除的id
  146. delrmBack,//delrm.vue返回模态框状态
  147. }
  148. },
  149. components: {
  150. Addrm,
  151. Delrm,
  152. Pagination,
  153. }
  154. }
  155. </script>
  156. <style scoped>
  157. .bigBox {
  158. width: 98%;
  159. height: 100%;
  160. margin-left: 15px;
  161. }
  162. .settingBox {
  163. text-align: center;
  164. }
  165. .moduleBox {
  166. display: flex;
  167. justify-content: flex-start;
  168. align-items: center;
  169. }
  170. .litBox {
  171. margin-right: 5px;
  172. }
  173. </style>