index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <!--
  2. @Datetime : 2024/8/30 17:42
  3. @Author : WANGKANG
  4. @Email : 1686617586@qq.com
  5. @Blog :
  6. @File : index.vue.vue
  7. @brief : 视频转图片
  8. -->
  9. <template>
  10. <div class="table-box">
  11. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listVideo2imageApi">
  12. <!-- 表格 header 按钮 -->
  13. <template #tableHeader="scope">
  14. <el-button type="primary" v-auth="['demo:video2image:add']" icon="CirclePlus" @click="openDialog(1, '新增')"> 新增 </el-button>
  15. <el-button type="primary" v-auth="['demo:video2image:import']" icon="Upload" plain @click="batchAdd" v-if="false"> 导入 </el-button>
  16. <el-button type="primary" v-auth="['demo:video2image:export']" icon="Download" plain @click="downloadFile" v-if="false"> 导出 </el-button>
  17. <el-button
  18. type="danger"
  19. v-auth="['demo:video2image:remove']"
  20. icon="Delete"
  21. plain
  22. :disabled="!scope.isSelected"
  23. @click="batchDelete(scope.selectedListIds)"
  24. >
  25. 批量删除
  26. </el-button>
  27. </template>
  28. <!-- 表格操作 -->
  29. <template #operation="scope">
  30. <el-button
  31. type="primary"
  32. link
  33. icon="View"
  34. v-auth="['demo:video2image:start']"
  35. @click="startVideo2image(scope.row)"
  36. v-if="scope.row.status !== '2'"
  37. >
  38. 图片提取
  39. </el-button>
  40. <el-button
  41. type="primary"
  42. link
  43. icon="View"
  44. v-auth="['demo:video2image:download']"
  45. @click="dowloadVideo2image(scope.row)"
  46. v-if="scope.row.status == '2'"
  47. >
  48. 下载图片
  49. </el-button>
  50. <el-button type="primary" link icon="View" v-auth="['demo:video2image:query']" @click="openDialog(3, '查看', scope.row)"> 查看 </el-button>
  51. <el-button type="primary" link icon="EditPen" v-auth="['demo:video2image:edit']" @click="openDialog(2, '编辑', scope.row)"> 编辑 </el-button>
  52. <el-button type="primary" link icon="Delete" v-auth="['demo:video2image:remove']" @click="deleteVideo2image(scope.row)"> 删除 </el-button>
  53. </template>
  54. </ProTable>
  55. <FormDialog ref="formDialogRef"></FormDialog>
  56. </div>
  57. </template>
  58. <script setup lang="tsx" name="Video2image">
  59. import { ref, reactive } from 'vue'
  60. import { useHandleData } from '@/hooks/useHandleData'
  61. import { useDownload } from '@/hooks/useDownload'
  62. import { ElMessageBox, ElMessage } from 'element-plus'
  63. import ProTable from '@/components/ProTable/index.vue'
  64. import ImportExcel from '@/components/ImportExcel/index.vue'
  65. import FormDialog from '@/components/FormDialog/index.vue'
  66. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  67. import {
  68. listVideo2imageApi,
  69. delVideo2imageApi,
  70. addVideo2imageApi,
  71. updateVideo2imageApi,
  72. importTemplateApi,
  73. importVideo2imageDataApi,
  74. exportVideo2imageApi,
  75. getVideo2imageApi,
  76. startVideo2imageApi,
  77. downloadVideo2imageApi
  78. } from '@/api/modules/demo/video2image'
  79. const startVideo2image = async (params: any) => {
  80. const res = await startVideo2imageApi(params.id)
  81. if (res.code === 200) {
  82. ElMessage.success('开始视频转图片已经开始,请等待完成!')
  83. } else {
  84. ElMessage.error('开始视频转图片开始失败,请检查!')
  85. }
  86. }
  87. const dowloadVideo2image = async (params: any) => {
  88. await useDownload(downloadVideo2imageApi, params.name, params.id, true, '.zip')
  89. }
  90. // ProTable 实例
  91. const proTable = ref<ProTableInstance>()
  92. // 删除视频转图片信息
  93. const deleteVideo2image = async (params: any) => {
  94. await useHandleData(delVideo2imageApi, params.id, '删除【' + params.id + '】视频转图片')
  95. proTable.value?.getTableList()
  96. }
  97. // 批量删除视频转图片信息
  98. const batchDelete = async (ids: string[]) => {
  99. await useHandleData(delVideo2imageApi, ids, '删除所选视频转图片信息')
  100. proTable.value?.clearSelection()
  101. proTable.value?.getTableList()
  102. }
  103. // 导出视频转图片列表
  104. const downloadFile = async () => {
  105. ElMessageBox.confirm('确认导出视频转图片数据?', '温馨提示', { type: 'warning' }).then(() =>
  106. useDownload(exportVideo2imageApi, '视频转图片列表', proTable.value?.searchParam)
  107. )
  108. }
  109. // 批量添加视频转图片
  110. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  111. const batchAdd = () => {
  112. const params = {
  113. title: '视频转图片',
  114. tempApi: importTemplateApi,
  115. importApi: importVideo2imageDataApi,
  116. getTableList: proTable.value?.getTableList
  117. }
  118. dialogRef.value?.acceptParams(params)
  119. }
  120. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  121. // 打开弹框的功能
  122. const openDialog = async (type: number, title: string, row?: any) => {
  123. let res = { data: {} }
  124. if (row?.id) {
  125. res = await getVideo2imageApi(row?.id || null)
  126. }
  127. // 重置表单
  128. setItemsOptions()
  129. const params = {
  130. title,
  131. width: 580,
  132. isEdit: type !== 3,
  133. itemsOptions: itemsOptions,
  134. model: type == 1 ? {} : res.data,
  135. api: type == 1 ? addVideo2imageApi : updateVideo2imageApi,
  136. getTableList: proTable.value?.getTableList,
  137. showVideoUpload: type == 1 ? true : false
  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. width: 120
  152. },
  153. {
  154. prop: 'status',
  155. label: '任务状态',
  156. search: {
  157. el: 'input'
  158. },
  159. width: 120
  160. },
  161. {
  162. prop: 'outPath',
  163. label: '切割好的图片的保存路径',
  164. search: {
  165. el: 'input'
  166. },
  167. width: 120
  168. },
  169. {
  170. prop: 'startTime',
  171. label: '开始时间',
  172. search: {
  173. el: 'date-picker',
  174. props: { type: 'datetimerange', valueFormat: 'YYYY-MM-DD HH:mm:ss' }
  175. },
  176. width: 120
  177. },
  178. {
  179. prop: 'endTime',
  180. label: '结束时间',
  181. search: {
  182. el: 'date-picker',
  183. props: { type: 'datetimerange', valueFormat: 'YYYY-MM-DD HH:mm:ss' }
  184. },
  185. width: 120
  186. },
  187. {
  188. prop: 'costSecond',
  189. label: '耗时',
  190. search: {
  191. el: 'input'
  192. },
  193. width: 120
  194. },
  195. {
  196. prop: 'log',
  197. label: '日志',
  198. search: {
  199. el: 'input'
  200. },
  201. width: 120
  202. },
  203. {
  204. prop: 'remarks',
  205. label: '备注',
  206. search: {
  207. el: 'input'
  208. },
  209. width: 120
  210. },
  211. {
  212. prop: 'path',
  213. label: '视频本身保存路径',
  214. search: {
  215. el: 'input'
  216. },
  217. width: 120
  218. },
  219. {
  220. prop: 'fps',
  221. label: '切割帧率,默认1',
  222. search: {
  223. el: 'input'
  224. },
  225. width: 120
  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: 'remarks',
  244. rules: [{ required: true, message: '备注不能为空', trigger: 'blur' }],
  245. compOptions: {
  246. placeholder: '请输入备注'
  247. }
  248. },
  249. {
  250. label: '切割帧率',
  251. prop: 'fps',
  252. rules: [
  253. { required: true, message: '切割帧率不能为空', trigger: 'blur' }
  254. // {
  255. // type: 'number',
  256. // message: '切割帧率必须为数字',
  257. // trigger: 'blur'
  258. // },
  259. // { min: 1, message: '切割帧率必须大于等于1', trigger: 'blur' },
  260. // { max: 60, message: '切割帧率必须小于等于60', trigger: 'blur' }
  261. ],
  262. compOptions: {
  263. type: 'number',
  264. placeholder: '请输入切割帧率,范围:1-60'
  265. }
  266. }
  267. ]
  268. }
  269. </script>
  270. <style scoped></style>