PipeAuditInspectionCommentsNotice.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <SmartTable
  3. ref="smartTableRef"
  4. v-model:columns="getColumnsByReportType"
  5. v-model:page-no="pageNo"
  6. v-model:page-size="pageSize"
  7. v-model:form-data="searchFormData"
  8. :data="inspectionCommentsList"
  9. :total="total"
  10. :buttons="buttons"
  11. @on-page-no-change="() => getAuditListByReportType()"
  12. @on-page-size-change="() => getAuditListByReportType()"
  13. @on-reset="
  14. () => {
  15. filterStatus = '100'
  16. handleStatusFilter()
  17. }
  18. "
  19. @on-search="() => getAuditListByReportType()"
  20. @refresh="() => getAuditListByReportType()"
  21. >
  22. <template #toolbarRowExtra>
  23. <el-radio-group
  24. v-model="filterStatus"
  25. @change="handleStatusFilter"
  26. style="margin-bottom: 15px"
  27. >
  28. <el-radio-button label="全部" value="all" />
  29. <el-radio-button label="已通过" value="200" />
  30. <el-radio-button label="审核中" value="100" />
  31. <el-radio-button label="已拒绝" value="300" />
  32. <!-- <el-radio-button label="已作废" value="400" />-->
  33. </el-radio-group>
  34. </template>
  35. </SmartTable>
  36. <AuditCheckRecord
  37. v-if="showAuditCheckRecord"
  38. v-model:visible="showAuditCheckRecord"
  39. :showRollbackStage="false"
  40. :reportUrl="operationItem.reportUrl"
  41. :auditId="operationItem.reportId"
  42. :apiParams="auditApiParams"
  43. :rejectFn="rejectOpinionNoticeApproval"
  44. :passFn="passOpinionNoticeApproval"
  45. :pageType="pageType"
  46. :recordFn="getOpinionNoticeApprovalRecordList"
  47. :reportType="getReportType"
  48. :id="operationItem.id"
  49. :templateId="templateId"
  50. :manualUrl="manualUrl"
  51. :useType="useType"
  52. :rowInfo="rowInfo"
  53. @close="handleCloseAuditDetail"
  54. @update="() => getAuditListByReportType()"
  55. />
  56. </template>
  57. <script setup lang="tsx">
  58. import AuditCheckRecord from './AuditCheckRecord.vue'
  59. import SmartTable from '@/components/SmartTable/SmartTable'
  60. import dayjs from 'dayjs'
  61. import { useDictStore } from '@/store/modules/dict'
  62. import {
  63. PressureTaskOrderStatusMap,
  64. PressureTaskOrderStatus,
  65. PressureReportType
  66. } from '@/utils/constants'
  67. import { useRoute } from 'vue-router'
  68. import _, { get } from 'lodash'
  69. import { SmartInstanceExpose, SmartTableColumn } from '@/types/table'
  70. import { buildFileUrl } from '@/utils'
  71. import { PipeTaskOrderApi } from '@/api/pressure2/pipetaskorder'
  72. const route = useRoute()
  73. const {
  74. getOpinionNoticeApproval,
  75. passOpinionNoticeApproval,
  76. rejectOpinionNoticeApproval,
  77. getOpinionNoticeApprovalRecordList // 没有分页
  78. } = PipeTaskOrderApi
  79. const useType = 'checkNotice'
  80. const dictStore = useDictStore()
  81. const auditText = ref('审核')
  82. const getReportType = computed(() => {
  83. switch (route.name) {
  84. case 'WorkInstructionAuditPipe':
  85. auditText.value = '批准'
  86. return PressureReportType['WORKINSTRUCTION']
  87. case 'InspectionPlanAuditPipe':
  88. auditText.value = '审批'
  89. return PressureReportType['INSPECTIONPLAN']
  90. case 'MajorIssueCluesNoticePipe':
  91. // 重大问题线索通知
  92. return PressureReportType['MAINQUESTION']
  93. case 'AuditInspectionCommentsNoticePipe':
  94. // 检验意见通知书
  95. return PressureReportType['SUGGUESTION']
  96. }
  97. })
  98. // 检验性质 pressure_inspection_nature
  99. const getPressureInspectionNature = computed(
  100. () => dictStore.getDictMap['pressure_inspection_nature_pipe']
  101. )
  102. const columns = ref<SmartTableColumn[]>([
  103. {
  104. label: '任务单号',
  105. prop: 'orderNo',
  106. search: {
  107. type: 'input'
  108. },
  109. fieldProps: {
  110. showOverflowTooltip: true,
  111. align: 'center'
  112. }
  113. },
  114. {
  115. label: '工程号',
  116. prop: 'projectNo',
  117. width: 200,
  118. search: {
  119. type: 'input'
  120. },
  121. fieldProps: {
  122. showOverflowTooltip: true,
  123. align: 'center'
  124. },
  125. render(row, value) {
  126. return (
  127. <div style="text-align:center">
  128. <div>{value}</div>
  129. {row.productNo && (
  130. <div class="mt-8px">
  131. <el-tag type="success">{row.productNo}</el-tag>
  132. </div>
  133. )}{' '}
  134. </div>
  135. )
  136. }
  137. },
  138. {
  139. label: '出厂编号',
  140. width: 120,
  141. prop: 'productNo',
  142. hidden: true,
  143. search: {
  144. type: 'input'
  145. },
  146. fieldProps: {
  147. showOverflowTooltip: true,
  148. align: 'center'
  149. }
  150. },
  151. {
  152. label: '使用单位',
  153. prop: 'unitName',
  154. search: {
  155. type: 'input'
  156. },
  157. fieldProps: {
  158. showOverflowTooltip: true,
  159. align: 'center'
  160. }
  161. },
  162. {
  163. label: '检验性质',
  164. prop: 'checkType',
  165. search: {
  166. type: 'select',
  167. options: getPressureInspectionNature.value
  168. },
  169. fieldProps: {
  170. showOverflowTooltip: true,
  171. align: 'center'
  172. },
  173. render: (row, checkType) =>
  174. getPressureInspectionNature.value.find((x) => x.value == checkType)?.label || '-'
  175. },
  176. {
  177. label: '检验项目',
  178. prop: 'reportName',
  179. fieldProps: {
  180. showOverflowTooltip: true,
  181. align: 'center'
  182. }
  183. },
  184. {
  185. label: '检验时间',
  186. prop: 'checkDate',
  187. search: {
  188. type: 'daterange'
  189. },
  190. fieldProps: {
  191. showOverflowTooltip: true,
  192. align: 'center'
  193. },
  194. render: (row, checkDate) => (!checkDate ? '-' : (checkDate || []).join('-'))
  195. },
  196. {
  197. label: '状态',
  198. prop: 'status',
  199. // search: {
  200. // type: 'select',
  201. // options: Object.entries(PressureTaskOrderStatusMap).map(([value, label]) => ({value, label}))
  202. // },
  203. fieldProps: {
  204. showOverflowTooltip: true,
  205. align: 'center'
  206. },
  207. render: (row, status) => (!status ? '-' : PressureTaskOrderStatusMap[status])
  208. },
  209. {
  210. label: '当前流程',
  211. prop: 'currentNode',
  212. fieldProps: {
  213. showOverflowTooltip: true,
  214. headerAlign: 'center'
  215. },
  216. render: (row) => {
  217. switch (row.status) {
  218. case PressureTaskOrderStatus['CANCELLED']:
  219. return '-'
  220. case PressureTaskOrderStatus['APPROVED']:
  221. return '审核通过'
  222. case PressureTaskOrderStatus['AUDITING']:
  223. case PressureTaskOrderStatus['REJECTED']:
  224. return (
  225. <div>
  226. <p>当前流程:{row?.currentNode || '-'}</p>
  227. <p>
  228. 状态:
  229. {row.status === PressureTaskOrderStatus['AUDITING']
  230. ? '审核中'
  231. : `${row?.currentAuditor?.nickname}(${row?.currentAuditor?.employeeNo})拒绝`}
  232. </p>
  233. </div>
  234. )
  235. default:
  236. return '-'
  237. }
  238. }
  239. },
  240. {
  241. label: '退回原因',
  242. prop: 'returnReason',
  243. fieldProps: {
  244. showOverflowTooltip: true,
  245. headerAlign: 'center'
  246. },
  247. render: (row, returnReason) => returnReason || '-'
  248. },
  249. {
  250. label: '审核人',
  251. prop: 'currentAuditor',
  252. fieldProps: {
  253. showOverflowTooltip: true,
  254. align: 'center'
  255. },
  256. search: {
  257. type: 'selectUserModal',
  258. prop: 'bpmUserId'
  259. },
  260. render: (row, val) => {
  261. return !val ? '-' : val?.nickname
  262. }
  263. },
  264. {
  265. label: '审批人',
  266. prop: 'ratifyUser',
  267. fieldProps: {
  268. showOverflowTooltip: true,
  269. align: 'center'
  270. },
  271. // search: {
  272. // type: 'selectUserModal',
  273. // prop: 'bpmUserId'
  274. // },
  275. render: (row, val) => {
  276. return !val ? '-' : val?.nickname
  277. }
  278. },
  279. {
  280. label: '提交人',
  281. prop: 'submitUser',
  282. search: {
  283. type: 'input'
  284. },
  285. fieldProps: {
  286. showOverflowTooltip: true,
  287. align: 'center'
  288. },
  289. render: (row, submitUser) => {
  290. return !submitUser ? '-' : submitUser?.nickname
  291. }
  292. },
  293. {
  294. label: '提交时间',
  295. prop: 'submitTime',
  296. fieldProps: {
  297. showOverflowTooltip: true,
  298. align: 'center'
  299. },
  300. render: (row, submitTime) =>
  301. !submitTime ? '-' : dayjs(submitTime).format('YYYY-MM-DD HH:mm:ss')
  302. },
  303. {
  304. label: '操作',
  305. prop: 'operation',
  306. fieldProps: {
  307. showOverflowTooltip: true,
  308. align: 'center'
  309. },
  310. render: (row) => {
  311. return (
  312. <div>
  313. {PressureTaskOrderStatus['AUDITING'] == row.status && (
  314. <el-button
  315. link
  316. type="primary"
  317. onClick={() => handleOpenAuditDetailOrInfo(row, 'check')}
  318. >
  319. {row.currentNode == '部长审批'?'审批':auditText.value}
  320. </el-button>
  321. )}
  322. {PressureTaskOrderStatus['AUDITING'] !== row.status && (
  323. <el-button
  324. link
  325. type="primary"
  326. onClick={() => handleOpenAuditDetailOrInfo(row, 'detail')}
  327. >
  328. 详情
  329. </el-button>
  330. )}
  331. </div>
  332. )
  333. }
  334. }
  335. ])
  336. const getColumnsByReportType = computed(() => {
  337. switch (getReportType.value) {
  338. case PressureReportType['SUGGUESTION']:
  339. return columns.value.filter((col) => col.prop !== 'bpmUserId') as SmartTableColumn[]
  340. case PressureReportType['WORKINSTRUCTION']:
  341. case PressureReportType['MAINQUESTION']:
  342. // const columnsTitle = [ '任务单号', '检验时间', '状态', '当前流程', '退回原因', '提交人', '审核人', '提交时间', '操作' ]
  343. // return columns.value.filter((col) => columnsTitle.includes(col.label)) as SmartTableColumn[]
  344. const columnsProp = [
  345. 'orderNo',
  346. 'checkDate',
  347. 'status',
  348. 'currentNode',
  349. 'returnReason',
  350. 'submitUser',
  351. 'currentAuditor',
  352. 'submitTime',
  353. 'operation'
  354. ]
  355. return columns.value.filter((col) =>
  356. columnsProp.includes(col.prop as string)
  357. ) as SmartTableColumn[]
  358. case PressureReportType['INSPECTIONPLAN']:
  359. const columnsPropIns = [
  360. 'orderNo',
  361. 'checkDate',
  362. 'status',
  363. 'currentNode',
  364. 'returnReason',
  365. 'submitUser',
  366. 'currentAuditor',
  367. 'ratifyUser',
  368. 'submitTime',
  369. 'operation'
  370. ]
  371. return columns.value.filter((col) =>
  372. columnsPropIns.includes(col.prop as string)
  373. ) as SmartTableColumn[]
  374. default:
  375. return [] as SmartTableColumn[]
  376. }
  377. })
  378. const buttons = ref([])
  379. const pageNo = ref(1)
  380. const pageSize = ref(10)
  381. const total = ref(0)
  382. const inspectionCommentsList = ref([])
  383. const searchFormData = ref<any>({
  384. status: '100' // 默认状态为审核中
  385. })
  386. // 状态筛选
  387. const filterStatus = ref('100') // 默认选中审核中
  388. // 获取检验意见通知书审核列表
  389. const fetchInspectionCommentsAuditList = async () => {
  390. inspectionCommentsList.value = []
  391. // TODO: 在这里获取审核列表数据
  392. const params = {
  393. pageNo: pageNo.value,
  394. pageSize: pageSize.value,
  395. reportType: getReportType.value,
  396. ...searchFormData.value,
  397. status: filterStatus.value
  398. }
  399. if (params.status == 'all') delete params.status
  400. const response = await getOpinionNoticeApproval(params)
  401. inspectionCommentsList.value = response.list
  402. total.value = response.total
  403. }
  404. // 获取重大问题线索 & 检验方案 & 作业指导书的审核列表
  405. const handleGetOperationReportAuditList = async (reportType) => {
  406. const params = {
  407. pageNo: pageNo.value,
  408. pageSize: pageSize.value,
  409. reportType,
  410. ...searchFormData.value,
  411. status: filterStatus.value
  412. }
  413. if (params.status == 'all') delete params.status
  414. const auditListResult = await PipeTaskOrderApi.getMajorIssuesAuditList(params)
  415. // const auditListResult = await TaskOrderApi.getMajorIssuesAuditList(params)
  416. inspectionCommentsList.value = auditListResult.list
  417. total.value = auditListResult.total
  418. }
  419. const getAuditListByReportType = () => {
  420. switch (getReportType.value) {
  421. case PressureReportType['SUGGUESTION']:
  422. fetchInspectionCommentsAuditList()
  423. break
  424. case PressureReportType['WORKINSTRUCTION']:
  425. case PressureReportType['INSPECTIONPLAN']:
  426. case PressureReportType['MAINQUESTION']:
  427. handleGetOperationReportAuditList(getReportType.value)
  428. break
  429. default:
  430. return false
  431. }
  432. }
  433. // watch(
  434. // () => getReportType.value,
  435. // (reportType) => {
  436. // if (!reportType) return
  437. // getAuditListByReportType()
  438. // },
  439. // {
  440. // immediate: true
  441. // }
  442. // )
  443. // 审核 && 查看详情
  444. const showAuditCheckRecord = ref(false)
  445. const auditApiParams = ref({})
  446. const operationItem = ref<any>({})
  447. const rowInfo = ref<any>({})
  448. const pageType = ref('check')
  449. const templateId = ref('')
  450. const manualUrl = ref('')
  451. const handleOpenAuditDetailOrInfo = async (row, type) => {
  452. operationItem.value = row
  453. rowInfo.value = row
  454. pageType.value = type
  455. templateId.value = row.templateId
  456. manualUrl.value = row.manualUrl
  457. auditApiParams.value = {
  458. ids: [row.id],
  459. reportIds: [row.reportId],
  460. reportType: getReportType.value
  461. }
  462. /*switch (getReportType.value) {
  463. case PressureReportType['SUGGUESTION']:
  464. auditApiParams.value = {
  465. ids: [row.reportId]
  466. }
  467. break
  468. case PressureReportType['WORKINSTRUCTION']:
  469. case PressureReportType['INSPECTIONPLAN']:
  470. case PressureReportType['MAINQUESTION']:
  471. auditApiParams.value = {
  472. ids: [row.id],
  473. reportType: getReportType.value
  474. }
  475. let reportUrl = ''
  476. if(PressureReportType['MAINQUESTION'] == getReportType.value && row.signFilePdf){
  477. reportUrl = buildFileUrl(row.signFilePdf)
  478. } else {
  479. // 获取pdf文件流
  480. const response = await TaskOrderApi.getReportPreview({
  481. reportId: row.id,
  482. fileType: 200
  483. })
  484. // 文件流转成url
  485. if (response) {
  486. const flow = new Blob([response], { type: 'application/pdf' })
  487. reportUrl = window.URL.createObjectURL(flow)
  488. }
  489. }
  490. operationItem.value = { ...row, reportId: row.id, reportUrl }
  491. break
  492. default:
  493. return false
  494. }*/
  495. // 打开弹窗
  496. showAuditCheckRecord.value = true
  497. }
  498. // 处理状态筛选
  499. const handleStatusFilter = () => {
  500. if (filterStatus.value === 'all') {
  501. // 清除状态筛选
  502. searchFormData.value.status = undefined
  503. } else {
  504. // 设置状态筛选
  505. searchFormData.value.status = filterStatus.value
  506. }
  507. // 重置页码并触发查询
  508. pageNo.value = 1
  509. getAuditListByReportType()
  510. }
  511. // 关闭审核详情回调
  512. const handleCloseAuditDetail = () => {
  513. operationItem.value = false
  514. showAuditCheckRecord.value = false
  515. }
  516. const smartTableRef = ref<SmartInstanceExpose>()
  517. onMounted(() => {
  518. const { bpmUserId } = route.query
  519. if (bpmUserId && PressureReportType['SUGGUESTION'] !== unref(getReportType)) {
  520. searchFormData.value.bpmUserId = bpmUserId
  521. }
  522. smartTableRef.value?.setSearchForm(searchFormData.value)
  523. getAuditListByReportType()
  524. })
  525. </script>
  526. <style lang="scss" scoped></style>