index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div class="table-box">
  3. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listBizProcessApi">
  4. <!-- 表格 header 按钮 -->
  5. <template #tableHeader="scope">
  6. <el-button type="primary" v-auth="['task:bizProcess:add']" icon="CirclePlus" @click="openDialog(1, '算法业务处理新增')"> 新增 </el-button>
  7. <el-button type="primary" v-auth="['task:bizProcess:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
  8. <el-button type="primary" v-auth="['task:bizProcess:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
  9. <el-button
  10. type="danger"
  11. v-auth="['task:bizProcess: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:bizProcess:query']" @click="openDialog(3, '算法业务处理查看', scope.row)">
  23. 查看
  24. </el-button>
  25. <el-button type="primary" link icon="EditPen" v-auth="['task:bizProcess:edit']" @click="openDialog(2, '算法业务处理编辑', scope.row)">
  26. 编辑
  27. </el-button>
  28. <el-button type="primary" link icon="Delete" v-auth="['task:bizProcess:remove']" @click="deleteBizProcess(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="BizProcess">
  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. listBizProcessApi,
  46. delBizProcessApi,
  47. addBizProcessApi,
  48. updateBizProcessApi,
  49. importTemplateApi,
  50. importBizProcessDataApi,
  51. exportBizProcessApi,
  52. getBizProcessApi
  53. } from '@/api/modules/task/bizProcess'
  54. // ProTable 实例
  55. const proTable = ref<ProTableInstance>()
  56. // 删除算法业务处理信息
  57. const deleteBizProcess = async (params: any) => {
  58. await useHandleData(delBizProcessApi, params.id, '删除【' + params.id + '】算法业务处理')
  59. proTable.value?.getTableList()
  60. }
  61. // 批量删除算法业务处理信息
  62. const batchDelete = async (ids: string[]) => {
  63. await useHandleData(delBizProcessApi, ids, '删除所选算法业务处理信息')
  64. proTable.value?.clearSelection()
  65. proTable.value?.getTableList()
  66. }
  67. // 导出算法业务处理列表
  68. const downloadFile = async () => {
  69. ElMessageBox.confirm('确认导出算法业务处理数据?', '温馨提示', { type: 'warning' }).then(() =>
  70. useDownload(exportBizProcessApi, '算法业务处理列表', 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: importBizProcessDataApi,
  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 getBizProcessApi(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 ? addBizProcessApi : updateBizProcessApi,
  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: 'modelId',
  147. label: '模型',
  148. width: 120
  149. },
  150. {
  151. prop: 'parameters',
  152. label: '调用算法时所用的参数',
  153. width: 120
  154. },
  155. {
  156. prop: 'preprocessPath',
  157. label: '预处理数据路径',
  158. width: 120
  159. },
  160. {
  161. prop: 'resultPath',
  162. label: '结果数据路径',
  163. width: 120
  164. },
  165. {
  166. prop: 'index',
  167. label: '序号',
  168. width: 120
  169. },
  170. {
  171. prop: 'startTime',
  172. label: '开始时间',
  173. width: 120
  174. },
  175. {
  176. prop: 'endTime',
  177. label: '结束时间',
  178. width: 120
  179. },
  180. {
  181. prop: 'costSecond',
  182. label: '耗时',
  183. width: 120
  184. },
  185. {
  186. prop: 'log',
  187. label: '日志',
  188. width: 120
  189. },
  190. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  191. ])
  192. // 表单配置项
  193. let itemsOptions: ProForm.ItemsOptions[] = []
  194. const setItemsOptions = () => {
  195. itemsOptions = [
  196. {
  197. label: '子任务id',
  198. prop: 'subTaskId',
  199. compOptions: {
  200. placeholder: '请输入子任务id'
  201. }
  202. },
  203. {
  204. label: '任务名称',
  205. prop: 'name',
  206. compOptions: {
  207. placeholder: '请输入任务名称'
  208. }
  209. },
  210. {
  211. label: '任务类型',
  212. prop: 'type',
  213. compOptions: {
  214. placeholder: '请输入任务类型'
  215. }
  216. },
  217. {
  218. label: '任务状态',
  219. prop: 'status',
  220. compOptions: {
  221. placeholder: '请输入任务状态'
  222. }
  223. },
  224. {
  225. label: '算法',
  226. prop: 'algorithmId',
  227. compOptions: {
  228. placeholder: '请输入算法'
  229. }
  230. },
  231. {
  232. label: '模型',
  233. prop: 'modelId',
  234. compOptions: {
  235. placeholder: '请输入模型'
  236. }
  237. },
  238. {
  239. label: '调用算法时所用的参数',
  240. prop: 'parameters',
  241. compOptions: {
  242. type: 'textarea',
  243. clearable: true,
  244. placeholder: '请输入内容'
  245. }
  246. },
  247. {
  248. label: '预处理数据路径',
  249. prop: 'preprocessPath',
  250. compOptions: {
  251. placeholder: '请输入预处理数据路径'
  252. }
  253. },
  254. {
  255. label: '结果数据路径',
  256. prop: 'resultPath',
  257. compOptions: {
  258. placeholder: '请输入结果数据路径'
  259. }
  260. },
  261. {
  262. label: '序号',
  263. prop: 'index',
  264. compOptions: {
  265. placeholder: '请输入序号'
  266. }
  267. },
  268. {
  269. label: '开始时间',
  270. prop: 'startTime',
  271. compOptions: {
  272. elTagName: 'date-picker',
  273. type: 'date',
  274. placeholder: '请选择开始时间'
  275. }
  276. },
  277. {
  278. label: '结束时间',
  279. prop: 'endTime',
  280. compOptions: {
  281. elTagName: 'date-picker',
  282. type: 'date',
  283. placeholder: '请选择结束时间'
  284. }
  285. },
  286. {
  287. label: '耗时',
  288. prop: 'costSecond',
  289. compOptions: {
  290. placeholder: '请输入耗时'
  291. }
  292. },
  293. {
  294. label: '日志',
  295. prop: 'log',
  296. compOptions: {
  297. type: 'textarea',
  298. clearable: true,
  299. placeholder: '请输入内容'
  300. }
  301. }
  302. ]
  303. }
  304. </script>