auditDocumentsMain.vue 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411
  1. <template>
  2. <div class="catalog-manage">
  3. <div class="documents-layout">
  4. <!-- 左侧文书类型列表 -->
  5. <div class="documents-type-list">
  6. <h3>监审文书类型:</h3>
  7. <div
  8. v-for="type in documentData.documentTypes"
  9. :key="type.id"
  10. class="type-item"
  11. :class="{ active: activeDocumentTypeId === type.id }"
  12. @click="handleDocumentTypeClick(type)"
  13. >
  14. {{ type.documentName }}
  15. </div>
  16. </div>
  17. <!-- 右侧文书列表表格 -->
  18. <div class="documents-content">
  19. <div class="operation-bar">
  20. <el-button
  21. v-if="!isView"
  22. plain
  23. type="success"
  24. icon="el-icon-circle-plus"
  25. @click="handleGenerateDocument"
  26. >
  27. 生成文书
  28. </el-button>
  29. </div>
  30. <CostAuditTable
  31. :table-data="documentData.list"
  32. :columns="documentData.documentColumns"
  33. :show-index="true"
  34. :show-pagination="true"
  35. :show-action-column="true"
  36. :pagination="documentData.pagination"
  37. @pagination-change="handlePaginationChange"
  38. >
  39. <template #documentId="{ row }">
  40. {{ row.documentName || getDocumenType(row) }}
  41. </template>
  42. <template #enterpriseId="{ row }">
  43. {{ getEnterpriseName(row) }}
  44. </template>
  45. <template #generateTime="{ row }">
  46. <div>
  47. {{ row.generateTime ? row.generateTime.split(' ')[0] : '' }}
  48. </div>
  49. <div>
  50. {{ row.generateTime ? row.generateTime.split(' ')[1] : '' }}
  51. </div>
  52. </template>
  53. <template #scanDocumentUrl="scope">
  54. <el-button
  55. v-if="!isView && getDocumenType(scope.row).includes('送达回证')"
  56. type="text"
  57. size="mini"
  58. @click="handleUploadScan(scope.row, 'scanDocumentUrl')"
  59. >
  60. 上传附件
  61. </el-button>
  62. <el-button
  63. v-if="getDocumenType(scope.row).includes('送达回证')"
  64. type="text"
  65. size="mini"
  66. @click="handleViewScan(scope.row.scanDocumentUrl)"
  67. >
  68. 查看附件
  69. </el-button>
  70. </template>
  71. <template #feedbackDocumentUrl="scope">
  72. <!-- <el-button
  73. type="text"
  74. size="mini"
  75. :disabled="isView"
  76. @click="handleUploadScan(scope.row, 'feedbackDocumentUrl')"
  77. >
  78. 上传附件
  79. </el-button> -->
  80. <div v-if="getDocumenType(scope.row).includes('送达回证')">
  81. <!-- <span>
  82. {{ scope.row.feedbackDocumentUrl ? '已回传' : '未回传' }}
  83. </span> -->
  84. <el-button
  85. v-if="scope.row.feedbackDocumentUrl"
  86. type="text"
  87. size="mini"
  88. @click="handleViewScan(scope.row.feedbackDocumentUrl)"
  89. >
  90. 查看附件
  91. </el-button>
  92. </div>
  93. </template>
  94. <template #electronicDocumentUrl="scope">
  95. <el-button
  96. type="text"
  97. size="mini"
  98. @click="handleDocView(scope.row)"
  99. >
  100. 查看
  101. </el-button>
  102. <el-button
  103. v-if="!isView && !getDocumenType(scope.row).includes('通知书')"
  104. type="text"
  105. size="mini"
  106. @click="handleEditDocument(scope.row)"
  107. >
  108. 修改
  109. </el-button>
  110. <!-- <el-button
  111. v-if="!isView"
  112. type="text"
  113. size="mini"
  114. @click="handleSignDocument(scope.row)"
  115. >
  116. 签章
  117. </el-button> -->
  118. <el-button
  119. v-if="!isView"
  120. type="text"
  121. size="mini"
  122. @click="handleDeleteDocument(scope.row)"
  123. >
  124. 删除
  125. </el-button>
  126. <el-button
  127. type="text"
  128. size="mini"
  129. @click="handleDownloadDocument(scope.row)"
  130. >
  131. 下载
  132. </el-button>
  133. </template>
  134. </CostAuditTable>
  135. </div>
  136. </div>
  137. <!-- <div style="margin-top: 20px; font-size: 14px" class="table-description">
  138. 说明:此处只能生成各被监审单位的《成本监审通知书》和《送达回证》,同时接收或上传被监审单位的反馈的《送达回证》。
  139. </div> -->
  140. <!-- 编辑监审通知书 -->
  141. <CostAuditDialog
  142. :title="documentDialogTitle"
  143. :visible="documentDialogVisible"
  144. width="82%"
  145. :close-on-click-modal="false"
  146. :z-index="9999"
  147. @cancel="handleCancel"
  148. @confirm="handleConfirm"
  149. >
  150. <div class="document-edit-container">
  151. <!-- 左侧:文书参数设置 -->
  152. <div class="document-params">
  153. <h4>文书参数设置:</h4>
  154. <el-form
  155. ref="documentForm"
  156. v-loading="loading.saveDocument"
  157. :model="document"
  158. label-width="170px"
  159. size="small"
  160. :rules="documentRules"
  161. >
  162. <el-form-item label="选择模板:" prop="documentId">
  163. <el-select
  164. v-model="document.documentId"
  165. placeholder="请选择模板"
  166. style="width: 100%"
  167. @change="handleTemplateChange"
  168. >
  169. <el-option
  170. v-for="item in documentData.documentTypes"
  171. :key="item.id"
  172. :label="item.documentName"
  173. :value="item.id"
  174. ></el-option>
  175. </el-select>
  176. </el-form-item>
  177. <el-form-item label="通知书文号:" prop="documentNumber">
  178. <el-input
  179. v-model="document.documentNumber"
  180. placeholder="请选择通知书文号"
  181. style="width: 74%"
  182. disabled
  183. ></el-input>
  184. <!-- disabled -->
  185. <el-button
  186. type="primary"
  187. size="small"
  188. class="ml10"
  189. @click="selectClick"
  190. >
  191. 选择文号
  192. </el-button>
  193. </el-form-item>
  194. <el-form-item label="被监审单位" prop="enterpriseId">
  195. <div style="display: flex; align-items: center; gap: 15px">
  196. <el-select
  197. v-model="document.enterpriseId"
  198. placeholder="请选择被监审单位"
  199. style="width: 100%"
  200. clearable
  201. :multiple="isMultipleMode"
  202. @change="handleEnterpriseChange"
  203. >
  204. <el-option
  205. v-for="item in allUnits"
  206. :key="item.unitId"
  207. :label="item.unitName"
  208. :value="item.unitId"
  209. ></el-option>
  210. </el-select>
  211. </div>
  212. </el-form-item>
  213. <el-form-item label="是否推送被监审单位:" prop="isPushed">
  214. <!-- 是否推送被监审单位 -->
  215. <el-radio-group v-model="document.isPushed">
  216. <el-radio label="1">是</el-radio>
  217. <el-radio label="0">否</el-radio>
  218. </el-radio-group>
  219. </el-form-item>
  220. <!-- <el-form-item label="被监审单位:">
  221. <el-select
  222. v-model="document.enterpriseId"
  223. placeholder="请选择被监审单位"
  224. style="width: 100%"
  225. clearable
  226. >
  227. <el-option
  228. v-for="item in allUnits"
  229. :key="item.unitId"
  230. :label="item.unitName"
  231. :value="item.unitId"
  232. ></el-option>
  233. </el-select>
  234. </el-form-item> -->
  235. <!-- 数据内容区域 -->
  236. <div style="margin-top: 20px">
  237. <h4 style="margin-bottom: 10px">数据内容:</h4>
  238. <el-table
  239. :data="costDocumentTemplateFiles"
  240. style="
  241. width: 100%;
  242. border: 1px solid #dcdfe6;
  243. border-radius: 4px;
  244. "
  245. >
  246. <el-table-column
  247. prop="originalText"
  248. label="数据项"
  249. width="120"
  250. align="center"
  251. show-overflow-tooltip
  252. ></el-table-column>
  253. <!-- <el-table-column
  254. prop="labelValue"
  255. label="标签"
  256. width="100"
  257. align="center"
  258. show-overflow-tooltip
  259. ></el-table-column> -->
  260. <el-table-column
  261. prop="originalText"
  262. label="描述"
  263. min-width="120"
  264. align="center"
  265. show-overflow-tooltip
  266. ></el-table-column>
  267. <el-table-column
  268. prop="dataValue"
  269. label="数据值"
  270. min-width="150"
  271. align="center"
  272. show-overflow-tooltip
  273. >
  274. <template slot-scope="scope">
  275. <el-input
  276. v-if="scope.row.originalText !== '需要提供材料'"
  277. v-model="scope.row.dataValue"
  278. size="small"
  279. placeholder="请输入数据值"
  280. ></el-input>
  281. <!-- 否则显示上传按钮 -->
  282. <div v-else>
  283. <el-button
  284. type="text"
  285. size="small"
  286. @click="handleUploadClick(scope.row)"
  287. >
  288. 上传附件
  289. </el-button>
  290. <el-button
  291. v-if="scope.row.dataValue"
  292. type="text"
  293. size="small"
  294. @click="handleViewScan(scope.row.dataValue)"
  295. >
  296. 查看附件
  297. </el-button>
  298. </div>
  299. </template>
  300. </el-table-column>
  301. </el-table>
  302. <div style="margin-top: 10px; font-size: 12px; color: #909399">
  303. 说明:数据内容可以在此处直接修改,修改后的数据将用于生成监审文书。
  304. </div>
  305. </div>
  306. </el-form>
  307. </div>
  308. <!-- 右侧:模板预览和编辑区 -->
  309. <div class="document-preview">
  310. <!-- 预览/修改标签页 -->
  311. <TemplatePreviewEdit :active-tab="activeTab" :file-url="fileUrl" />
  312. </div>
  313. </div>
  314. </CostAuditDialog>
  315. <CostAuditDialog
  316. :title="dialogTitle"
  317. :visible="dialogVisible"
  318. :width="dialogWidth"
  319. :close-on-click-modal="false"
  320. :z-index="10000"
  321. @cancel="handleCancel"
  322. @confirm="handleConfirm"
  323. >
  324. <cost-audit-table
  325. :table-data="selectDocumentWhData"
  326. :columns="selectDocumentWhColumns"
  327. :show-selection="true"
  328. :show-pagination="true"
  329. :pagination="selectDocumentWhPagination"
  330. @pagination-change="selectDocumentWhPaginationChange"
  331. @selection-change="selectDocumentWhSelectionChange"
  332. >
  333. <!-- 创建时间自定义单元格 -->
  334. <template #createTime="{ row }">
  335. <div>{{ row.createTime ? row.createTime.split(' ')[0] : '-' }}</div>
  336. <div>{{ row.createTime ? row.createTime.split(' ')[1] : '-' }}</div>
  337. </template>
  338. </cost-audit-table>
  339. </CostAuditDialog>
  340. </div>
  341. </template>
  342. <script>
  343. import CostAuditTable from '@/components/costAudit/CostAuditTable.vue'
  344. import CostAuditDialog from '@/components/costAudit/CostAuditDialog.vue'
  345. import TemplatePreviewEdit from '@/components/costAudit/TemplatePreviewEdit.vue'
  346. import { getAllUnitList } from '@/api/auditEntityManage'
  347. import {
  348. getDocList,
  349. getCostProjectDocumentFile,
  350. queryByDocumentIdandWhereValue,
  351. } from '@/api/auditReviewDocManage.js'
  352. import { getData } from '@/api/auditDocNoManage.js'
  353. import {
  354. addCostProjectDocument,
  355. updateCostProjectDocument,
  356. deleteCostProjectDocument,
  357. getCostProjectDocumentDetail,
  358. updateScan,
  359. downDocument,
  360. getCostProjectDocumentPageList,
  361. } from '@/api/taskCustomizedRelease.js'
  362. import { dictMixin, regionMixin } from '@/mixins/useDict'
  363. import { uploadFile } from '@/api/file'
  364. export default {
  365. components: { CostAuditTable, CostAuditDialog, TemplatePreviewEdit },
  366. mixins: [dictMixin, regionMixin],
  367. props: {
  368. // 父组件传递的参数
  369. project: {
  370. type: Object,
  371. default: () => {},
  372. },
  373. id: {
  374. type: String,
  375. default: '',
  376. },
  377. isView: {
  378. type: Boolean,
  379. default: false,
  380. },
  381. },
  382. data() {
  383. return {
  384. isMultipleMode: false,
  385. dictData: {
  386. whGenerateType: [],
  387. },
  388. activeDocumentTypeId: '',
  389. document: {
  390. createBy: '',
  391. createTime: '',
  392. documentAlias: '',
  393. documentId: '',
  394. documentName: '',
  395. documentNumber: '',
  396. documentType: '',
  397. documentWhId: '',
  398. electronicDocumentUrl: '',
  399. enterpriseId: [],
  400. feedbackDocumentUrl: '',
  401. feedbackTime: '',
  402. generateTime: '',
  403. id: '',
  404. isDeleted: '',
  405. isPushed: '',
  406. orderNum: 0,
  407. pkVal: '',
  408. projectId: '',
  409. pushTime: '',
  410. scanDocumentUrl: '',
  411. updateBy: '',
  412. updateTime: '',
  413. },
  414. loading: {
  415. saveDocument: false,
  416. },
  417. activeView: 'list', // list edit
  418. activeTab: 'preview', // 当前标签页,preview:预览,edit:修改
  419. // 所有单位列表
  420. allUnits: [],
  421. dialogVisible: false,
  422. dialogTitle: '选择文号',
  423. documentDialogVisible: false,
  424. documentDialogTitle: '添加监审通知书',
  425. dialogWidth: '80%',
  426. fileUrl: '',
  427. selectDocumentWhData: [],
  428. selectDocumentWhPagination: {
  429. currentPage: 1,
  430. pageSize: 50,
  431. total: 0,
  432. },
  433. selectDocumentWhSelection: [],
  434. costDocumentTemplateFiles: [],
  435. documentData: {
  436. documentTypes: [],
  437. selectedDoc: 'notice',
  438. list: [],
  439. pagination: {
  440. currentPage: 1,
  441. pageSize: 50,
  442. total: 0,
  443. },
  444. documentColumns: [
  445. {
  446. prop: 'documentId',
  447. label: '文书类型',
  448. align: 'center',
  449. slotName: 'documentId',
  450. },
  451. {
  452. prop: 'documentNumber',
  453. label: '文书文号',
  454. width: 200,
  455. align: 'center',
  456. },
  457. {
  458. prop: 'enterpriseId',
  459. label: '被监审单位',
  460. width: 200,
  461. align: 'left',
  462. slotName: 'enterpriseId',
  463. },
  464. {
  465. prop: 'generateTime',
  466. label: '生成时间',
  467. width: 100,
  468. align: 'center',
  469. slotName: 'generateTime',
  470. },
  471. {
  472. prop: 'electronicDocumentUrl',
  473. label: '电子文书',
  474. width: 200,
  475. align: 'center',
  476. slotName: 'electronicDocumentUrl',
  477. },
  478. {
  479. prop: 'scanDocumentUrl',
  480. label: '上传扫描件',
  481. width: 150,
  482. align: 'center',
  483. slotName: 'scanDocumentUrl',
  484. },
  485. {
  486. prop: 'isPushed',
  487. label: '是否推送被监审单位',
  488. width: 100,
  489. align: 'center',
  490. formatter: (row) => (row.isPushed == 1 ? '是' : '否'),
  491. },
  492. {
  493. prop: 'feedbackDocumentUrl',
  494. label: '被监审单位反馈资料',
  495. width: 150,
  496. align: 'center',
  497. slotName: 'feedbackDocumentUrl',
  498. },
  499. ],
  500. },
  501. documentRules: {
  502. // documentNumber: [
  503. // {
  504. // required: true,
  505. // message: '请选择通知书文号',
  506. // trigger: 'change',
  507. // },
  508. // ],
  509. enterpriseId: [
  510. {
  511. required: true,
  512. message: '请选择被监审单位',
  513. trigger: 'change',
  514. },
  515. ],
  516. documentId: [
  517. {
  518. required: true,
  519. message: '请选择模板',
  520. trigger: 'change',
  521. },
  522. ],
  523. isPushed: [
  524. {
  525. required: true,
  526. message: '请选择否推送被监审单位',
  527. trigger: 'change',
  528. },
  529. ],
  530. },
  531. dataUploadUrl: [],
  532. }
  533. },
  534. computed: {
  535. selectDocumentWhColumns() {
  536. return [
  537. {
  538. prop: 'whType',
  539. label: '文号分类',
  540. showOverflowTooltip: true,
  541. align: 'center',
  542. formatter: (row) => {
  543. let documentName =
  544. this.documentData.documentTypes.find(
  545. (item) => item.id == row.whType
  546. )?.documentName || '-'
  547. return documentName
  548. },
  549. },
  550. {
  551. prop: 'whName',
  552. label: '文号名称',
  553. showOverflowTooltip: true,
  554. align: 'center',
  555. },
  556. {
  557. prop: 'areaCode',
  558. label: '适用区域',
  559. showOverflowTooltip: true,
  560. align: 'center',
  561. formatter: (row) => this.regionNameMap[row.areaCode] || '-',
  562. },
  563. {
  564. prop: 'generateType',
  565. label: '生成类型',
  566. showOverflowTooltip: true,
  567. align: 'center',
  568. width: 120,
  569. formatter: (row) =>
  570. this.getDictName('whGenerateType', row.generateType),
  571. },
  572. ]
  573. },
  574. },
  575. watch: {
  576. id: {
  577. handler(newVal) {
  578. if (newVal) {
  579. this.getData()
  580. }
  581. },
  582. deep: true,
  583. immediate: true,
  584. },
  585. costDocumentTemplateFiles: {
  586. handler(newVal, oldVal) {
  587. if (newVal.length > 0) {
  588. console.log(this.costDocumentTemplateFiles)
  589. this.costDocumentTemplateFiles.forEach((item) => {
  590. if (
  591. item.pinyin.includes('ShiJian') &&
  592. (item.dataValue == null || item.dataValue == '')
  593. ) {
  594. // 获取当前时间,格式为YYYY-MM-DD HH:mm:ss
  595. let date = new Date()
  596. let year = date.getFullYear()
  597. let month = String(date.getMonth() + 1).padStart(2, '0')
  598. let day = String(date.getDate()).padStart(2, '0')
  599. let hours = String(date.getHours()).padStart(2, '0')
  600. let minutes = String(date.getMinutes()).padStart(2, '0')
  601. let seconds = String(date.getSeconds()).padStart(2, '0')
  602. item.dataValue = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
  603. }
  604. if (
  605. item.originalText.includes('需要提供材料') &&
  606. item.dataValue
  607. ) {
  608. this.dataUploadUrl = item.dataValue
  609. }
  610. })
  611. }
  612. },
  613. deep: true,
  614. },
  615. },
  616. mounted() {
  617. this.getData()
  618. this.loadOpts()
  619. },
  620. methods: {
  621. handleDocumentTypeClick(data) {
  622. this.activeDocumentTypeId = data.id
  623. this.getData(data)
  624. },
  625. // 获取监审通知数据
  626. async getData(data) {
  627. const res = await getDocList({
  628. page: 1,
  629. pageSize: 50,
  630. })
  631. this.documentData.documentTypes = res.value.records || []
  632. const pid = this.project.projectId
  633. if (!pid) return
  634. this.getlist(data)
  635. },
  636. getlist(data) {
  637. getCostProjectDocumentPageList({
  638. pageNum: this.documentData.pagination.currentPage,
  639. pageSize: this.documentData.pagination.pageSize,
  640. projectId: this.project.projectId,
  641. documentName: data ? data.documentName : '',
  642. permissionType: '0',
  643. }).then((res) => {
  644. let records = res.value.value.records
  645. this.documentData.list = records.filter((item) => {
  646. const excludeTypes = [
  647. '成本监审工作底稿-送达回证',
  648. '成本监审提取资料登记表-送达回证',
  649. '成本审核初步意见表1-送达回证',
  650. '成本监审集体审议记录-送达回证',
  651. ]
  652. return !excludeTypes.includes(item.documentName)
  653. })
  654. this.documentData.pagination.total = res.value.value.total
  655. })
  656. },
  657. getEnterpriseName(row) {
  658. // 处理enterpriseId,无论是数组还是逗号分隔的字符串
  659. let enterpriseIds = []
  660. if (Array.isArray(row.enterpriseId)) {
  661. enterpriseIds = row.enterpriseId
  662. } else if (typeof row.enterpriseId === 'string') {
  663. // 处理逗号分隔的字符串
  664. enterpriseIds = row.enterpriseId
  665. .split(',')
  666. .map((id) => id.trim())
  667. .filter((id) => id)
  668. } else if (row.enterpriseId) {
  669. // 处理其他可能的非空值
  670. enterpriseIds = [row.enterpriseId]
  671. }
  672. if (enterpriseIds.length > 0) {
  673. // 返回多个企业名称,用逗号分隔
  674. return enterpriseIds
  675. .map(
  676. (id) => this.allUnits.find((item) => item.unitId == id)?.unitName
  677. )
  678. .filter((name) => name)
  679. .join(', ')
  680. }
  681. return '-'
  682. },
  683. getDocumenType(row) {
  684. return this.documentData.documentTypes.find(
  685. (item) => item.id == row.documentId
  686. )?.documentName
  687. },
  688. handlePaginationChange({ currentPage, pageSize }) {
  689. this.documentData.pagination.currentPage = currentPage
  690. this.documentData.pagination.pageSize = pageSize
  691. this.getlist()
  692. },
  693. // 加载选项数据
  694. loadOpts() {
  695. // 加载所有单位列表
  696. getAllUnitList().then((res) => {
  697. this.allUnits = res.value || []
  698. // 过滤掉状态为停用的数据
  699. this.allUnits = this.allUnits.filter((item) => item.status == 1)
  700. // 筛选this.project.auditedUnitId中的单位,支持多种格式
  701. if (this.project.auditedUnitId) {
  702. // 确保将project.auditedUnitId转换为数组格式
  703. let auditedUnitIds = []
  704. if (Array.isArray(this.project.auditedUnitId)) {
  705. auditedUnitIds = this.project.auditedUnitId
  706. } else if (
  707. typeof this.project.auditedUnitId === 'string' &&
  708. this.project.auditedUnitId.includes(',')
  709. ) {
  710. // 如果是逗号分隔的字符串,转换为数组
  711. auditedUnitIds = this.project.auditedUnitId
  712. .split(',')
  713. .map((id) => id.trim())
  714. } else {
  715. // 单个ID也转换为数组
  716. auditedUnitIds = [this.project.auditedUnitId]
  717. }
  718. // 使用数组进行筛选
  719. this.allUnits = this.allUnits.filter((item) =>
  720. auditedUnitIds.includes(item.unitId)
  721. )
  722. }
  723. })
  724. },
  725. // 生成文书
  726. handleGenerateDocument() {
  727. this.documentDialogTitle = '添加监审通知书'
  728. this.documentDialogVisible = true
  729. this.activeView = 'form'
  730. this.costDocumentTemplateFiles = []
  731. this.document = {
  732. createBy: '',
  733. createTime: '',
  734. documentAlias: '',
  735. documentId: '',
  736. documentName: '',
  737. documentNumber: '',
  738. documentType: '',
  739. documentWhId: '',
  740. electronicDocumentUrl: '',
  741. enterpriseId: this.isMultipleMode ? [] : '',
  742. feedbackDocumentUrl: '',
  743. feedbackTime: '',
  744. generateTime: '',
  745. id: '',
  746. isDeleted: '',
  747. isPushed: '1',
  748. orderNum: this.documentData.list.length + 1,
  749. pkVal: '',
  750. projectId: '',
  751. pushTime: '',
  752. scanDocumentUrl: '',
  753. updateBy: '',
  754. updateTime: '',
  755. }
  756. // if(this.isMultipleMode){
  757. // this.document.enterpriseId = this.project.auditedUnitId ? this.project.auditedUnitId.split(',') : []
  758. // console.log('this.document.enterpriseId',this.document.enterpriseId)
  759. // }else{
  760. // this.document.enterpriseId = this.project.auditedUnitId
  761. // }
  762. this.loadOpts()
  763. if (this.activeDocumentTypeId) {
  764. this.document.documentId = this.activeDocumentTypeId
  765. this.handleTemplateChange()
  766. }
  767. },
  768. getDetail() {
  769. getCostProjectDocumentDetail({
  770. projectId: this.project.projectId,
  771. }).then((res) => {
  772. if (res.value) {
  773. this.document = {
  774. ...this.document,
  775. ...res.value,
  776. }
  777. this.loadOpts()
  778. }
  779. })
  780. },
  781. selectClick() {
  782. this.dialogVisible = true
  783. this.activeView = 'table'
  784. this.getWhListData()
  785. },
  786. getWhListData() {
  787. getData({
  788. page: this.selectDocumentWhPagination.currentPage,
  789. pageSize: this.selectDocumentWhPagination.pageSize,
  790. whType: this.document.documentId,
  791. }).then((res) => {
  792. this.selectDocumentWhData = res.rows || []
  793. this.selectDocumentWhPagination.total = res.total || 0
  794. // 获取区域名称,填充regionNameMap
  795. if (this.selectDocumentWhData.length > 0) {
  796. this.fetchRegionNames(this.selectDocumentWhData, 'areaCode')
  797. }
  798. })
  799. },
  800. selectDocumentWhPaginationChange({ currentPage, pageSize }) {
  801. this.selectDocumentWhPagination.currentPage = currentPage
  802. this.selectDocumentWhPagination.pageSize = pageSize
  803. },
  804. selectDocumentWhSelectionChange(selection) {
  805. if (selection.length > 1) {
  806. this.$message.error('只能选择一个文号!')
  807. return
  808. } else {
  809. this.selectDocumentWhSelection = selection
  810. }
  811. },
  812. handleTemplateChange() {
  813. let data = this.documentData.documentTypes.find(
  814. (item) => item.id === this.document.documentId
  815. )
  816. this.fileUrl = data.fileUrl
  817. this.document.documentName = data.documentName
  818. this.document.documentNumber = ''
  819. this.document.documentWhId = ''
  820. },
  821. getDocumentData() {
  822. if (this.document.id === null || this.document.id === '') {
  823. queryByDocumentIdandWhereValue({
  824. documentId: this.document.documentId,
  825. whereValue: this.project.projectId,
  826. unitId: this.document.enterpriseId,
  827. }).then((res) => {
  828. this.costDocumentTemplateFiles = res.value || []
  829. let unit = this.allUnits.find(
  830. (item) => item.unitId === this.document.enterpriseId
  831. )
  832. this.costDocumentTemplateFiles.forEach((item) => {
  833. if (item.pinyin.includes('BeiJianShenDanWei')) {
  834. item.dataValue = unit.unitName
  835. }
  836. if (item.pinyin.includes('ShouSongDaRen')) {
  837. item.dataValue = unit.contactName
  838. }
  839. if (item.pinyin.includes('BeiJianShenDanWeiBanGongDiDian')) {
  840. item.dataValue = unit.address
  841. }
  842. if (item.pinyin.includes('BeiJianShenDanWeiLianXiRenDianHua')) {
  843. item.dataValue = unit.contactMobile
  844. }
  845. // 回显文号
  846. // 获取选中的文号信息
  847. const selectedDocument = this.selectDocumentWhSelection[0]
  848. if (
  849. item.pinyin.includes('WenHao') ||
  850. item.pinyin.includes('WenJianHao')
  851. ) {
  852. item.dataValue = selectedDocument.whNo
  853. }
  854. if (item.pinyin.includes('SongDaWenShuMingCheng')) {
  855. item.dataValue = selectedDocument.whName
  856. }
  857. })
  858. })
  859. } else {
  860. getCostProjectDocumentFile({
  861. // documentId: this.document.documentId,
  862. // whereValue: this.project.projectId,
  863. id: this.document.id,
  864. }).then((res) => {
  865. this.costDocumentTemplateFiles = res.value || []
  866. })
  867. }
  868. },
  869. handleConfirm() {
  870. switch (this.activeView) {
  871. case 'table':
  872. this.handleConfirmSelect()
  873. break
  874. case 'form':
  875. this.handleSaveDocument()
  876. break
  877. default:
  878. break
  879. }
  880. },
  881. handleConfirmSelect() {
  882. if (this.selectDocumentWhSelection.length !== 1) {
  883. this.$message.error('请选择一个文号!')
  884. return
  885. }
  886. // 获取选中的文号信息
  887. const selectedDocument = this.selectDocumentWhSelection[0]
  888. this.document.documentNumber = selectedDocument.whNo
  889. this.document.documentWhId = selectedDocument.id
  890. // 数据表格回显文号
  891. this.costDocumentTemplateFiles.forEach((item) => {
  892. if (
  893. item.pinyin.includes('WenHao') ||
  894. item.pinyin.includes('WenJianHao')
  895. ) {
  896. item.dataValue = selectedDocument.whNo
  897. }
  898. if (item.pinyin.includes('SongDaWenShuMingCheng')) {
  899. item.dataValue = selectedDocument.whName
  900. }
  901. })
  902. this.dialogVisible = false
  903. this.activeView = 'form'
  904. },
  905. handleEnterpriseChange(val) {
  906. if (this.document.enterpriseId) {
  907. // BeiJianShenDanWei
  908. this.getDocumentData()
  909. }
  910. },
  911. // 保存文档
  912. handleSaveDocument() {
  913. // 校验表单
  914. this.$refs.documentForm.validate((valid) => {
  915. if (!valid) {
  916. this.$message.error('请填写必填项!')
  917. return false
  918. }
  919. this.loading.saveDocument = true
  920. if (this.document.id) {
  921. updateCostProjectDocument({
  922. ...this.document,
  923. costProjectDocumentFiles: this.costDocumentTemplateFiles,
  924. projectId: this.project.projectId,
  925. electronicDocumentUrl:
  926. this.document.electronicDocumentUrl || this.fileUrl,
  927. enterpriseId: this.isMultipleMode
  928. ? this.document.enterpriseId.join(',')
  929. : this.document.enterpriseId, // 保存时转换为逗号分隔的字符串
  930. })
  931. .then((res) => {
  932. this.loading.saveDocument = false
  933. this.$message.success('保存成功!')
  934. this.documentDialogVisible = false
  935. this.activeView = ''
  936. this.getlist()
  937. })
  938. .catch((err) => {
  939. this.loading.saveDocument = false
  940. })
  941. } else {
  942. addCostProjectDocument({
  943. ...this.document,
  944. projectId: this.project.projectId,
  945. costProjectDocumentFiles: this.costDocumentTemplateFiles || [],
  946. enterpriseId: this.isMultipleMode
  947. ? this.document.enterpriseId.join(',')
  948. : this.document.enterpriseId,
  949. electronicDocumentUrl: this.fileUrl,
  950. })
  951. .then(() => {
  952. this.loading.saveDocument = false
  953. this.$message.success('保存成功!')
  954. this.documentDialogVisible = false
  955. this.activeView = ''
  956. this.getlist()
  957. })
  958. .catch((err) => {
  959. this.loading.saveDocument = false
  960. })
  961. }
  962. })
  963. },
  964. // 处理取消
  965. handleCancel() {
  966. if (this.activeView === 'form') {
  967. this.documentDialogVisible = false
  968. } else {
  969. this.activeView = 'form'
  970. this.dialogVisible = false
  971. }
  972. },
  973. // 上传扫描件
  974. handleUploadScan(row, type) {
  975. let loading = null
  976. // 第一步:创建文件选择器
  977. const input = document.createElement('input')
  978. input.type = 'file'
  979. input.accept = '.pdf,.doc,.docx,.xls,.xlsx,.csv' // 允许的文件类型
  980. input.onchange = async (event) => {
  981. const file = event.target.files[0]
  982. if (!file) return
  983. try {
  984. // 校验文件大小(50MB)
  985. const maxSize = 50 * 1024 * 1024 // 50MB
  986. if (file.size > maxSize) {
  987. this.$message.error('文件大小不能超过50MB!')
  988. return
  989. }
  990. // 校验文件格式
  991. const allowedFormats = [
  992. '.pdf',
  993. '.doc',
  994. '.docx',
  995. '.xls',
  996. '.xlsx',
  997. 'csv',
  998. ]
  999. const fileName = file.name.toLowerCase()
  1000. const isValidFormat = allowedFormats.some((format) =>
  1001. fileName.endsWith(format)
  1002. )
  1003. if (!isValidFormat) {
  1004. this.$message.error(
  1005. '只允许上传.pdf,.doc,.docx,.xls,.xlsx,.csv格式的文件!'
  1006. )
  1007. return
  1008. }
  1009. // 显示遮罩层
  1010. loading = this.$baseLoading(1, '文件上传中...')
  1011. // 第三步:创建FormData并上传文件
  1012. const formData = new FormData()
  1013. formData.append('file', file)
  1014. // 先调用上传API
  1015. const uploadRes = await uploadFile('/api/file/v1/upload', formData)
  1016. // 第四步:检查上传结果
  1017. if (!uploadRes || !uploadRes.value) {
  1018. // this.$message.error('文件上传失败!');
  1019. return
  1020. }
  1021. // 第五步:文件上传成功后,再更新数据
  1022. const fileInfo = uploadRes.value
  1023. // 创建更新数据对象
  1024. const updateData = {
  1025. id: row.id,
  1026. scanDocumentUrl: fileInfo?.savePath, // 更新扫描件URL
  1027. }
  1028. // 第六步:调用更新API
  1029. await updateScan(updateData)
  1030. // 第七步:更新成功,显示提示并刷新
  1031. this.$message.success('文件上传成功并更新数据!')
  1032. this.getlist()
  1033. } catch (error) {
  1034. // 错误处理
  1035. // this.$message.error('操作失败:' + (error.message || '未知错误'))
  1036. } finally {
  1037. // 关闭遮罩层
  1038. loading.close()
  1039. }
  1040. }
  1041. // 触发文件选择
  1042. input.click()
  1043. },
  1044. // 查看监审文书
  1045. handleDocView(row) {
  1046. this.document = {
  1047. ...row,
  1048. }
  1049. // 从API中获取文件URL
  1050. downDocument({
  1051. id: row.id,
  1052. }).then((res) => {
  1053. if (res.state) {
  1054. // this.fileUrl = res.value || ''
  1055. this.handleViewScan(res.value || '')
  1056. } else {
  1057. this.$message.error('获取文件URL失败')
  1058. }
  1059. })
  1060. // this.handleTemplateChange()
  1061. // this.documentDialogVisible = true
  1062. // getCostProjectDocumentFile({
  1063. // id: row.id,
  1064. // }).then((res) => {
  1065. // this.costDocumentTemplateFiles = res.value || []
  1066. // })
  1067. },
  1068. // 查看扫描件
  1069. handleViewScan(fileUrl) {
  1070. if (!fileUrl) {
  1071. this.$message.error('暂无文件!')
  1072. return
  1073. }
  1074. let _fileUrl = ''
  1075. if (fileUrl.startsWith('http')) {
  1076. _fileUrl = fileUrl
  1077. } else {
  1078. _fileUrl = window.context.form + fileUrl
  1079. }
  1080. // 对文件URL进行Base64编码
  1081. const encodedUrl = encodeURIComponent(Base64.encode(_fileUrl))
  1082. // 构建 kkFileView 预览URL
  1083. // onlinePreview - 在线预览
  1084. // onlinePreview?type=pdf - 强制使用PDF模式预览
  1085. window.open(`${host}:8012/onlinePreview?url=${encodedUrl}`)
  1086. },
  1087. // 编辑文档
  1088. handleEditDocument(row) {
  1089. this.documentDialogTitle = '修改监审通知书'
  1090. this.documentDialogVisible = true
  1091. this.activeView = 'form'
  1092. this.loadOpts()
  1093. // 确保enterpriseId是数组格式,处理可能的逗号分隔字符串
  1094. const enterpriseId = this.isMultipleMode
  1095. ? row.enterpriseId.split(',')
  1096. : row.enterpriseId
  1097. this.document = {
  1098. ...row,
  1099. documentId: Number(row.documentId),
  1100. enterpriseId,
  1101. // 确保isPushed有值,如果row中没有,设置默认值'1'
  1102. isPushed: row.isPushed !== undefined ? row.isPushed : '1',
  1103. }
  1104. // 从API中获取文件URL
  1105. downDocument({
  1106. id: row.id,
  1107. }).then((res) => {
  1108. if (res.state) {
  1109. this.fileUrl = res.value || ''
  1110. } else {
  1111. this.$message.error('获取文件URL失败')
  1112. }
  1113. })
  1114. this.getDocumentData()
  1115. },
  1116. // 签章
  1117. handleSignDocument(row) {
  1118. this.$message.warning('签章功能待实现!')
  1119. },
  1120. // 删除文档
  1121. handleDeleteDocument(row) {
  1122. this.$confirm('确定要删除该数据吗?', '提示', {
  1123. confirmButtonText: '确定',
  1124. cancelButtonText: '取消',
  1125. type: 'warning',
  1126. }).then(() => {
  1127. deleteCostProjectDocument(row.id).then((res) => {
  1128. this.$message.success('删除成功!')
  1129. this.getlist()
  1130. })
  1131. })
  1132. },
  1133. handleDownloadDocument1(row) {
  1134. // 显示加载状态
  1135. this.$loading({
  1136. lock: true,
  1137. text: '文件下载中...',
  1138. spinner: 'el-icon-loading',
  1139. background: 'rgba(0, 0, 0, 0.7)',
  1140. })
  1141. let fileUrl = window.context.form + row.electronicDocumentUrl
  1142. let fileName = ''
  1143. // 从URL中提取文件名
  1144. const urlParts = fileUrl.split('/')
  1145. let urlFileName = urlParts[urlParts.length - 1]
  1146. // 处理URL可能包含查询参数的情况
  1147. if (urlFileName.includes('?')) {
  1148. urlFileName = urlFileName.split('?')[0]
  1149. }
  1150. // 检查从URL提取的文件名是否有效
  1151. if (urlFileName && /\.[a-zA-Z0-9]+$/.test(urlFileName)) {
  1152. fileName = urlFileName
  1153. } else {
  1154. // URL中无法提取有效文件名时,使用row.documentName作为备选
  1155. fileName = row.documentName || `监审通知书_${new Date().getTime()}`
  1156. // 确保备选文件名有扩展名
  1157. if (!/\.[a-zA-Z0-9]+$/.test(fileName)) {
  1158. fileName += '.pdf'
  1159. }
  1160. }
  1161. // 创建隐藏的a标签进行下载
  1162. const link = document.createElement('a')
  1163. link.style.display = 'none'
  1164. link.href = fileUrl
  1165. // 设置下载文件名
  1166. link.download = fileName
  1167. document.body.appendChild(link)
  1168. link.click()
  1169. document.body.removeChild(link)
  1170. // 关闭加载状态
  1171. this.$loading().close()
  1172. },
  1173. // 下载文档
  1174. handleDownloadDocument(row) {
  1175. // 显示加载状态
  1176. this.$loading({
  1177. lock: true,
  1178. text: '文件下载中...',
  1179. spinner: 'el-icon-loading',
  1180. background: 'rgba(0, 0, 0, 0.7)',
  1181. })
  1182. // 从API中获取文件URL
  1183. downDocument({
  1184. id: row.id,
  1185. })
  1186. .then((res) => {
  1187. // 关闭加载状态
  1188. this.$loading().close()
  1189. // 检查返回结果是否成功
  1190. if (!res || !res.state) {
  1191. this.$message.error(
  1192. `下载失败:${res?.message || '未获取到文件数据'}`
  1193. )
  1194. return
  1195. }
  1196. // 获取文件URL
  1197. const fileUrl = res.value
  1198. if (!fileUrl) {
  1199. this.$message.error('下载失败:未获取到文件URL')
  1200. return
  1201. }
  1202. // 优先从URL中提取文件名
  1203. let fileName = ''
  1204. // 从URL中提取文件名
  1205. const urlParts = fileUrl.split('/')
  1206. let urlFileName = urlParts[urlParts.length - 1]
  1207. // 处理URL可能包含查询参数的情况
  1208. if (urlFileName.includes('?')) {
  1209. urlFileName = urlFileName.split('?')[0]
  1210. }
  1211. // 检查从URL提取的文件名是否有效
  1212. if (urlFileName && /\.[a-zA-Z0-9]+$/.test(urlFileName)) {
  1213. fileName = urlFileName
  1214. } else {
  1215. // URL中无法提取有效文件名时,使用row.documentName作为备选
  1216. fileName =
  1217. row.documentName || `监审通知书_${new Date().getTime()}`
  1218. // 确保备选文件名有扩展名
  1219. if (!/\.[a-zA-Z0-9]+$/.test(fileName)) {
  1220. fileName += '.pdf'
  1221. }
  1222. }
  1223. // 创建隐藏的a标签进行下载
  1224. const link = document.createElement('a')
  1225. link.style.display = 'none'
  1226. link.href = fileUrl
  1227. // link.href = window.context.form + row.electronicDocumentUrl
  1228. // 设置下载文件名
  1229. link.download = fileName
  1230. document.body.appendChild(link)
  1231. link.click()
  1232. document.body.removeChild(link)
  1233. })
  1234. .catch((error) => {
  1235. // 关闭加载状态
  1236. this.$loading().close()
  1237. console.error('获取文件URL失败:', error)
  1238. })
  1239. },
  1240. handleUploadClick(row) {
  1241. console.log('handleUploadClick', row)
  1242. let loading = null
  1243. // 第一步:创建文件选择器
  1244. const input = document.createElement('input')
  1245. input.type = 'file'
  1246. input.accept = '.pdf,.doc,.docx,.xls,.xlsx,.csv' // 允许的文件类型
  1247. input.onchange = async (event) => {
  1248. const file = event.target.files[0]
  1249. if (!file) return
  1250. try {
  1251. // 校验文件大小(50MB)
  1252. const maxSize = 50 * 1024 * 1024 // 50MB
  1253. if (file.size > maxSize) {
  1254. this.$message.error('文件大小不能超过50MB!')
  1255. return
  1256. }
  1257. // 校验文件格式
  1258. const allowedFormats = [
  1259. '.pdf',
  1260. '.doc',
  1261. '.docx',
  1262. '.xls',
  1263. '.xlsx',
  1264. 'csv',
  1265. ]
  1266. const fileName = file.name.toLowerCase()
  1267. const isValidFormat = allowedFormats.some((format) =>
  1268. fileName.endsWith(format)
  1269. )
  1270. if (!isValidFormat) {
  1271. this.$message.error(
  1272. '只允许上传.pdf,.doc,.docx,.xls,.xlsx,.csv格式的文件!'
  1273. )
  1274. return
  1275. }
  1276. // 显示遮罩层
  1277. loading = this.$baseLoading(1, '文件上传中...')
  1278. // 第三步:创建FormData并上传文件
  1279. const formData = new FormData()
  1280. formData.append('file', file)
  1281. // 先调用上传API
  1282. const uploadRes = await uploadFile('/api/file/v1/upload', formData)
  1283. // 第四步:检查上传结果
  1284. if (!uploadRes || !uploadRes.value) {
  1285. // this.$message.error('文件上传失败!');
  1286. return
  1287. }
  1288. // 第五步:文件上传成功后,再更新数据
  1289. const fileInfo = uploadRes.value
  1290. this.costDocumentTemplateFiles.find(
  1291. (item) => item.originalText === row.originalText
  1292. ).dataValue = fileInfo.savePath
  1293. this.$message.success('文件上传成功!')
  1294. } catch (error) {
  1295. console.error('文件上传失败:', error)
  1296. } finally {
  1297. // 关闭遮罩层
  1298. loading.close()
  1299. }
  1300. }
  1301. // 触发文件选择对话框显示
  1302. input.click()
  1303. },
  1304. },
  1305. }
  1306. </script>
  1307. <style lang="scss" scoped>
  1308. @import '@/styles/costAudit.scss';
  1309. .documents-layout {
  1310. display: flex;
  1311. margin-bottom: 20px;
  1312. }
  1313. .documents-type-list {
  1314. width: 200px;
  1315. border: 1px solid #ebeef5;
  1316. border-radius: 5px;
  1317. padding: 10px;
  1318. margin-right: 20px;
  1319. }
  1320. .documents-type-list h3 {
  1321. margin-bottom: 10px;
  1322. font-size: 14px;
  1323. font-weight: bold;
  1324. }
  1325. .type-item {
  1326. padding: 5px 0;
  1327. cursor: pointer;
  1328. font-size: 12px;
  1329. }
  1330. .type-item:hover {
  1331. color: #409eff;
  1332. }
  1333. .documents-content {
  1334. flex: 1;
  1335. }
  1336. .generate-btn {
  1337. margin-bottom: 10px;
  1338. }
  1339. .cursor-pointer {
  1340. cursor: pointer;
  1341. }
  1342. .mt10 {
  1343. margin-top: 10px;
  1344. }
  1345. .mt20 {
  1346. margin-top: 20px;
  1347. }
  1348. .document-edit-container {
  1349. display: flex;
  1350. .document-params {
  1351. width: 50%;
  1352. }
  1353. .document-preview {
  1354. width: 50%;
  1355. }
  1356. }
  1357. </style>