details.vue 18 KB

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