TableCard.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <HcNewCard>
  3. <template #header>
  4. <div class="w-32">
  5. <el-select v-model="searchForm.typeValue" block clearable placeholder="任务类型">
  6. <el-option v-for="item in tasksType" :label="item.dictValue" :value="item.dictKey" />
  7. </el-select>
  8. </div>
  9. <div class="w-32 ml-3">
  10. <el-select v-model="searchForm.statusValue" block clearable placeholder="任务状态">
  11. <el-option v-for="item in tasksStatus" :label="item.dictValue" :value="item.dictKey" />
  12. </el-select>
  13. </div>
  14. <div class="w-32 ml-3">
  15. <el-select v-model="searchForm.contractIdValue" block clearable placeholder="合同段" @change="ContractIdChange">
  16. <el-option v-for="item in contractList" :label="item.contractName" :value="item.id" />
  17. </el-select>
  18. </div>
  19. <div class="w-32 ml-3">
  20. <el-select v-model="searchForm.batch" block clearable placeholder="上报批次">
  21. <el-option v-for="item in reportBatch" :label="item.batch" :value="item.batch" />
  22. </el-select>
  23. </div>
  24. <div class="w-64 ml-3">
  25. <HcDatePicker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
  26. </div>
  27. <div class="w-56 ml-3">
  28. <el-input v-model="searchForm.queryValue" block clearable placeholder="请输入名称关键词检索" @keyup="keyUpEvent" />
  29. </div>
  30. <div class="ml-2">
  31. <el-button type="primary" @click="searchClick">
  32. <HcIcon name="search-2" />
  33. <span>搜索</span>
  34. </el-button>
  35. </div>
  36. </template>
  37. <template #extra>
  38. <HcTooltip keys="tasks_data_set_sign_rules">
  39. <el-button hc-btn @click="setSignRulesClick">
  40. <HcIcon name="settings" />
  41. <span>设置重签规则</span>
  42. </el-button>
  43. </HcTooltip>
  44. <HcTooltip v-if="isTableKey === 'key1'" keys="tasks_data_batch_review">
  45. <el-button
  46. :disabled="tableCheckedKeys.length <= 0" hc-btn type="primary"
  47. @click="batchApprovalTaskClick"
  48. >
  49. <HcIcon name="check-double" />
  50. <span>批量审批</span>
  51. </el-button>
  52. </HcTooltip>
  53. </template>
  54. <HcTable
  55. ref="tableListRef" :column="tableListColumn" :datas="tableListData" :loading="tableLoading"
  56. is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
  57. @selection-change="tableSelectionChange"
  58. >
  59. <template #taskName="{ row }">
  60. <span class="text-link" @click="rowTaskName(row)">{{ row?.taskName }}</span>
  61. </template>
  62. <template #taskStatusName="{ row }">
  63. <el-tag
  64. v-if="row?.taskStatusName"
  65. :type="`${row.taskStatusName === '已审批' ? 'success' : row.taskStatusName === '已废除' ? 'warning' : 'info'}`" class="mx-1" effect="dark"
  66. >
  67. {{ row.taskStatusName }}
  68. </el-tag>
  69. </template>
  70. <template #taskApproveUserNamesList="{ row }">
  71. <template v-for="item in row.taskApproveUserNamesList">
  72. <el-tag
  73. v-if="item.taskUserName"
  74. :type="`${item.evisaStatus === 2 ? 'success' : item.evisaStatus === 3 ? 'warning' : item.evisaStatus === 999 ? 'danger' : 'info'}`" class="mx-1" effect="dark"
  75. >
  76. {{ item.taskUserName }}
  77. </el-tag>
  78. </template>
  79. </template>
  80. </HcTable>
  81. <template #action>
  82. <div class="lr-dialog-footer">
  83. <div class="left">
  84. <span class="text-success">审批人员中:</span>
  85. <el-tag class="mx-1" effect="dark" type="info">未签字</el-tag>
  86. <el-tag class="mx-1" effect="dark" type="success">已签字</el-tag>
  87. <el-tag class="mx-1" effect="dark" type="warning">已废除</el-tag>
  88. <el-tag class="mx-1" effect="dark" type="danger">签字异常</el-tag>
  89. </div>
  90. <div class="right">
  91. <HcPages :pages="searchForm" :sizes="[10, 20, 30, 40, 50, 200]" @change="pageChange" />
  92. </div>
  93. </div>
  94. </template>
  95. </HcNewCard>
  96. </template>
  97. <script setup>
  98. import { nextTick, ref, watch } from 'vue'
  99. import { getArrValue } from 'js-fast-way'
  100. import tasksApi from '~api/tasks/data'
  101. import { useAppStore } from '~src/store'
  102. //参数
  103. const props = defineProps({
  104. projectId: {
  105. type: [String, Number],
  106. default: '',
  107. },
  108. contractId: {
  109. type: [String, Number],
  110. default: '',
  111. },
  112. contractList: {
  113. type: Array,
  114. default: () => ([]),
  115. },
  116. tableKey: {
  117. type: String,
  118. default: '',
  119. },
  120. selectContracId:{
  121. type: String,
  122. default: '',
  123. },
  124. })
  125. //事件
  126. const emit = defineEmits(['rowTaskName', 'signRules', 'batchApproval', 'changeselectContracId'])
  127. //初始变量
  128. const useAppState = useAppStore()
  129. //变量
  130. const projectId = ref(props.projectId)
  131. const contractId = ref(props.contractId)
  132. const isTableKey = ref(props.tableKey)
  133. const currentContractId = ref(useAppState.getContractId)
  134. const selectContracId = ref(props.selectContracId)
  135. //监听
  136. watch(() => [
  137. props.tableKey, props.selectContracId,
  138. ], ([Key, Sid]) => {
  139. isTableKey.value = Key
  140. selectContracId.value = Sid
  141. setQueryData()
  142. })
  143. //渲染完成
  144. nextTick(() => {
  145. setQueryData()
  146. })
  147. //获取相关数据
  148. const setQueryData = () => {
  149. // searchForm.value.contractIdValue = contractId.value
  150. searchForm.value.contractIdValue = selectContracId.value
  151. queryTaskType()
  152. queryTaskStatus()
  153. searchClick()
  154. queryBatchList()
  155. }
  156. //获取任务类型
  157. const tasksType = ref([])
  158. const queryTaskType = async () => {
  159. const { error, code, data } = await tasksApi.queryTaskTypeStatus({
  160. typeOrStatus: 'task_type',
  161. })
  162. if (!error && code === 200) {
  163. tasksType.value = getArrValue(data)
  164. } else {
  165. tasksType.value = []
  166. }
  167. }
  168. //获取任务状态
  169. const tasksStatus = ref([])
  170. const queryTaskStatus = async () => {
  171. const { error, code, data } = await tasksApi.queryTaskTypeStatus({
  172. typeOrStatus: 'task_status',
  173. })
  174. if (!error && code === 200) {
  175. tasksStatus.value = getArrValue(data)
  176. } else {
  177. tasksStatus.value = []
  178. }
  179. }
  180. //合同段
  181. const ContractIdChange = (val) => {
  182. searchForm.value.batch = null
  183. emit('changeselectContracId', val)
  184. queryBatchList()
  185. // queryUserStartFlow()
  186. getTableData()
  187. }
  188. //获取上报批次
  189. const reportBatch = ref([])
  190. const queryBatchList = async () => {
  191. const { contractId } = searchForm.value
  192. if (contractId) {
  193. const { error, code, data } = await tasksApi.queryBatchList({
  194. projectId: projectId.value,
  195. contractId: contractId || '',
  196. })
  197. if (!error && code === 200) {
  198. reportBatch.value = getArrValue(data)
  199. } else {
  200. reportBatch.value = []
  201. }
  202. } else {
  203. reportBatch.value = []
  204. }
  205. }
  206. //搜索表单
  207. const searchForm = ref({
  208. queryValue: null, typeValue: null, statusValue: null, batch: null, startTimeValue: null, endTimeValue: null,
  209. current: 1, size: 200, total: 0,
  210. })
  211. //日期时间被选择
  212. const betweenTime = ref(null)
  213. const betweenTimeUpdate = ({ val, arr }) => {
  214. betweenTime.value = arr
  215. searchForm.value.startTimeValue = val['start']
  216. searchForm.value.endTimeValue = val['end']
  217. }
  218. //回车搜索
  219. const keyUpEvent = (e) => {
  220. if (e.key === 'Enter') {
  221. searchForm.value.current = 1
  222. getTableData()
  223. }
  224. }
  225. //搜索
  226. const searchClick = () => {
  227. searchForm.value.current = 1
  228. getTableData()
  229. }
  230. //分页被点击
  231. const pageChange = ({ current, size }) => {
  232. searchForm.value.current = current
  233. searchForm.value.size = size
  234. getTableData()
  235. }
  236. //获取数据
  237. const tableLoading = ref(false)
  238. const tableListColumn = ref([
  239. { key: 'taskName', name: '任务名称' },
  240. { key: 'taskTypeName', name: '任务类型', width: '120' },
  241. { key: 'taskStatusName', name: '任务状态', width: '160' },
  242. { key: 'startTime', name: '开始时间', width: '180' },
  243. { key: 'endTime', name: '限定时间', width: '180' },
  244. { key: 'taskDesc', name: '任务描述' },
  245. { key: 'taskReportUserName', name: '上报人', width: '120' },
  246. { key: 'taskApproveUserNamesList', name: '签字人员' },
  247. { key: 'evisaStatus', name: '电签状态' },
  248. ])
  249. const tableListData = ref([])
  250. const getTableData = () => {
  251. const key = isTableKey.value
  252. tableListRef.value?.clearSelection()
  253. tableCheckedKeys.value = []
  254. // if (key === 'key1') {
  255. // queryUserToDoTaskList()
  256. // } else if (key === 'key2') {
  257. // queryUserDoneTaskList()
  258. // } else if (key === 'key3') {
  259. // queryUserStartFlow()
  260. // }
  261. if (key === 'key1') {
  262. searchForm.value.selectedType = 1
  263. } else if (key === 'key2') {
  264. searchForm.value.selectedType = 2
  265. } else if (key === 'key3') {
  266. searchForm.value.selectedType = 3
  267. }
  268. queryPage()
  269. }
  270. //待办任务列表
  271. // const queryUserToDoTaskList = async () => {
  272. // tableLoading.value = true
  273. // const { error, code, data } = await tasksApi.queryUserToDoTaskList({
  274. // ...searchForm.value,
  275. // projectId: projectId.value,
  276. // currentContractId:currentContractId.value,
  277. // })
  278. // //处理数据
  279. // tableLoading.value = false
  280. // if (!error && code === 200) {
  281. // tableListData.value = getArrValue(data['records'])
  282. // searchForm.value.total = data.total || 0
  283. // } else {
  284. // tableListData.value = []
  285. // searchForm.value.total = 0
  286. // }
  287. // }
  288. //任务列表
  289. const queryPage = async () => {
  290. tableLoading.value = true
  291. const { error, code, data } = await tasksApi.getTaskPage({
  292. ...searchForm.value,
  293. projectIdValue: projectId.value,
  294. currentContractId:currentContractId.value,
  295. })
  296. //处理数据
  297. tableLoading.value = false
  298. if (!error && code === 200) {
  299. tableListData.value = getArrValue(data['records'])
  300. searchForm.value.total = data.total || 0
  301. } else {
  302. tableListData.value = []
  303. searchForm.value.total = 0
  304. }
  305. }
  306. //获取已办任务
  307. const queryUserDoneTaskList = async () => {
  308. tableLoading.value = true
  309. const { error, code, data } = await tasksApi.queryUserDoneTaskList({
  310. ...searchForm.value,
  311. projectId: projectId.value,
  312. })
  313. //处理数据
  314. tableLoading.value = false
  315. if (!error && code === 200) {
  316. tableListData.value = getArrValue(data['records'])
  317. searchForm.value.total = data.total || 0
  318. } else {
  319. tableListData.value = []
  320. searchForm.value.total = 0
  321. }
  322. }
  323. //获取我发起的
  324. const queryUserStartFlow = async () => {
  325. tableLoading.value = true
  326. const { error, code, data } = await tasksApi.queryUserStartFlow({
  327. ...searchForm.value,
  328. projectId: projectId.value,
  329. })
  330. //处理数据
  331. tableLoading.value = false
  332. if (!error && code === 200) {
  333. tableListData.value = getArrValue(data?.records) || []
  334. searchForm.value.total = data?.total || 0
  335. } else {
  336. tableListData.value = []
  337. searchForm.value.total = 0
  338. }
  339. }
  340. //多选
  341. const tableListRef = ref(null)
  342. const tableCheckedKeys = ref([])
  343. const tableSelectionChange = (rows) => {
  344. tableCheckedKeys.value = rows.filter((item) => {
  345. return (item ?? '') !== ''
  346. })
  347. }
  348. //任务审核
  349. const rowTaskName = (row) => {
  350. emit('rowTaskName', row)
  351. }
  352. //设置重签规则
  353. const setSignRulesClick = () => {
  354. emit('signRules', {})
  355. }
  356. //批量审批
  357. const batchApprovalTaskClick = () => {
  358. const rows = tableCheckedKeys.value
  359. if (rows.length > 0) {
  360. emit('batchApproval', rows)
  361. } else {
  362. window?.$message?.warning('请先勾选需要审批的数据')
  363. }
  364. }
  365. </script>
  366. <style lang="scss" scoped>
  367. </style>