ReportModule.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div>
  3. <div class="bigBox">
  4. <div class="settingBox">
  5. <h1 style="font-size: 18px;">报告模板管理</h1>
  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 style="font-size: 14px;margin: 0 10px;">模板名称</span>
  17. <el-input style="width: 260px;" v-model="moduleName" placeholder="请输入模板名称"></el-input>
  18. </div>
  19. <div class="litBox">
  20. <span style="font-size: 14px;margin: 0 10px;">状态</span>
  21. <el-select v-model="stateValue" @change="stateChange" class="m-2" placeholder="选择状态" size="default"
  22. style="width: 240px">
  23. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
  24. </el-select>
  25. <!-- <el-date-picker v-model="getTime" @change="timeChange" type="datetimerange" start-placeholder="开始时间"
  26. end-placeholder="结束时间" format="YYYY-MM-DD HH:mm:ss" date-format="YYYY/MM/DD ddd"
  27. time-format="A hh:mm:ss" /> -->
  28. </div>
  29. <div class="litBox">
  30. <el-button type="primary" plain @click="search"><el-icon>
  31. <Search />
  32. </el-icon>查询</el-button>
  33. <el-button @click="searchReport"><el-icon>
  34. <RefreshLeft />
  35. </el-icon>重置</el-button>
  36. </div>
  37. </div>
  38. <div class="tableBox">
  39. <el-table ref="multipleTableRef" :data="reportList" style="width: 100%;height: calc(100vh - 260px);"
  40. @selection-change="handleSelectionChange">
  41. <el-table-column type="selection" width="55" />
  42. <el-table-column label="编号" width="auto">
  43. <template #default="scope">
  44. {{ scope.$index + 1 }}
  45. </template>
  46. </el-table-column>
  47. <el-table-column property="name" label="模板名称" width="auto" show-overflow-tooltip />
  48. <el-table-column property="memo" label="模板描述" width="auto" show-overflow-tooltip />
  49. <el-table-column property="ct" label="上传时间" width="auto" show-overflow-tooltip />
  50. <el-table-column property="state" label="状态" width="auto" show-overflow-tooltip>
  51. <template #default="scope">
  52. <span>{{ reState(scope.row.state) }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column fixed="right" label="操作" width="180">
  56. <template #default="scope">
  57. <el-button link type="primary" size="small" @click="openAdd(1, scope.row)">
  58. <el-icon>
  59. <EditPen />
  60. </el-icon>编辑</el-button>
  61. <el-button link type="primary" size="small" @click="downFile(scope.row)">
  62. <el-icon>
  63. <Download />
  64. </el-icon>下载</el-button>
  65. <el-button style="color: red;" link type="primary" size="small" @click="openDel(scope.row)">
  66. <el-icon style="color: red;">
  67. <Delete />
  68. </el-icon>删除</el-button>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. </div>
  73. </div>
  74. <div class="pageBox">
  75. <Pagination :tLength="totals"></Pagination>
  76. </div>
  77. <div class="modalBox">
  78. <Addrm v-if="addModal" :addModal="addModal" :addOrEdit="addOrEdit" :editRow="editRow"
  79. :searchReport="searchReport" @armBack="armBack">
  80. </Addrm>
  81. <Delrm v-if="delModal" :delModal="delModal" :delId="delId" :searchReport="searchReport"
  82. @delrmBack="delrmBack"></Delrm>
  83. </div>
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import { ref, onMounted, toRefs } from 'vue'
  89. import report from '@/api/report';
  90. import system from '@/api/system';
  91. import moment from 'moment';
  92. import Addrm from '../modalComp/Addrm.vue'
  93. import Delrm from '../modalComp/Delrm.vue'
  94. import Pagination from './Pagination.vue';
  95. import { ElMessage } from 'element-plus';
  96. export default {
  97. setup() {
  98. let reportList = ref([])//报告模板列表
  99. let moduleName = ref('')//搜索报告模型
  100. let getTime = ref("")//选择的时间范围
  101. let addModal = ref(false)//新增,修改的模态框状态
  102. let delModal = ref(false)//删除确认模态框状态
  103. let pages = ref(0)//页数
  104. let sizes = ref(0)//条数
  105. let totals = ref(0)//总条数
  106. let addOrEdit = ref(0)//0为新增,1为修改
  107. let editRow = ref({})//需要回显的对象
  108. let delId = ref('')//需要删除的id
  109. let options = ref([
  110. {
  111. label: "全部",
  112. value: '',
  113. },
  114. {
  115. label: "启用",
  116. value: 1,
  117. },
  118. {
  119. label: "禁用",
  120. value: 2
  121. }
  122. ])
  123. let stateValue = ref("")
  124. function searchReport() {//查询所有报告模板
  125. report.getReport({ pageno: 1, pagesize: 20 }).then(res => {
  126. if (res.data != null && res.code == 0) {
  127. reportList.value = res.data
  128. totals.value = res.count
  129. stateValue.value = ''//清空选择器
  130. moduleName.value = ''//清空名称
  131. } else {
  132. ElMessage({
  133. message: res.msg,
  134. type: "error"
  135. })
  136. }
  137. })
  138. }
  139. function handleSelectionChange(val) {//表格多选事件
  140. console.log(val, 'val');
  141. }
  142. function timeChange(e) {//时间选择器change事件
  143. let a = moment(e[0]).format("YYYY-MM-DD HH:mm:ss")//开始时间
  144. let b = moment(e[1]).format("YYYY-MM-DD HH:mm:ss")//结束时间
  145. }
  146. function search() {
  147. report.getReport({
  148. name: moduleName?.value,
  149. state: stateValue?.value - 0,
  150. }).then(res => {
  151. if (res.code == 0 && res.data != null) {
  152. reportList.value = res.data
  153. } else if (res.code == 0 && res.data == null) {
  154. console.log('进入了为查询');
  155. ElMessage({
  156. message: "未查询到数据",
  157. type: "info"
  158. })
  159. } else if (res.code == 1) {
  160. console.log("进入了错误");
  161. ElMessage({
  162. message: res.msg,
  163. type: "error"
  164. })
  165. }
  166. })
  167. }
  168. // 下载数据
  169. function downFile(row) {
  170. system.downLoad({
  171. ids: row.doc_id - 0
  172. }).then(res => {
  173. if (res.code == 0) {
  174. ElMessage({
  175. message: "正在下载",
  176. type: "success",
  177. duration: 1000
  178. })
  179. const la = window.location.hostname
  180. let result = la + ':8080' + res.data
  181. console.log(result, 'result');
  182. }
  183. })
  184. }
  185. function stateChange(e) {
  186. stateValue.value = e
  187. }
  188. function reState(num) {
  189. if (num == 1) {
  190. return '已启用'
  191. } else if (num == 2) {
  192. return '已禁用'
  193. }
  194. }
  195. function openAdd(num, row) {//打开,新增编辑模态框
  196. addOrEdit.value = num
  197. editRow.value = row
  198. addModal.value = true
  199. }
  200. function openDel(row) {
  201. delModal.value = true
  202. delId.value = row.id
  203. }
  204. function armBack(data) {//新增编辑模态框返回数据
  205. addModal.value = data
  206. }
  207. function delrmBack(data) {
  208. delModal.value = data
  209. }
  210. onMounted(() => {
  211. searchReport()
  212. })
  213. return {
  214. reportList,//报告模板列表
  215. searchReport,//查询所有报告模板
  216. moduleName,//搜索报告模板
  217. getTime,//时间选择器
  218. timeChange,//时间选择器change事件
  219. handleSelectionChange,//表格多选事件
  220. addModal,//新增,修改的模态框状态
  221. delModal,//删除确认模态框状态
  222. pages,
  223. sizes,
  224. totals,
  225. armBack,//新增编辑模态框返回数据
  226. openAdd,//打开新增编辑模态框
  227. addOrEdit,//0新增,1修改
  228. editRow,//需要回显的对象
  229. openDel,//打开删除模态框
  230. delId,//需要删除的id
  231. delrmBack,//delrm.vue返回模态框状态
  232. search,//查询列表
  233. options,//选择
  234. stateValue,//选择状态value
  235. stateChange,//选择器change事件
  236. reState,//表格筛选状态
  237. downFile,//下载报告模板
  238. }
  239. },
  240. components: {
  241. Addrm,
  242. Delrm,
  243. Pagination,
  244. }
  245. }
  246. </script>
  247. <style scoped>
  248. .bigBox {
  249. width: 98%;
  250. height: 100%;
  251. margin-left: 15px;
  252. }
  253. .settingBox {
  254. text-align: center;
  255. }
  256. .moduleBox {
  257. display: flex;
  258. justify-content: flex-start;
  259. align-items: center;
  260. }
  261. .litBox {
  262. margin-right: 5px;
  263. }
  264. </style>