hc-data.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <hc-tab-card :tabs="tabsData" :tab-key="tabsKey" @change="tabsClick">
  3. <!-- template v-if="tabsKey === '1'" #extra>
  4. <el-button :disabled="tableCheckedKeys.length <= 0" hc-btn type="primary" @click="batchApprovalTaskClick">批量审批</el-button>
  5. </template -->
  6. <template #search>
  7. <div class="w-32">
  8. <el-select v-model="searchForm.typeValue" clearable block placeholder="任务类型11111111">
  9. <el-option v-for="item in tasksType" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  10. </el-select>
  11. </div>
  12. <div class="ml-2 w-32">
  13. <el-select v-model="searchForm.statusValue" clearable block placeholder="任务状态">
  14. <el-option v-for="item in tasksStatus" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  15. </el-select>
  16. </div>
  17. <div class="ml-2 w-32">
  18. <el-select v-model="searchForm.batchValue" clearable block placeholder="上报批次">
  19. <!-- el-option v-for="item in reportBatch" :label="item.batch" :value="item.batch" / -->
  20. </el-select>
  21. </div>
  22. <div class="ml-2 w-64">
  23. <hc-date-picker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
  24. </div>
  25. <hc-search-input v-model="searchForm.queryValue" class="ml-2" placeholder="请输入名称关键词检索" @search="searchClick" />
  26. </template>
  27. <hc-table
  28. ref="tableListRef" :column="tableListColumn" :datas="tableListData" :loading="tableLoading"
  29. is-new is-check :check-style="{ width: 29 }" :index-style="{ width: 60 }"
  30. @selection-change="tableSelectionChange"
  31. >
  32. <template #taskName="{ row }">
  33. <span class="text-link" @click="rowTaskName(row)">{{ row?.taskName }}</span>
  34. </template>
  35. <template #taskStatusName="{ row }">
  36. <el-tooltip effect="dark" :content="row.rejectDesc" placement="top" :disabled="row.taskStatusName !== '已废除'">
  37. <HcTaskTag :name="row.taskStatusName" :type="`${row.taskStatusName === '已审批' ? 'success' : row.taskStatusName === '已废除' ? 'warning' : 'info'}`" />
  38. </el-tooltip>
  39. </template>
  40. <template #taskApproveUserNamesList="{ row }">
  41. <template v-for="(item, index) in row.taskApproveUserNamesList" :key="index">
  42. <HcTaskTag :name="item.taskUserName" :type="`${item.evisaStatus === 2 ? 'success' : item.evisaStatus === 3 ? 'warning' : item.evisaStatus === 999 ? 'danger' : 'info'}`" />
  43. </template>
  44. </template>
  45. </hc-table>
  46. <template #action>
  47. <div class="lr-dialog-footer">
  48. <div class="left">
  49. <span class="text-success">审批人员中:</span>
  50. <el-tag class="mx-1" effect="dark" type="info">未签字</el-tag>
  51. <el-tag class="mx-1" effect="dark" type="success">已签字</el-tag>
  52. <el-tag class="mx-1" effect="dark" type="warning">已废除</el-tag>
  53. <el-tag class="mx-1" effect="dark" type="danger">签字异常</el-tag>
  54. </div>
  55. <div class="right">
  56. <hc-pages :pages="searchForm" :sizes="[50, 100, 150, 200, 300]" @change="pageChange" />
  57. </div>
  58. </div>
  59. </template>
  60. <!-- 任务审核 -->
  61. <taskReview v-model="isTaskReviewModalshow" :tabs="tabsKey" :row="taskReviewRow" @finish="taskReviewFinish" />
  62. </hc-tab-card>
  63. </template>
  64. <script setup>
  65. import { nextTick, onActivated, ref } from 'vue'
  66. import { getArrValue } from 'js-fast-way'
  67. import mainApi from '~api/tasks/hc-data'
  68. import { useAppStore } from '~src/store'
  69. import taskReview from './components/hc-data/task-review.vue'
  70. import HcTaskTag from './components/hc-data/task-tag.vue'
  71. const useAppState = useAppStore()
  72. const projectId = ref(useAppState.getProjectId || '')
  73. const contractId = ref(useAppState.getContractId || '')
  74. //渲染完成
  75. onActivated(() => {
  76. queryTaskType()
  77. queryTaskStatus()
  78. getTableData()
  79. })
  80. //类型处理
  81. const tabsKey = ref('1')
  82. const tabsData = [
  83. { key: '1', name: '待办任务' },
  84. { key: '2', name: '已办任务' },
  85. { key: '3', name: '我发起的' },
  86. ]
  87. const tabsClick = ({ key }) => {
  88. tabsKey.value = key
  89. searchForm.value.selectedType = key
  90. searchForm.value.current = 1
  91. getTableData()
  92. }
  93. //搜索条件
  94. const searchForm = ref({
  95. selectedType: 1, typeValue: '', statusValue: '', batchValue: '', queryValue: '', startTimeValue: '', endTimeValue: '',
  96. current: 1, size: 100, total: 0,
  97. })
  98. //获取任务类型
  99. const tasksType = ref([])
  100. const queryTaskType = async () => {
  101. const { data } = await mainApi.queryTaskType()
  102. tasksType.value = getArrValue(data)
  103. }
  104. //获取任务状态
  105. const tasksStatus = ref([])
  106. const queryTaskStatus = async () => {
  107. const { data } = await mainApi.queryTaskStatus({ typeOrStatus: 'task_status' })
  108. // tasksStatus.value = getArrValue(data)
  109. tasksStatus.value = [{ dictKey: '1', dictValue: '待审批' }, { dictKey: '2', dictValue: '已审批' }, { dictKey: '3', dictValue: '已废除' }, { dictKey: '4', dictValue: '可审批' }]
  110. }
  111. //日期范围选择
  112. const betweenTime = ref(null)
  113. const betweenTimeUpdate = ({ val, arr }) => {
  114. betweenTime.value = arr
  115. searchForm.value.startTimeValue = val['start']
  116. searchForm.value.endTimeValue = val['end']
  117. }
  118. //搜索
  119. const searchClick = () => {
  120. searchForm.value.current = 1
  121. getTableData()
  122. }
  123. //分页被点击
  124. const pageChange = ({ current, size }) => {
  125. searchForm.value.current = current
  126. searchForm.value.size = size
  127. getTableData()
  128. }
  129. //获取数据
  130. const tableListRef = ref(null)
  131. const tableListColumn = ref([
  132. { key: 'taskName', name: '任务名称', autoWidth: true },
  133. { key: 'taskTypeName', name: '任务类型', width: '120' },
  134. { key: 'taskStatusName', name: '任务状态', width: '120' },
  135. { key: 'startTime', name: '开始时间', width: '160' },
  136. { key: 'endTime', name: '限定时间', width: '160' },
  137. { key: 'taskDesc', name: '任务描述', autoWidth: true },
  138. { key: 'taskReportUserName', name: '上报人', width: '120' },
  139. { key: 'fixedFlowName', name: '任务流程', width: '120' },
  140. { key: 'taskApproveUserNamesList', name: '签字人员', autoWidth: true },
  141. { key: 'evisaStatus', name: '电签状态', width: '120' },
  142. ])
  143. const tableListData = ref([])
  144. //获取表格数据
  145. const tableLoading = ref(false)
  146. const getTableData = async () => {
  147. tableLoading.value = true
  148. //清空数据
  149. tableListData.value = []
  150. tableListRef.value?.clearSelection()
  151. tableCheckedKeys.value = []
  152. //发起请求
  153. const { error, code, data } = await mainApi.getPage({
  154. ...searchForm.value,
  155. projectId: projectId.value,
  156. contractId: contractId.value,
  157. })
  158. //处理数据
  159. tableLoading.value = false
  160. if (!error && code === 200) {
  161. tableListData.value = getArrValue(data?.records)
  162. searchForm.value.total = data.total || 0
  163. } else {
  164. tableListData.value = []
  165. searchForm.value.total = 0
  166. }
  167. }
  168. //多选
  169. const tableCheckedKeys = ref([])
  170. const tableSelectionChange = (rows) => {
  171. tableCheckedKeys.value = rows
  172. }
  173. //任务名称被点击
  174. const taskReviewRow = ref({})
  175. const isTaskReviewModalshow = ref(false)
  176. const rowTaskName = (row) => {
  177. taskReviewRow.value = row
  178. nextTick(() => {
  179. isTaskReviewModalshow.value = true
  180. })
  181. }
  182. //审批完成
  183. const taskReviewFinish = () => {
  184. getTableData()
  185. }
  186. </script>