index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div class="table-box">
  3. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listDataProcessApi">
  4. <!-- 表格 header 按钮 -->
  5. <template #tableHeader="scope">
  6. <el-button type="primary" v-auth="['task:dataProcess:add']" icon="CirclePlus" @click="openDialog(1, '算法数据处理新增')"> 新增 </el-button>
  7. <el-button type="primary" v-auth="['task:dataProcess:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
  8. <el-button type="primary" v-auth="['task:dataProcess:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
  9. <el-button
  10. type="danger"
  11. v-auth="['task:dataProcess:remove']"
  12. icon="Delete"
  13. plain
  14. :disabled="!scope.isSelected"
  15. @click="batchDelete(scope.selectedListIds)"
  16. >
  17. 批量删除
  18. </el-button>
  19. </template>
  20. <!-- 表格操作 -->
  21. <template #operation="scope">
  22. <el-button type="primary" link icon="View" v-auth="['task:dataProcess:query']" @click="openDialog(3, '算法数据处理查看', scope.row)">
  23. 查看
  24. </el-button>
  25. <el-button type="primary" link icon="EditPen" v-auth="['task:dataProcess:edit']" @click="openDialog(2, '算法数据处理编辑', scope.row)">
  26. 编辑
  27. </el-button>
  28. <el-button type="primary" link icon="Delete" v-auth="['task:dataProcess:remove']" @click="deleteDataProcess(scope.row)"> 删除 </el-button>
  29. </template>
  30. </ProTable>
  31. <FormDialog ref="formDialogRef" />
  32. <ImportExcel ref="dialogRef" />
  33. </div>
  34. </template>
  35. <script setup lang="tsx" name="DataProcess">
  36. import { ref, reactive } from 'vue'
  37. import { useHandleData } from '@/hooks/useHandleData'
  38. import { useDownload } from '@/hooks/useDownload'
  39. import { ElMessageBox } from 'element-plus'
  40. import ProTable from '@/components/ProTable/index.vue'
  41. import ImportExcel from '@/components/ImportExcel/index.vue'
  42. import FormDialog from '@/components/FormDialog/index.vue'
  43. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  44. import {
  45. listDataProcessApi,
  46. delDataProcessApi,
  47. addDataProcessApi,
  48. updateDataProcessApi,
  49. importTemplateApi,
  50. importDataProcessDataApi,
  51. exportDataProcessApi,
  52. getDataProcessApi
  53. } from '@/api/modules/task/dataProcess'
  54. // ProTable 实例
  55. const proTable = ref<ProTableInstance>()
  56. // 删除算法数据处理信息
  57. const deleteDataProcess = async (params: any) => {
  58. await useHandleData(delDataProcessApi, params.id, '删除【' + params.id + '】算法数据处理')
  59. proTable.value?.getTableList()
  60. }
  61. // 批量删除算法数据处理信息
  62. const batchDelete = async (ids: string[]) => {
  63. await useHandleData(delDataProcessApi, ids, '删除所选算法数据处理信息')
  64. proTable.value?.clearSelection()
  65. proTable.value?.getTableList()
  66. }
  67. // 导出算法数据处理列表
  68. const downloadFile = async () => {
  69. ElMessageBox.confirm('确认导出算法数据处理数据?', '温馨提示', { type: 'warning' }).then(() =>
  70. useDownload(exportDataProcessApi, '算法数据处理列表', proTable.value?.searchParam)
  71. )
  72. }
  73. // 批量添加算法数据处理
  74. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  75. const batchAdd = () => {
  76. const params = {
  77. title: '算法数据处理',
  78. tempApi: importTemplateApi,
  79. importApi: importDataProcessDataApi,
  80. getTableList: proTable.value?.getTableList
  81. }
  82. dialogRef.value?.acceptParams(params)
  83. }
  84. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  85. // 打开弹框的功能
  86. const openDialog = async (type: number, title: string, row?: any) => {
  87. let res = { data: {} }
  88. if (row?.id) {
  89. res = await getDataProcessApi(row?.id || null)
  90. }
  91. // 重置表单
  92. setItemsOptions()
  93. const params = {
  94. title,
  95. width: 580,
  96. isEdit: type !== 3,
  97. itemsOptions: itemsOptions,
  98. model: type == 1 ? {} : res.data,
  99. api: type == 1 ? addDataProcessApi : updateDataProcessApi,
  100. getTableList: proTable.value?.getTableList
  101. }
  102. formDialogRef.value?.openDialog(params)
  103. }
  104. // 表格配置项
  105. const columns = reactive<ColumnProps<any>[]>([
  106. { type: 'selection', fixed: 'left', width: 70 },
  107. { prop: 'id', label: '主键ID' },
  108. {
  109. prop: 'subTaskId',
  110. label: '子任务id',
  111. search: {
  112. el: 'input'
  113. },
  114. width: 120
  115. },
  116. {
  117. prop: 'name',
  118. label: '任务名称',
  119. search: {
  120. el: 'input'
  121. },
  122. width: 120
  123. },
  124. {
  125. prop: 'type',
  126. label: '任务类型',
  127. search: {
  128. el: 'input'
  129. },
  130. width: 120
  131. },
  132. {
  133. prop: 'status',
  134. label: '任务状态',
  135. search: {
  136. el: 'input'
  137. },
  138. width: 120
  139. },
  140. {
  141. prop: 'algorithmId',
  142. label: '算法',
  143. width: 120
  144. },
  145. {
  146. prop: 'parameters',
  147. label: '调用算法时所用的参数',
  148. width: 120
  149. },
  150. {
  151. prop: 'preprocessPath',
  152. label: '预处理数据路径',
  153. width: 120
  154. },
  155. {
  156. prop: 'resultPath',
  157. label: '结果数据路径',
  158. width: 120
  159. },
  160. {
  161. prop: 'startTime',
  162. label: '开始时间',
  163. width: 120
  164. },
  165. {
  166. prop: 'index',
  167. label: '序号',
  168. width: 120
  169. },
  170. {
  171. prop: 'endTime',
  172. label: '结束时间',
  173. width: 120
  174. },
  175. {
  176. prop: 'costSecond',
  177. label: '耗时',
  178. width: 120
  179. },
  180. {
  181. prop: 'log',
  182. label: '日志',
  183. width: 120
  184. },
  185. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  186. ])
  187. // 表单配置项
  188. let itemsOptions: ProForm.ItemsOptions[] = []
  189. const setItemsOptions = () => {
  190. itemsOptions = [
  191. {
  192. label: '子任务id',
  193. prop: 'subTaskId',
  194. compOptions: {
  195. placeholder: '请输入子任务id'
  196. }
  197. },
  198. {
  199. label: '任务名称',
  200. prop: 'name',
  201. compOptions: {
  202. placeholder: '请输入任务名称'
  203. }
  204. },
  205. {
  206. label: '任务类型',
  207. prop: 'type',
  208. compOptions: {
  209. placeholder: '请输入任务类型'
  210. }
  211. },
  212. {
  213. label: '任务状态',
  214. prop: 'status',
  215. compOptions: {
  216. placeholder: '请输入任务状态'
  217. }
  218. },
  219. {
  220. label: '算法',
  221. prop: 'algorithmId',
  222. compOptions: {
  223. placeholder: '请输入算法'
  224. }
  225. },
  226. {
  227. label: '调用算法时所用的参数',
  228. prop: 'parameters',
  229. compOptions: {
  230. type: 'textarea',
  231. clearable: true,
  232. placeholder: '请输入内容'
  233. }
  234. },
  235. {
  236. label: '预处理数据路径',
  237. prop: 'preprocessPath',
  238. compOptions: {
  239. placeholder: '请输入预处理数据路径'
  240. }
  241. },
  242. {
  243. label: '结果数据路径',
  244. prop: 'resultPath',
  245. compOptions: {
  246. placeholder: '请输入结果数据路径'
  247. }
  248. },
  249. {
  250. label: '开始时间',
  251. prop: 'startTime',
  252. compOptions: {
  253. elTagName: 'date-picker',
  254. type: 'date',
  255. placeholder: '请选择开始时间'
  256. }
  257. },
  258. {
  259. label: '序号',
  260. prop: 'index',
  261. compOptions: {
  262. placeholder: '请输入序号'
  263. }
  264. },
  265. {
  266. label: '结束时间',
  267. prop: 'endTime',
  268. compOptions: {
  269. elTagName: 'date-picker',
  270. type: 'date',
  271. placeholder: '请选择结束时间'
  272. }
  273. },
  274. {
  275. label: '耗时',
  276. prop: 'costSecond',
  277. compOptions: {
  278. placeholder: '请输入耗时'
  279. }
  280. },
  281. {
  282. label: '日志',
  283. prop: 'log',
  284. compOptions: {
  285. type: 'textarea',
  286. clearable: true,
  287. placeholder: '请输入内容'
  288. }
  289. }
  290. ]
  291. }
  292. </script>