index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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="listDataSeqApi">
  9. <!-- 表格 header 按钮 -->
  10. <template #tableHeader="scope">
  11. <el-button type="primary" v-auth="['demo:DataSeq:add']" icon="CirclePlus" @click="openDialog(1, '数据集新增')"> 新增 </el-button>
  12. <!-- <el-button type="primary" v-auth="['demo:DataSeq:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
  13. <el-button type="primary" v-auth="['demo:DataSeq:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button> -->
  14. <el-button
  15. type="danger"
  16. v-auth="['demo:DataSeq: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" v-auth="['demo:DataSeq:query']" @click="openDialog(3, '数据管理查看', scope.row)">
  28. 查看
  29. </el-button>
  30. <el-button type="primary" link icon="View" v-auth="['demo:DataSeq:query']" @click="preview(scope.row)"> 预览</el-button>
  31. <!-- <el-button type="primary" link icon="EditPen" v-auth="['demo:DataSeq:edit']" @click="openDialog(2, '数据管理编辑', scope.row)">
  32. 编辑
  33. </el-button> -->
  34. <el-button type="primary" link icon="Delete" v-auth="['demo:DataSeq:remove']" @click="deleteDataSeq(scope.row)"> 删除 </el-button>
  35. </template>
  36. </ProTable>
  37. <FormDialog ref="formDialogRef" />
  38. <!-- <ImportExcel ref="dialogRef" /> -->
  39. <PreviewImages ref="previewImagesRef" />
  40. <PreviewCompareImages ref="previewCompareImagesRef" />
  41. </div>
  42. </template>
  43. <script setup lang="tsx" name="DataSeq">
  44. import { ref, reactive } from 'vue'
  45. import { useHandleData } from '@/hooks/useHandleData'
  46. import { useDownload } from '@/hooks/useDownload'
  47. import { ElMessageBox } from 'element-plus'
  48. import ProTable from '@/components/ProTable/index.vue'
  49. import ImportExcel from '@/components/ImportExcel/index.vue'
  50. import FormDialog from '@/components/FormDialog/index.vue'
  51. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  52. import {
  53. listDataSeqApi,
  54. delDataSeqApi,
  55. addDataSeqApi,
  56. updateDataSeqApi,
  57. importTemplateApi,
  58. importDataSeqDataApi,
  59. exportDataSeqApi,
  60. getDataSeqApi,
  61. getAllImagesApi,
  62. getCOMPImagesApi
  63. } from '@/api/modules/demo/DataSeq'
  64. import { enumsSubSystem } from '../utils'
  65. import PreviewImages from '@/views/demo/components/PreviewImages.vue'
  66. import { SubSystem__ } from '@/views/demo/utils'
  67. import PreviewCompareImages from '@/views/demo/components/PreviewCompareImages.vue'
  68. const previewImagesRef = ref()
  69. const previewCompareImagesRef = ref()
  70. const preview = async row => {
  71. console.log('showImages')
  72. console.log(row)
  73. if (row.subsystem !== SubSystem__['可见光转红外']) {
  74. console.log('不可见光转红外')
  75. await previewImagesRef.value?.handleOpen(getAllImagesApi, row.inputOssId)
  76. } else {
  77. console.log('可见光转红外')
  78. let res = null
  79. try {
  80. res = await previewCompareImagesRef.value?.handleOpen(getCOMPImagesApi, row.inputOssId)
  81. } catch (error) {
  82. console.log(error)
  83. res = null
  84. }
  85. if (!res) {
  86. previewCompareImagesRef.value?.closeDialog()
  87. await previewImagesRef.value?.handleOpen(getAllImagesApi, row.inputOssId)
  88. }
  89. }
  90. }
  91. // ProTable 实例
  92. const proTable = ref<ProTableInstance>()
  93. // 删除数据管理信息
  94. const deleteDataSeq = async (params: any) => {
  95. await useHandleData(delDataSeqApi, params.id, '删除【' + params.id + '】数据管理')
  96. proTable.value?.getTableList()
  97. }
  98. // 批量删除数据管理信息
  99. const batchDelete = async (ids: string[]) => {
  100. await useHandleData(delDataSeqApi, ids, '删除所选数据管理信息')
  101. proTable.value?.clearSelection()
  102. proTable.value?.getTableList()
  103. }
  104. // 导出数据管理列表
  105. const downloadFile = async () => {
  106. ElMessageBox.confirm('确认导出数据管理数据?', '温馨提示', { type: 'warning' }).then(() =>
  107. useDownload(exportDataSeqApi, '数据管理列表', proTable.value?.searchParam)
  108. )
  109. }
  110. // 批量添加数据管理
  111. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  112. const batchAdd = () => {
  113. const params = {
  114. title: '数据管理',
  115. tempApi: importTemplateApi,
  116. importApi: importDataSeqDataApi,
  117. getTableList: proTable.value?.getTableList
  118. }
  119. dialogRef.value?.acceptParams(params)
  120. }
  121. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  122. // 打开弹框的功能
  123. const openDialog = async (type: number, title: string, row?: any) => {
  124. let res = { data: {} }
  125. if (row?.id) {
  126. res = await getDataSeqApi(row?.id || null)
  127. }
  128. // 重置表单
  129. setItemsOptions()
  130. const params = {
  131. title,
  132. width: 580,
  133. isEdit: type !== 3,
  134. itemsOptions: itemsOptions,
  135. model: type == 1 ? {} : res.data,
  136. api: type == 1 ? addDataSeqApi : updateDataSeqApi,
  137. getTableList: proTable.value?.getTableList
  138. }
  139. formDialogRef.value?.openDialog(params)
  140. }
  141. // 表格配置项
  142. const columns = reactive<ColumnProps<any>[]>([
  143. { type: 'selection', fixed: 'left', width: 70 },
  144. { prop: 'id', label: 'id' },
  145. {
  146. prop: 'name',
  147. label: '名称',
  148. search: {
  149. el: 'input'
  150. }
  151. },
  152. {
  153. prop: 'subsystem',
  154. label: '分系统',
  155. tag: true,
  156. enum: enumsSubSystem,
  157. search: {
  158. el: 'select'
  159. },
  160. width: 120
  161. },
  162. {
  163. prop: 'objectType',
  164. label: '目标类型',
  165. search: {
  166. el: 'input'
  167. },
  168. width: 120
  169. },
  170. {
  171. prop: 'objectSubtype',
  172. label: '目标子类型',
  173. search: {
  174. el: 'input'
  175. },
  176. width: 120
  177. },
  178. {
  179. prop: 'batchNum',
  180. label: '批次号',
  181. search: {
  182. el: 'input'
  183. }
  184. },
  185. {
  186. prop: 'scene',
  187. label: '场景',
  188. search: {
  189. el: 'input'
  190. }
  191. },
  192. {
  193. prop: 'dataSource',
  194. label: '数据源',
  195. search: {
  196. el: 'input'
  197. }
  198. },
  199. {
  200. prop: 'gatherSpot',
  201. label: '采集地点',
  202. search: {
  203. el: 'input'
  204. }
  205. },
  206. {
  207. prop: 'remarks',
  208. label: '备注',
  209. search: {
  210. el: 'input'
  211. }
  212. },
  213. {
  214. prop: 'filePath',
  215. label: '文件路径',
  216. search: {
  217. el: 'input'
  218. }
  219. },
  220. {
  221. prop: 'unzipPath',
  222. label: '解压路径',
  223. search: {
  224. el: 'input'
  225. }
  226. },
  227. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  228. ])
  229. // 表单配置项
  230. let itemsOptions: ProForm.ItemsOptions[] = []
  231. const setItemsOptions = () => {
  232. itemsOptions = [
  233. {
  234. label: '名称',
  235. prop: 'name',
  236. rules: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
  237. compOptions: {
  238. placeholder: '请输入名称'
  239. }
  240. },
  241. {
  242. label: '分系统',
  243. prop: 'subsystem',
  244. rules: [{ required: true, message: '分系统不能为空', trigger: 'blur' }],
  245. compOptions: {
  246. elTagName: 'select',
  247. enum: enumsSubSystem,
  248. placeholder: '请选择分系统'
  249. }
  250. },
  251. {
  252. label: '批次号',
  253. prop: 'batchNum',
  254. rules: [{ required: true, message: '批次号不能为空', trigger: 'blur' }],
  255. compOptions: {
  256. placeholder: '请输入批次号'
  257. }
  258. },
  259. {
  260. label: '上传文件',
  261. prop: 'inputOssId',
  262. rules: [{ required: true, message: '数据集文件不能为空', trigger: 'blur' }],
  263. compOptions: {
  264. elTagName: 'file-upload',
  265. fileSize: 4096,
  266. fileType: ['zip'],
  267. placeholder: '请上传数据集文件'
  268. }
  269. },
  270. // {
  271. // label: '文件类型',
  272. // prop: 'fileType',
  273. // rules: [{ required: true, message: '文件类型不能为空', trigger: 'blur' }],
  274. // compOptions: {
  275. // placeholder: '请输入文件类型'
  276. // }
  277. // },
  278. {
  279. label: '目标类型',
  280. prop: 'objectType',
  281. rules: [{ required: false, message: '目标类型不能为空', trigger: 'blur' }],
  282. compOptions: {
  283. placeholder: '请输入目标类型'
  284. }
  285. },
  286. {
  287. label: '目标子类型',
  288. prop: 'objectSubtype',
  289. rules: [{ required: false, message: '目标子类型不能为空', trigger: 'blur' }],
  290. compOptions: {
  291. placeholder: '请输入目标子类型'
  292. }
  293. },
  294. {
  295. label: '场景',
  296. prop: 'scene',
  297. rules: [{ required: false, message: '场景不能为空', trigger: 'blur' }],
  298. compOptions: {
  299. placeholder: '请输入场景'
  300. }
  301. },
  302. {
  303. label: '数据源',
  304. prop: 'dataSource',
  305. rules: [{ required: false, message: '数据源不能为空', trigger: 'blur' }],
  306. compOptions: {
  307. placeholder: '请输入数据源'
  308. }
  309. },
  310. {
  311. label: '采集时间',
  312. prop: 'gatherTime',
  313. rules: [{ required: false, message: '采集时间不能为空', trigger: 'change' }],
  314. compOptions: {
  315. elTagName: 'date-picker',
  316. type: 'date',
  317. placeholder: '请选择采集时间'
  318. }
  319. },
  320. {
  321. label: '采集地点',
  322. prop: 'gatherSpot',
  323. rules: [{ required: false, message: '采集地点不能为空', trigger: 'blur' }],
  324. compOptions: {
  325. placeholder: '请输入采集地点'
  326. }
  327. },
  328. // {
  329. // label: '图片url',
  330. // prop: 'url',
  331. // rules: [{ required: true, message: '图片url不能为空', trigger: 'blur' }],
  332. // compOptions: {
  333. // placeholder: '请输入图片url'
  334. // }
  335. // },
  336. // {
  337. // label: '日志',
  338. // prop: 'log',
  339. // rules: [{ required: true, message: '日志不能为空', trigger: 'blur' }],
  340. // compOptions: {
  341. // type: 'textarea',
  342. // clearable: true,
  343. // placeholder: '请输入内容'
  344. // }
  345. // },
  346. {
  347. label: '备注',
  348. prop: 'remarks',
  349. rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
  350. compOptions: {
  351. placeholder: '请输入备注'
  352. }
  353. }
  354. ]
  355. }
  356. </script>
  357. <style lang="scss" scoped></style>