index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div class="table-box">
  3. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listToInfraredApi">
  4. <!-- 表格 header 按钮 -->
  5. <template #tableHeader="scope">
  6. <el-button type="primary" v-auth="['demo:toInfrared:add']" icon="CirclePlus" @click="openDialog(1, '可见光转红外新增')"> 新增 </el-button>
  7. <!-- <el-button type="primary" v-auth="['demo:toInfrared:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
  8. <el-button type="primary" v-auth="['demo:toInfrared:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button> -->
  9. <el-button
  10. type="danger"
  11. v-auth="['demo:toInfrared: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
  23. type="primary"
  24. link
  25. icon="View"
  26. v-auth="['demo:video2image:start']"
  27. v-if="scope.row.status == '0' || scope.row.status == '3' || scope.row.status == '4'"
  28. ><!-- @click="startVideo2image(scope.row)" -->
  29. <!-- @confirm="stopVideo2image(scope.row)" -->
  30. 开始
  31. </el-button>
  32. <el-popconfirm title="确定终止此任务吗?" v-if="scope.row.status == '1'">
  33. <template #reference>
  34. <el-button type="primary" link icon="Delete"> 终止 </el-button>
  35. </template>
  36. </el-popconfirm>
  37. <el-button type="primary" link icon="View" v-auth="['demo:video2image:download']" v-if="scope.row.status == '2'">
  38. <!-- @click="dowloadVideo2image(scope.row)" -->
  39. 下载
  40. </el-button>
  41. <!-- <el-button type="primary" link icon="View" v-auth="['demo:toInfrared:query']" @click="openDialog(3, '查看', scope.row)"> 查看 </el-button> -->
  42. <!-- <el-button type="primary" link icon="EditPen"v-auth="['demo:toInfrared:edit']" @click="openDialog(2, '编辑', scope.row)"> 编辑 </el-button> -->
  43. <el-button
  44. type="primary"
  45. link
  46. icon="Delete"
  47. v-auth="['demo:toInfrared:remove']"
  48. @click="deleteToInfrared(scope.row)"
  49. :disabled="scope.row.status == '1'"
  50. >
  51. 删除
  52. </el-button>
  53. </template>
  54. </ProTable>
  55. <FormDialog ref="formDialogRef" />
  56. <ImportExcel ref="dialogRef" />
  57. </div>
  58. </template>
  59. <script setup lang="tsx" name="ToInfrared">
  60. import { ref, reactive } from 'vue'
  61. import { useHandleData } from '@/hooks/useHandleData'
  62. import { useDownload } from '@/hooks/useDownload'
  63. import { ElMessageBox } from 'element-plus'
  64. import ProTable from '@/components/ProTable/index.vue'
  65. import ImportExcel from '@/components/ImportExcel/index.vue'
  66. import FormDialog from '@/components/FormDialog/index.vue'
  67. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  68. import {
  69. listToInfraredApi,
  70. delToInfraredApi,
  71. addToInfraredApi,
  72. updateToInfraredApi,
  73. importTemplateApi,
  74. importToInfraredDataApi,
  75. exportToInfraredApi,
  76. getToInfraredApi
  77. } from '@/api/modules/demo/toInfrared'
  78. import statusEnums from '@/utils/status'
  79. // ProTable 实例
  80. const proTable = ref<ProTableInstance>()
  81. // 删除可见光转红外信息
  82. const deleteToInfrared = async (params: any) => {
  83. await useHandleData(delToInfraredApi, params.id, '删除【' + params.id + '】可见光转红外')
  84. proTable.value?.getTableList()
  85. }
  86. // 批量删除可见光转红外信息
  87. const batchDelete = async (ids: string[]) => {
  88. await useHandleData(delToInfraredApi, ids, '删除所选可见光转红外信息')
  89. proTable.value?.clearSelection()
  90. proTable.value?.getTableList()
  91. }
  92. // 导出可见光转红外列表
  93. const downloadFile = async () => {
  94. ElMessageBox.confirm('确认导出可见光转红外数据?', '温馨提示', { type: 'warning' }).then(() =>
  95. useDownload(exportToInfraredApi, '可见光转红外列表', proTable.value?.searchParam)
  96. )
  97. }
  98. // 批量添加可见光转红外
  99. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  100. const batchAdd = () => {
  101. const params = {
  102. title: '可见光转红外',
  103. tempApi: importTemplateApi,
  104. importApi: importToInfraredDataApi,
  105. getTableList: proTable.value?.getTableList
  106. }
  107. dialogRef.value?.acceptParams(params)
  108. }
  109. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  110. // 打开弹框的功能
  111. const openDialog = async (type: number, title: string, row?: any) => {
  112. let res = { data: {} }
  113. if (row?.id) {
  114. res = await getToInfraredApi(row?.id || null)
  115. }
  116. // 重置表单
  117. setItemsOptions()
  118. const params = {
  119. title,
  120. width: 580,
  121. isEdit: type !== 3,
  122. itemsOptions: itemsOptions,
  123. model: type == 1 ? {} : res.data,
  124. api: type == 1 ? addToInfraredApi : updateToInfraredApi,
  125. getTableList: proTable.value?.getTableList
  126. }
  127. formDialogRef.value?.openDialog(params)
  128. }
  129. // 表格配置项
  130. const columns = reactive<ColumnProps<any>[]>([
  131. { type: 'selection', fixed: 'left', width: 70 },
  132. { prop: 'id', label: '主键ID', width: 180 },
  133. {
  134. prop: 'name',
  135. label: '任务名称',
  136. search: {
  137. el: 'input'
  138. },
  139. width: 150
  140. },
  141. {
  142. prop: 'status',
  143. label: '任务状态',
  144. search: {
  145. el: 'select'
  146. },
  147. tag: true,
  148. enum: statusEnums,
  149. width: 150
  150. },
  151. {
  152. prop: 'startTime',
  153. label: '开始时间',
  154. width: 180
  155. },
  156. {
  157. prop: 'endTime',
  158. label: '结束时间',
  159. width: 180
  160. },
  161. {
  162. prop: 'costSecond',
  163. label: '耗时',
  164. width: 120
  165. },
  166. {
  167. prop: 'log',
  168. label: '日志',
  169. width: 120
  170. },
  171. {
  172. prop: 'outputPath',
  173. label: '输出路径',
  174. width: 120
  175. },
  176. {
  177. prop: 'remarks',
  178. label: '备注',
  179. search: {
  180. el: 'input'
  181. },
  182. width: 120
  183. },
  184. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  185. ])
  186. // 表单配置项
  187. let itemsOptions: ProForm.ItemsOptions[] = []
  188. const setItemsOptions = () => {
  189. itemsOptions = [
  190. {
  191. label: '任务名称',
  192. prop: 'name',
  193. rules: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
  194. compOptions: {
  195. placeholder: '请输入任务名称'
  196. }
  197. },
  198. {
  199. label: '上传图片集',
  200. prop: 'inputOssId',
  201. rules: [{ required: true, message: '图片集不能为空', trigger: 'blur' }],
  202. compOptions: {
  203. elTagName: 'file-upload',
  204. fileSize: 4096,
  205. fileType: ['zip'],
  206. placeholder: '请上传图片集'
  207. }
  208. },
  209. {
  210. label: '备注',
  211. prop: 'remarks',
  212. rules: [],
  213. compOptions: {
  214. placeholder: '请输入备注'
  215. }
  216. }
  217. ]
  218. }
  219. </script>