index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div class="table-box">
  3. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listAlgorithmConfigTrackApi">
  4. <!-- 表格 header 按钮 -->
  5. <template #tableHeader="scope">
  6. <el-button type="primary" v-auth="['demo:AlgorithmConfigTrack:add']" icon="CirclePlus" @click="openDialog(1, '算法任务配置新增')">
  7. 新增
  8. </el-button>
  9. <el-button type="primary" v-auth="['demo:AlgorithmConfigTrack:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
  10. <el-button type="primary" v-auth="['demo:AlgorithmConfigTrack:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
  11. <el-button
  12. type="danger"
  13. v-auth="['demo:AlgorithmConfigTrack:remove']"
  14. icon="Delete"
  15. plain
  16. :disabled="!scope.isSelected"
  17. @click="batchDelete(scope.selectedListIds)"
  18. >
  19. 批量删除
  20. </el-button>
  21. </template>
  22. <!-- 表格操作 -->
  23. <template #operation="scope">
  24. <el-button type="primary" link icon="View" v-auth="['demo:AlgorithmConfigTrack:query']" @click="openDialog(3, '算法任务配置查看', scope.row)">
  25. 查看
  26. </el-button>
  27. <el-button
  28. type="primary"
  29. link
  30. icon="EditPen"
  31. v-auth="['demo:AlgorithmConfigTrack:edit']"
  32. @click="openDialog(2, '算法任务配置编辑', scope.row)"
  33. >
  34. 编辑
  35. </el-button>
  36. <el-button type="primary" link icon="Delete" v-auth="['demo:AlgorithmConfigTrack:remove']" @click="deleteAlgorithmConfigTrack(scope.row)">
  37. 删除
  38. </el-button>
  39. </template>
  40. </ProTable>
  41. <FormDialog ref="formDialogRef" />
  42. <ImportExcel ref="dialogRef" />
  43. </div>
  44. </template>
  45. <script setup lang="tsx" name="AlgorithmConfigTrack">
  46. import { ref, reactive } from 'vue'
  47. import { useHandleData } from '@/hooks/useHandleData'
  48. import { useDownload } from '@/hooks/useDownload'
  49. import { ElMessageBox } from 'element-plus'
  50. import ProTable from '@/components/ProTable/index.vue'
  51. import ImportExcel from '@/components/ImportExcel/index.vue'
  52. import FormDialog from '@/components/FormDialog/index.vue'
  53. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  54. import {
  55. listAlgorithmConfigTrackApi,
  56. delAlgorithmConfigTrackApi,
  57. addAlgorithmConfigTrackApi,
  58. updateAlgorithmConfigTrackApi,
  59. importTemplateApi,
  60. importAlgorithmConfigTrackDataApi,
  61. exportAlgorithmConfigTrackApi,
  62. getAlgorithmConfigTrackApi
  63. } from '@/api/modules/demo/AlgorithmConfigTrack'
  64. // ProTable 实例
  65. const proTable = ref<ProTableInstance>()
  66. // 删除算法任务配置信息
  67. const deleteAlgorithmConfigTrack = async (params: any) => {
  68. await useHandleData(delAlgorithmConfigTrackApi, params.id, '删除【' + params.id + '】算法任务配置')
  69. proTable.value?.getTableList()
  70. }
  71. // 批量删除算法任务配置信息
  72. const batchDelete = async (ids: string[]) => {
  73. await useHandleData(delAlgorithmConfigTrackApi, ids, '删除所选算法任务配置信息')
  74. proTable.value?.clearSelection()
  75. proTable.value?.getTableList()
  76. }
  77. // 导出算法任务配置列表
  78. const downloadFile = async () => {
  79. ElMessageBox.confirm('确认导出算法任务配置数据?', '温馨提示', { type: 'warning' }).then(() =>
  80. useDownload(exportAlgorithmConfigTrackApi, '算法任务配置列表', proTable.value?.searchParam)
  81. )
  82. }
  83. // 批量添加算法任务配置
  84. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  85. const batchAdd = () => {
  86. const params = {
  87. title: '算法任务配置',
  88. tempApi: importTemplateApi,
  89. importApi: importAlgorithmConfigTrackDataApi,
  90. getTableList: proTable.value?.getTableList
  91. }
  92. dialogRef.value?.acceptParams(params)
  93. }
  94. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  95. // 打开弹框的功能
  96. const openDialog = async (type: number, title: string, row?: any) => {
  97. let res = { data: {} }
  98. if (row?.id) {
  99. res = await getAlgorithmConfigTrackApi(row?.id || null)
  100. }
  101. // 重置表单
  102. setItemsOptions()
  103. const params = {
  104. title,
  105. width: 580,
  106. isEdit: type !== 3,
  107. itemsOptions: itemsOptions,
  108. model: type == 1 ? {} : res.data,
  109. api: type == 1 ? addAlgorithmConfigTrackApi : updateAlgorithmConfigTrackApi,
  110. getTableList: proTable.value?.getTableList
  111. }
  112. formDialogRef.value?.openDialog(params)
  113. }
  114. // 表格配置项
  115. const columns = reactive<ColumnProps<any>[]>([
  116. { type: 'selection', fixed: 'left', width: 70 },
  117. { prop: 'id', label: '主键ID' },
  118. // {
  119. // prop: 'type',
  120. // label: '类型',
  121. // search: {
  122. // el: 'input'
  123. // },
  124. // width: 120
  125. // },
  126. // {
  127. // prop: 'parentId',
  128. // label: '父id',
  129. // search: {
  130. // el: 'input'
  131. // },
  132. // width: 120
  133. // },
  134. // {
  135. // prop: 'subsystem',
  136. // label: '分系统',
  137. // search: {
  138. // el: 'input'
  139. // },
  140. // width: 120
  141. // },
  142. {
  143. prop: 'algorithmName',
  144. label: '算法名称',
  145. search: {
  146. el: 'input'
  147. }
  148. },
  149. {
  150. prop: 'algorithmAddress',
  151. label: '算法地址',
  152. search: {
  153. el: 'input'
  154. }
  155. },
  156. {
  157. prop: 'parameterConfig',
  158. label: '参数配置',
  159. search: {
  160. el: 'input'
  161. }
  162. },
  163. {
  164. prop: 'remarks',
  165. label: '备注',
  166. search: {
  167. el: 'input'
  168. }
  169. },
  170. // {
  171. // prop: 'system',
  172. // label: '系统',
  173. // search: {
  174. // el: 'input'
  175. // }
  176. // },
  177. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  178. ])
  179. // 表单配置项
  180. let itemsOptions: ProForm.ItemsOptions[] = []
  181. const setItemsOptions = () => {
  182. itemsOptions = [
  183. // {
  184. // label: '类型',
  185. // prop: 'type',
  186. // rules: [{ required: true, message: '类型不能为空', trigger: 'blur' }],
  187. // compOptions: {
  188. // placeholder: '请输入类型'
  189. // }
  190. // },
  191. // {
  192. // label: '父id',
  193. // prop: 'parentId',
  194. // rules: [{ required: true, message: '父id不能为空', trigger: 'blur' }],
  195. // compOptions: {
  196. // placeholder: '请输入父id'
  197. // }
  198. // },
  199. // {
  200. // label: '分系统',
  201. // prop: 'subsystem',
  202. // rules: [{ required: true, message: '分系统不能为空', trigger: 'blur' }],
  203. // compOptions: {
  204. // placeholder: '请输入分系统'
  205. // }
  206. // },
  207. {
  208. label: '算法名称',
  209. prop: 'algorithmName',
  210. rules: [{ required: true, message: '算法名称不能为空', trigger: 'blur' }],
  211. compOptions: {
  212. placeholder: '请输入算法名称'
  213. }
  214. },
  215. {
  216. label: '算法地址',
  217. prop: 'algorithmAddress',
  218. rules: [{ required: true, message: '算法地址不能为空', trigger: 'blur' }],
  219. compOptions: {
  220. placeholder: '请输入算法地址'
  221. }
  222. },
  223. {
  224. label: '参数配置',
  225. prop: 'parameterConfig',
  226. rules: [{ required: true, message: '参数配置不能为空', trigger: 'blur' }],
  227. compOptions: {
  228. type: 'textarea',
  229. clearable: true,
  230. placeholder: '请输入内容'
  231. }
  232. },
  233. {
  234. label: '备注',
  235. prop: 'remarks',
  236. rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
  237. compOptions: {
  238. placeholder: '请输入备注'
  239. }
  240. }
  241. // {
  242. // label: '系统',
  243. // prop: 'system',
  244. // rules: [{ required: true, message: '系统不能为空', trigger: 'blur' }],
  245. // compOptions: {
  246. // placeholder: '请输入系统'
  247. // }
  248. // }
  249. ]
  250. }
  251. </script>