index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="table-box">
  3. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listSubtaskDetailApi">
  4. <!-- 表格 header 按钮 -->
  5. <template #tableHeader="scope">
  6. <el-button type="primary" v-auth="['identification:identificationSubtaskDetails:add']" icon="CirclePlus" @click="openDialog(1, '算法子任务详情新增')">
  7. 新增
  8. </el-button>
  9. <el-button type="primary" v-auth="['identification:identificationSubtaskDetails:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
  10. <el-button type="primary" v-auth="['identification:identificationSubtaskDetails:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
  11. <el-button
  12. type="danger"
  13. v-auth="['identification:identificationSubtaskDetails:remove']"
  14. icon="Delete"
  15. plain
  16. :disabled="!scope.isSelected"
  17. @click="batchDelete(scope.selectedListIds)"
  18. >
  19. 批量删除
  20. </el-button>
  21. </template>
  22. <!-- 表格操作 -->
  23. <template #operation="scope">
  24. <el-button type="primary" link icon="View" v-auth="['identification:identificationSubtaskDetails:query']" @click="openDialog(3, '算法子任务详情查看', scope.row)">
  25. 查看
  26. </el-button>
  27. <el-button type="primary" link icon="EditPen" v-auth="['identification:identificationSubtaskDetails:edit']" @click="openDialog(2, '算法子任务详情编辑', scope.row)">
  28. 编辑
  29. </el-button>
  30. <el-button type="primary" link icon="Delete" v-auth="['identification:identificationSubtaskDetails:remove']" @click="deleteSubtaskDetail(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="SubtaskDetail">
  38. import { ref, reactive } from 'vue'
  39. import { useHandleData } from '@/hooks/useHandleData'
  40. import { useDownload } from '@/hooks/useDownload'
  41. import { ElMessageBox } 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. listSubtaskDetailApi,
  48. delSubtaskDetailApi,
  49. addSubtaskDetailApi,
  50. updateSubtaskDetailApi,
  51. importTemplateApi,
  52. importSubtaskDetailDataApi,
  53. exportSubtaskDetailApi,
  54. getSubtaskDetailApi
  55. } from '@/api/modules/task/subtaskDetailNew'
  56. import { getDictsApi } from '@/api/modules/system/dictData'
  57. // ProTable 实例
  58. const proTable = ref<ProTableInstance>()
  59. // 删除算法子任务详情信息
  60. const deleteSubtaskDetail = async (params: any) => {
  61. await useHandleData(delSubtaskDetailApi, params.id, '删除【' + params.id + '】算法子任务详情')
  62. proTable.value?.getTableList()
  63. }
  64. // 批量删除算法子任务详情信息
  65. const batchDelete = async (ids: string[]) => {
  66. await useHandleData(delSubtaskDetailApi, ids, '删除所选算法子任务详情信息')
  67. proTable.value?.clearSelection()
  68. proTable.value?.getTableList()
  69. }
  70. // 导出算法子任务详情列表
  71. const downloadFile = async () => {
  72. ElMessageBox.confirm('确认导出算法子任务详情数据?', '温馨提示', { type: 'warning' }).then(() =>
  73. useDownload(exportSubtaskDetailApi, '算法子任务详情列表', proTable.value?.searchParam)
  74. )
  75. }
  76. // 批量添加算法子任务详情
  77. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  78. const batchAdd = () => {
  79. const params = {
  80. title: '算法子任务详情',
  81. tempApi: importTemplateApi,
  82. importApi: importSubtaskDetailDataApi,
  83. getTableList: proTable.value?.getTableList
  84. }
  85. dialogRef.value?.acceptParams(params)
  86. }
  87. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  88. // 打开弹框的功能
  89. const openDialog = async (type: number, title: string, row?: any) => {
  90. let res = { data: {} }
  91. if (row?.id) {
  92. res = await getSubtaskDetailApi(row?.id || null)
  93. }
  94. // 重置表单
  95. setItemsOptions()
  96. const params = {
  97. title,
  98. width: 580,
  99. isEdit: type !== 3,
  100. itemsOptions: itemsOptions,
  101. model: type == 1 ? {} : res.data,
  102. api: type == 1 ? addSubtaskDetailApi : updateSubtaskDetailApi,
  103. getTableList: proTable.value?.getTableList
  104. }
  105. formDialogRef.value?.openDialog(params)
  106. }
  107. // 表格配置项
  108. const columns = reactive<ColumnProps<any>[]>([
  109. { type: 'selection', fixed: 'left', width: 70 },
  110. {
  111. prop: 'name',
  112. label: '任务名称',
  113. search: {
  114. el: 'input'
  115. }
  116. },
  117. {
  118. prop: 'status',
  119. label: '任务状态',
  120. tag: true,
  121. enum: () => getDictsApi('biz_task_status'),
  122. search: {
  123. el: 'tree-select'
  124. },
  125. fieldNames: { label: 'dictLabel', value: 'dictValue' },
  126. width: 120
  127. },
  128. {
  129. prop: 'startTime',
  130. label: '开始时间',
  131. width: 120
  132. },
  133. {
  134. prop: 'endTime',
  135. label: '结束时间',
  136. width: 200
  137. },
  138. {
  139. prop: 'costSecond',
  140. label: '耗时',
  141. width: 200
  142. },
  143. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  144. ])
  145. // 表单配置项
  146. let itemsOptions: ProForm.ItemsOptions[] = []
  147. const setItemsOptions = () => {
  148. itemsOptions = [
  149. {
  150. label: '任务名称',
  151. prop: 'name',
  152. rules: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
  153. compOptions: {
  154. placeholder: '请输入任务名称'
  155. }
  156. },
  157. {
  158. label: '任务状态',
  159. prop: 'status',
  160. rules: [{ required: true, message: '任务状态不能为空', trigger: 'change' }],
  161. compOptions: {
  162. elTagName: 'select',
  163. labelKey: 'dictLabel',
  164. valueKey: 'dictValue',
  165. enum: () => getDictsApi('biz_task_status'),
  166. placeholder: '请选择任务状态'
  167. }
  168. },
  169. {
  170. label: '调用算法时所用的参数',
  171. prop: 'parameters',
  172. compOptions: {
  173. type: 'textarea',
  174. clearable: true,
  175. placeholder: '请输入内容'
  176. }
  177. },
  178. {
  179. label: '开始时间',
  180. prop: 'startTime',
  181. compOptions: {
  182. elTagName: 'date-picker',
  183. type: 'date',
  184. placeholder: '请选择开始时间'
  185. }
  186. },
  187. {
  188. label: '结束时间',
  189. prop: 'endTime',
  190. compOptions: {
  191. elTagName: 'date-picker',
  192. type: 'date',
  193. placeholder: '请选择结束时间'
  194. }
  195. },
  196. {
  197. label: '耗时',
  198. prop: 'costSecond',
  199. compOptions: {
  200. placeholder: '请输入耗时'
  201. }
  202. },
  203. {
  204. label: '日志',
  205. prop: 'log',
  206. compOptions: {
  207. type: 'textarea',
  208. clearable: true,
  209. placeholder: '请输入内容'
  210. }
  211. }
  212. ]
  213. }
  214. </script>