index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <div class="table-box">
  3. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listTrackSequenceApi">
  4. <!-- 表格 header 按钮 -->
  5. <template #tableHeader="scope">
  6. <el-button type="primary" v-auth="['demo:trackSequence:add']" icon="CirclePlus" @click="openDialog(1, '注视轨迹序列新增')"> 新增 </el-button>
  7. <!-- <el-button type="primary" v-auth="['demo:trackSequence:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
  8. <el-button type="primary" v-auth="['demo:trackSequence:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button> -->
  9. <el-button
  10. type="danger"
  11. v-auth="['demo:trackSequence: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-if="scope.row.algorithmModelId != null" @click="openModelDialog(scope.row)">
  23. <!--@click="openStartDialog(scope.row)" -->
  24. 模型
  25. </el-button>
  26. <el-button
  27. type="primary"
  28. link
  29. icon="View"
  30. v-auth="['demo:trackSequence:start']"
  31. v-if="scope.row.status == '0' || scope.row.status == '3' || scope.row.status == '4'"
  32. @click="startTrackSequence(scope.row)"
  33. >
  34. 开始
  35. </el-button>
  36. <el-popconfirm title="确定终止此任务吗?" @confirm="stopTrackSequence(scope.row)" v-if="scope.row.status == '1'">
  37. <template #reference>
  38. <el-button type="primary" link icon="Delete"> 终止</el-button>
  39. </template>
  40. </el-popconfirm>
  41. <el-button
  42. type="primary"
  43. link
  44. icon="View"
  45. v-auth="['demo:trackSequence:download']"
  46. v-if="scope.row.status == '2'"
  47. @click="dowloadtrackSequence(scope.row)"
  48. >
  49. 下载
  50. </el-button>
  51. <!-- <el-button type="primary" link icon="View" v-auth="['demo:toInfrared:query']" @click="openDialog(3, '查看', scope.row)"> 查看 </el-button> -->
  52. <!-- <el-button type="primary" link icon="EditPen"v-auth="['demo:toInfrared:edit']" @click="openDialog(2, '编辑', scope.row)"> 编辑 </el-button> -->
  53. <el-button
  54. type="primary"
  55. link
  56. icon="Delete"
  57. v-auth="['demo:toInfrared:remove']"
  58. @click="deleteTrackSequence(scope.row)"
  59. :disabled="scope.row.status == '1'"
  60. >
  61. 删除
  62. </el-button>
  63. </template>
  64. </ProTable>
  65. <FormDialog ref="formDialogRef" />
  66. <ImportExcel ref="dialogRef" />
  67. </div>
  68. </template>
  69. <script setup lang="tsx" name="TrackSequence">
  70. import { ref, reactive, onMounted } from 'vue'
  71. import { useHandleData } from '@/hooks/useHandleData'
  72. import { useDownload } from '@/hooks/useDownload'
  73. import { ElMessage, ElMessageBox } from 'element-plus'
  74. import ProTable from '@/components/ProTable/index.vue'
  75. import ImportExcel from '@/components/ImportExcel/index.vue'
  76. import FormDialog from '@/components/FormDialog/index.vue'
  77. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  78. import {
  79. listTrackSequenceApi,
  80. delTrackSequenceApi,
  81. addTrackSequenceApi,
  82. updateTrackSequenceApi,
  83. importTemplateApi,
  84. importTrackSequenceDataApi,
  85. exportTrackSequenceApi,
  86. getTrackSequenceApi,
  87. startTrackSequenceApi,
  88. stopTrackSequenceApi,
  89. dowloadTrackSequenceApi
  90. } from '@/api/modules/demo/trackSequence'
  91. import { enumAlgorithmModelTrackApi } from '@/api/modules/demo/AlgorithmModelTrack'
  92. import { getAlgorithmModelTrackApi } from '@/api/modules/demo/AlgorithmModelTrack'
  93. import { enumAlgorithmConfigTrackApi } from '@/api/modules/demo/AlgorithmConfigTrack'
  94. import { listDataSeqApi } from '@/api/modules/demo/DataSeq'
  95. import statusEnums from '@/utils/status'
  96. import { AlgorithmType, SubSystem, SubSystem__, enumsAlgorithmType, enumsSubSystem } from '@/views/demo/utils'
  97. const enumsAlgorithmConfigTrack = ref<any>([])
  98. onMounted(async () => {
  99. const result = await enumAlgorithmConfigTrackApi()
  100. // console.log(result)
  101. // console.log(result['data'])
  102. enumsAlgorithmConfigTrack.value = result['data']
  103. return result['data']
  104. })
  105. const openModelDialog = async row => {
  106. const algorithmModelId = row.algorithmModelId
  107. const result: any = await getAlgorithmModelTrackApi(algorithmModelId)
  108. // console.log(result.data)
  109. setItemsOptionsModel()
  110. const params = {
  111. title: '模型',
  112. width: 580,
  113. isEdit: false,
  114. itemsOptions: itemsOptions,
  115. model: result.data,
  116. api: updateTrackSequenceApi,
  117. getTableList: proTable.value?.getTableList
  118. }
  119. formDialogRef.value?.openDialog(params)
  120. }
  121. const startTrackSequence = async (params: any) => {
  122. const res: any = await startTrackSequenceApi(params.id)
  123. if (res.code === 200) {
  124. ElMessage.success('任务已开始,请等待完成!')
  125. } else {
  126. ElMessage.error('任务开始失败,请检查!')
  127. }
  128. proTable.value?.getTableList()
  129. }
  130. const stopTrackSequence = async (params: any) => {
  131. const res: any = await stopTrackSequenceApi(params.id)
  132. if (res.code === 200) {
  133. ElMessage.success('终止任务成功!')
  134. } else {
  135. ElMessage.error('终止任务失败,请检查!')
  136. }
  137. proTable.value?.getTableList()
  138. }
  139. const dowloadToInfrared = async (params: any) => {
  140. await useDownload(dowloadTrackSequenceApi, params.name, params.id, true, '.zip')
  141. }
  142. // ProTable 实例
  143. const proTable = ref<ProTableInstance>()
  144. // 删除注视轨迹序列信息
  145. const deleteTrackSequence = async (params: any) => {
  146. await useHandleData(delTrackSequenceApi, params.id, '删除【' + params.id + '】注视轨迹序列')
  147. proTable.value?.getTableList()
  148. }
  149. // 批量删除注视轨迹序列信息
  150. const batchDelete = async (ids: string[]) => {
  151. await useHandleData(delTrackSequenceApi, ids, '删除所选注视轨迹序列信息')
  152. proTable.value?.clearSelection()
  153. proTable.value?.getTableList()
  154. }
  155. // 导出注视轨迹序列列表
  156. const downloadFile = async () => {
  157. ElMessageBox.confirm('确认导出注视轨迹序列数据?', '温馨提示', { type: 'warning' }).then(() =>
  158. useDownload(exportTrackSequenceApi, '注视轨迹序列列表', proTable.value?.searchParam)
  159. )
  160. }
  161. // 批量添加注视轨迹序列
  162. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  163. const batchAdd = () => {
  164. const params = {
  165. title: '注视轨迹序列',
  166. tempApi: importTemplateApi,
  167. importApi: importTrackSequenceDataApi,
  168. getTableList: proTable.value?.getTableList
  169. }
  170. dialogRef.value?.acceptParams(params)
  171. }
  172. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  173. // 打开弹框的功能
  174. const openDialog = async (type: number, title: string, row?: any) => {
  175. let res = { data: {} }
  176. if (row?.id) {
  177. res = await getTrackSequenceApi(row?.id || null)
  178. }
  179. // 重置表单
  180. setItemsOptions()
  181. const params = {
  182. title,
  183. width: 580,
  184. isEdit: type !== 3,
  185. itemsOptions: itemsOptions,
  186. model: type == 1 ? {} : res.data,
  187. api: type == 1 ? addTrackSequenceApi : updateTrackSequenceApi,
  188. getTableList: proTable.value?.getTableList
  189. }
  190. formDialogRef.value?.openDialog(params)
  191. }
  192. // 表格配置项
  193. const columns = reactive<ColumnProps<any>[]>([
  194. { type: 'selection', fixed: 'left', width: 70 },
  195. { prop: 'id', label: '主键ID', width: 180 },
  196. {
  197. prop: 'name',
  198. label: '任务名称',
  199. search: {
  200. el: 'input'
  201. },
  202. width: 150
  203. },
  204. {
  205. prop: 'status',
  206. label: '任务状态',
  207. search: {
  208. el: 'select'
  209. },
  210. tag: true,
  211. enum: statusEnums,
  212. width: 150
  213. },
  214. {
  215. prop: 'type',
  216. label: '类型',
  217. tag: true,
  218. enum: enumsAlgorithmType,
  219. width: 120
  220. },
  221. {
  222. prop: 'subsystem',
  223. label: '分系统',
  224. tag: true,
  225. enum: enumsSubSystem,
  226. width: 200
  227. },
  228. {
  229. prop: 'algorithmName',
  230. label: '算法名称',
  231. width: 200
  232. },
  233. {
  234. prop: 'modelName',
  235. label: '模型名称',
  236. width: 200
  237. },
  238. // {
  239. // prop: 'algorithmModelId',
  240. // label: '模型',
  241. // search: {
  242. // el: 'input'
  243. // },
  244. // width: 150
  245. // },
  246. {
  247. prop: 'startTime',
  248. label: '开始时间',
  249. width: 180
  250. },
  251. {
  252. prop: 'endTime',
  253. label: '结束时间',
  254. width: 180
  255. },
  256. {
  257. prop: 'costSecond',
  258. label: '耗时',
  259. width: 120
  260. },
  261. {
  262. prop: 'log',
  263. label: '日志',
  264. width: 120
  265. },
  266. {
  267. prop: 'outputPath',
  268. label: '输出路径',
  269. width: 120
  270. },
  271. {
  272. prop: 'remarks',
  273. label: '备注',
  274. search: {
  275. el: 'input'
  276. },
  277. width: 120
  278. },
  279. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  280. ])
  281. // 表单配置项
  282. let itemsOptions: ProForm.ItemsOptions[] = []
  283. const setItemsOptions = () => {
  284. itemsOptions = [
  285. {
  286. label: '任务名称',
  287. prop: 'name',
  288. rules: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
  289. compOptions: {
  290. placeholder: '请输入任务名称'
  291. }
  292. },
  293. {
  294. label: '选择图片集',
  295. prop: 'inputOssId',
  296. rules: [{ required: false, message: '图片集不能为空', trigger: 'blur' }],
  297. compOptions: {
  298. elTagName: 'select',
  299. placeholder: '请选择或者上传图片集',
  300. enum: getImageDataList,
  301. clearable: true
  302. }
  303. },
  304. {
  305. label: '上传图片集',
  306. prop: 'inputOssId',
  307. rules: [{ required: false, message: '图片集不能为空', trigger: 'blur' }],
  308. compOptions: {
  309. elTagName: 'file-upload',
  310. fileSize: 4096,
  311. fileType: ['zip'],
  312. placeholder: '请上传图片集'
  313. }
  314. },
  315. {
  316. label: '选择模型',
  317. prop: 'algorithmModelId',
  318. rules: [{ required: true, message: '模型不能为空', trigger: 'blur' }],
  319. compOptions: {
  320. elTagName: 'select',
  321. placeholder: '请选择模型',
  322. enum: enumsAlgorithmModelTrack
  323. }
  324. },
  325. {
  326. label: '备注',
  327. prop: 'remarks',
  328. rules: [],
  329. compOptions: {
  330. placeholder: '请输入备注'
  331. }
  332. }
  333. ]
  334. }
  335. const setItemsOptionsModel = () => {
  336. itemsOptions = [
  337. {
  338. label: '算法ID',
  339. prop: 'algorithmId',
  340. rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
  341. compOptions: {
  342. disabled: true,
  343. placeholder: '请输入算法'
  344. }
  345. },
  346. {
  347. label: '算法类型',
  348. prop: 'algorithmType',
  349. rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
  350. compOptions: {
  351. disabled: true,
  352. elTagName: 'select',
  353. placeholder: '请输入算法',
  354. enum: enumsAlgorithmConfigTrack
  355. }
  356. },
  357. {
  358. label: '算法参数',
  359. prop: 'parameterConfig',
  360. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  361. compOptions: {
  362. placeholder: '请输入模型名称'
  363. }
  364. },
  365. {
  366. label: '模型ID',
  367. prop: 'id',
  368. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  369. compOptions: {
  370. placeholder: '请输入模型名称'
  371. }
  372. },
  373. {
  374. label: '模型名称',
  375. prop: 'modelName',
  376. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  377. compOptions: {
  378. placeholder: '请输入模型名称'
  379. }
  380. },
  381. {
  382. label: '模型保存路径',
  383. prop: 'modelAddress',
  384. rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
  385. compOptions: {
  386. placeholder: '请输入模型名称'
  387. }
  388. },
  389. {
  390. label: '备注',
  391. prop: 'remarks',
  392. rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
  393. compOptions: {
  394. placeholder: '请输入备注'
  395. }
  396. }
  397. ]
  398. }
  399. const getImageDataList = ref<any>([])
  400. onMounted(async () => {
  401. const qyery = {
  402. subsystem: SubSystem__['注释轨迹序列'],
  403. pageNum: 1,
  404. pageSize: 25
  405. }
  406. const result: any = await listDataSeqApi(qyery)
  407. const data = result['data']['list']
  408. for (const item of data) {
  409. getImageDataList.value.push({
  410. value: item['inputOssId'],
  411. label: item['name']
  412. })
  413. }
  414. })
  415. const enumsAlgorithmModelTrack = ref<any>([])
  416. onMounted(async () => {
  417. const result: any = await enumAlgorithmModelTrackApi()
  418. // console.log(result.data);
  419. enumsAlgorithmModelTrack.value = []
  420. for (const item of result.data) {
  421. if (SubSystem[item['subsystem']] === '注释轨迹序列') {
  422. item['label'] = item['label'] + '-' + SubSystem[item['subsystem']] + '-' + AlgorithmType[item['type']] + '-' + item['algorithmName']
  423. enumsAlgorithmModelTrack.value.push(item)
  424. }
  425. }
  426. })
  427. </script>