index.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  1. <!--
  2. @Date: 2024-10-29
  3. @Author: ©WANGKANG
  4. @Email: 1686617586@qq.com
  5. -->
  6. <template>
  7. <div class="table-box">
  8. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listTrackSequenceApi">
  9. <!-- 表格 header 按钮 -->
  10. <template #tableHeader="scope">
  11. <el-button type="primary" v-auth="['demo:trackSequence:add']" icon="CirclePlus" @click="openDialog(1, '注视轨迹序列新增')"> 新增 </el-button>
  12. <!-- <el-button type="primary" v-auth="['demo:trackSequence:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
  13. <el-button type="primary" v-auth="['demo:trackSequence:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button> -->
  14. <el-button
  15. type="danger"
  16. v-auth="['demo:trackSequence:remove']"
  17. icon="Delete"
  18. plain
  19. :disabled="!scope.isSelected"
  20. @click="batchDelete(scope.selectedListIds)"
  21. >
  22. 批量删除
  23. </el-button>
  24. </template>
  25. <!-- 表格操作 -->
  26. <template #operation="scope">
  27. <el-button type="primary" link icon="View" @click="openDialog(3, '详情', scope.row)">
  28. <!--@click="openStartDialog(scope.row)" -->
  29. 详情
  30. </el-button>
  31. <el-button type="primary" link icon="EditPen" @click="openDialog(2, '编辑', scope.row)"> 编辑 </el-button>
  32. <el-button
  33. type="primary"
  34. link
  35. icon="View"
  36. v-auth="['demo:trackSequence:start']"
  37. v-if="scope.row.status == '0' || scope.row.status == '3' || scope.row.status == '4'"
  38. @click="startTrackSequence(scope.row)"
  39. >
  40. 开始
  41. </el-button>
  42. <el-popconfirm title="确定终止此任务吗?" @confirm="stopTrackSequence(scope.row)" v-if="scope.row.status == '1'">
  43. <template #reference>
  44. <el-button type="primary" link icon="Delete"> 终止</el-button>
  45. </template>
  46. </el-popconfirm>
  47. <el-button
  48. type="primary"
  49. link
  50. icon="View"
  51. v-auth="['demo:DataSeq:query']"
  52. v-if="scope.row.status == '2' && scope.row.type == AlgorithmType2['测试']"
  53. @click="showEvaluateResultRef.get_statistics_result(scope.row.id)"
  54. >
  55. 结果
  56. </el-button>
  57. <el-button
  58. type="primary"
  59. link
  60. icon="View"
  61. v-auth="['demo:DataSeq:query']"
  62. v-if="scope.row.status == '2' && scope.row.type == AlgorithmType2['预测/推理']"
  63. @click="preview(scope.row)"
  64. >
  65. 预览
  66. </el-button>
  67. <el-button
  68. type="primary"
  69. link
  70. icon="View"
  71. v-auth="['demo:DataSeq:query']"
  72. v-if="scope.row.status == '2' && scope.row.type == AlgorithmType2['预测/推理']"
  73. @click="showStatisticResultRef.get_statistics_result(scope.row.id)"
  74. >
  75. 结果
  76. </el-button>
  77. <el-button
  78. type="primary"
  79. link
  80. icon="View"
  81. v-auth="['demo:toInfrared:query']"
  82. @click="viewLogRef.handleOpen(scope.row.id)"
  83. v-if="scope.row.status != '0'"
  84. >
  85. 日志
  86. </el-button>
  87. <el-button
  88. type="primary"
  89. link
  90. icon="View"
  91. v-auth="['demo:trackSequence:download']"
  92. v-if="scope.row.status == '2'"
  93. @click="dowloadTrackSequence(scope.row)"
  94. >
  95. 下载
  96. </el-button>
  97. <el-button
  98. type="primary"
  99. link
  100. icon="View"
  101. v-if="scope.row.status == '2' && scope.row.type === AlgorithmType2['预测/推理']"
  102. @click="showEvaluate(scope.row)"
  103. >
  104. 评估
  105. </el-button>
  106. <el-button
  107. type="primary"
  108. link
  109. icon="View"
  110. v-auth="['demo:ToInfrared:download']"
  111. v-if="scope.row.status == '2' && scope.row.type == AlgorithmType2['训练']"
  112. @click="showModelDialog(scope.row.id)"
  113. >
  114. 模型
  115. </el-button>
  116. <el-button
  117. type="primary"
  118. link
  119. icon="Delete"
  120. v-auth="['demo:toInfrared:remove']"
  121. @click="deleteTrackSequence(scope.row)"
  122. :disabled="scope.row.status == '1'"
  123. >
  124. 删除
  125. </el-button>
  126. </template>
  127. </ProTable>
  128. <FormDialog ref="formDialogRef" />
  129. <ImportExcel ref="dialogRef" />
  130. <ViewLog ref="viewLogRef" :get-log-api="getLogTrackSequenceApi" />
  131. <PreviewCompareImages ref="previewImagesRef" />
  132. <ShowStatisticResult ref="showStatisticResultRef" :api="getStatisticsResultTrackSequenceApi" />
  133. <ShowStatisticResult ref="showEvaluateResultRef" :api="previewEvaluateTrackSequenceApi" title="评估结果" />
  134. <el-dialog v-model="showModelDialogVisible" title="模型列表" width="1000">
  135. <el-scrollbar ref="scrollbarRef" id="scrollbarRef1" height="500px">
  136. <template v-for="model in model_list" :key="model">
  137. <el-card style="width: 100%; margin-bottom: 10px">
  138. <el-form label-width="130px" label-position="left">
  139. <el-form-item label="Model Name">
  140. {{ model.name }}
  141. </el-form-item>
  142. <el-form-item label="Model Path">
  143. {{ model.path }}
  144. </el-form-item>
  145. <el-form-item label="Model Size">
  146. {{ model.size }}
  147. </el-form-item>
  148. <el-form-item label="操作">
  149. <el-link :href="model.url" type="primary" icon="Download" :underline="false" target="_blank" style="margin-right: 20px"
  150. >下载
  151. </el-link>
  152. <el-button type="success" link @click="addModel(model.path, model.name)">
  153. <el-icon>
  154. <Plus />
  155. </el-icon>
  156. 添加模型
  157. </el-button>
  158. </el-form-item>
  159. </el-form>
  160. </el-card>
  161. </template>
  162. </el-scrollbar>
  163. </el-dialog>
  164. </div>
  165. </template>
  166. <script setup lang="tsx" name="TrackSequence">
  167. import { ref, reactive, onMounted } from 'vue'
  168. import { useHandleData } from '@/hooks/useHandleData'
  169. import { useDownload } from '@/hooks/useDownload'
  170. import { ElMessage, ElMessageBox } from 'element-plus'
  171. import ProTable from '@/components/ProTable/index.vue'
  172. import ImportExcel from '@/components/ImportExcel/index.vue'
  173. import FormDialog from '@/components/FormDialog/index.vue'
  174. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  175. import {
  176. listTrackSequenceApi,
  177. delTrackSequenceApi,
  178. addTrackSequenceApi,
  179. updateTrackSequenceApi,
  180. importTemplateApi,
  181. importTrackSequenceDataApi,
  182. exportTrackSequenceApi,
  183. getTrackSequenceApi,
  184. startTrackSequenceApi,
  185. stopTrackSequenceApi,
  186. dowloadTrackSequenceApi,
  187. getLogTrackSequenceApi,
  188. getLDetailTrackSequenceApi,
  189. addEvaluateTrackSequenceApi,
  190. showCATModelApi,
  191. previewPredictResultTrackSequenceModelApi,
  192. previewEvaluateTrackSequenceApi,
  193. getStatisticsResultTrackSequenceApi
  194. } from '@/api/modules/demo/trackSequence'
  195. import { enumAlgorithmModelTrackApi } from '@/api/modules/demo/AlgorithmModelTrack'
  196. import { getAlgorithmModelTrackApi } from '@/api/modules/demo/AlgorithmModelTrack'
  197. import { enumAlgorithmConfigTrackApi, getAlgorithmConfigTrackApi } from '@/api/modules/demo/AlgorithmConfigTrack'
  198. import { listDataSeqApi } from '@/api/modules/demo/DataSeq'
  199. import statusEnums from '@/utils/status'
  200. import { AlgorithmType, SubSystem, SubSystem__, enumsAlgorithmType, enumsSubSystem, AlgorithmType2 } from '@/views/demo/utils'
  201. import ViewLog from '@/views/demo/components/ViewLog.vue'
  202. import { addAlgorithmModelTrackApi } from '@/api/modules/demo/AlgorithmModelTrack'
  203. import useWebSocketStore from '@/stores/modules/websocket'
  204. import { resetHeart } from '@/utils/websocket'
  205. import PreviewCompareImages from '@/views/demo/components/PreviewCompareImages.vue'
  206. import ShowStatisticResult from '@/views/demo/components/ShowStatisticResult.vue'
  207. import { getTargetDetectionApi } from '@/api/modules/demo/TargetDetection'
  208. import { getDictsApi } from '@/api/modules/system/dictData'
  209. const zipFileDescDict = ref<any>({})
  210. onMounted(async () => {
  211. const res = await getDictsApi('zip_file_format_description')
  212. for (let i = 0; i < res.data.length; i++) {
  213. const item = res.data[i]
  214. zipFileDescDict.value[item.dictValue] = item.remark
  215. }
  216. })
  217. const showStatisticResultRef = ref()
  218. const showEvaluateResultRef = ref()
  219. const previewImagesRef = ref()
  220. const preview = async row => {
  221. previewImagesRef.value?.handleOpen(previewPredictResultTrackSequenceModelApi, row.id)
  222. }
  223. onMounted(() => {
  224. const websocketStore = useWebSocketStore()
  225. websocketStore.websocket.onmessage = (e: any) => {
  226. if (e.data.indexOf('heartbeat') > 0) {
  227. resetHeart()
  228. }
  229. if (e.data.indexOf('ping') > 0) {
  230. return
  231. }
  232. console.log(e)
  233. proTable.value?.getTableList(true)
  234. }
  235. })
  236. const enumsAlgorithmConfigTrack_addModel____ = ref<any>([])
  237. const setItemsOptions222 = async () => {
  238. console.log('setItemsOptions222')
  239. const result = await enumAlgorithmConfigTrackApi()
  240. enumsAlgorithmConfigTrack_addModel____.value = []
  241. const tmp_data: any = result['data']
  242. for (const item of tmp_data) {
  243. if (item.subsystem === SubSystem__['注释轨迹序列'] && item.type === AlgorithmType2['预测/推理']) {
  244. item['label'] = item['label'] + '-' + SubSystem[item['subsystem']] + '-' + AlgorithmType[item['type']]
  245. enumsAlgorithmConfigTrack_addModel____.value.push(item)
  246. }
  247. }
  248. console.log(enumsAlgorithmConfigTrack_addModel____.value)
  249. itemsOptions = [
  250. {
  251. label: '算法',
  252. prop: 'algorithmId',
  253. rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
  254. compOptions: {
  255. elTagName: 'select',
  256. placeholder: '请输入算法',
  257. enum: enumsAlgorithmConfigTrack_addModel____
  258. }
  259. },
  260. {
  261. label: '子系统',
  262. prop: 'subSystem',
  263. rules: [{ required: true, message: '子系统不能为空', trigger: 'blur' }],
  264. compOptions: {
  265. disabled: true,
  266. elTagName: 'select',
  267. placeholder: '请输入子系统',
  268. enum: enumsSubSystem
  269. }
  270. },
  271. {
  272. label: '模型名称',
  273. prop: 'modelName',
  274. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  275. compOptions: {
  276. disabled: false,
  277. placeholder: '请输入模型名称'
  278. }
  279. },
  280. {
  281. label: '模型路径',
  282. prop: 'modelPath',
  283. rules: [{ required: false, message: '模型文件不能为空', trigger: 'blur' }],
  284. compOptions: {
  285. placeholder: '请输入模型名称',
  286. disabled: true
  287. }
  288. },
  289. {
  290. label: '备注',
  291. prop: 'remarks',
  292. rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
  293. compOptions: {
  294. placeholder: '请输入备注'
  295. }
  296. }
  297. ]
  298. }
  299. const addModel = async (modelPath: string, modelName: string) => {
  300. console.log(modelPath, modelName)
  301. let res = { data: { modelPath, subSystem: SubSystem__['目标检测'], type: AlgorithmType2['预测/推理'], modelName: modelName } }
  302. // 重置表单
  303. await setItemsOptions222()
  304. const params = {
  305. title: '添加模型',
  306. width: 580,
  307. isEdit: true,
  308. itemsOptions: itemsOptions,
  309. model: res.data,
  310. api: addAlgorithmModelTrackApi,
  311. getTableList: proTable.value?.getTableList,
  312. closedEvent: async () => {
  313. await updateEnumsAlgorithmModelTrack()
  314. }
  315. }
  316. formDialogRef.value?.openDialog(params)
  317. }
  318. const showModelDialogVisible = ref(false)
  319. const model_list: Ref<any> = ref([])
  320. const showModelDialog = async (id: any) => {
  321. const res: any = await showCATModelApi(id)
  322. model_list.value = res.data
  323. showModelDialogVisible.value = true
  324. }
  325. const setItemsOptionsAddCAT = () => {
  326. itemsOptions = [
  327. {
  328. label: '任务名称',
  329. prop: 'name',
  330. rules: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
  331. compOptions: {
  332. placeholder: '请输入任务名称'
  333. }
  334. },
  335. {
  336. label: '选择数据集',
  337. prop: 'inputOssId',
  338. rules: [{ required: false, message: '数据集不能为空', trigger: 'blur' }],
  339. compOptions: {
  340. elTagName: 'select',
  341. placeholder: '请选择或者上传数据集',
  342. enum: datasetList,
  343. clearable: true
  344. }
  345. },
  346. {
  347. label: '上传数据集',
  348. prop: 'inputOssId',
  349. rules: [{ required: false, message: '数据集不能为空', trigger: 'blur' }],
  350. tooltip: zipFileDescDict.value['track_sequence'],
  351. compOptions: {
  352. elTagName: 'file-upload',
  353. fileSize: 4096,
  354. fileType: ['zip'],
  355. placeholder: '请上传数据集'
  356. }
  357. },
  358. {
  359. label: '选择模型',
  360. prop: 'algorithmModelId',
  361. rules: [{ required: true, message: '模型不能为空', trigger: 'blur' }],
  362. compOptions: {
  363. elTagName: 'select',
  364. placeholder: '请选择模型',
  365. enum: enumsAlgorithmModelTrack_______.value
  366. }
  367. },
  368. {
  369. label: '备注',
  370. prop: 'remarks',
  371. rules: [],
  372. compOptions: {
  373. placeholder: '请输入备注'
  374. }
  375. }
  376. ]
  377. }
  378. const enumsAlgorithmModelTrack_______ = ref([])
  379. const addCATDialog = async () => {
  380. const result: any = await enumAlgorithmModelTrackApi()
  381. // console.log(result.data);
  382. enumsAlgorithmModelTrack_______.value = []
  383. for (const item of result.data) {
  384. if (SubSystem[item['subsystem']] === '注释轨迹序列' || SubSystem[item['subsystem']] === '目标检测') {
  385. item['label'] =
  386. item['value'] + '_' + item['label'] + '-' + SubSystem[item['subsystem']] + '-' + AlgorithmType[item['type']] + '-' + item['algorithmName']
  387. enumsAlgorithmModelTrack_______.value.push(item)
  388. }
  389. }
  390. // 重置表单
  391. setItemsOptionsAddCAT()
  392. const params = {
  393. title: '注释轨迹序列新增',
  394. width: 580,
  395. isEdit: true,
  396. itemsOptions: itemsOptions,
  397. model: {},
  398. api: addTrackSequenceApi,
  399. getTableList: proTable.value?.getTableList
  400. }
  401. formDialogRef.value?.openDialog(params)
  402. }
  403. const showEvaluate = (row: any) => {
  404. const newItem = {
  405. predictTaskId: row.id
  406. }
  407. const enumsAlgorithmConfigTrack__: Array<any> = []
  408. for (const item of enumsAlgorithmConfigTrack.value) {
  409. if (item.subsystem === SubSystem__['注释轨迹序列'] && item.type === AlgorithmType2['测试']) {
  410. enumsAlgorithmConfigTrack__.push(item)
  411. }
  412. }
  413. itemsOptions = [
  414. {
  415. label: '任务名称',
  416. prop: 'name',
  417. rules: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
  418. compOptions: {
  419. placeholder: '请输入任务名称'
  420. }
  421. },
  422. {
  423. label: '选择算法',
  424. prop: 'algorithmId',
  425. rules: [{ required: true, message: '请选择算法', trigger: 'blur' }],
  426. compOptions: {
  427. disabled: false,
  428. elTagName: 'select',
  429. placeholder: '请输入算法',
  430. enum: enumsAlgorithmConfigTrack__
  431. }
  432. },
  433. {
  434. label: '选择Label文件',
  435. prop: 'inputLabelOssId',
  436. rules: [{ required: false, message: 'Label文件不能为空', trigger: 'blur' }],
  437. compOptions: {
  438. elTagName: 'select',
  439. placeholder: '请选择或者上传Label文件',
  440. enum: datasetList,
  441. clearable: true
  442. }
  443. },
  444. {
  445. label: '上传Label文件',
  446. prop: 'inputLabelOssId',
  447. rules: [{ required: false, message: '请上传Label文件', trigger: 'blur' }],
  448. compOptions: {
  449. elTagName: 'file-upload',
  450. fileSize: 4096,
  451. fileType: ['txt', 'xlsx', 'xls'],
  452. placeholder: '请上传数据集'
  453. }
  454. },
  455. {
  456. label: '备注',
  457. prop: 'remarks',
  458. rules: [],
  459. compOptions: {
  460. placeholder: '请输入备注'
  461. }
  462. }
  463. ]
  464. const params = {
  465. title: '新增评估',
  466. width: 580,
  467. isEdit: true,
  468. itemsOptions: itemsOptions,
  469. model: newItem,
  470. api: addTrackSequenceApi,
  471. getTableList: proTable.value?.getTableList
  472. }
  473. formDialogRef.value?.openDialog(params)
  474. }
  475. const viewLogRef = ref()
  476. const enumsAlgorithmConfigTrack = ref<any>([])
  477. onMounted(async () => {
  478. const result = await enumAlgorithmConfigTrackApi()
  479. enumsAlgorithmConfigTrack.value = []
  480. const tmp_data: any = result['data']
  481. for (const item of tmp_data) {
  482. if (item.subsystem === SubSystem__['注释轨迹序列']) {
  483. item['label'] = item['label'] + '-' + SubSystem[item['subsystem']] + '-' + AlgorithmType[item['type']]
  484. enumsAlgorithmConfigTrack.value.push(item)
  485. }
  486. }
  487. })
  488. const openModelDialog = async id => {
  489. const result: any = await getLDetailTrackSequenceApi(id)
  490. // console.log(result.data)
  491. setItemsOptionsModel()
  492. const params = {
  493. title: '模型',
  494. width: 580,
  495. isEdit: false,
  496. itemsOptions: itemsOptions,
  497. model: result.data,
  498. api: updateTrackSequenceApi,
  499. getTableList: proTable.value?.getTableList
  500. }
  501. formDialogRef.value?.openDialog(params)
  502. }
  503. const startTrackSequence = async (params: any) => {
  504. const res: any = await startTrackSequenceApi(params.id)
  505. if (res.code === 200) {
  506. ElMessage.success('任务已开始,请等待完成!')
  507. } else {
  508. ElMessage.error('任务开始失败,请检查!')
  509. }
  510. proTable.value?.getTableList()
  511. }
  512. const stopTrackSequence = async (params: any) => {
  513. const res: any = await stopTrackSequenceApi(params.id)
  514. if (res.code === 200) {
  515. ElMessage.success('终止任务成功!')
  516. } else {
  517. ElMessage.error('终止任务失败,请检查!')
  518. }
  519. proTable.value?.getTableList()
  520. }
  521. const dowloadTrackSequence = async (params: any) => {
  522. await useDownload(dowloadTrackSequenceApi, params.name, params.id, true, '.zip')
  523. }
  524. // ProTable 实例
  525. const proTable = ref<ProTableInstance>()
  526. // 删除注视轨迹序列信息
  527. const deleteTrackSequence = async (params: any) => {
  528. await useHandleData(delTrackSequenceApi, params.id, '删除【' + params.id + '】注视轨迹序列')
  529. proTable.value?.getTableList()
  530. }
  531. // 批量删除注视轨迹序列信息
  532. const batchDelete = async (ids: string[]) => {
  533. await useHandleData(delTrackSequenceApi, ids, '删除所选注视轨迹序列信息')
  534. proTable.value?.clearSelection()
  535. proTable.value?.getTableList()
  536. }
  537. // 导出注视轨迹序列列表
  538. const downloadFile = async () => {
  539. ElMessageBox.confirm('确认导出注视轨迹序列数据?', '温馨提示', { type: 'warning' }).then(() =>
  540. useDownload(exportTrackSequenceApi, '注视轨迹序列列表', proTable.value?.searchParam)
  541. )
  542. }
  543. // 批量添加注视轨迹序列
  544. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  545. const batchAdd = () => {
  546. const params = {
  547. title: '注视轨迹序列',
  548. tempApi: importTemplateApi,
  549. importApi: importTrackSequenceDataApi,
  550. getTableList: proTable.value?.getTableList
  551. }
  552. dialogRef.value?.acceptParams(params)
  553. }
  554. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  555. // 打开弹框的功能
  556. const openDialog = async (type: number, title: string, row?: any) => {
  557. let res = { data: {} }
  558. if (row?.id) {
  559. res = await getTrackSequenceApi(row.id || null)
  560. const params = JSON.parse(res.data['algorithmParameters'])
  561. if (params.otherParams) {
  562. res.data = { ...res.data, ...params.otherParams }
  563. }
  564. }
  565. // 重置表单
  566. setItemsOptions()
  567. if (row?.id) {
  568. itemsOptions = await updateItemsOptions(row.algorithmId)
  569. }
  570. const params = {
  571. title,
  572. width: 580,
  573. isEdit: type !== 3,
  574. itemsOptions: itemsOptions,
  575. model: type == 1 ? {} : res.data,
  576. api: type == 1 ? addTrackSequenceApi : updateTrackSequenceApi,
  577. getTableList: proTable.value?.getTableList
  578. }
  579. formDialogRef.value?.openDialog(params)
  580. }
  581. // 表格配置项
  582. const columns = reactive<ColumnProps<any>[]>([
  583. { type: 'selection', fixed: 'left', width: 70 },
  584. { prop: 'id', label: '主键ID', width: 180 },
  585. {
  586. prop: 'name',
  587. label: '任务名称',
  588. search: {
  589. el: 'input'
  590. },
  591. width: 150
  592. },
  593. {
  594. prop: 'status',
  595. label: '任务状态',
  596. search: {
  597. el: 'select'
  598. },
  599. tag: true,
  600. enum: statusEnums,
  601. width: 150
  602. },
  603. {
  604. prop: 'type',
  605. label: '类型',
  606. tag: true,
  607. enum: enumsAlgorithmType,
  608. width: 120
  609. },
  610. {
  611. prop: 'subsystem',
  612. label: '分系统',
  613. tag: true,
  614. enum: enumsSubSystem,
  615. width: 200
  616. },
  617. {
  618. prop: 'algorithmName',
  619. label: '算法名称',
  620. width: 200
  621. },
  622. {
  623. prop: 'modelName',
  624. label: '模型名称',
  625. width: 200
  626. },
  627. {
  628. prop: 'algorithmParameters',
  629. label: '算法参数',
  630. search: {
  631. el: 'input'
  632. },
  633. width: 150
  634. },
  635. // {
  636. // prop: 'algorithmModelId',
  637. // label: '模型',
  638. // search: {
  639. // el: 'input'
  640. // },
  641. // width: 150
  642. // },
  643. {
  644. prop: 'startTime',
  645. label: '开始时间',
  646. width: 180
  647. },
  648. {
  649. prop: 'endTime',
  650. label: '结束时间',
  651. width: 180
  652. },
  653. {
  654. prop: 'costSecond',
  655. label: '耗时',
  656. width: 120
  657. },
  658. {
  659. prop: 'log',
  660. label: '日志',
  661. width: 120
  662. },
  663. {
  664. prop: 'outputPath',
  665. label: '输出路径',
  666. width: 120
  667. },
  668. {
  669. prop: 'remarks',
  670. label: '备注',
  671. search: {
  672. el: 'input'
  673. },
  674. width: 120
  675. },
  676. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  677. ])
  678. const remove_unnecessary_parameters = (itemsOptions: ProForm.ItemsOptions[]): ProForm.ItemsOptions[] => {
  679. try {
  680. const endIndex = itemsOptions.findIndex(option => option['label'] === '备注')
  681. if (endIndex !== -1) {
  682. itemsOptions = itemsOptions.slice(0, endIndex + 1)
  683. }
  684. return itemsOptions
  685. } catch (error) {
  686. console.error('移除不必要的参数时出错:', error)
  687. // ElMessage.error('移除不必要的参数时出错,请检查!');
  688. return itemsOptions // 返回原始选项,避免进一步的问题
  689. }
  690. }
  691. const updateItemsOptions = async (algorithmId: any) => {
  692. try {
  693. const result = await getAlgorithmConfigTrackApi(algorithmId)
  694. if (result.code === 200) {
  695. // 处理结果
  696. const parameters = JSON.parse(result.data['parameters'])
  697. // console.log('parameters: ', parameters)
  698. const itemsOptions_new = remove_unnecessary_parameters(itemsOptions)
  699. for (const item of parameters) {
  700. // 添加新的表单项选项
  701. itemsOptions_new.push({
  702. label: item['name'],
  703. prop: item['agName'],
  704. rules: [{ required: item['required'], message: item['agName'] + '不能为空', trigger: 'blur' }],
  705. tooltip: item['prompt'],
  706. compOptions: {
  707. elTagName: 'input',
  708. placeholder: item['defaultValue']
  709. // value: item['defaultValue']
  710. }
  711. })
  712. }
  713. formDialogRef.value?.updateItemOptions(itemsOptions_new)
  714. return itemsOptions_new
  715. }
  716. } catch (err) {
  717. console.log(err)
  718. ElMessage.error('获取算法配置失败,请检查!')
  719. }
  720. }
  721. // 表单配置项
  722. let itemsOptions: ProForm.ItemsOptions[] = []
  723. const setItemsOptions = () => {
  724. itemsOptions = [
  725. {
  726. label: '任务名称',
  727. prop: 'name',
  728. rules: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
  729. compOptions: {
  730. placeholder: '请输入任务名称'
  731. }
  732. },
  733. {
  734. label: '选择数据集',
  735. prop: 'inputOssId',
  736. rules: [{ required: false, message: '数据集不能为空', trigger: 'blur' }],
  737. compOptions: {
  738. elTagName: 'select',
  739. placeholder: '请选择或者上传数据集',
  740. enum: datasetList,
  741. clearable: true
  742. }
  743. },
  744. {
  745. label: '上传数据集',
  746. prop: 'inputOssId',
  747. rules: [{ required: false, message: '数据集不能为空', trigger: 'blur' }],
  748. tooltip: zipFileDescDict.value['track_sequence'],
  749. compOptions: {
  750. elTagName: 'file-upload',
  751. fileSize: 4096,
  752. fileType: ['zip'],
  753. placeholder: '请上传数据集'
  754. }
  755. },
  756. {
  757. label: '选择算法',
  758. prop: 'algorithmId',
  759. rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
  760. compOptions: {
  761. elTagName: 'select',
  762. placeholder: '请选择算法',
  763. enum: enumsAlgorithmConfigTrack,
  764. clearable: true,
  765. onChange: async (value: any) => {
  766. if (value != undefined && value != null && value != '') {
  767. await updateItemsOptions(value)
  768. }
  769. }
  770. }
  771. },
  772. {
  773. label: '任务类型',
  774. prop: 'type',
  775. rules: [{ required: true, message: '任务类型不能为空', trigger: 'blur' }],
  776. compOptions: {
  777. disabled: true,
  778. elTagName: 'select',
  779. placeholder: '请选择任务类型',
  780. enum: enumsAlgorithmType,
  781. clearable: true,
  782. value: ''
  783. },
  784. show: params => {
  785. if (params.value.algorithmId != undefined) {
  786. for (let i = 0; i < enumsAlgorithmConfigTrack.value.length; i++) {
  787. if (enumsAlgorithmConfigTrack.value[i]['value'] === params.value.algorithmId) {
  788. params.value.type = enumsAlgorithmConfigTrack.value[i]['type']
  789. return true
  790. }
  791. }
  792. }
  793. return false
  794. }
  795. },
  796. {
  797. label: '视觉模型',
  798. prop: 'algorithmModelId',
  799. rules: [{ required: false, message: '模型不能为空', trigger: 'blur' }],
  800. show: params => {
  801. if (params.value.type == AlgorithmType2['预测/推理']) {
  802. return true
  803. }
  804. params.value.algorithmModelId = ''
  805. return false
  806. },
  807. compOptions: {
  808. elTagName: 'select',
  809. placeholder: '请选择模型',
  810. enum: enumsAlgorithmModelTrack,
  811. clearable: true
  812. }
  813. },
  814. {
  815. label: '目标检测模型',
  816. prop: 'algorithmModelTargetDetectionId',
  817. rules: [{ required: true, message: '目标检测模型不能为空', trigger: 'blur' }],
  818. show: params => {
  819. if (params.value.type == AlgorithmType2['预测/推理']) {
  820. return true
  821. }
  822. params.value.algorithmModelTargetDetectionId = ''
  823. return false
  824. },
  825. compOptions: {
  826. elTagName: 'select',
  827. placeholder: '请选择目标检测模型',
  828. enum: enumsAlgorithmModelTrack_TD,
  829. clearable: true
  830. }
  831. },
  832. {
  833. label: '上传标签',
  834. prop: 'inputLabelOssId',
  835. rules: [{ required: true, message: '标签不能为空', trigger: 'blur' }],
  836. tooltip: zipFileDescDict.value['track_sequence_label'],
  837. show: params => {
  838. if (params.value.type == AlgorithmType2['测试']) {
  839. return true
  840. }
  841. return false
  842. },
  843. compOptions: {
  844. elTagName: 'file-upload',
  845. fileSize: 4096,
  846. fileType: ['txt', 'xlsx', 'xls'],
  847. placeholder: '请上传标签'
  848. }
  849. },
  850. {
  851. label: '备注',
  852. prop: 'remarks',
  853. rules: [],
  854. compOptions: {
  855. placeholder: '请输入备注'
  856. }
  857. }
  858. ]
  859. }
  860. const setItemsOptionsModel = () => {
  861. itemsOptions = [
  862. {
  863. label: '算法ID',
  864. prop: 'algorithmId',
  865. rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
  866. compOptions: {
  867. disabled: true,
  868. placeholder: '请输入算法'
  869. }
  870. },
  871. {
  872. label: '算法名称',
  873. prop: 'algorithmName',
  874. rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
  875. compOptions: {
  876. disabled: true,
  877. elTagName: 'select',
  878. placeholder: '请输入算法',
  879. enum: enumsAlgorithmConfigTrack
  880. }
  881. },
  882. {
  883. label: '算法参数',
  884. prop: 'parameterConfig',
  885. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  886. compOptions: {
  887. placeholder: '请输入模型名称'
  888. }
  889. },
  890. {
  891. label: '模型ID',
  892. prop: 'id',
  893. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  894. compOptions: {
  895. placeholder: '请输入模型名称'
  896. }
  897. },
  898. {
  899. label: '模型名称',
  900. prop: 'modelName',
  901. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  902. compOptions: {
  903. placeholder: '请输入模型名称'
  904. }
  905. },
  906. {
  907. label: '模型保存路径',
  908. prop: 'modelAddress',
  909. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  910. compOptions: {
  911. placeholder: '请输入模型名称'
  912. }
  913. },
  914. {
  915. label: '备注',
  916. prop: 'remarks',
  917. rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
  918. compOptions: {
  919. placeholder: '请输入备注'
  920. }
  921. }
  922. ]
  923. }
  924. const datasetList = ref<any>([])
  925. const getImageData = async (subsystem: string) => {
  926. const qyery = {
  927. subsystem: SubSystem__[subsystem],
  928. pageNum: 1,
  929. pageSize: 1000
  930. }
  931. const result: any = await listDataSeqApi(qyery)
  932. const data = result['data']['list']
  933. for (const item of data) {
  934. datasetList.value.push({
  935. value: item['inputOssId'],
  936. label: item['name'] + '-' + subsystem
  937. })
  938. }
  939. }
  940. onMounted(async () => {
  941. await getImageData('可见光转红外')
  942. await getImageData('目标检测')
  943. await getImageData('注释轨迹序列')
  944. })
  945. const enumsAlgorithmModelTrack = ref<any>([])
  946. const enumsAlgorithmModelTrack_TD = ref<any>([])
  947. const updateEnumsAlgorithmModelTrack = async () => {
  948. const result: any = await enumAlgorithmModelTrackApi()
  949. // console.log(result.data);
  950. enumsAlgorithmModelTrack.value = []
  951. for (const item of result.data) {
  952. if (item.type !== AlgorithmType2['预测/推理']) {
  953. continue
  954. }
  955. if (SubSystem[item['subsystem']] === '注释轨迹序列') {
  956. item['label'] =
  957. item['value'] + '_' + item['label'] + '-' + SubSystem[item['subsystem']] + '-' + AlgorithmType[item['type']] + '-' + item['algorithmName']
  958. enumsAlgorithmModelTrack.value.push(item)
  959. }
  960. if (SubSystem[item['subsystem']] === '目标检测') {
  961. item['label'] =
  962. item['value'] + '_' + item['label'] + '-' + SubSystem[item['subsystem']] + '-' + AlgorithmType[item['type']] + '-' + item['algorithmName']
  963. enumsAlgorithmModelTrack_TD.value.push(item)
  964. }
  965. }
  966. }
  967. onMounted(async () => {
  968. updateEnumsAlgorithmModelTrack()
  969. })
  970. </script>
  971. <style lang="scss" scoped>
  972. .evaluate-data {
  973. span {
  974. margin-bottom: 20px;
  975. font-size: 20px;
  976. line-height: 2;
  977. }
  978. }
  979. </style>