index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="home-container">
  3. <dv-border-box1 ref="borderRef" style="width: 100%; height: 100%; margin: 0 auto">
  4. <div class="table-box">
  5. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listITaskNewApi" :tool-button="false">
  6. <template #tableHeader="scope">
  7. <!-- <el-button type="primary" v-auth="['system:user:add']" :icon="CirclePlus" @click="createTask()"> 创建任务 </el-button>-->
  8. <el-button type="primary" v-auth="['system:user:add']" :icon="CirclePlus" @click="createTaskNew()"> 创建任务 </el-button>
  9. <el-button type="danger" icon="Delete" plain :disabled="!scope.isSelected" @click="batchDelete(scope.selectedListIds)">
  10. 批量删除
  11. </el-button>
  12. </template>
  13. <!-- 表格操作 -->
  14. <template #operation="scope">
  15. <el-button type="primary" link icon="View" v-auth="['task:task:query']" @click="viewDetails(scope.row)"> 查看详情 </el-button>
  16. <!-- <el-button type="primary" link :icon="View" @click="openDialog(3, '任务查看', scope.row)">查看</el-button>-->
  17. </template>
  18. </ProTable>
  19. <!-- <ProTable
  20. ref="proTable"
  21. row-key="id"
  22. :columns="columns"
  23. :request-api="listTaskApi"
  24. :request-auto="false"
  25. :tool-button="false"
  26. >
  27. <template #tableHeader="">
  28. <el-button type="primary" v-auth="['system:user:add']" :icon="CirclePlus" @click="createTask()"> 创建任务 </el-button>
  29. </template>
  30. <template #operation="scope">
  31. <el-button type="primary" link :icon="View" @click="openDialog(3, '任务查看', scope.row)">查看</el-button>
  32. </template>
  33. </ProTable> -->
  34. </div>
  35. </dv-border-box1>
  36. </div>
  37. </template>
  38. <script setup lang="tsx" name="homePage">
  39. import { onMounted, reactive, ref } from 'vue'
  40. import { User } from '@/api/interface'
  41. import ProTable from '@/components/ProTable/index.vue'
  42. import FormDialog from '@/components/DialogOld/form.vue'
  43. import { CirclePlus, View } from '@element-plus/icons-vue'
  44. import { useRouter } from 'vue-router'
  45. import { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
  46. import { addUserApi, updateUserApi, deptTreeSelectApi } from '@/api/modules/system/user'
  47. // import { getTaskApi } from '@/api/modules/taais/task'
  48. // import { listTaskApi, getTaskApi } from '@/api/modules/task/task'
  49. import { listITaskNewApi, getITaskNewApi, delTaskApi } from '@/api/modules/task/task'
  50. import { getDictsApi } from '@/api/modules/system/dictData'
  51. import { useHandleData } from '@/hooks/useHandleData'
  52. // import taskDataList from '@/assets/mock/taskData.json'
  53. // import { getDictsApi } from '@/api/modules/system/dictData'
  54. onMounted(() => {
  55. getTreeFilter()
  56. })
  57. // ProTable 实例
  58. const proTable = ref<ProTableInstance>()
  59. // 如果表格需要初始化请求参数,直接定义传给 ProTable(之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
  60. const initParam = reactive({ deptId: '' })
  61. // 获取 treeFilter 数据
  62. // 当 proTable 的 requestAuto 属性为 false,不会自动请求表格数据,等待 treeFilter 数据回来之后,更改 initParam.departmentId 的值,才会触发请求 proTable 数据
  63. const treeFilterData = ref<any>([])
  64. const getTreeFilter = async () => {
  65. const { data } = await deptTreeSelectApi()
  66. treeFilterData.value = data
  67. initParam.deptId = treeFilterData.value[0].id
  68. }
  69. // 批量删除多物体融合轨迹识别信息
  70. const batchDelete = async (ids: string[]) => {
  71. await useHandleData(delTaskApi, ids, '删除所选任务')
  72. proTable.value?.clearSelection()
  73. proTable.value?.getTableList()
  74. }
  75. // 查看详情
  76. const viewDetails = row => {
  77. console.log(row)
  78. router.push({ path: `/task/subtask/`, query: { id: row.id } })
  79. }
  80. // 批量添加用户
  81. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  82. // 打开弹框的功能
  83. const openDialog = async (type: number, title: string, row?: any) => {
  84. console.log(row)
  85. let res = getITaskNewApi(row?.id || null)
  86. // 表单项配置
  87. const fieldList: Form.FieldItem[] = [
  88. {
  89. label: '任务名称',
  90. placeholder: '请输入任务名称',
  91. span: 12,
  92. field: 'taskName',
  93. rules: [{ required: true, message: '任务名称不能为空' }]
  94. }
  95. ]
  96. const params = {
  97. title,
  98. width: 680,
  99. isEdit: type !== 3,
  100. fieldList: fieldList,
  101. model: res,
  102. api: type == 1 ? addUserApi : updateUserApi,
  103. getTableList: proTable.value?.getTableList
  104. }
  105. formDialogRef.value?.openDialog(params)
  106. }
  107. const router = useRouter()
  108. // // 增加任务
  109. // const createTask = () => {
  110. // router.push(`/createTask`)
  111. // }
  112. const createTaskNew = () => {
  113. router.push(`/createTaskNew`)
  114. }
  115. // 表格配置项
  116. const columns = reactive<ColumnProps<User.ResUserList>[]>([
  117. { type: 'selection', width: 70 },
  118. { prop: 'name', label: '任务名称' },
  119. // {
  120. // prop: 'status',
  121. // label: '任务状态',
  122. // tag: true,
  123. // enum: () => getDictsApi('biz_task_status'),
  124. // fieldNames: { label: 'dictLabel', value: 'dictValue' }
  125. // },
  126. {
  127. prop: 'createTime',
  128. label: '创建时间'
  129. // search: {
  130. // el: 'input'
  131. // }
  132. },
  133. {
  134. prop: 'updateTime',
  135. label: '更新时间'
  136. // search: {
  137. // el: 'input'
  138. // }
  139. },
  140. { prop: 'operation', label: '操作', width: 230 }
  141. ])
  142. </script>
  143. <style scoped lang="scss">
  144. @import './index.scss';
  145. </style>