index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. import {enumsAlgorithmType, enumsSubSystem} from "@/views/demo/utils";
  65. // ProTable 实例
  66. const proTable = ref<ProTableInstance>()
  67. // 删除算法任务配置信息
  68. const deleteAlgorithmConfigTrack = async (params: any) => {
  69. await useHandleData(delAlgorithmConfigTrackApi, params.id, '删除【' + params.id + '】算法任务配置')
  70. proTable.value?.getTableList()
  71. }
  72. // 批量删除算法任务配置信息
  73. const batchDelete = async (ids: string[]) => {
  74. await useHandleData(delAlgorithmConfigTrackApi, ids, '删除所选算法任务配置信息')
  75. proTable.value?.clearSelection()
  76. proTable.value?.getTableList()
  77. }
  78. // 导出算法任务配置列表
  79. const downloadFile = async () => {
  80. ElMessageBox.confirm('确认导出算法任务配置数据?', '温馨提示', { type: 'warning' }).then(() =>
  81. useDownload(exportAlgorithmConfigTrackApi, '算法任务配置列表', proTable.value?.searchParam)
  82. )
  83. }
  84. // 批量添加算法任务配置
  85. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  86. const batchAdd = () => {
  87. const params = {
  88. title: '算法任务配置',
  89. tempApi: importTemplateApi,
  90. importApi: importAlgorithmConfigTrackDataApi,
  91. getTableList: proTable.value?.getTableList
  92. }
  93. dialogRef.value?.acceptParams(params)
  94. }
  95. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  96. // 打开弹框的功能
  97. const openDialog = async (type: number, title: string, row?: any) => {
  98. let res = { data: {} }
  99. if (row?.id) {
  100. res = await getAlgorithmConfigTrackApi(row?.id || null)
  101. }
  102. // 重置表单
  103. setItemsOptions()
  104. const params = {
  105. title,
  106. width: 580,
  107. isEdit: type !== 3,
  108. itemsOptions: itemsOptions,
  109. model: type == 1 ? {} : res.data,
  110. api: type == 1 ? addAlgorithmConfigTrackApi : updateAlgorithmConfigTrackApi,
  111. getTableList: proTable.value?.getTableList
  112. }
  113. formDialogRef.value?.openDialog(params)
  114. }
  115. // 表格配置项
  116. const columns = reactive<ColumnProps<any>[]>([
  117. { type: 'selection', fixed: 'left', width: 70 },
  118. { prop: 'id', label: '主键ID' },
  119. {
  120. prop: 'type',
  121. label: '类型',
  122. tag: true,
  123. enum: enumsAlgorithmType,
  124. search: {
  125. el: 'select'
  126. },
  127. width: 120
  128. },
  129. // {
  130. // prop: 'parentId',
  131. // label: '父id',
  132. // search: {
  133. // el: 'input'
  134. // },
  135. // width: 120
  136. // },
  137. {
  138. prop: 'subsystem',
  139. label: '分系统',
  140. tag: true,
  141. enum: enumsSubSystem,
  142. search: {
  143. el: 'input'
  144. },
  145. width: 120
  146. },
  147. {
  148. prop: 'algorithmName',
  149. label: '算法名称',
  150. search: {
  151. el: 'input'
  152. }
  153. },
  154. {
  155. prop: 'algorithmAddress',
  156. label: '算法地址',
  157. search: {
  158. el: 'input'
  159. }
  160. },
  161. {
  162. prop: 'parameterConfig',
  163. label: '参数配置',
  164. search: {
  165. el: 'input'
  166. }
  167. },
  168. {
  169. prop: 'remarks',
  170. label: '备注',
  171. search: {
  172. el: 'input'
  173. }
  174. },
  175. // {
  176. // prop: 'system',
  177. // label: '系统',
  178. // search: {
  179. // el: 'input'
  180. // }
  181. // },
  182. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  183. ])
  184. // 表单配置项
  185. let itemsOptions: ProForm.ItemsOptions[] = []
  186. const setItemsOptions = () => {
  187. itemsOptions = [
  188. {
  189. label: '类型',
  190. prop: 'type',
  191. rules: [{ required: true, message: '算法类型不能为空', trigger: 'blur' }],
  192. compOptions: {
  193. elTagName: 'select',
  194. enum: enumsAlgorithmType,
  195. placeholder: '请选择算法类型'
  196. }
  197. },
  198. // {
  199. // label: '父id',
  200. // prop: 'parentId',
  201. // rules: [{ required: true, message: '父id不能为空', trigger: 'blur' }],
  202. // compOptions: {
  203. // placeholder: '请输入父id'
  204. // }
  205. // },
  206. {
  207. label: '分系统',
  208. prop: 'subsystem',
  209. rules: [{ required: true, message: '分系统不能为空', trigger: 'blur' }],
  210. compOptions: {
  211. elTagName: 'select',
  212. enum: enumsSubSystem,
  213. placeholder: '请选择分系统'
  214. }
  215. },
  216. {
  217. label: '算法名称',
  218. prop: 'algorithmName',
  219. rules: [{ required: true, message: '算法名称不能为空', trigger: 'blur' }],
  220. compOptions: {
  221. placeholder: '请输入算法名称'
  222. }
  223. },
  224. {
  225. label: '算法地址',
  226. prop: 'algorithmAddress',
  227. rules: [{ required: true, message: '算法地址不能为空', trigger: 'blur' }],
  228. compOptions: {
  229. placeholder: '请输入算法地址'
  230. }
  231. },
  232. {
  233. label: '参数配置',
  234. prop: 'parameterConfig',
  235. rules: [{ required: true, message: '参数配置不能为空', trigger: 'blur' }],
  236. compOptions: {
  237. type: 'textarea',
  238. clearable: true,
  239. placeholder: '请输入内容'
  240. }
  241. },
  242. {
  243. label: '备注',
  244. prop: 'remarks',
  245. rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
  246. compOptions: {
  247. placeholder: '请输入备注'
  248. }
  249. }
  250. // {
  251. // label: '系统',
  252. // prop: 'system',
  253. // rules: [{ required: true, message: '系统不能为空', trigger: 'blur' }],
  254. // compOptions: {
  255. // placeholder: '请输入系统'
  256. // }
  257. // }
  258. ]
  259. }
  260. </script>