task-review.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <hc-new-dialog v-model="isShow" is-table widths="96%" title="任务审核" @close="cancelClick">
  3. <template #header="{ titleId, titleClass }">
  4. <div class="hc-card-header flex items-center">
  5. <div :id="titleId" :class="titleClass">任务审核 【已开启电签】</div>
  6. </div>
  7. </template>
  8. <div v-loading="isLoading" class="relative h-full">
  9. <div class="hc-task-name relative">{{ rowInfo.taskName }} 审批信息</div>
  10. <div class="hc-task-body relative flex">
  11. <div class="hc-task-time">
  12. <hc-body class="hc-task-body-card" padding="10px" scrollbar>
  13. <el-timeline v-if="rowInfo.fixedFlowId == null" class="hc-time-line">
  14. <template v-for="(item, index) in flowList" :key="index">
  15. <el-timeline-item :class="item.status === '2' ? 'success' : 'primary'" size="large">
  16. <div class="timeline-item-icon">
  17. <hc-icon v-if="item.status === '2'" class="check-icon" name="check" />
  18. </div>
  19. <div class="reply-name">{{ item.name }}</div>
  20. <div class="reply-time">{{ item.date }}</div>
  21. <div class="reply-content" v-html="item.flowValue" />
  22. </el-timeline-item>
  23. </template>
  24. </el-timeline>
  25. <el-timeline v-else class="hc-time-line">
  26. <template v-for="(item, index) in flowListTask" :key="index">
  27. <el-timeline-item :class="item.status == '2' ? 'success' : 'primary'" size="large">
  28. <div class="timeline-item-icon">
  29. <hc-icon v-if="item.status == '2'" class="check-icon" name="check" />
  30. </div>
  31. <div v-if="!item.isTask" class="reply-name">
  32. {{ item.name }}
  33. </div>
  34. <div v-if="item.isTask">
  35. <div class="reply-name">
  36. {{ item.name }}
  37. <HcIcon v-if="item.type == 2" name="links" class="ml-2" />
  38. <HcIcon v-if="item.type == 1" name="exchange-2" class="ml-2" />
  39. <br>
  40. <el-tooltip placement="right" effect="light" :visible="item.taskDetailvisible">
  41. <template #content>
  42. <el-timeline class="hc-time-line">
  43. <template v-for="(item1, index1) in item.userList" :key="index1">
  44. <el-timeline-item :class="item1.status === '2' ? 'success' : 'primary'" size="large">
  45. <div class="timeline-item-icon">
  46. <hc-icon v-if="item1.status === '2'" class="check-icon" name="check" />
  47. </div>
  48. <div class="reply-name">{{ item1.name }}</div>
  49. <div class="reply-time">{{ item1.date }}</div>
  50. <div class="reply-content" v-html="item1.flowValue" />
  51. </el-timeline-item>
  52. </template>
  53. </el-timeline>
  54. </template>
  55. <el-link @click="getTaskDetail" @mouseenter="item.taskDetailvisible = true" @mouseleave="item.taskDetailvisible = false">点击查看详情</el-link>
  56. </el-tooltip>
  57. </div>
  58. </div>
  59. <div class="reply-time">{{ item.date }}</div>
  60. <div class="reply-content" v-html="item.flowValue" />
  61. </el-timeline-item>
  62. </template>
  63. </el-timeline>
  64. </hc-body>
  65. </div>
  66. <div :id="`hc_task_table_${uuid}`" class="hc-task-table">
  67. <hc-body class="hc-task-body-card" padding="10px">
  68. <hc-table
  69. ref="tableRef" :column="tableColumn" :datas="tableData" :is-stripe="false"
  70. is-new :index-style="{ width: 60 }" is-current-row @row-click="tableRowClick"
  71. >
  72. <template #action="{ row }">
  73. <div class="hc-task-table-action" :class="row.isComment === 1 ? 'is-cur' : ''" @click="rowRemarkClick(row)">
  74. <i class="i-iconoir-star-solid" />
  75. </div>
  76. </template>
  77. <template #state="{ row }">
  78. <div class="hc-task-table-state">
  79. <i v-if="row.status === 1" class="i-iconoir-check-circle-solid is-success" />
  80. <i v-else-if="row.status === 2" class="i-iconoir-xmark-circle-solid is-danger" />
  81. <span v-else-if="row.status === 3">审批结束</span>
  82. <i v-else class="i-iconoir-help-circle-solid" />
  83. </div>
  84. </template>
  85. </hc-table>
  86. </hc-body>
  87. </div>
  88. <div :id="`hc_task_form_${uuid}`" class="hc-task-form">
  89. <hc-body class="hc-task-body-card" padding="10px" scrollbar>
  90. <HcTaskForm :table="tableInfo" :info="rowInfo" :is-edit="tabsKey === 1" @finish="taskFormFinish" />
  91. </hc-body>
  92. </div>
  93. </div>
  94. </div>
  95. <template #footer>
  96. <div class="hc-task-dialog-footer">
  97. <el-button :disabled="tabsKey !== 1" @click="rejectionClick">驳回审批</el-button>
  98. <el-button type="primary" :loading="confirmLoading" :disabled="tabsKey !== 1" @click="confirmClick">同意审批</el-button>
  99. </div>
  100. </template>
  101. </hc-new-dialog>
  102. <!-- 批注 -->
  103. <HcTaskNotes v-model="isNotesShow" :table="tableNoteInfo" :info="rowInfo" :is-edit="tabsKey === 1" @finish="taskNotesFinish" />
  104. <!-- 驳回 -->
  105. <HcRepealForm v-model="isRepealShow" :info="rowInfo" @finish="taskRepealFinish" />
  106. </template>
  107. <script setup>
  108. import { nextTick, ref, watch } from 'vue'
  109. import { arrUnion, getArrValue, getObjValue, getRandom } from 'js-fast-way'
  110. import { useAppStore } from '~src/store'
  111. import HcTaskForm from './task-form.vue'
  112. import HcTaskNotes from './task-notes.vue'
  113. import HcRepealForm from './repeal-form.vue'
  114. import mainApi from '~api/tasks/hc-data'
  115. const props = defineProps({
  116. tabs: {
  117. type: [String, Number],
  118. default: '',
  119. },
  120. row: {
  121. type: Object,
  122. default: () => ({}),
  123. },
  124. })
  125. //事件
  126. const emit = defineEmits(['finish', 'close'])
  127. const uuid = getRandom(4)
  128. const useAppState = useAppStore()
  129. const projectId = ref(useAppState.getProjectId || '')
  130. const contractId = ref(useAppState.getContractId || '')
  131. //双向绑定
  132. // eslint-disable-next-line no-undef
  133. const isShow = defineModel('modelValue', {
  134. default: false,
  135. })
  136. //监听
  137. const tableRef = ref(null)
  138. const tabsKey = ref(Number(props.tabs))
  139. const rowInfo = ref(props.row)
  140. watch(() => [
  141. props.tabs,
  142. props.row,
  143. ], ([key, row]) => {
  144. tabsKey.value = Number(key)
  145. rowInfo.value = row
  146. console.log(rowInfo.value.fixedFlowId == null)
  147. }, {
  148. immediate: true,
  149. deep: true,
  150. })
  151. //监听显示
  152. watch(isShow, (val) => {
  153. if (val) {
  154. setTaskInfo()
  155. setSplitRef()
  156. }
  157. })
  158. //初始化设置拖动分割线
  159. const setSplitRef = () => {
  160. //配置参考: https://split.js.org/#/?direction=vertical&snapOffset=0
  161. nextTick(() => {
  162. window.$split(['#hc_task_table_' + uuid, '#hc_task_form_' + uuid], {
  163. sizes: [50, 50],
  164. snapOffset: 0,
  165. minSize: [50, 500],
  166. })
  167. })
  168. }
  169. //设置任务信息
  170. const setTaskInfo = () => {
  171. //meterType:1中间,2材料,3开工,4变更令
  172. const { meterType } = rowInfo.value
  173. if (meterType === 1) {
  174. tableColumn.value = middlepayTableColumn.value
  175. } else if (meterType === 2) {
  176. tableColumn.value = materialTableColumn.value
  177. } else if (meterType === 3) {
  178. tableColumn.value = startWorkTableColumn.value
  179. } else if (meterType === 4) {
  180. tableColumn.value = alterTableColumn.value
  181. } else {
  182. tableColumn.value = []
  183. }
  184. getTableDetail()
  185. }
  186. //获取数据详情
  187. const isLoading = ref(false)
  188. const getTableDetail = async () => {
  189. isLoading.value = true
  190. confirmLoading.value = true
  191. //获取数据
  192. const { data } = await mainApi.getDetail(rowInfo.value.id)
  193. const { taskProcessInfo, taskCenterDataInfo } = getObjValue(data)
  194. tableData.value = getArrValue(taskCenterDataInfo)
  195. flowList.value = getArrValue(taskProcessInfo)
  196. if (rowInfo.value?.fixedFlowId) {
  197. const list = [...flowList.value]
  198. let firstarr = list.slice(0, 1)
  199. let taskList = list.slice(1, list.length)
  200. taskList.forEach((ele)=>{
  201. ele.name = ele.taskBranchName
  202. ele.status = ele.taskBranchStatus
  203. ele.type = ele.taskBranchType
  204. ele.isTask = true
  205. })
  206. flowListTask.value = arrUnion(firstarr, taskList)
  207. }
  208. //默认选中第一行
  209. let info = {}
  210. if (tableData.value.length > 0) {
  211. info = tableData.value[0]
  212. }
  213. await nextTick(() => {
  214. tableInfo.value = info
  215. tableRef.value?.tableRef?.setCurrentRow(info)
  216. })
  217. //关闭加载状态
  218. isLoading.value = false
  219. confirmLoading.value = false
  220. }
  221. //流程信息,1待审批,2已审批
  222. const flowList = ref([])
  223. //type为1流程审批,type为2是平行审批
  224. const flowListTask = ref([
  225. { name: 'PCT', date: '2024-03-01 09:27:17', status: '2', flowValue: '上报', isTask:false },
  226. { name: '"222"', date: '', status: '2', flowValue: '', type:1, isTask:true },
  227. { name: '"111"', date: '', status: '1', flowValue: '', type:2, isTask:true },
  228. ])
  229. const taskDetailList = ref([])
  230. //中间计量单的表格数据
  231. const middlepayTableColumn = ref([
  232. { key: 'action', name: '批注', width: 45, align: 'center' },
  233. { key: 'meterNumber', name: '计量单编号' },
  234. { key: 'meterMoney', name: '计量金额', width: 100 },
  235. { key: 'engineerDivide', name: '工程划分' },
  236. { key: 'state', name: '审批状态', fixed: 'right', width: 70, align: 'center' },
  237. ])
  238. //开工预付款计量单的表格数据
  239. const startWorkTableColumn = ref([
  240. { key: 'action', name: '批注', width: 45, align: 'center' },
  241. { key: 'periodName', name: '计量期', minWidth: 100, align: 'center' },
  242. { key: 'businessDate', name: '业务日期', width: 160, align: 'center' },
  243. { key: 'meterMoney', name: '计量金额', width: 100, align: 'center' },
  244. { key: 'state', name: '审批状态', fixed: 'right', width: 70, align: 'center' },
  245. ])
  246. //变更令的表格数据
  247. const alterTableColumn = ref([
  248. { key: 'action', name: '批注', width: 45, align: 'center' },
  249. { key: 'changeNumber', name: '变更编号', minWidth: 120, align: 'center' },
  250. { key: 'changeName', name: '变更名称', minWidth: 120, align: 'center' },
  251. { key: 'changeMoney', name: '变更金额', width: 100, align: 'center' },
  252. { key: 'changeApprovalDate', name: '变更批复日期', width: 160, align: 'center' },
  253. { key: 'state', name: '审批状态', fixed: 'right', width: 70, align: 'center' },
  254. ])
  255. //材料计量单的表格数据
  256. const materialTableColumn = ref([
  257. { key: 'action', name: '批注', width: 45, align: 'center' },
  258. { key: 'periodName', name: '计量期', minWidth: 100, align: 'center' },
  259. { key: 'contractMaterialName', name: '合同材料', minWidth: 120, align: 'center' },
  260. { key: 'materialArriveNumber', name: '材料到场编号', width: 120, align: 'center' },
  261. { key: 'meterMoney', name: '计量金额', width: 100, align: 'center' },
  262. { key: 'state', name: '审批状态', fixed: 'right', width: 70, align: 'center' },
  263. ])
  264. //表格数据
  265. const tableColumn = ref([])
  266. const tableData = ref([])
  267. //表格行被点击
  268. const tableInfo = ref({})
  269. const tableRowClick = ({ row }) => {
  270. tableInfo.value = row
  271. }
  272. //批注, isComment 是否已批注,1=是,0=否
  273. const isNotesShow = ref(false)
  274. const tableNoteInfo = ref({})
  275. const rowRemarkClick = (row) => {
  276. tableNoteInfo.value = row
  277. nextTick(() => {
  278. isNotesShow.value = true
  279. })
  280. }
  281. //批注完成
  282. const taskNotesFinish = () => {
  283. getTableDetail()
  284. }
  285. //单条审批
  286. const taskFormFinish = () => {
  287. getTableDetail()
  288. }
  289. //确认审批
  290. const confirmLoading = ref(false)
  291. const confirmClick = async () => {
  292. confirmLoading.value = true
  293. const { error, code, msg } = await mainApi.taskApprove({
  294. taskId: rowInfo.value.id,
  295. projectId: projectId.value,
  296. contractId: contractId.value,
  297. })
  298. confirmLoading.value = false
  299. if (!error && code === 200) {
  300. window.$message.success('审批成功')
  301. emit('finish')
  302. cancelClick()
  303. } else {
  304. window.$message.error(msg ?? '审批失败')
  305. }
  306. }
  307. //驳回审批
  308. const isRepealShow = ref(false)
  309. const rejectionClick = async () => {
  310. isRepealShow.value = true
  311. }
  312. //驳回完成
  313. const taskRepealFinish = () => {
  314. emit('finish')
  315. cancelClick()
  316. }
  317. //取消审批
  318. const cancelClick = () => {
  319. isShow.value = false
  320. isLoading.value = false
  321. confirmLoading.value = false
  322. tableColumn.value = []
  323. tableData.value = []
  324. tableInfo.value = {}
  325. emit('close')
  326. }
  327. const taskDetailvisible = ref(false)
  328. const getTaskDetail = ()=>{
  329. taskDetailvisible.value = true
  330. }
  331. </script>
  332. <style lang="scss" scoped>
  333. .hc-task-name {
  334. font-weight: bold;
  335. color: #1A1a1a;
  336. padding-bottom: 10px;
  337. border-bottom: 1px solid #f5f5f5;
  338. }
  339. .hc-task-body {
  340. height: calc(100% - 27px);
  341. .hc-task-time {
  342. position: relative;
  343. height: 100%;
  344. flex-shrink: 0;
  345. width: 170px;
  346. }
  347. .hc-task-table, .hc-task-form {
  348. position: relative;
  349. height: 100%;
  350. flex: 1;
  351. flex-basis: auto;
  352. }
  353. .hc-task-table {
  354. border-left: 1px solid #e5e5e5;
  355. }
  356. }
  357. //表格图标
  358. .hc-task-table-action, .hc-task-table-state {
  359. position: relative;
  360. display: flex;
  361. justify-content: center;
  362. align-items: center;
  363. cursor: pointer;
  364. font-size: 20px;
  365. color: #929293;
  366. i {
  367. display: inline-flex;
  368. }
  369. }
  370. //表格批注
  371. .hc-task-table-action.is-cur {
  372. color: #F2B90B;
  373. }
  374. //表格状态
  375. .hc-task-table-state {
  376. .is-success {
  377. color: #25a62d;
  378. }
  379. .is-danger {
  380. color: #F5221D;
  381. }
  382. span {
  383. color: #1A1a1a;
  384. }
  385. }
  386. //弹窗底部
  387. .hc-task-dialog-footer {
  388. position: relative;
  389. text-align: center;
  390. }
  391. </style>
  392. <style lang="scss">
  393. .hc-task-body-card {
  394. background: #f7f7f7;
  395. .el-scrollbar__bar.is-vertical {
  396. right: -8px;
  397. }
  398. }
  399. </style>