TableCard.vue 11 KB

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