auditNoticeTab.vue 41 KB

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