details.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. <template>
  2. <div class="details-container">
  3. <el-drawer
  4. :visible.sync="visible"
  5. :title="dialogTitle"
  6. size="90%"
  7. @close="handleClose"
  8. >
  9. <!-- 操作按钮区域 -->
  10. <div class="btn-group">
  11. <el-button
  12. v-for="item in buttonData"
  13. :key="item.id"
  14. type="primary"
  15. @click="handleAuditPass(item)"
  16. >
  17. {{ item.value }}
  18. </el-button>
  19. </div>
  20. <!-- 标签页面 -->
  21. <el-tabs
  22. v-model="activeTab"
  23. type="card"
  24. class="audit-tabs"
  25. @tab-click="handleTabClick"
  26. >
  27. <el-tab-pane label="报送资料" name="submitData">
  28. <submit-data
  29. :id="id"
  30. :current-node="currentNode"
  31. :current-status="currentStatus"
  32. :materials="submitMaterials"
  33. />
  34. </el-tab-pane>
  35. <el-tab-pane label="成本调查表" name="costSurvey">
  36. <cost-survey
  37. :id="id"
  38. :current-node="currentNode"
  39. :current-status="currentStatus"
  40. />
  41. </el-tab-pane>
  42. <el-tab-pane
  43. v-if="currentNode !== 'clcs'"
  44. label="成本审核"
  45. name="costAudit"
  46. >
  47. <cost-audit
  48. :id="id"
  49. :current-node="currentNode"
  50. :current-status="currentStatus"
  51. />
  52. </el-tab-pane>
  53. <el-tab-pane
  54. v-if="currentNode !== 'clcs'"
  55. label="工作底稿"
  56. name="workDraft"
  57. >
  58. <work-draft
  59. :id="id"
  60. :current-node="currentNode"
  61. :current-status="currentStatus"
  62. />
  63. </el-tab-pane>
  64. <el-tab-pane
  65. v-if="currentNode !== 'clcs'"
  66. label="提取材料登记"
  67. name="extractMaterial"
  68. >
  69. <extract-material
  70. :id="id"
  71. :current-node="currentNode"
  72. :current-status="currentStatus"
  73. />
  74. </el-tab-pane>
  75. <el-tab-pane
  76. v-if="currentNode !== 'clcs' && currentNode !== 'sdsh'"
  77. label="成本审核意见"
  78. name="auditOpinion"
  79. >
  80. <audit-opinion
  81. :id="id"
  82. :current-node="currentNode"
  83. :current-status="currentStatus"
  84. @refresh="handleAuditOpinionRefresh"
  85. @close="handleClose"
  86. />
  87. </el-tab-pane>
  88. <el-tab-pane label="消息通知" name="messageNotify">
  89. <message-notify :id="id" />
  90. </el-tab-pane>
  91. </el-tabs>
  92. </el-drawer>
  93. <!-- 补充资料弹窗 -->
  94. <el-dialog
  95. :visible.sync="showSupplementDialog"
  96. title="补充资料"
  97. width="500px"
  98. :modal="false"
  99. >
  100. <div class="dialog-content">
  101. <div class="form-item">
  102. <label class="form-label">补充意见:</label>
  103. <el-input
  104. v-model="additionalParams.content"
  105. type="textarea"
  106. :rows="6"
  107. placeholder="请输入补充意见"
  108. maxlength="500"
  109. show-word-limit
  110. />
  111. </div>
  112. <!-- <div class="form-item">
  113. <label class="form-label">发送方式:</label>
  114. <el-checkbox-group v-model="additionalParams.sendType">
  115. <el-checkbox label="site">站内消息</el-checkbox>
  116. <el-checkbox label="sms">短信通知</el-checkbox>
  117. </el-checkbox-group>
  118. </div> -->
  119. </div>
  120. <div slot="footer" class="dialog-footer">
  121. <el-button @click="showSupplementDialog = false">取消</el-button>
  122. <el-button type="primary" @click="submitSupplement">发送</el-button>
  123. </div>
  124. </el-dialog>
  125. <!-- 中止监审弹窗 -->
  126. <el-dialog
  127. :visible.sync="showAbortDialog"
  128. title="中止监审"
  129. width="500px"
  130. :modal="false"
  131. >
  132. <div class="dialog-content">
  133. <div class="form-item">
  134. <label class="form-label">中止意见:</label>
  135. <el-input
  136. v-model="additionalParams.content"
  137. type="textarea"
  138. :rows="6"
  139. placeholder="请输入中止意见"
  140. maxlength="500"
  141. show-word-limit
  142. />
  143. </div>
  144. <!-- <div class="form-item">
  145. <label class="form-label">发送方式:</label>
  146. <el-checkbox-group v-model="additionalParams.sendType">
  147. <el-checkbox label="site">站内消息</el-checkbox>
  148. <el-checkbox label="sms">短信通知</el-checkbox>
  149. </el-checkbox-group>
  150. </div> -->
  151. </div>
  152. <div slot="footer" class="dialog-footer">
  153. <el-button @click="showAbortDialog = false">取消</el-button>
  154. <el-button type="primary" @click="submitAbort">发送</el-button>
  155. </div>
  156. </el-dialog>
  157. <!-- 初审退回弹窗 -->
  158. <el-dialog
  159. :visible.sync="showRejectDialog"
  160. title="初审退回"
  161. width="500px"
  162. :modal="false"
  163. >
  164. <div class="dialog-content">
  165. <div class="form-item">
  166. <label class="form-label">退回意见:</label>
  167. <el-input
  168. v-model="additionalParams.content"
  169. type="textarea"
  170. :rows="6"
  171. placeholder="请输入退回意见"
  172. maxlength="500"
  173. show-word-limit
  174. />
  175. </div>
  176. <!-- <div class="form-item">
  177. <label class="form-label">发送方式:</label>
  178. <el-checkbox-group v-model="additionalParams.sendType">
  179. <el-checkbox label="site">站内消息</el-checkbox>
  180. <el-checkbox label="sms">短信通知</el-checkbox>
  181. </el-checkbox-group>
  182. </div> -->
  183. </div>
  184. <div slot="footer" class="dialog-footer">
  185. <el-button @click="showRejectDialog = false">取消</el-button>
  186. <el-button type="primary" @click="submitReject">发送</el-button>
  187. </div>
  188. </el-dialog>
  189. </div>
  190. </template>
  191. <script>
  192. import costAudit from './costAudit.vue'
  193. import costSurvey from './costSurvey.vue'
  194. import submitData from './submitData.vue'
  195. import workDraft from './workDraft.vue'
  196. import extractMaterial from './extractMaterial.vue'
  197. import auditOpinion from './auditOpinion.vue'
  198. import messageNotify from './messageNotify.vue'
  199. import {
  200. getDataPreliminaryReviewButton,
  201. doProcessBtn,
  202. } from '@/api/dataPreliminaryReview'
  203. import { getTaskRequirementList } from '@/api/auditTaskProcessing'
  204. export default {
  205. name: 'Details',
  206. components: {
  207. costAudit,
  208. costSurvey,
  209. submitData,
  210. workDraft,
  211. extractMaterial,
  212. auditOpinion,
  213. messageNotify,
  214. },
  215. props: {
  216. visible: {
  217. type: Boolean,
  218. default: true,
  219. },
  220. id: {
  221. type: [String, Number],
  222. default: null,
  223. },
  224. currentNode: {
  225. type: String,
  226. default: '',
  227. },
  228. currentStatus: {
  229. type: String,
  230. default: '',
  231. },
  232. },
  233. data() {
  234. return {
  235. buttonData: [], //资料初审按钮数据
  236. activeTab: 'submitData', // 默认选中报送资料标签页
  237. // 报送资料数据(从接口获取后下发给子组件)
  238. submitMaterials: [],
  239. // 弹窗显示状态
  240. showSupplementDialog: false,
  241. showAbortDialog: false,
  242. showRejectDialog: false,
  243. // 弹窗数据
  244. additionalParams: {},
  245. // 当前操作按钮信息
  246. currentButton: null,
  247. }
  248. },
  249. computed: {
  250. dialogTitle() {
  251. // 根据节点类型设置标题
  252. if (
  253. this.currentNode === 'sdshenhe' &&
  254. this.currentStatus === '审核中'
  255. ) {
  256. return '审核详情'
  257. } else if (this.currentNode === 'clcs') {
  258. return '成本调查详情'
  259. } else if (
  260. this.currentNode === 'yjgaozhi' ||
  261. this.currentNode === 'yjfk'
  262. ) {
  263. return '意见告知'
  264. }
  265. return '成本审核详情'
  266. },
  267. },
  268. watch: {
  269. visible(newVal) {
  270. // 监听visible变化,弹窗打开时设置标签页并获取按钮数据
  271. if (newVal && this.id) {
  272. // 使用 $nextTick 确保 props 已更新
  273. this.$nextTick(() => {
  274. // 设置标签页
  275. this.setActiveTab()
  276. // 弹窗打开时,无论什么情况都要获取资料初审按钮数据
  277. this.getPreliminaryReviewButton()
  278. // 若默认在报送资料页,加载报送资料
  279. if (this.activeTab === 'submitData') {
  280. this.loadSubmitMaterials()
  281. }
  282. })
  283. }
  284. },
  285. // 监听currentNode变化,如果弹窗已打开,更新标签页并重新获取按钮数据
  286. currentNode(newVal, oldVal) {
  287. if (this.visible && this.id && newVal && newVal !== oldVal) {
  288. this.$nextTick(() => {
  289. // 设置标签页
  290. this.setActiveTab()
  291. // 重新获取按钮数据
  292. this.getPreliminaryReviewButton()
  293. })
  294. }
  295. },
  296. // 监听currentStatus变化,如果弹窗已打开,更新标签页并重新获取按钮数据
  297. currentStatus(newVal, oldVal) {
  298. if (this.visible && this.id && newVal && newVal !== oldVal) {
  299. this.$nextTick(() => {
  300. // 设置标签页
  301. this.setActiveTab()
  302. // 重新获取按钮数据
  303. this.getPreliminaryReviewButton()
  304. })
  305. }
  306. },
  307. // 监听id变化,如果弹窗已打开,重新获取按钮数据
  308. id(newVal) {
  309. if (this.visible && newVal) {
  310. this.$nextTick(() => {
  311. // 设置标签页
  312. this.setActiveTab()
  313. // 获取按钮数据
  314. this.getPreliminaryReviewButton()
  315. // 任务变化时,若在报送资料页,刷新报送资料
  316. if (this.activeTab === 'submitData') {
  317. this.loadSubmitMaterials()
  318. }
  319. })
  320. }
  321. },
  322. },
  323. mounted() {
  324. // 设置标签页
  325. this.setActiveTab()
  326. // 如果组件挂载时弹窗已打开且有id,也要获取按钮数据
  327. if (this.visible && this.id) {
  328. this.$nextTick(() => {
  329. // 弹窗打开时,无论什么情况都要获取资料初审按钮数据
  330. this.getPreliminaryReviewButton()
  331. if (this.activeTab === 'submitData') {
  332. this.loadSubmitMaterials()
  333. }
  334. })
  335. }
  336. },
  337. methods: {
  338. // 根据 currentNode 和 currentStatus 设置活动标签页
  339. setActiveTab() {
  340. if (this.currentNode === 'sdsh' && this.currentStatus === '审核中') {
  341. this.activeTab = 'costAudit'
  342. } else if (this.currentNode === 'clcs') {
  343. // 如果 currentNode 是 'clcs',显示成本调查表标签页
  344. this.activeTab = 'submitData'
  345. } else if (
  346. this.currentNode === 'yjgaozhi' ||
  347. this.currentNode === 'yjfk'
  348. ) {
  349. // 如果 currentNode 是 'yjgaozhi',显示意见告知标签页(成本审核意见)
  350. this.activeTab = 'auditOpinion'
  351. } else {
  352. // 其他情况默认显示报送资料标签页
  353. this.activeTab = 'submitData'
  354. }
  355. },
  356. // 获取资料初审按钮
  357. async getPreliminaryReviewButton() {
  358. // 直接从 props 获取 currentNode,确保是最新的值
  359. const currentNode = this.currentNode
  360. // 构建参数对象
  361. const params = {
  362. taskId: this.id,
  363. }
  364. // 只有当 currentNode 有值时才添加 processNodeKey
  365. if (currentNode && currentNode.trim() !== '') {
  366. params.processNodeKey = currentNode === 'ccls' ? 'clcs' : currentNode
  367. }
  368. try {
  369. const response = await getDataPreliminaryReviewButton(params)
  370. this.buttonData = response.value || []
  371. } catch (error) {
  372. this.buttonData = []
  373. }
  374. },
  375. handleClose() {
  376. // 关闭弹窗时触发事件
  377. this.$emit('update:visible', false)
  378. this.$emit('close')
  379. },
  380. // 处理审核意见保存成功后的刷新
  381. handleAuditOpinionRefresh() {
  382. // 触发父组件刷新列表
  383. this.$emit('refresh')
  384. },
  385. open() {
  386. // 打开弹窗方法,供父组件通过ref调用
  387. this.$emit('update:visible', true)
  388. },
  389. handleTabClick(tab) {
  390. if (tab && tab.name === 'submitData' && this.id) {
  391. this.loadSubmitMaterials()
  392. }
  393. },
  394. async loadSubmitMaterials() {
  395. try {
  396. const resp = await getTaskRequirementList(this.id)
  397. const list = resp?.value || resp?.data || resp || []
  398. this.submitMaterials = Array.isArray(list) ? list : []
  399. } catch (e) {
  400. this.submitMaterials = []
  401. }
  402. },
  403. // 处理审核操作按钮点击
  404. handleAuditPass(item) {
  405. this.additionalParams = {
  406. content: '',
  407. // sendType: [], // 默认选中站内消息和短信通知
  408. }
  409. this.currentButton = item // 保存当前按钮信息
  410. console.log('点击的按钮数据:', item)
  411. const key = Number(item.key)
  412. if (key === 1) {
  413. this.showSupplementDialog = true
  414. } else if (key === 2) {
  415. // 中止监审
  416. this.showAbortDialog = true
  417. } else if (key === 4) {
  418. // 初审退回
  419. this.showRejectDialog = true
  420. } else {
  421. // 添加确认对话框
  422. this.$confirm(
  423. `确定要执行"${this.currentButton.value}"操作吗?`,
  424. '操作确认',
  425. {
  426. confirmButtonText: '确定',
  427. cancelButtonText: '取消',
  428. type: 'warning',
  429. }
  430. )
  431. .then(() => {
  432. this.executeAuditOperation()
  433. })
  434. .catch(() => {
  435. // 用户取消操作
  436. this.$message.info('已取消操作')
  437. })
  438. }
  439. },
  440. // 执行审核操作
  441. async executeAuditOperation() {
  442. if (!this.id) {
  443. this.$message.error('缺少任务ID')
  444. return
  445. }
  446. if (!this.currentButton) {
  447. this.$message.error('操作失败:缺少按钮信息')
  448. return
  449. }
  450. try {
  451. const params = {
  452. taskId: this.id,
  453. processNodeKey: this.currentNode,
  454. key: this.currentButton.key,
  455. // sendType: this.additionalParams.sendType?.join(','),
  456. content: this.additionalParams.content,
  457. }
  458. const response = await doProcessBtn(params)
  459. if (response && response.code === 200) {
  460. this.$message.success(this.currentButton.value + '操作成功')
  461. // 关闭所有弹窗
  462. this.showSupplementDialog = false
  463. this.showAbortDialog = false
  464. this.showRejectDialog = false
  465. // 关闭主弹窗
  466. this.handleClose()
  467. // 触发父组件刷新列表
  468. this.$emit('refresh')
  469. } else {
  470. this.$message.error(
  471. response?.message || this.currentButton.value + '操作失败'
  472. )
  473. }
  474. } catch (error) {
  475. this.$message.error(this.currentButton.value + '操作失败')
  476. }
  477. },
  478. // 提交补充资料
  479. submitSupplement() {
  480. if (
  481. !this.additionalParams.content ||
  482. !this.additionalParams.content.trim()
  483. ) {
  484. this.$message.error('请输入补充意见')
  485. return
  486. }
  487. if (this.currentButton) {
  488. this.executeAuditOperation(this.currentButton)
  489. } else {
  490. this.$message.error('操作失败:缺少按钮信息')
  491. }
  492. },
  493. // 提交中止监审
  494. submitAbort() {
  495. if (
  496. !this.additionalParams.content ||
  497. !this.additionalParams.content.trim()
  498. ) {
  499. this.$message.error('请输入中止意见')
  500. return
  501. }
  502. if (this.currentButton) {
  503. this.executeAuditOperation(this.currentButton)
  504. } else {
  505. this.$message.error('操作失败:缺少按钮信息')
  506. }
  507. },
  508. // 提交初审退回
  509. submitReject() {
  510. if (
  511. !this.additionalParams.content ||
  512. !this.additionalParams.content.trim()
  513. ) {
  514. this.$message.error('请输入退回意见')
  515. return
  516. }
  517. if (this.currentButton) {
  518. this.executeAuditOperation(this.currentButton)
  519. } else {
  520. this.$message.error('操作失败:缺少按钮信息')
  521. }
  522. },
  523. },
  524. }
  525. </script>
  526. <style scoped>
  527. .btn-group {
  528. margin-bottom: 20px;
  529. margin-left: 20px;
  530. }
  531. .btn-group .el-button {
  532. margin-right: 10px;
  533. }
  534. .details-container {
  535. width: 100%;
  536. height: 100%;
  537. }
  538. .audit-tabs {
  539. height: calc(100vh - 150px);
  540. }
  541. .audit-tabs .el-tabs__header {
  542. margin-bottom: 0;
  543. padding: 15px 15px 0;
  544. background: #f5f7fa;
  545. border-bottom: 1px solid #ebeef5;
  546. }
  547. .audit-tabs .el-tabs__nav-wrap {
  548. padding-bottom: 10px;
  549. }
  550. .audit-tabs .el-tabs__content {
  551. height: calc(100% - 60px);
  552. padding: 15px;
  553. overflow-y: auto;
  554. }
  555. .audit-tabs .el-tab-pane {
  556. height: 100%;
  557. }
  558. /* 弹窗样式 */
  559. .dialog-content {
  560. padding: 10px 0;
  561. }
  562. .form-item {
  563. display: flex;
  564. align-items: flex-start;
  565. margin-bottom: 20px;
  566. }
  567. .form-label {
  568. display: inline-block;
  569. width: 100px;
  570. text-align: center;
  571. color: #606266;
  572. vertical-align: top;
  573. flex-shrink: 0;
  574. }
  575. .form-item .el-checkbox-group {
  576. display: inline-block;
  577. margin-left: 10px;
  578. }
  579. .form-item .el-checkbox {
  580. margin-right: 20px;
  581. vertical-align: middle;
  582. }
  583. .form-item .el-input,
  584. .form-item .el-textarea {
  585. flex: 1;
  586. }
  587. .form-item .el-input__inner {
  588. width: 100%;
  589. margin-left: 0;
  590. }
  591. </style>