index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. </div>
  36. </template>
  37. <script setup lang="tsx" name="VideoStable">
  38. import { ref, reactive } from 'vue'
  39. import { useHandleData } from '@/hooks/useHandleData'
  40. import { useDownload } from '@/hooks/useDownload'
  41. import { ElMessageBox, ElMessage } from 'element-plus'
  42. import ProTable from '@/components/ProTable/index.vue'
  43. import ImportExcel from '@/components/ImportExcel/index.vue'
  44. import FormDialog from '@/components/FormDialog/index.vue'
  45. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  46. import {
  47. listVideoStableApi,
  48. delVideoStableApi,
  49. addVideoStableApi,
  50. updateVideoStableApi,
  51. importTemplateApi,
  52. importVideoStableDataApi,
  53. exportVideoStableApi,
  54. getVideoStableApi,
  55. startVideoStableApi
  56. } from '@/api/modules/demo/videoStable'
  57. const startVideoStable = async (params: any) => {
  58. const res = await startVideoStableApi(params.id)
  59. if (res.code === 200) {
  60. ElMessage.success('开始去抖动成功')
  61. proTable.value?.getTableList()
  62. } else {
  63. ElMessage.error('开始去抖动失败')
  64. }
  65. }
  66. const compareVideoStable = (params: any) => {}
  67. // ProTable 实例
  68. const proTable = ref<ProTableInstance>()
  69. // 删除视频去抖动信息
  70. const deleteVideoStable = async (params: any) => {
  71. await useHandleData(delVideoStableApi, params.id, '删除【' + params.id + '】视频去抖动')
  72. proTable.value?.getTableList()
  73. }
  74. // 批量删除视频去抖动信息
  75. const batchDelete = async (ids: string[]) => {
  76. await useHandleData(delVideoStableApi, ids, '删除所选视频去抖动信息')
  77. proTable.value?.clearSelection()
  78. proTable.value?.getTableList()
  79. }
  80. // 导出视频去抖动列表
  81. const downloadFile = async () => {
  82. ElMessageBox.confirm('确认导出视频去抖动数据?', '温馨提示', { type: 'warning' }).then(() =>
  83. useDownload(exportVideoStableApi, '视频去抖动列表', proTable.value?.searchParam)
  84. )
  85. }
  86. // 批量添加视频去抖动
  87. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  88. const batchAdd = () => {
  89. const params = {
  90. title: '视频去抖动',
  91. tempApi: importTemplateApi,
  92. importApi: importVideoStableDataApi,
  93. getTableList: proTable.value?.getTableList
  94. }
  95. dialogRef.value?.acceptParams(params)
  96. }
  97. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  98. // 打开弹框的功能
  99. const openDialog = async (type: number, title: string, row?: any) => {
  100. let res = { data: {} }
  101. if (row?.id) {
  102. res = await getVideoStableApi(row?.id || null)
  103. }
  104. // 重置表单
  105. setItemsOptions()
  106. const params = {
  107. title,
  108. width: 580,
  109. isEdit: type !== 3,
  110. itemsOptions: itemsOptions,
  111. model: type == 1 ? {} : res.data,
  112. api: type == 1 ? addVideoStableApi : updateVideoStableApi,
  113. getTableList: proTable.value?.getTableList
  114. }
  115. formDialogRef.value?.openDialog(params)
  116. }
  117. // 表格配置项
  118. const columns = reactive<ColumnProps<any>[]>([
  119. { type: 'selection', fixed: 'left', width: 70 },
  120. { prop: 'id', label: '主键ID' },
  121. {
  122. prop: 'name',
  123. label: '视频名称',
  124. search: {
  125. el: 'input'
  126. },
  127. width: 120
  128. },
  129. {
  130. prop: 'status',
  131. label: '任务状态 0未开始 1进行中 2已结束',
  132. search: {
  133. el: 'input'
  134. },
  135. width: 120
  136. },
  137. {
  138. prop: 'inPath',
  139. label: '输入图片集路径',
  140. search: {
  141. el: 'input'
  142. },
  143. width: 120
  144. },
  145. {
  146. prop: 'outPath',
  147. label: '去抖动的图片集路径',
  148. search: {
  149. el: 'input'
  150. },
  151. width: 120
  152. },
  153. {
  154. prop: 'startTime',
  155. label: '开始时间',
  156. search: {
  157. el: 'date-picker',
  158. props: { type: 'datetimerange', valueFormat: 'YYYY-MM-DD HH:mm:ss' }
  159. },
  160. width: 120
  161. },
  162. {
  163. prop: 'endTime',
  164. label: '结束时间',
  165. search: {
  166. el: 'date-picker',
  167. props: { type: 'datetimerange', valueFormat: 'YYYY-MM-DD HH:mm:ss' }
  168. },
  169. width: 120
  170. },
  171. {
  172. prop: 'costSecond',
  173. label: '耗时',
  174. search: {
  175. el: 'input'
  176. },
  177. width: 120
  178. },
  179. {
  180. prop: 'log',
  181. label: '日志',
  182. search: {
  183. el: 'input'
  184. },
  185. width: 120
  186. },
  187. {
  188. prop: 'remarks',
  189. label: '备注',
  190. search: {
  191. el: 'input'
  192. },
  193. width: 120
  194. },
  195. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  196. ])
  197. // 表单配置项
  198. let itemsOptions: ProForm.ItemsOptions[] = []
  199. const setItemsOptions = () => {
  200. itemsOptions = [
  201. {
  202. label: '任务名称',
  203. prop: 'name',
  204. rules: [{ required: true, message: '视频名称不能为空', trigger: 'blur' }],
  205. compOptions: {
  206. placeholder: '请输入视频名称'
  207. }
  208. },
  209. {
  210. label: '输入路径',
  211. prop: 'inPath',
  212. rules: [{ required: true, message: '输入图片集路径不能为空', trigger: 'blur' }],
  213. compOptions: {
  214. type: 'block_size',
  215. clearable: true,
  216. placeholder: '请输入内容'
  217. }
  218. },
  219. {
  220. label: '输出路径',
  221. prop: 'outPath',
  222. rules: [{ required: true, message: '去抖动的图片集路径不能为空', trigger: 'blur' }],
  223. compOptions: {
  224. type: 'block_size',
  225. clearable: true,
  226. placeholder: '请输入内容'
  227. }
  228. },
  229. {
  230. label: '备注',
  231. prop: 'remarks',
  232. rules: [
  233. {
  234. required: false,
  235. message: '备注不能为空',
  236. trigger: 'blur'
  237. }
  238. ],
  239. compOptions: {
  240. placeholder: '请输入备注'
  241. }
  242. },
  243. {
  244. label: 'block_size',
  245. prop: 'block_size',
  246. rules: [{ required: true, message: 'block_size不能为空', trigger: 'blur' }],
  247. compOptions: {
  248. type: 'input',
  249. clearable: true,
  250. placeholder: '请输入内容',
  251. value: 50
  252. }
  253. },
  254. {
  255. label: 'radius',
  256. prop: 'radius',
  257. rules: [{ required: true, message: 'radius不能为空', trigger: 'blur' }],
  258. compOptions: {
  259. type: 'block_size',
  260. clearable: true,
  261. placeholder: '请输入内容',
  262. value: 500
  263. }
  264. },
  265. {
  266. label: 'buffer_size',
  267. prop: 'buffer_size',
  268. rules: [{ required: true, message: 'buffer_size不能为空', trigger: 'blur' }],
  269. compOptions: {
  270. type: 'block_size',
  271. clearable: true,
  272. placeholder: '请输入内容',
  273. value: 200
  274. }
  275. },
  276. {
  277. label: 'cornerquality',
  278. prop: 'cornerquality',
  279. rules: [{ required: true, message: 'cornerquality不能为空', trigger: 'blur' }],
  280. compOptions: {
  281. type: 'block_size',
  282. clearable: true,
  283. placeholder: '请输入内容',
  284. value: 0.2
  285. }
  286. },
  287. {
  288. label: 'cornerminDistance',
  289. prop: 'cornerminDistance',
  290. rules: [{ required: true, message: 'cornerminDistance不能为空', trigger: 'blur' }],
  291. compOptions: {
  292. type: 'block_size',
  293. clearable: true,
  294. placeholder: '请输入内容',
  295. value: 5
  296. }
  297. },
  298. {
  299. label: 'lklevel',
  300. prop: 'lklevel',
  301. rules: [{ required: true, message: 'lklevel不能为空', trigger: 'blur' }],
  302. compOptions: {
  303. type: 'block_size',
  304. clearable: true,
  305. placeholder: '请输入内容',
  306. value: 3
  307. }
  308. },
  309. {
  310. label: 'lkwinSiz',
  311. prop: 'lkwinSiz',
  312. rules: [{ required: true, message: 'lkwinSiz不能为空', trigger: 'blur' }],
  313. compOptions: {
  314. type: 'block_size',
  315. clearable: true,
  316. placeholder: '请输入内容',
  317. value: 15
  318. }
  319. }
  320. ]
  321. }
  322. </script>