index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <div class="table-box">
  3. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listAlgorithmModelTrackApi">
  4. <!-- 表格 header 按钮 -->
  5. <template #tableHeader="scope">
  6. <el-button type="primary" v-auth="['demo:AlgorithmModelTrack:add']" icon="CirclePlus" @click="openDialog(1, '算法模型配置新增')">
  7. 新增
  8. </el-button>
  9. <!-- <el-button type="primary" v-auth="['demo:AlgorithmModelTrack:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
  10. <el-button type="primary" v-auth="['demo:AlgorithmModelTrack:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button> -->
  11. <el-button
  12. type="danger"
  13. v-auth="['demo:AlgorithmModelTrack: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:AlgorithmModelTrack: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:AlgorithmModelTrack:edit']"
  32. @click="openDialog(2, '算法模型配置编辑', scope.row)"
  33. >
  34. 编辑
  35. </el-button> -->
  36. <el-button type="primary" link icon="Delete" v-auth="['demo:AlgorithmModelTrack:remove']" @click="deleteAlgorithmModelTrack(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="AlgorithmModelTrack">
  46. import { ref, reactive, onMounted } 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. listAlgorithmModelTrackApi,
  56. delAlgorithmModelTrackApi,
  57. addAlgorithmModelTrackApi,
  58. updateAlgorithmModelTrackApi,
  59. importTemplateApi,
  60. importAlgorithmModelTrackDataApi,
  61. exportAlgorithmModelTrackApi,
  62. getAlgorithmModelTrackApi
  63. } from '@/api/modules/demo/AlgorithmModelTrack'
  64. import { enumAlgorithmConfigTrackApi } from '@/api/modules/demo/AlgorithmConfigTrack'
  65. import { AlgorithmType, SubSystem, enumsModelStatus, enumsAlgorithmType, enumsSubSystem } from '@/views/demo/utils'
  66. // ProTable 实例
  67. const proTable = ref<ProTableInstance>()
  68. // 删除算法模型配置信息
  69. const deleteAlgorithmModelTrack = async (params: any) => {
  70. await useHandleData(delAlgorithmModelTrackApi, params.id, '删除【' + params.id + '】算法模型配置')
  71. proTable.value?.getTableList()
  72. }
  73. // 批量删除算法模型配置信息
  74. const batchDelete = async (ids: string[]) => {
  75. await useHandleData(delAlgorithmModelTrackApi, ids, '删除所选算法模型配置信息')
  76. proTable.value?.clearSelection()
  77. proTable.value?.getTableList()
  78. }
  79. // 导出算法模型配置列表
  80. const downloadFile = async () => {
  81. ElMessageBox.confirm('确认导出算法模型配置数据?', '温馨提示', { type: 'warning' }).then(() =>
  82. useDownload(exportAlgorithmModelTrackApi, '算法模型配置列表', proTable.value?.searchParam)
  83. )
  84. }
  85. // 批量添加算法模型配置
  86. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  87. const batchAdd = () => {
  88. const params = {
  89. title: '算法模型配置',
  90. tempApi: importTemplateApi,
  91. importApi: importAlgorithmModelTrackDataApi,
  92. getTableList: proTable.value?.getTableList
  93. }
  94. dialogRef.value?.acceptParams(params)
  95. }
  96. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  97. // 打开弹框的功能
  98. const openDialog = async (type: number, title: string, row?: any) => {
  99. let res = { data: {} }
  100. if (row?.id) {
  101. res = await getAlgorithmModelTrackApi(row?.id || null)
  102. }
  103. // 重置表单
  104. setItemsOptions()
  105. const params = {
  106. title,
  107. width: 580,
  108. isEdit: type !== 3,
  109. itemsOptions: itemsOptions,
  110. model: type == 1 ? {} : res.data,
  111. api: type == 1 ? addAlgorithmModelTrackApi : updateAlgorithmModelTrackApi,
  112. getTableList: proTable.value?.getTableList
  113. }
  114. formDialogRef.value?.openDialog(params)
  115. }
  116. // 表格配置项
  117. const columns = reactive<ColumnProps<any>[]>([
  118. { type: 'selection', fixed: 'left', width: 70 },
  119. { prop: 'id', label: 'ID' },
  120. {
  121. prop: 'modelName',
  122. label: '模型名称',
  123. search: {
  124. el: 'input'
  125. },
  126. minWidth: 150
  127. },
  128. {
  129. prop: 'algorithmType',
  130. label: '算法',
  131. search: {
  132. el: 'input'
  133. },
  134. minWidth: 200
  135. },
  136. {
  137. prop: 'type',
  138. label: '类型',
  139. tag: true,
  140. enum: enumsAlgorithmType,
  141. search: {
  142. el: 'select'
  143. },
  144. width: 120
  145. },
  146. // {
  147. // prop: 'parentId',
  148. // label: '父id',
  149. // search: {
  150. // el: 'input'
  151. // },
  152. // width: 120
  153. // },
  154. {
  155. prop: 'subsystem',
  156. label: '分系统',
  157. tag: true,
  158. enum: enumsSubSystem,
  159. search: {
  160. el: 'input'
  161. },
  162. width: 120
  163. },
  164. {
  165. prop: 'modelStatus',
  166. label: '模型状态',
  167. tag: true,
  168. enum: enumsModelStatus,
  169. search: {
  170. el: 'select'
  171. },
  172. width: 120
  173. },
  174. // {
  175. // prop: 'sampleNumber',
  176. // label: '训练样本数',
  177. // search: {
  178. // el: 'input'
  179. // },
  180. // width: 120
  181. // },
  182. // {
  183. // prop: 'cycleEpoch',
  184. // label: '训练循环次数',
  185. // search: {
  186. // el: 'input'
  187. // },
  188. // width: 120
  189. // },
  190. {
  191. prop: 'modelAddress',
  192. label: '模型',
  193. search: {
  194. el: 'input'
  195. },
  196. width: 120
  197. },
  198. {
  199. prop: 'remarks',
  200. label: '备注',
  201. search: {
  202. el: 'input'
  203. },
  204. width: 200
  205. },
  206. // {
  207. // prop: 'system',
  208. // label: '系统',
  209. // search: {
  210. // el: 'input'
  211. // },
  212. // width: 120
  213. // },
  214. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  215. ])
  216. // 表单配置项
  217. let itemsOptions: ProForm.ItemsOptions[] = []
  218. const enumsAlgorithmConfigTrack = ref<any>([])
  219. onMounted(async () => {
  220. const result: any = await enumAlgorithmConfigTrackApi()
  221. // console.log(result)
  222. // console.log(result['data'])
  223. for (let item of result['data']) {
  224. // console.log(item)
  225. // console.log(item['type'])
  226. // console.log(item['subsystem'])
  227. // console.log(AlgorithmType[item['type']])
  228. // console.log(SubSystem[item['subsystem']])
  229. // console.log(AlgorithmType)
  230. // console.log(SubSystem)
  231. // console.log('-------------------')
  232. item['label'] = item['label'] + '-' + SubSystem[item['subsystem']] + '-' + AlgorithmType[item['type']]
  233. }
  234. enumsAlgorithmConfigTrack.value = result['data']
  235. return result['data']
  236. })
  237. const setItemsOptions = () => {
  238. itemsOptions = [
  239. {
  240. label: '算法',
  241. prop: 'algorithmId',
  242. rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
  243. compOptions: {
  244. elTagName: 'select',
  245. placeholder: '请输入算法',
  246. enum: enumsAlgorithmConfigTrack
  247. }
  248. },
  249. {
  250. label: '模型名称',
  251. prop: 'modelName',
  252. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  253. compOptions: {
  254. placeholder: '请输入模型名称'
  255. }
  256. },
  257. {
  258. label: '模型',
  259. prop: 'modelInputOssId',
  260. rules: [{ required: false, message: '模型文件不能为空', trigger: 'blur' }],
  261. compOptions: {
  262. elTagName: 'file-upload',
  263. fileSize: 4096,
  264. fileType: ['pt', 'zip'],
  265. placeholder: '请上传模型文件'
  266. }
  267. },
  268. // {
  269. // label: '训练样本数',
  270. // prop: 'sampleNumber',
  271. // rules: [{ required: true, message: '训练样本数不能为空', trigger: 'blur' }],
  272. // compOptions: {
  273. // placeholder: '请输入训练样本数'
  274. // }
  275. // },
  276. // {
  277. // label: '训练循环次数',
  278. // prop: 'cycleEpoch',
  279. // rules: [{ required: true, message: '训练循环次数不能为空', trigger: 'blur' }],
  280. // compOptions: {
  281. // placeholder: '请输入训练循环次数'
  282. // }
  283. // },
  284. {
  285. label: '备注',
  286. prop: 'remarks',
  287. rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
  288. compOptions: {
  289. placeholder: '请输入备注'
  290. }
  291. }
  292. // {
  293. // label: '系统',
  294. // prop: 'system',
  295. // rules: [{ required: true, message: '系统不能为空', trigger: 'blur' }],
  296. // compOptions: {
  297. // placeholder: '请输入系统'
  298. // }
  299. // }
  300. ]
  301. }
  302. </script>