index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <div class="table-box">
  3. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listVideoStableApi">
  4. <!-- 表格 header 按钮 -->
  5. <template #tableHeader="scope">
  6. <el-button type="primary" v-auth="['demo:videoStable:add']" icon="CirclePlus" @click="openDialog(1, '视频去抖动新增')"> 新增 </el-button>
  7. <el-button type="primary" v-auth="['demo:videoStable:import']" icon="Upload" plain @click="batchAdd"> 导入</el-button>
  8. <el-button type="primary" v-auth="['demo:videoStable:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
  9. <el-button
  10. type="danger"
  11. v-auth="['demo:videoStable: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" @click="startVideoStable(scope.row)" v-if="scope.row.status !== '2'"> 开始去抖动 </el-button>
  23. <el-button type="primary" link icon="View" @click="compareVideoStable(scope.row)" v-if="scope.row.status == '2'"> 图片对比 </el-button>
  24. <el-button type="primary" link icon="View" v-auth="['demo:videoStable:query']" @click="openDialog(3, '视频去抖动查看', scope.row)">
  25. 查看
  26. </el-button>
  27. <el-button type="primary" link icon="EditPen" v-auth="['demo:videoStable:edit']" @click="openDialog(2, '视频去抖动编辑', scope.row)">
  28. 编辑
  29. </el-button>
  30. <el-button type="primary" link icon="Delete" v-auth="['demo:videoStable:remove']" @click="deleteVideoStable(scope.row)"> 删除 </el-button>
  31. </template>
  32. </ProTable>
  33. <FormDialog ref="formDialogRef" />
  34. <ImportExcel ref="dialogRef" />
  35. <el-dialog v-model="dialogVisible" :title="'图片对比: ' + taskName + '第' + imageIdx + '张图片对比'" width="80%">
  36. <div class="image-dialog">
  37. <el-image :src="'data:image/png;base64,' + imageBase64List.origin" style="width: 45%"></el-image>
  38. <el-image :src="'data:image/png;base64,' + imageBase64List.stable" style="width: 45%"></el-image>
  39. </div>
  40. <div class="image-dialog-btn">
  41. <el-button type="primary" @click="pre_picture" :disabled="imageIdx === 1">上一个</el-button>
  42. <el-button type="primary" @click="next_picture">下一个</el-button>
  43. </div>
  44. </el-dialog>
  45. </div>
  46. </template>
  47. <script setup lang="tsx" name="VideoStable">
  48. import { ref, reactive } from 'vue'
  49. import { useHandleData } from '@/hooks/useHandleData'
  50. import { useDownload } from '@/hooks/useDownload'
  51. import { ElMessageBox, ElMessage } from 'element-plus'
  52. import ProTable from '@/components/ProTable/index.vue'
  53. import ImportExcel from '@/components/ImportExcel/index.vue'
  54. import FormDialog from '@/components/FormDialog/index.vue'
  55. import { ProTableInstance, ColumnProps, EnumProps } from '@/components/ProTable/interface'
  56. import {
  57. listVideoStableApi,
  58. delVideoStableApi,
  59. addVideoStableApi,
  60. updateVideoStableApi,
  61. importTemplateApi,
  62. importVideoStableDataApi,
  63. exportVideoStableApi,
  64. getVideoStableApi,
  65. startVideoStableApi,
  66. getCompareImageApi
  67. } from '@/api/modules/demo/videoStable'
  68. const dialogVisible = ref(false)
  69. const taskName = ref('')
  70. const imageIdx = ref(1)
  71. const imageBase64List = ref({
  72. origin: '',
  73. stable: ''
  74. })
  75. const startVideoStable = async (params: any) => {
  76. const res = await startVideoStableApi(params.id)
  77. if (res.code === 200) {
  78. ElMessage.success('开始去抖动成功')
  79. } else {
  80. ElMessage.error('开始去抖动失败')
  81. }
  82. proTable.value?.getTableList()
  83. }
  84. const loadImageData = async (taskName: string, imageIdx: number) => {
  85. const res: any = await getCompareImageApi(taskName, imageIdx)
  86. imageBase64List.value.origin = res.origin
  87. imageBase64List.value.stable = res.stable
  88. }
  89. const compareVideoStable = async (params: any) => {
  90. taskName.value = params.name
  91. imageIdx.value = 1
  92. await loadImageData(taskName.value, imageIdx.value)
  93. dialogVisible.value = true
  94. }
  95. const next_picture = async () => {
  96. imageIdx.value = imageIdx.value + 1
  97. await loadImageData(taskName.value, imageIdx.value)
  98. }
  99. const pre_picture = async () => {
  100. if (imageIdx.value > 1) {
  101. imageIdx.value = imageIdx.value - 1
  102. await loadImageData(taskName.value, imageIdx.value)
  103. }
  104. }
  105. // ProTable 实例
  106. const proTable = ref<ProTableInstance>()
  107. // 删除视频去抖动信息
  108. const deleteVideoStable = async (params: any) => {
  109. await useHandleData(delVideoStableApi, params.id, '删除【' + params.id + '】视频去抖动')
  110. proTable.value?.getTableList()
  111. }
  112. // 批量删除视频去抖动信息
  113. const batchDelete = async (ids: string[]) => {
  114. await useHandleData(delVideoStableApi, ids, '删除所选视频去抖动信息')
  115. proTable.value?.clearSelection()
  116. proTable.value?.getTableList()
  117. }
  118. // 导出视频去抖动列表
  119. const downloadFile = async () => {
  120. ElMessageBox.confirm('确认导出视频去抖动数据?', '温馨提示', { type: 'warning' }).then(() =>
  121. useDownload(exportVideoStableApi, '视频去抖动列表', proTable.value?.searchParam)
  122. )
  123. }
  124. // 批量添加视频去抖动
  125. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  126. const batchAdd = () => {
  127. const params = {
  128. title: '视频去抖动',
  129. tempApi: importTemplateApi,
  130. importApi: importVideoStableDataApi,
  131. getTableList: proTable.value?.getTableList
  132. }
  133. dialogRef.value?.acceptParams(params)
  134. }
  135. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  136. // 打开弹框的功能
  137. const openDialog = async (type: number, title: string, row?: any) => {
  138. let res = { data: {} }
  139. if (row?.id) {
  140. res = await getVideoStableApi(row?.id || null)
  141. }
  142. // 重置表单
  143. setItemsOptions()
  144. const params = {
  145. title,
  146. width: 580,
  147. isEdit: type !== 3,
  148. itemsOptions: itemsOptions,
  149. model: type == 1 ? {} : res.data,
  150. api: type == 1 ? addVideoStableApi : updateVideoStableApi,
  151. getTableList: proTable.value?.getTableList
  152. }
  153. formDialogRef.value?.openDialog(params)
  154. }
  155. const statusEnums: EnumProps[] = [
  156. {
  157. label: '未开始',
  158. value: '0',
  159. disabled: false,
  160. tagType: 'default'
  161. },
  162. {
  163. label: '进行中',
  164. value: '1',
  165. disabled: false,
  166. tagType: 'primary'
  167. },
  168. {
  169. label: '已结束',
  170. value: '2',
  171. disabled: false,
  172. tagType: 'success'
  173. },
  174. {
  175. label: '失败',
  176. value: '3',
  177. disabled: false,
  178. tagType: 'danger'
  179. }
  180. ]
  181. // 表格配置项
  182. const columns = reactive<ColumnProps<any>[]>([
  183. { type: 'selection', fixed: 'left', width: 70 },
  184. { prop: 'id', label: '主键ID' },
  185. {
  186. prop: 'name',
  187. label: '视频名称',
  188. search: {
  189. el: 'input'
  190. },
  191. width: 120
  192. },
  193. {
  194. prop: 'status',
  195. label: '任务状态',
  196. search: {
  197. el: 'input'
  198. },
  199. width: 120,
  200. tag: true,
  201. enum: statusEnums
  202. },
  203. {
  204. prop: 'startTime',
  205. label: '开始时间',
  206. search: {
  207. el: 'date-picker',
  208. props: {
  209. type: 'datetimerange',
  210. valueFormat: 'YYYY-MM-DD HH:mm:ss'
  211. }
  212. },
  213. width: 120
  214. },
  215. {
  216. prop: 'endTime',
  217. label: '结束时间',
  218. search: {
  219. el: 'date-picker',
  220. props: {
  221. type: 'datetimerange',
  222. valueFormat: 'YYYY-MM-DD HH:mm:ss'
  223. }
  224. },
  225. width: 120
  226. },
  227. {
  228. prop: 'costSecond',
  229. label: '耗时',
  230. search: {
  231. el: 'input'
  232. },
  233. width: 120
  234. },
  235. {
  236. prop: 'log',
  237. label: '日志',
  238. search: {
  239. el: 'input'
  240. },
  241. width: 120
  242. },
  243. {
  244. prop: 'block_size',
  245. label: 'block_size',
  246. search: {
  247. el: 'input'
  248. },
  249. width: 120
  250. },
  251. {
  252. prop: 'radius',
  253. label: 'radius',
  254. search: {
  255. el: 'input'
  256. },
  257. width: 120
  258. },
  259. {
  260. prop: 'cornerquality',
  261. label: 'cornerquality',
  262. search: {
  263. el: 'input'
  264. },
  265. width: 130
  266. },
  267. {
  268. prop: 'cornerminDistance',
  269. label: 'cornerminDistance',
  270. search: {
  271. el: 'input'
  272. },
  273. width: 180
  274. },
  275. {
  276. prop: 'lklevel',
  277. label: 'lklevel',
  278. search: {
  279. el: 'input'
  280. },
  281. width: 120
  282. },
  283. {
  284. prop: 'lkwinSiz',
  285. label: 'lkwinSiz',
  286. search: {
  287. el: 'input'
  288. },
  289. width: 120
  290. },
  291. {
  292. prop: 'remarks',
  293. label: '备注',
  294. search: {
  295. el: 'input'
  296. },
  297. width: 120
  298. },
  299. {
  300. prop: 'operation',
  301. label: '操作',
  302. width: 230,
  303. fixed: 'right'
  304. }
  305. ])
  306. // 表单配置项
  307. let itemsOptions: ProForm.ItemsOptions[] = []
  308. const setItemsOptions = () => {
  309. itemsOptions = [
  310. {
  311. label: '任务名称',
  312. prop: 'name',
  313. rules: [{ required: true, message: '视频名称不能为空', trigger: 'blur' }],
  314. compOptions: {
  315. placeholder: '请输入视频名称'
  316. }
  317. },
  318. {
  319. label: '图片集压缩包',
  320. prop: 'inputOssId',
  321. rules: [{ required: true, message: '图片集压缩包不能为空', trigger: 'blur' }],
  322. compOptions: {
  323. elTagName: 'file-upload',
  324. fileSize: 4096,
  325. fileType: ['zip'],
  326. placeholder: '请输入视频名称'
  327. }
  328. },
  329. {
  330. label: 'block_size',
  331. prop: 'block_size',
  332. rules: [{ required: true, message: 'block_size不能为空', trigger: 'blur' }],
  333. compOptions: {
  334. type: 'input',
  335. clearable: true,
  336. placeholder: '请输入内容',
  337. value: 50
  338. }
  339. },
  340. {
  341. label: 'radius',
  342. prop: 'radius',
  343. rules: [{ required: true, message: 'radius不能为空', trigger: 'blur' }],
  344. compOptions: {
  345. type: 'input',
  346. clearable: true,
  347. placeholder: '请输入内容',
  348. value: 500
  349. }
  350. },
  351. {
  352. label: 'buffer_size',
  353. prop: 'buffer_size',
  354. rules: [{ required: true, message: 'buffer_size不能为空', trigger: 'blur' }],
  355. compOptions: {
  356. type: 'input',
  357. clearable: true,
  358. placeholder: '请输入内容',
  359. value: 200
  360. }
  361. },
  362. {
  363. label: 'cornerquality',
  364. prop: 'cornerquality',
  365. rules: [{ required: true, message: 'cornerquality不能为空', trigger: 'blur' }],
  366. compOptions: {
  367. type: 'input',
  368. clearable: true,
  369. placeholder: '请输入内容',
  370. value: 0.2
  371. }
  372. },
  373. {
  374. label: 'cornerminDistance',
  375. prop: 'cornerminDistance',
  376. rules: [{ required: true, message: 'cornerminDistance不能为空', trigger: 'blur' }],
  377. compOptions: {
  378. type: 'input',
  379. clearable: true,
  380. placeholder: '请输入内容',
  381. value: 5
  382. }
  383. },
  384. {
  385. label: 'lklevel',
  386. prop: 'lklevel',
  387. rules: [{ required: true, message: 'lklevel不能为空', trigger: 'blur' }],
  388. compOptions: {
  389. type: 'input',
  390. clearable: true,
  391. placeholder: '请输入内容',
  392. value: 3
  393. }
  394. },
  395. {
  396. label: 'lkwinSiz',
  397. prop: 'lkwinSiz',
  398. rules: [{ required: true, message: 'lkwinSiz不能为空', trigger: 'blur' }],
  399. compOptions: {
  400. type: 'input',
  401. clearable: true,
  402. placeholder: '请输入内容',
  403. value: 15
  404. }
  405. },
  406. {
  407. label: '备注',
  408. prop: 'remarks',
  409. rules: [
  410. {
  411. required: false,
  412. message: '备注不能为空',
  413. trigger: 'blur'
  414. }
  415. ],
  416. compOptions: {
  417. placeholder: '请输入备注'
  418. }
  419. }
  420. ]
  421. }
  422. </script>
  423. <style lang="scss" scoped>
  424. .image-dialog {
  425. display: flex;
  426. justify-content: center;
  427. .el-image {
  428. margin-right: 20px;
  429. margin-bottom: 20px;
  430. }
  431. }
  432. .image-dialog-btn {
  433. display: flex;
  434. justify-content: center;
  435. margin-top: 20px;
  436. }
  437. </style>