taskFillIn.vue 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470
  1. <template>
  2. <el-drawer
  3. :visible.sync="drawerVisible"
  4. :size="drawerSize"
  5. :with-header="true"
  6. :modal="true"
  7. :z-index="9000"
  8. :close-on-click-modal="false"
  9. :show-close="true"
  10. @close="handleDrawerClose"
  11. @update:visible="(val) => $emit('update:visible', val)"
  12. >
  13. <div slot="title" class="drawer-title">
  14. <span>{{ pageTitle || '填报任务' }}</span>
  15. </div>
  16. <div class="audit-task-manage-container">
  17. <!-- 操作按钮 -->
  18. <div class="action-buttons" style="margin-bottom: 20px">
  19. <el-button
  20. type="primary"
  21. :loading="loading.submit"
  22. :disabled="isViewMode"
  23. @click="handleSubmit"
  24. >
  25. 提交
  26. </el-button>
  27. <!-- <el-button type="primary" :loading="loading.save" @click="handleSave" :disabled="isViewMode">
  28. 保存
  29. </el-button> -->
  30. <!-- <el-button type="primary" class="ml10" @click="handleBack">
  31. 返回
  32. </el-button> -->
  33. </div>
  34. <!-- 标签页容器 -->
  35. <div
  36. v-loading="tabLoading[activeTab]"
  37. class="tabs-container"
  38. element-loading-text="数据加载中..."
  39. >
  40. <el-tabs
  41. v-model="activeTab"
  42. type="border-card"
  43. @tab-click="handleTabClick"
  44. >
  45. <!-- 立项信息 -->
  46. <el-tab-pane label="立项信息" name="projectInfo">
  47. <project-info-tab
  48. :form-data="formData.basicInfo"
  49. :is-view-mode="isViewMode"
  50. :unit-list="unitList"
  51. :org-list="OrgList"
  52. :user-list="userList"
  53. :dict-data="dictData"
  54. @change="handleProjectInfoChange"
  55. @handleCatalogChange="handleCatalogChange"
  56. @handleRegionChange="handleRegionChange"
  57. @addCostYear="addCostYear"
  58. @deleteCostYear="deleteCostYear"
  59. />
  60. </el-tab-pane>
  61. <!-- 监审文书 -->
  62. <el-tab-pane label="监审文书" name="auditDocument">
  63. <audit-document-tab
  64. :form-data="formData.auditDocument"
  65. :is-view-mode="isViewMode"
  66. :pagination="auditDocumentPagination"
  67. @handleClick="handleClick"
  68. @handleDownload="handleDownload"
  69. @handleUpload="handleUpload"
  70. @refresh="getAuditDocumentList"
  71. @paginationChange="handleAuditDocumentPaginationChange"
  72. />
  73. </el-tab-pane>
  74. <!-- 报送资料 -->
  75. <el-tab-pane
  76. v-if="
  77. currentNode !== 'jtsy' ||
  78. currentNode !== 'cjbg' ||
  79. currentNode !== 'gd'
  80. "
  81. label="报送资料"
  82. name="dataRequirements"
  83. >
  84. <data-requirements-tab
  85. :data-requirements="groupedDataRequirements"
  86. :is-view-mode="isViewMode"
  87. :dict-data="dictData"
  88. :current-node="currentNode"
  89. :audited-unit-id="auditedUnitId"
  90. :task-id="taskId"
  91. @handleAddMaterial="handleAddMaterial"
  92. @handleFileView="handleFileView"
  93. @handleFileDownload="handleFileDownload"
  94. @handleFileUpload="handleFileUpload"
  95. @handleTemplateDownload="handleTemplateDownload"
  96. @data-upload-success="getTaskRequirementPage"
  97. @handleDataUpload="handleDataUpload"
  98. @handle-survey-form-save="getTaskRequirementPage"
  99. @handle-fixed-table-save="getTaskRequirementPage"
  100. @handle-dynamic-table-save="getTaskRequirementPage"
  101. />
  102. </el-tab-pane>
  103. <!-- 成本调查表 -->
  104. <el-tab-pane
  105. v-if="currentNode === 'clcs' || currentNode === 'tjcl'"
  106. label="成本调查表"
  107. name="costSurvey"
  108. >
  109. <cost-survey-tab
  110. :paginated-data="formData.paginatedData"
  111. :pagination="costSurveyPagination"
  112. :is-view-mode="isViewMode"
  113. :audited-unit-id="auditedUnitId"
  114. :catalog-id="taskInfo.catalogId"
  115. :task-id="taskInfo.taskId"
  116. :project-id="taskInfo.projectId"
  117. :audit-period="getAuditPeriodArray()"
  118. @handle-modify="handleModify"
  119. @handle-data-download="handleDataDownload"
  120. @handle-data-upload="handleDataUpload"
  121. @handle-preview="handlePreview"
  122. @handle-page-change="handleCostSurveyPageChange"
  123. @handle-size-change="handleCostSurveySizeChange"
  124. @handle-survey-form-save="handleSurveyFormSave"
  125. />
  126. </el-tab-pane>
  127. <!-- 监审意见 -->
  128. <el-tab-pane
  129. v-if="currentNode === 'yjfk'"
  130. label="监审意见"
  131. name="auditOpinion"
  132. >
  133. <audit-opinion-tab
  134. :id="taskId"
  135. ref="auditOpinionTabRef"
  136. :form-data="formData.auditOpinion"
  137. :is-view-mode="isViewMode"
  138. @change="handleAuditOpinionChange"
  139. @data-loaded="handleAuditOpinionDataLoaded"
  140. />
  141. </el-tab-pane>
  142. <!-- 消息通知 -->
  143. <el-tab-pane label="消息通知" name="messageNotice">
  144. <message-notice-tab
  145. :form-data="formData.messageNotice"
  146. :pagination="messageNoticePagination"
  147. @handleCurrentChange="handleMessageNoticePageChange"
  148. @handleSizeChange="handleMessageNoticeSizeChange"
  149. />
  150. </el-tab-pane>
  151. </el-tabs>
  152. </div>
  153. <!-- 补充材料弹窗 -->
  154. <el-dialog
  155. title="补充材料"
  156. :visible.sync="materialDialogVisible"
  157. width="600px"
  158. :z-index="10000"
  159. :close-on-click-modal="false"
  160. :modal="true"
  161. append-to-body
  162. >
  163. <el-form
  164. ref="materialForm"
  165. :model="materialForm"
  166. :rules="materialRulesComputed"
  167. label-width="100px"
  168. >
  169. <el-form-item v-if="isClcs" label="资料类别" prop="informationType">
  170. <el-select
  171. v-model="materialForm.informationType"
  172. placeholder="请选择资料类别"
  173. style="width: 100%"
  174. :disabled="isViewMode"
  175. >
  176. <el-option
  177. v-for="item in dictData['materialType']"
  178. :key="item.key"
  179. :label="item.name"
  180. :value="item.key"
  181. ></el-option>
  182. </el-select>
  183. </el-form-item>
  184. <el-form-item label="资料名称" prop="informationName">
  185. <el-input
  186. v-model="materialForm.informationName"
  187. placeholder="请输入资料名称"
  188. style="width: 100%"
  189. maxlength="30"
  190. show-word-limit
  191. :disabled="isViewMode"
  192. ></el-input>
  193. </el-form-item>
  194. <el-form-item
  195. v-if="isClcs"
  196. label="资料要求:"
  197. prop="informationRequire"
  198. >
  199. <el-input
  200. v-model="materialForm.informationRequire"
  201. placeholder="请输入资料要求"
  202. :disabled="isViewMode"
  203. maxlength="30"
  204. show-word-limit
  205. ></el-input>
  206. </el-form-item>
  207. <el-form-item v-if="isClcs" label="格式要求:" prop="formatRequired">
  208. <el-select
  209. v-model="materialForm.formatRequired"
  210. placeholder="请选择格式要求"
  211. style="width: 100%"
  212. :disabled="isViewMode"
  213. >
  214. <el-option
  215. v-for="item in dictData['formatAsk']"
  216. :key="item.id"
  217. :label="item.name"
  218. :value="item.key"
  219. ></el-option>
  220. </el-select>
  221. </el-form-item>
  222. <el-form-item label="上传附件:" prop="fileList">
  223. <el-upload
  224. class="upload-demo"
  225. :action="''"
  226. :http-request="handleMaterialUpload"
  227. :on-remove="handleMaterialRemove"
  228. :before-upload="beforeMaterialUpload"
  229. :on-success="handleMaterialUploadSuccess"
  230. :on-error="handleMaterialUploadError"
  231. :on-progress="handleMaterialUploadProgress"
  232. :file-list="materialForm.fileList"
  233. :limit="1"
  234. :on-exceed="handleMaterialExceed"
  235. :accept="uploadAccept"
  236. >
  237. <el-button
  238. v-show="
  239. !isTemplateFormat &&
  240. (!materialForm.fileList || materialForm.fileList.length === 0)
  241. "
  242. size="small"
  243. type="primary"
  244. :disabled="isViewMode"
  245. >
  246. 选择文件
  247. </el-button>
  248. <el-button
  249. v-if="isTemplateFormat"
  250. size="small"
  251. type="primary"
  252. :disabled="isViewMode"
  253. @click.stop="openLegalDialog"
  254. >
  255. 选择模版
  256. </el-button>
  257. <!-- <div slot="tip" class="el-upload__tip">
  258. 最多上传1个文件,支持 pdf, doc, docx, xls, xlsx, csv 格式,单个文件不超过50MB
  259. </div> -->
  260. </el-upload>
  261. </el-form-item>
  262. <!-- <el-button
  263. type="text"
  264. size="mini"
  265. @click="handleMaterialUpload"
  266. >
  267. 上传附件
  268. </el-button> -->
  269. </el-form>
  270. <div slot="footer" class="dialog-footer">
  271. <el-button
  272. type="primary"
  273. :loading="loading.materialSubmit"
  274. :disabled="isViewMode"
  275. @click="handleMaterialSubmit"
  276. >
  277. 保 存
  278. </el-button>
  279. <el-button :disabled="isViewMode" @click="handleMaterialCancel">
  280. 取 消
  281. </el-button>
  282. </div>
  283. </el-dialog>
  284. <!-- 预置模版选择弹窗 -->
  285. <!-- <legal-dialog
  286. v-if="legalDialogMounted"
  287. :visible.sync="legalDialogVisible"
  288. @confirm="handleLegalConfirm"
  289. @close="legalDialogVisible = false"
  290. /> -->
  291. <!-- 使用 CostAuditTable 的通用选择模版弹窗 -->
  292. <CostAuditDialog
  293. v-if="costAuditDialogVisible"
  294. :title="'选择模板'"
  295. :visible="costAuditDialogVisible"
  296. width="50%"
  297. :z-index="20000"
  298. :close-on-click-modal="false"
  299. :confirm-loading="costAuditSubmitting"
  300. @confirm="submitCostAuditTemplate"
  301. @cancel="costAuditDialogVisible = false"
  302. @close="costAuditDialogVisible = false"
  303. >
  304. <cost-audit-table
  305. :table-data="costTemplateData"
  306. :columns="costTemplateColumns"
  307. :show-selection="true"
  308. :show-pagination="true"
  309. :pagination="costTemplatePagination"
  310. @pagination-change="handleCostTemplatePaginationChange"
  311. @selection-change="handleCostTemplateSelectionChange"
  312. >
  313. <template #createTime="{ row }">
  314. <div>{{ row.createTime ? row.createTime.split(' ')[0] : '-' }}</div>
  315. <div>{{ row.createTime ? row.createTime.split(' ')[1] : '-' }}</div>
  316. </template>
  317. </cost-audit-table>
  318. </CostAuditDialog>
  319. <!-- 在线填报弹窗 -->
  320. <OnlineFillDialog
  321. :visible.sync="onlineFillDialogVisible"
  322. :table-type="currentSurveyData ? currentSurveyData.tableType : '单记录'"
  323. :survey-data="currentSurveyData || {}"
  324. />
  325. </div>
  326. </el-drawer>
  327. </template>
  328. <script>
  329. import { Message } from 'element-ui'
  330. import OnlineFillDialog from './OnlineFill.vue'
  331. import {
  332. getProjectInformationInfo,
  333. getTaskRequirementList,
  334. addOrUpdateTaskRequirement,
  335. submitTaskRequirement,
  336. sendMessage,
  337. } from '@/api/auditTaskProcessing'
  338. // import UploadComponent from '@/components/costAudit/UploadComponent.vue'
  339. import { getAllUnitList } from '@/api/auditEntityManage'
  340. import { getDefaultDem, getOrgListByDemId } from '@/api/annualReviewPlan'
  341. import { getAllUserList } from '@/api/uc'
  342. import { dictMixin } from '@/mixins/useDict'
  343. import { uploadFile } from '@/api/file'
  344. import { submitPreliminaryOpinion } from '@/api/audit/preliminaryOpinion'
  345. import { getSurveyList } from '@/api/audit/survey'
  346. import ProjectInfoTab from './components/ProjectInfoTab.vue'
  347. import AuditDocumentTab from './components/AuditDocumentTab.vue'
  348. import DataRequirementsTab from './components/DataRequirementsTab.vue'
  349. import CostSurveyTab from './components/CostSurveyTab.vue'
  350. import AuditOpinionTab from './components/AuditOpinionTab.vue'
  351. import MessageNoticeTab from './components/MessageNoticeTab.vue'
  352. import LegalDialog from '@/views/costAudit/baseInfo/catalogManage/legalDialog.vue'
  353. import CostAuditDialog from '@/components/costAudit/CostAuditDialog'
  354. import CostAuditTable from '@/components/costAudit/CostAuditTable.vue'
  355. import { allcurrentCostSurveyList } from '@/api/financeSheetManage'
  356. import { getCostProjectDocumentPageList } from '@/api/taskCustomizedRelease.js'
  357. export default {
  358. name: 'TaskFillIn',
  359. components: {
  360. OnlineFillDialog,
  361. // UploadComponent,
  362. ProjectInfoTab,
  363. AuditDocumentTab,
  364. DataRequirementsTab,
  365. CostSurveyTab,
  366. AuditOpinionTab,
  367. MessageNoticeTab,
  368. // LegalDialog,
  369. CostAuditDialog,
  370. CostAuditTable,
  371. },
  372. mixins: [dictMixin],
  373. props: {
  374. // 侧边弹窗是否显示
  375. visible: {
  376. type: Boolean,
  377. default: false,
  378. },
  379. // 侧边弹窗尺寸
  380. drawerSize: {
  381. type: String,
  382. default: '85%',
  383. },
  384. // 任务信息(从props传入,替代路由query)
  385. taskInfo: {
  386. type: Object,
  387. default: () => ({}),
  388. },
  389. // 是否为查看模式
  390. viewMode: {
  391. type: Boolean,
  392. default: false,
  393. },
  394. },
  395. data() {
  396. return {
  397. drawerVisible: false, // 侧边弹窗显示状态
  398. isViewMode: false, // 是否为查看模式
  399. localTaskInfo: {}, // 本地任务信息(用于存储)
  400. unitList: [],
  401. OrgList: [],
  402. userList: [],
  403. dictData: {
  404. attributionYear: [], // 归属年度
  405. projectProposal: [], // 立项来源
  406. auditType: [], //监审形式
  407. materialType: [], // 资料类别
  408. materialCategory: [], // 资料类别
  409. formatAsk: [], // 资料类型
  410. clshzt: [], // 是否通过
  411. },
  412. // 立项依据文件列表
  413. accordingFileList: [],
  414. // 其他材料文件列表
  415. otherFileList: [],
  416. // 页面标题
  417. pageTitle: '立项信息',
  418. projectId: '', // 项目ID
  419. taskId: '', // 任务ID
  420. auditedUnitId: '', // 被监审单位ID
  421. currentNode: '', // 当前节点
  422. // 当前激活的标签页
  423. activeTab: 'projectInfo',
  424. // 加载状态管理
  425. loading: {
  426. submit: false,
  427. save: false,
  428. materialSubmit: false,
  429. },
  430. // 标签页加载状态
  431. tabLoading: {
  432. projectInfo: false,
  433. auditDocument: false,
  434. dataRequirements: false,
  435. costSurvey: false,
  436. auditOpinion: false,
  437. messageNotice: false,
  438. },
  439. isDisabled: false,
  440. tabCheck: '', // 状态判断监审意见是否显示
  441. tabVisiable: true, // 标签页是否显示
  442. // 成本调查表分页相关
  443. costSurveyPagination: {
  444. currentPage: 1,
  445. pageSize: 10,
  446. total: 0,
  447. },
  448. // 消息通知分页相关
  449. messageNoticePagination: {
  450. pageNo: 1,
  451. pageSize: 10,
  452. total: 0,
  453. },
  454. auditDocumentPagination: {
  455. page: 1,
  456. pageSize: 50,
  457. total: 0,
  458. },
  459. // 所有表单数据聚合
  460. formData: {
  461. basicInfo: {
  462. projectName: '',
  463. catalogId: '',
  464. areaCode: '',
  465. auditUnitId: [],
  466. auditUnitName: '',
  467. orgId: '',
  468. orgName: '',
  469. projectYear: '',
  470. sourceType: '',
  471. auditType: '',
  472. auditPeriod: '',
  473. auditPeriodArray: [{ value: '' }],
  474. needHearing: 1,
  475. isEmergency: 1,
  476. establishmentReason: '',
  477. accordingFileUrl: '',
  478. otherFileUrl: '',
  479. auditGroup: '',
  480. auditTeamMembers: [],
  481. expertStr: '',
  482. plannedAuditStartDate: '',
  483. plannedAuditEndDate: '',
  484. },
  485. auditDocument: [],
  486. dataRequirements: [],
  487. costSurveyData: [
  488. {
  489. index: 1,
  490. name: '封面',
  491. dataType: '模版定制',
  492. tableType: '单记录',
  493. isRequired: '是',
  494. isUploaded: false,
  495. isDisabled: false,
  496. },
  497. {
  498. index: 2,
  499. name: '企业基本情况调查表',
  500. dataType: '模版定制',
  501. tableType: '固定表',
  502. isRequired: '是',
  503. isUploaded: true,
  504. isDisabled: false,
  505. },
  506. {
  507. index: 3,
  508. name: '企业成本费用调查表',
  509. dataType: '模版定制',
  510. tableType: '固定表',
  511. isRequired: '是',
  512. isUploaded: true,
  513. isDisabled: false,
  514. },
  515. {
  516. index: 4,
  517. name: '企业期间费用调查表',
  518. dataType: '模版定制',
  519. tableType: '动态表',
  520. isRequired: '是',
  521. isUploaded: false,
  522. isDisabled: true, // 灰色不可点击
  523. },
  524. {
  525. index: 5,
  526. name: '企业职工薪酬调查表',
  527. dataType: '模版定制',
  528. tableType: '动态表',
  529. isRequired: '是',
  530. isUploaded: false,
  531. isDisabled: true, // 灰色不可点击
  532. },
  533. {
  534. index: 6,
  535. name: '……',
  536. dataType: '模版定制',
  537. tableType: '动态表',
  538. isRequired: '是',
  539. isUploaded: false,
  540. isDisabled: false,
  541. },
  542. ],
  543. auditOpinion: {
  544. basicFinancialInfo:
  545. '此处为被监审单位基本情况及主要财务状况的内容...',
  546. priceStandard: '此处为监审项目现行执行的价格标准的内容...',
  547. costComposition:
  548. '此处为监审项目的成本构成、数据核增核减情况、依据及理由的内容...',
  549. preliminaryOpinion: '此处为成本审核初步意见的内容...',
  550. feedbackOpinion: '', // 被监审单位可输入反馈意见
  551. feedbackMaterials: [], // 被监审单位上传的反馈文件
  552. },
  553. messageNotice: [], // 消息通知列表
  554. paginatedData: [
  555. {
  556. name: '封面',
  557. dataType: '模版定制',
  558. tableType: '单记录',
  559. isRequired: '是',
  560. isUploaded: false,
  561. isDisabled: false,
  562. },
  563. {
  564. name: '企业基本情况调查表',
  565. dataType: '模版定制',
  566. tableType: '固定表',
  567. isRequired: '是',
  568. isUploaded: true,
  569. isDisabled: false,
  570. },
  571. {
  572. name: '企业成本费用调查表',
  573. dataType: '模版定制',
  574. tableType: '动态表',
  575. isRequired: '是',
  576. isUploaded: true,
  577. isDisabled: false,
  578. },
  579. ],
  580. },
  581. // 监审地区级联选择器
  582. regionOptions: [
  583. {
  584. value: 'zhinan',
  585. label: '指南',
  586. children: [
  587. {
  588. value: 'shejiyuanze',
  589. label: '设计原则',
  590. children: [
  591. {
  592. value: 'yizhi',
  593. label: '一致',
  594. },
  595. {
  596. value: 'fankui',
  597. label: '反馈',
  598. },
  599. {
  600. value: 'xiaolv',
  601. label: '效率',
  602. },
  603. {
  604. value: 'kekong',
  605. label: '可控',
  606. },
  607. ],
  608. },
  609. ],
  610. },
  611. ],
  612. dialogVisible: false,
  613. catalogueData: [
  614. {
  615. label: '一级 1',
  616. children: [
  617. {
  618. label: '二级 1-1',
  619. children: [
  620. {
  621. label: '三级 1-1-1',
  622. },
  623. ],
  624. },
  625. ],
  626. },
  627. {
  628. label: '一级 2',
  629. children: [
  630. {
  631. label: '二级 2-1',
  632. children: [
  633. {
  634. label: '三级 2-1-1',
  635. },
  636. ],
  637. },
  638. {
  639. label: '二级 2-2',
  640. children: [
  641. {
  642. label: '三级 2-2-1',
  643. },
  644. ],
  645. },
  646. ],
  647. },
  648. {
  649. label: '一级 3',
  650. children: [
  651. {
  652. label: '二级 3-1',
  653. children: [
  654. {
  655. label: '三级 3-1-1',
  656. },
  657. ],
  658. },
  659. {
  660. label: '二级 3-2',
  661. children: [
  662. {
  663. label: '三级 3-2-1',
  664. },
  665. ],
  666. },
  667. ],
  668. },
  669. ],
  670. defaultProps: {
  671. children: 'children',
  672. label: 'label',
  673. },
  674. // 补充材料弹窗相关数据
  675. materialDialogVisible: false,
  676. materialForm: {
  677. informationType: '',
  678. informationName: '',
  679. informationRequire: '',
  680. formatRequired: '',
  681. fileList: [],
  682. fileUrl: '',
  683. templateId: '',
  684. },
  685. materialRules: {
  686. informationType: [
  687. { required: true, message: '请选择资料类别', trigger: 'change' },
  688. ],
  689. informationName: [
  690. { required: true, message: '请输入资料名称', trigger: 'blur' },
  691. ],
  692. formatRequired: [
  693. { required: true, message: '请选择格式要求', trigger: 'change' },
  694. ],
  695. informationRequire: [
  696. { required: true, message: '请输入资料要求', trigger: 'blur' },
  697. ],
  698. },
  699. materialCategoryOptions: [
  700. { label: '综合性资料', value: 'comprehensive' },
  701. { label: '财务会计资料', value: 'financial' },
  702. { label: '其他资料', value: 'other' },
  703. ],
  704. // 修复未定义的变量
  705. value: [], // 监审地区级联选择器的值
  706. value3: null, // 年份选择器的值
  707. // 在线填报弹窗相关数据
  708. onlineFillDialogVisible: false,
  709. currentSurveyData: null,
  710. // 选择模版弹窗
  711. legalDialogVisible: false,
  712. legalDialogMounted: false,
  713. // 使用 CostAuditTable 的选择弹窗
  714. costAuditDialogVisible: false,
  715. costAuditSubmitting: false,
  716. costTemplateData: [],
  717. selectedCostTemplates: [],
  718. costTemplatePagination: {
  719. currentPage: 1,
  720. pageSize: 10,
  721. total: 0,
  722. },
  723. costTemplateColumns: [
  724. { prop: 'surveyTemplateName', label: '财务数据表名称' },
  725. {
  726. prop: 'templateType',
  727. label: '模版类型',
  728. width: '100px',
  729. formatter: (row) => {
  730. return row.templateType == '1'
  731. ? '单记录'
  732. : row.templateType == '2'
  733. ? '固定表'
  734. : '动态表'
  735. },
  736. },
  737. { prop: 'status', label: '状态', width: '100px' },
  738. {
  739. prop: 'createTime',
  740. label: '创建时间',
  741. slotName: 'createTime',
  742. width: '100px',
  743. },
  744. ],
  745. }
  746. },
  747. computed: {
  748. // 是否为材料处理初审阶段
  749. isClcs() {
  750. return this.currentNode === 'clcs'
  751. },
  752. // 补充材料校验规则:clcs 阶段严格,其它阶段仅名称必填
  753. materialRulesComputed() {
  754. const fileRequiredRule = {
  755. validator: (rule, value, callback) => {
  756. const hasFile =
  757. (this.materialForm.fileList &&
  758. this.materialForm.fileList.length > 0) ||
  759. (this.materialForm.fileUrl &&
  760. String(this.materialForm.fileUrl).trim() !== '')
  761. if (!hasFile) return callback(new Error('请上传附件'))
  762. callback()
  763. },
  764. trigger: 'change',
  765. }
  766. if (this.currentNode === 'clcs') {
  767. // 基于原有规则补充“上传附件必填”
  768. return {
  769. ...this.materialRules,
  770. fileList: [fileRequiredRule],
  771. }
  772. }
  773. // 其它节点:仅资料名称必填 + 上传附件必填
  774. return {
  775. informationName: [
  776. { required: true, message: '请输入资料名称', trigger: 'blur' },
  777. ],
  778. fileList: [fileRequiredRule],
  779. }
  780. },
  781. // 是否选择了“预置模版”格式(通过名称或key含义判断,兼容后端字典差异)
  782. isTemplateFormat() {
  783. const raw = this.materialForm.formatRequired
  784. const v = (raw == null ? '' : String(raw)).toLowerCase()
  785. // 显式数值/字符串 3 代表预置模版
  786. if (raw === 3 || raw === '3') return true
  787. // 名称兜底匹配
  788. return (
  789. v.includes('template') ||
  790. v.includes('preset') ||
  791. v.includes('tpl') ||
  792. v.includes('模版') ||
  793. v.includes('模板')
  794. )
  795. },
  796. // 是否为文档(pdf/word)
  797. isDocumentFormat() {
  798. const raw = this.materialForm.formatRequired
  799. const v = (raw == null ? '' : String(raw)).toLowerCase()
  800. // 显式数值/字符串 1 代表文档
  801. if (raw === 1 || raw === '1') return true
  802. return (
  803. v.includes('doc') ||
  804. v.includes('word') ||
  805. v.includes('pdf') ||
  806. v.includes('文档') ||
  807. v.includes('word文档')
  808. )
  809. },
  810. // 是否为Excel
  811. isExcelFormat() {
  812. const raw = this.materialForm.formatRequired
  813. const v = (raw == null ? '' : String(raw)).toLowerCase()
  814. // 显式数值/字符串 2 代表excel
  815. if (raw === 2 || raw === '2') return true
  816. return (
  817. v.includes('excel') ||
  818. v.includes('xls') ||
  819. v.includes('xlsx') ||
  820. v.includes('表格')
  821. )
  822. },
  823. // 根据所选格式动态生成 accept
  824. uploadAccept() {
  825. if (this.isTemplateFormat) return ''
  826. if (this.isDocumentFormat) return '.pdf,.doc,.docx'
  827. if (this.isExcelFormat) return '.xls,.xlsx'
  828. // 默认允许常见类型
  829. return '.pdf,.doc,.docx,.xls,.xlsx,.csv'
  830. },
  831. // 按类别分组的报送资料列表
  832. groupedDataRequirements() {
  833. if (
  834. !this.formData.dataRequirements ||
  835. !Array.isArray(this.formData.dataRequirements) ||
  836. this.formData.dataRequirements.length === 0
  837. ) {
  838. return []
  839. }
  840. // 按类别分组
  841. const groups = {}
  842. this.formData.dataRequirements.forEach((item, index) => {
  843. // 获取类别标识,使用 informationType 作为类别 key
  844. const categoryKey =
  845. item.informationType ||
  846. item.category ||
  847. item.categoryId ||
  848. item.categoryName ||
  849. 'other'
  850. // 优先从字典中获取类别名称
  851. let categoryName = ''
  852. if (categoryKey) {
  853. // 优先使用 getDictNameByValue 根据 value 查找
  854. categoryName = this.getDictNameByValue(
  855. 'materialCategory',
  856. categoryKey
  857. )
  858. // 如果 getDictNameByValue 没找到,尝试使用 getDictName 根据 key 查找
  859. if (!categoryName || categoryName === String(categoryKey)) {
  860. categoryName = this.getDictName('materialCategory', categoryKey)
  861. }
  862. // 如果字典中都找不到,使用 item.categoryName 作为后备
  863. if (!categoryName || categoryName === String(categoryKey)) {
  864. categoryName = item.informationTypeName || categoryKey
  865. }
  866. }
  867. if (!groups[categoryKey]) {
  868. groups[categoryKey] = {
  869. categoryKey,
  870. categoryName: categoryName || String(categoryKey),
  871. items: [],
  872. }
  873. }
  874. // 添加序号(每个类别内从1开始)
  875. const itemWithSeq = {
  876. ...item,
  877. index: index + 1,
  878. seq: groups[categoryKey].items.length + 1,
  879. }
  880. groups[categoryKey].items.push(itemWithSeq)
  881. })
  882. // 将分组转换为扁平数组,插入类别标题行
  883. const result = []
  884. Object.keys(groups).forEach((categoryKey) => {
  885. const group = groups[categoryKey]
  886. // 添加类别标题行
  887. result.push({
  888. isCategoryHeader: true,
  889. categoryName: group.categoryName,
  890. categoryKey: group.categoryKey,
  891. })
  892. // 添加该类别下的所有项目
  893. group.items.forEach((item) => {
  894. result.push({
  895. ...item,
  896. isCategoryHeader: false,
  897. })
  898. })
  899. })
  900. return result
  901. },
  902. // 分页后的成本调查表数据
  903. paginatedCostSurveyData() {
  904. const start =
  905. (this.costSurveyPagination.currentPage - 1) *
  906. this.costSurveyPagination.pageSize
  907. const end = start + this.costSurveyPagination.pageSize
  908. return this.formData.costSurveyData.slice(start, end)
  909. },
  910. },
  911. watch: {
  912. visible: {
  913. immediate: true,
  914. handler(newVal) {
  915. this.drawerVisible = newVal
  916. if (
  917. newVal &&
  918. this.taskInfo &&
  919. Object.keys(this.taskInfo).length > 0
  920. ) {
  921. // 弹窗打开时初始化数据
  922. this.initData()
  923. }
  924. },
  925. },
  926. drawerVisible(newVal) {
  927. if (!newVal) {
  928. this.$emit('update:visible', false)
  929. this.$emit('close')
  930. }
  931. },
  932. taskInfo: {
  933. immediate: true,
  934. deep: true,
  935. handler(newVal) {
  936. // 如果props传入taskInfo且有值,且弹窗已打开,则初始化数据
  937. if (newVal && Object.keys(newVal).length > 0 && this.drawerVisible) {
  938. this.initData()
  939. }
  940. },
  941. },
  942. },
  943. mounted() {
  944. this.drawerVisible = this.visible
  945. this.getAllUnitList()
  946. this.getDefaultDem()
  947. this.getUser()
  948. // 默认设置立项信息标签页
  949. this.activeTab = 'projectInfo'
  950. this.pageTitle = '立项信息'
  951. // 如果有传入taskInfo,初始化数据
  952. if (this.taskInfo && Object.keys(this.taskInfo).length > 0) {
  953. this.initData()
  954. }
  955. // 初始化成本调查表分页总数
  956. this.costSurveyPagination.total = this.formData.costSurveyData.length
  957. },
  958. methods: {
  959. // 初始化数据
  960. initData() {
  961. // 优先使用props传入的taskInfo,其次使用localTaskInfo
  962. const info =
  963. this.taskInfo && Object.keys(this.taskInfo).length > 0
  964. ? this.taskInfo
  965. : this.localTaskInfo
  966. // 判断是否为查看模式
  967. this.isViewMode = this.viewMode || false
  968. this.projectId = info.projectId || ''
  969. this.taskId = (info.userTask && info.userTask.id) || info.taskId || ''
  970. this.tabCheck = info.status || ''
  971. this.auditedUnitId = info.auditedUnitId || ''
  972. console.log(this.auditedUnitId, 'this.auditedUnitId 122')
  973. this.currentNode = info.currentNode || ''
  974. if (this.tabCheck === 'jtsy') {
  975. this.tabVisiable = false
  976. }
  977. // 默认显示立项信息标签页
  978. this.activeTab = 'projectInfo'
  979. this.pageTitle = '立项信息'
  980. // 加载立项信息数据
  981. if (this.projectId) {
  982. this.getProjectInformation()
  983. }
  984. },
  985. // 打开弹窗方法(供外部调用)
  986. open(taskInfo, viewMode = false, options = {}) {
  987. this.localTaskInfo = taskInfo || {}
  988. this.initData()
  989. this.drawerVisible = true
  990. // 可选:默认切换指定标签页
  991. if (options && options.activeTab) {
  992. this.activeTab = options.activeTab
  993. // 同步标题
  994. const titleMap = {
  995. projectInfo: '立项信息',
  996. auditDocument: '监审文书',
  997. dataRequirements: '报送资料',
  998. costSurvey: '成本调查表',
  999. auditOpinion: '监审意见',
  1000. messageNotice: '消息通知',
  1001. }
  1002. this.pageTitle = titleMap[options.activeTab] || this.pageTitle
  1003. }
  1004. // 可选:直接打开补充材料弹窗
  1005. if (options && options.openMaterialDialog) {
  1006. this.getTaskRequirementPage()
  1007. // this.materialDialogVisible = true
  1008. }
  1009. },
  1010. // 关闭弹窗方法
  1011. close() {
  1012. this.drawerVisible = false
  1013. },
  1014. getAllUnitList() {
  1015. getAllUnitList().then((res) => {
  1016. this.unitList = res.value || []
  1017. })
  1018. },
  1019. // 获取默认维度
  1020. getDefaultDem() {
  1021. getDefaultDem().then((res) => {
  1022. if (res && res.code === 200) {
  1023. const demId = res.value ? res.value.id : null
  1024. if (demId) {
  1025. this.getOrgListByDemId(demId)
  1026. }
  1027. }
  1028. })
  1029. },
  1030. // 根据维度ID获取单位列表
  1031. getOrgListByDemId(demId) {
  1032. getOrgListByDemId({ demId }).then((res) => {
  1033. if (res && res.code === 200) {
  1034. this.OrgList = res.value || []
  1035. }
  1036. })
  1037. },
  1038. // 获取用户信息
  1039. getUser() {
  1040. getAllUserList()
  1041. .then((res) => {
  1042. this.userList = res.value || []
  1043. })
  1044. .catch(() => {})
  1045. },
  1046. // 添加监审年份
  1047. addCostYear() {
  1048. this.formData.basicInfo.auditPeriodArray.push({ value: '' })
  1049. },
  1050. // 删除监审年份
  1051. deleteCostYear(index) {
  1052. // 若只剩1条,禁止删除并提示
  1053. if (this.formData.basicInfo.auditPeriodArray.length <= 1) {
  1054. Message.warning('监审期间至少需保留1条,无法删除')
  1055. return
  1056. }
  1057. this.formData.basicInfo.auditPeriodArray.splice(index, 1)
  1058. },
  1059. // 更新auditPeriod字符串
  1060. updateAuditPeriodString() {
  1061. const values = this.formData.basicInfo.auditPeriodArray
  1062. .map((item) => item.value)
  1063. .filter(Boolean)
  1064. const uniqueValues = [...new Set(values)]
  1065. this.formData.basicInfo.auditPeriod = uniqueValues.join(',')
  1066. },
  1067. // 立项依据文件处理
  1068. saveAccordingFiles(data) {
  1069. this.accordingFileList = data
  1070. this.formData.basicInfo.accordingFileUrl = data[0]?.savePath || ''
  1071. },
  1072. // 移除立项依据文件
  1073. removeAccordingFile() {
  1074. this.accordingFileList = []
  1075. this.formData.basicInfo.accordingFileUrl = ''
  1076. },
  1077. // 其他材料文件处理
  1078. saveOtherFiles(data) {
  1079. this.otherFileList = data
  1080. this.formData.basicInfo.otherFileUrl = data[0]?.savePath || ''
  1081. },
  1082. // 移除其他材料文件
  1083. removeOtherFile() {
  1084. this.otherFileList = []
  1085. this.formData.basicInfo.otherFileUrl = ''
  1086. },
  1087. // 处理地区选择变化
  1088. handleRegionChange(region) {
  1089. this.formData.basicInfo.areaCode = region.code
  1090. },
  1091. // 处理监审目录选择后的回调
  1092. handleCatalogChange(value) {
  1093. // this.formData.catalogId = value.join(',')
  1094. this.formData.basicInfo.catalogId = value
  1095. },
  1096. // 处理立项信息变化
  1097. handleProjectInfoChange(data) {
  1098. this.formData.basicInfo = { ...data }
  1099. },
  1100. // 处理监审意见变化
  1101. handleAuditOpinionChange(data) {
  1102. this.formData.auditOpinion = { ...data }
  1103. },
  1104. // 处理监审意见数据加载完成
  1105. handleAuditOpinionDataLoaded() {
  1106. // 数据加载完成后,关闭加载状态
  1107. this.tabLoading.auditOpinion = false
  1108. },
  1109. // 表格行样式
  1110. getRowClassName({ row }) {
  1111. if (row.isCategoryHeader) {
  1112. return 'category-header-row'
  1113. }
  1114. return ''
  1115. },
  1116. // 标签页切换
  1117. handleTabClick(tab) {
  1118. console.log(tab, 'qiehuan')
  1119. if (tab.name === 'projectInfo') {
  1120. // 立项项目信息
  1121. this.getProjectInformation()
  1122. } else if (tab.name === 'dataRequirements') {
  1123. // 报送资料要求
  1124. this.getTaskRequirementPage()
  1125. } else if (tab.name === 'costSurvey') {
  1126. // 成本调查表
  1127. this.getCostSurveyList()
  1128. } else if (tab.name === 'messageNotice') {
  1129. // 消息通知
  1130. this.getSendMessage()
  1131. } else if (tab.name === 'auditOpinion') {
  1132. // 监审意见标签页,设置加载状态并调用接口
  1133. this.tabLoading.auditOpinion = true
  1134. // 通过 ref 调用子组件方法,确保接口被调用
  1135. this.$nextTick(() => {
  1136. this.$nextTick(() => {
  1137. const auditOpinionTab = this.$refs.auditOpinionTabRef
  1138. if (
  1139. auditOpinionTab &&
  1140. typeof auditOpinionTab.getPreliminaryOpinionData === 'function'
  1141. ) {
  1142. auditOpinionTab.getPreliminaryOpinionData()
  1143. } else {
  1144. // 如果找不到组件,可能是组件还未创建,延迟调用
  1145. setTimeout(() => {
  1146. const tab = this.$refs.auditOpinionTabRef
  1147. if (
  1148. tab &&
  1149. typeof tab.getPreliminaryOpinionData === 'function'
  1150. ) {
  1151. tab.getPreliminaryOpinionData()
  1152. } else {
  1153. this.tabLoading.auditOpinion = false
  1154. }
  1155. }, 200)
  1156. }
  1157. })
  1158. })
  1159. } else if (tab.name === 'auditDocument') {
  1160. // 监审文件
  1161. this.getAuditDocumentList()
  1162. }
  1163. // 其他标签页(如 auditDocument、costSurvey)如果不需要异步加载数据,则不需要设置加载状态
  1164. // 可添加标签页切换时的逻辑
  1165. this.pageTitle = tab.label
  1166. },
  1167. // 获取立项项目信息
  1168. getProjectInformation() {
  1169. this.tabLoading.projectInfo = true
  1170. getProjectInformationInfo(this.projectId)
  1171. .then((res) => {
  1172. console.log('立项项目信息', res)
  1173. if (res && res.value) {
  1174. const data = res.value
  1175. // 处理监审期间数组
  1176. let auditPeriodArray = [{ value: '' }]
  1177. if (data.auditPeriod && typeof data.auditPeriod === 'string') {
  1178. const periods = data.auditPeriod.split(',').filter(Boolean)
  1179. auditPeriodArray = periods.map((p) => ({ value: p }))
  1180. }
  1181. // 赋值并添加转换后的数组
  1182. this.formData.basicInfo = {
  1183. ...data,
  1184. auditPeriodArray: auditPeriodArray,
  1185. }
  1186. }
  1187. })
  1188. .catch((err) => {
  1189. console.error('获取立项项目信息失败', err)
  1190. })
  1191. .finally(() => {
  1192. this.tabLoading.projectInfo = false
  1193. })
  1194. },
  1195. // 获取报送资料要求列表
  1196. getTaskRequirementPage() {
  1197. this.tabLoading.dataRequirements = true
  1198. console.log('送报资料接口', this.taskId)
  1199. getTaskRequirementList(this.taskId)
  1200. .then((res) => {
  1201. console.log('报送资料要求', res)
  1202. if (res && res.code === 200 && res.value) {
  1203. this.formData.dataRequirements = Array.isArray(res.value)
  1204. ? res.value
  1205. : []
  1206. } else {
  1207. this.formData.dataRequirements = []
  1208. }
  1209. })
  1210. .catch((err) => {
  1211. console.error('获取报送资料失败', err)
  1212. this.formData.dataRequirements = []
  1213. })
  1214. .finally(() => {
  1215. this.tabLoading.dataRequirements = false
  1216. })
  1217. },
  1218. // 消息通知
  1219. getSendMessage() {
  1220. this.tabLoading.messageNotice = true
  1221. const params = {
  1222. taskId: this.taskId,
  1223. auditedUnitId: this.auditedUnitId,
  1224. projectId: this.projectId,
  1225. pageNum: this.messageNoticePagination.pageNo,
  1226. pageSize: this.messageNoticePagination.pageSize,
  1227. }
  1228. sendMessage(params)
  1229. .then((res) => {
  1230. console.log('消息通知', res)
  1231. if (res && res.code === 200 && res.value) {
  1232. this.formData.messageNotice = res.value.records || []
  1233. this.messageNoticePagination.total = res.value.total || 0
  1234. } else {
  1235. this.formData.messageNotice = []
  1236. this.messageNoticePagination.total = 0
  1237. }
  1238. })
  1239. .catch((err) => {
  1240. console.error('获取消息通知失败', err)
  1241. this.formData.messageNoticeData = []
  1242. this.messageNoticePagination.total = 0
  1243. })
  1244. .finally(() => {
  1245. this.tabLoading.messageNotice = false
  1246. })
  1247. },
  1248. // 获取成本调查表列表
  1249. getCostSurveyList() {
  1250. this.tabLoading.costSurvey = true
  1251. const params = {
  1252. taskId: this.taskId || (this.taskInfo && this.taskInfo.taskId) || '',
  1253. catalogId: this.taskInfo.catalogId,
  1254. pageNum: this.costSurveyPagination.currentPage,
  1255. pageSize: this.costSurveyPagination.pageSize,
  1256. type: 1,
  1257. }
  1258. // if (this.auditedUnitId) params.auditedUnitId = this.auditedUnitId
  1259. getSurveyList(params)
  1260. .then((res) => {
  1261. console.log('成本调查表列表', res)
  1262. if (res && res.code === 200 && res.value) {
  1263. // 处理返回的数据
  1264. const records = res.value.records || res.value || []
  1265. // 映射数据格式,转换为组件需要的格式
  1266. const mappedData = records.map((item, index) => {
  1267. // 转换表格类型:1=单记录,2=固定表,3=动态表
  1268. let tableType = ''
  1269. if (item.templateType === 1 || item.templateType === '1') {
  1270. tableType = '单记录'
  1271. } else if (
  1272. item.templateType === 2 ||
  1273. item.templateType === '2'
  1274. ) {
  1275. tableType = '固定表'
  1276. } else if (
  1277. item.templateType === 3 ||
  1278. item.templateType === '3'
  1279. ) {
  1280. tableType = '动态表'
  1281. } else if (item.tableType) {
  1282. tableType = item.tableType
  1283. }
  1284. // 转换是否必填:0=否,1=是
  1285. const isRequired =
  1286. item.isRequired === 1 || item.isRequired === '1' ? '是' : '否'
  1287. // 转换是否上传:0=未上传,1=已上传
  1288. const isUploaded = item.isUpload === 1 || item.isUpload === '1'
  1289. return {
  1290. index: index + 1,
  1291. id: item.id,
  1292. name: item.surveyTemplateName || '',
  1293. dataType: item.dataType || '', // 资料类型
  1294. tableType: tableType, // 表格类型(转换后)
  1295. isRequired: isRequired, // 是否必填(转换后)
  1296. isUploaded: isUploaded, // 是否上传(转换后)
  1297. surveyTemplateId: item.surveyTemplateId || '', // 成本调查表模板ID
  1298. isDisabled: item.isDisabled || false,
  1299. fileUrl: item.fileUrl || '',
  1300. dataUrl: item.dataUrl || '',
  1301. templateUrl: item.templateUrl || '',
  1302. ...item, // 保留其他字段
  1303. }
  1304. })
  1305. // 更新 costSurveyData(完整数据)
  1306. this.formData.costSurveyData = mappedData
  1307. console.log(
  1308. 'this.formData.costSurveyData',
  1309. this.formData.costSurveyData
  1310. )
  1311. // 更新 paginatedData(用于传递给子组件,如果接口返回的是分页数据,直接使用;否则使用全部数据)
  1312. this.formData.paginatedData = mappedData
  1313. // 更新分页信息
  1314. this.costSurveyPagination.total =
  1315. res.value.total || mappedData.length || 0
  1316. } else {
  1317. this.formData.costSurveyData = []
  1318. this.formData.paginatedData = []
  1319. this.costSurveyPagination.total = 0
  1320. }
  1321. })
  1322. .catch((err) => {
  1323. console.error('获取成本调查表列表失败', err)
  1324. this.formData.costSurveyData = []
  1325. this.formData.paginatedData = []
  1326. this.costSurveyPagination.total = 0
  1327. })
  1328. .finally(() => {
  1329. this.tabLoading.costSurvey = false
  1330. })
  1331. },
  1332. // 消息通知分页处理
  1333. handleMessageNoticePageChange(pageNo) {
  1334. this.messageNoticePagination.pageNo = pageNo
  1335. this.getSendMessage()
  1336. },
  1337. // 消息通知每页大小变化
  1338. handleMessageNoticeSizeChange(pageSize) {
  1339. this.messageNoticePagination.pageSize = pageSize
  1340. this.messageNoticePagination.pageNo = 1
  1341. this.getSendMessage()
  1342. },
  1343. // 提交
  1344. handleSubmit() {
  1345. // 验证必填的报送资料(仅在 clcs 或 tjcl 节点时验证)
  1346. // if (this.currentNode === 'clcs' || this.currentNode === 'tjcl') {
  1347. // // 验证报送资料必填项
  1348. // const requiredItems = this.formData.dataRequirements.filter(
  1349. // (item) => {
  1350. // // 只检查非类别标题行的数据项
  1351. // if (item.isCategoryHeader) {
  1352. // return false
  1353. // }
  1354. // // 只检查是否为必填项
  1355. // const isRequired =
  1356. // item.isRequired === '1' || item.isRequired === 1
  1357. // return isRequired
  1358. // }
  1359. // )
  1360. // if (requiredItems.length > 0) {
  1361. // // 获取必填项名称列表
  1362. // const itemNames = requiredItems
  1363. // .map((item) => item.informationName || '未命名资料')
  1364. // .join('、')
  1365. // Message.warning(
  1366. // `有必填数据必须先填完,请先完成以下报送资料:${itemNames}`
  1367. // )
  1368. // return
  1369. // }
  1370. // // 验证成本调查表必填项
  1371. // const requiredCostSurveys = this.formData.costSurveyData.filter(
  1372. // (item) => {
  1373. // // 只检查是否为必填项
  1374. // const isRequired =
  1375. // item.isRequired === '1' ||
  1376. // item.isRequired === 1 ||
  1377. // item.isRequired === '是'
  1378. // return isRequired
  1379. // }
  1380. // )
  1381. // if (requiredCostSurveys.length > 0) {
  1382. // // 获取必填项名称列表
  1383. // const itemNames = requiredCostSurveys
  1384. // .map((item) => item.name || '未命名调查表')
  1385. // .join('、')
  1386. // Message.warning(
  1387. // `有必填数据必须先填完,请先完成以下成本调查表:${itemNames}`
  1388. // )
  1389. // return
  1390. // }
  1391. // }
  1392. this.loading.submit = true
  1393. // 判断是否为监审意见提交(currentNode === 'yjfk')
  1394. if (this.currentNode === 'yjfk') {
  1395. // 企业监审意见提交
  1396. // 处理文件列表,提取文件URL
  1397. // let fileUrlList = []
  1398. // if (this.formData.auditOpinion?.feedbackMaterials && Array.isArray(this.formData.auditOpinion.feedbackMaterials)) {
  1399. // fileUrlList = this.formData.auditOpinion.feedbackMaterials.map((file) => {
  1400. // // 如果file是字符串,直接返回
  1401. // if (typeof file === 'string') {
  1402. // return file
  1403. // }
  1404. // // 如果file是对象,提取url字段
  1405. // return file.url || file.response?.savePath || file.savePath || ''
  1406. // }).filter((url) => url) // 过滤空值
  1407. // }
  1408. const submitData = {
  1409. taskId: this.taskId,
  1410. id: this.formData.auditOpinion.id,
  1411. // 成本监审意见数据
  1412. basicSituation: this.formData.auditOpinion?.basicSituation || '',
  1413. currentPriceStandard:
  1414. this.formData.auditOpinion?.currentPriceStandard || '',
  1415. costComposition: this.formData.auditOpinion?.costComposition || '',
  1416. preliminaryOpinion:
  1417. this.formData.auditOpinion?.preliminaryOpinion || '',
  1418. // 被监审单位反馈意见数据
  1419. feedbackOpinion: this.formData.auditOpinion?.feedbackOpinion || '',
  1420. feedbackMaterials:
  1421. this.formData.auditOpinion?.feedbackMaterials[0]?.url || '', // 附件URL
  1422. }
  1423. submitPreliminaryOpinion(submitData)
  1424. .then((res) => {
  1425. this.loading.submit = false
  1426. console.log('企业监审意见提交成功', res)
  1427. if (res && res.code === 200) {
  1428. Message.success('提交成功')
  1429. // 关闭弹窗
  1430. this.handleBack()
  1431. // 通知父组件刷新列表
  1432. this.$emit('refresh')
  1433. } else {
  1434. Message.error(res?.message || '提交失败')
  1435. }
  1436. })
  1437. .catch((err) => {
  1438. this.loading.submit = false
  1439. console.error('企业监审意见提交失败', err)
  1440. // Message.error('提交失败:' + (err.message || '未知错误'))
  1441. })
  1442. } else {
  1443. // 其他情况走原有逻辑
  1444. setTimeout(() => {
  1445. submitTaskRequirement({ taskId: this.taskId })
  1446. .then((res) => {
  1447. this.loading.submit = false
  1448. console.log('提交成功', res)
  1449. if (res && res.code === 200) {
  1450. Message.success('提交成功')
  1451. this.handleBack()
  1452. // 通知父组件刷新列表
  1453. this.$emit('refresh')
  1454. } else {
  1455. Message.error('提交失败')
  1456. }
  1457. })
  1458. .catch((err) => {
  1459. this.loading.submit = false
  1460. console.error('提交失败', err)
  1461. // Message.error('提交失败')
  1462. })
  1463. }, 500)
  1464. }
  1465. },
  1466. // 保存
  1467. handleSave() {
  1468. this.loading.save = true
  1469. // 保存逻辑
  1470. setTimeout(() => {
  1471. this.loading.save = false
  1472. Message.success('保存成功')
  1473. }, 500)
  1474. },
  1475. // 返回
  1476. handleBack() {
  1477. this.drawerVisible = false
  1478. this.$emit('close')
  1479. },
  1480. // 侧边弹窗关闭事件
  1481. handleDrawerClose() {
  1482. this.$emit('update:visible', false)
  1483. this.$emit('close')
  1484. },
  1485. // 监审地区级联选择器
  1486. handleChange(value) {
  1487. console.log(value)
  1488. },
  1489. // 监审地区级联选择器节点点击
  1490. handleNodeClick(data) {
  1491. console.log(data)
  1492. this.formData.basicInfo.projectName = data.label
  1493. },
  1494. // 获取监审文书
  1495. getAuditDocumentList() {
  1496. getCostProjectDocumentPageList({
  1497. pageNum: this.auditDocumentPagination.page,
  1498. pageSize: this.auditDocumentPagination.pageSize,
  1499. projectId: this.projectId,
  1500. documentName: '',
  1501. permissionType: 1,
  1502. }).then((res) => {
  1503. let records = res.value.value.records
  1504. this.formData.auditDocument = records.filter((item) => {
  1505. const excludeTypes = [
  1506. '成本监审工作底稿-送达回证',
  1507. '成本监审提取资料登记表-送达回证',
  1508. '成本审核初步意见表1-送达回证',
  1509. '成本监审集体审议记录-送达回证',
  1510. ]
  1511. return !excludeTypes.includes(item.documentName)
  1512. })
  1513. this.auditDocumentPagination.total = res.value.value.total
  1514. })
  1515. },
  1516. handleAuditDocumentPaginationChange(val) {
  1517. this.auditDocumentPagination.page = val.pageNum
  1518. this.auditDocumentPagination.pageSize = val.pageSize
  1519. this.getAuditDocumentList()
  1520. },
  1521. handleClick(row) {},
  1522. // 下载文书
  1523. handleDownload(row) {
  1524. console.log(row)
  1525. if (!row.fileUrl) {
  1526. this.$message.warning('该文书暂无文件可下载')
  1527. return
  1528. }
  1529. this.downloadByFetch(row.fileUrl, row.name || '文书文件')
  1530. },
  1531. // 上传附件
  1532. handleUpload(row) {
  1533. console.log(row)
  1534. },
  1535. // 报送资料相关操作方法
  1536. handleFileView(row) {
  1537. console.log('查看文件:', row)
  1538. // 实际开发中可添加文件预览逻辑(如打开新窗口、弹窗展示等)
  1539. if (row.fileUrl) {
  1540. window.open(row.fileUrl, '_blank')
  1541. } else {
  1542. this.$message.warning('暂无文件可查看')
  1543. }
  1544. },
  1545. handleFileDownload(row) {
  1546. console.log('下载文件:', row)
  1547. if (!row.fileUrl) {
  1548. this.$message.warning('该资料暂无文件可下载')
  1549. return
  1550. }
  1551. this.downloadByFetch(row.fileUrl, row.informationName || '下载文件')
  1552. },
  1553. async downloadByFetch(rawUrl, fallbackName) {
  1554. const url = this.normalizeUrl(rawUrl)
  1555. let loading
  1556. try {
  1557. loading = this.$baseLoading
  1558. ? this.$baseLoading(1, '文件下载中...')
  1559. : this.$loading({
  1560. lock: true,
  1561. text: '文件下载中...',
  1562. spinner: 'el-icon-loading',
  1563. background: 'rgba(0,0,0,0.7)',
  1564. })
  1565. const res = await fetch(url, { method: 'GET' })
  1566. if (!res.ok) throw new Error('下载失败')
  1567. const blob = await res.blob()
  1568. let fileName =
  1569. this.extractFileName(res.headers.get('content-disposition')) ||
  1570. fallbackName ||
  1571. '下载文件'
  1572. if (!/\.[a-zA-Z0-9]+$/.test(fileName)) {
  1573. const extFromUrl = (
  1574. url.split('?')[0].split('#')[0].split('.').pop() || ''
  1575. ).toLowerCase()
  1576. fileName = extFromUrl ? `${fileName}.${extFromUrl}` : fileName
  1577. }
  1578. const objectUrl = window.URL.createObjectURL(blob)
  1579. const link = document.createElement('a')
  1580. link.style.display = 'none'
  1581. link.href = objectUrl
  1582. link.download = fileName
  1583. document.body.appendChild(link)
  1584. link.click()
  1585. document.body.removeChild(link)
  1586. window.URL.revokeObjectURL(objectUrl)
  1587. this.$message.success('开始下载文件')
  1588. } catch (e) {
  1589. this.$message.error(e.message || '文件下载失败')
  1590. } finally {
  1591. if (loading && loading.close) loading.close()
  1592. }
  1593. },
  1594. normalizeUrl(u) {
  1595. if (!u) return ''
  1596. if (/^https?:\/\//i.test(u)) return u
  1597. const base = (window.context && window.context.form) || ''
  1598. if (!base) return u
  1599. if (u.startsWith('/')) return base + u
  1600. return base.replace(/\/$/, '') + '/' + u
  1601. },
  1602. extractFileName(contentDisposition) {
  1603. if (!contentDisposition) return ''
  1604. const match = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/i.exec(
  1605. contentDisposition
  1606. )
  1607. if (match && match[1]) {
  1608. try {
  1609. return decodeURIComponent(match[1].replace(/['"]/g, ''))
  1610. } catch (e) {
  1611. return match[1].replace(/['"]/g, '')
  1612. }
  1613. }
  1614. return ''
  1615. },
  1616. // 报送资料文件上传
  1617. async handleFileUpload(row, acceptFromChild) {
  1618. // 预置模版:直接打开 CostAuditTable 弹窗选择模版
  1619. const fmt = row && row.formatRequired
  1620. const isTemplate =
  1621. String(fmt) === '3' ||
  1622. (typeof fmt === 'string' && fmt.toLowerCase().includes('模板'))
  1623. if (isTemplate) {
  1624. this.currentDataRequirementRow = row || null
  1625. this.loadCostTemplates()
  1626. this.selectedCostTemplates = []
  1627. this.costAuditDialogVisible = true
  1628. console.log('打开 CostAuditTable 弹窗选择模版')
  1629. return
  1630. }
  1631. // 非预置模版:走本地文件上传
  1632. // 创建文件选择器
  1633. const input = document.createElement('input')
  1634. input.type = 'file'
  1635. input.accept =
  1636. (typeof acceptFromChild === 'string' && acceptFromChild) ||
  1637. '.pdf,.doc,.docx,.xls,.xlsx,.csv' // 允许的文件类型(兜底)
  1638. input.onchange = async (event) => {
  1639. const file = event.target.files[0]
  1640. if (!file) return
  1641. try {
  1642. // 校验文件大小(50MB)
  1643. const maxSize = 50 * 1024 * 1024 // 50MB
  1644. if (file.size > maxSize) {
  1645. this.$message.error('文件大小不能超过50MB!')
  1646. return
  1647. }
  1648. // 校验文件格式
  1649. const allowedFormats = [
  1650. '.pdf',
  1651. '.doc',
  1652. '.docx',
  1653. '.xls',
  1654. '.xlsx',
  1655. '.csv',
  1656. ]
  1657. const fileName = file.name.toLowerCase()
  1658. const isValidFormat = allowedFormats.some((format) =>
  1659. fileName.endsWith(format)
  1660. )
  1661. if (!isValidFormat) {
  1662. this.$message.error(
  1663. '只允许上传.pdf,.doc,.docx,.xls,.xlsx,.csv格式的文件!'
  1664. )
  1665. return
  1666. }
  1667. // 显示上传加载提示
  1668. const loading = this.$baseLoading(1, '文件上传中...')
  1669. // 创建FormData并上传文件
  1670. const formData = new FormData()
  1671. formData.append('file', file)
  1672. // 调用上传API
  1673. const uploadRes = await uploadFile('/api/file/v1/upload', formData)
  1674. // 检查上传结果
  1675. if (!uploadRes || uploadRes.code !== 200 || !uploadRes.value) {
  1676. loading.close()
  1677. this.$message.error('文件上传失败,请稍后重试')
  1678. return
  1679. }
  1680. // 文件上传成功后,更新报送资料项
  1681. const fileInfo = uploadRes.value
  1682. const updateData = {
  1683. // id: row.id,
  1684. // taskId: this.taskId,
  1685. // projectId: this.projectId,
  1686. // informationType: row.informationType,
  1687. // informationName: row.informationName,
  1688. // informationRequire: row.informationRequire,
  1689. // formatRequired: row.formatRequired,
  1690. // isRequired: row.isRequired,
  1691. ...row,
  1692. fileUrl: fileInfo.savePath || fileInfo.url, // 更新文件URL
  1693. }
  1694. // 调用更新API
  1695. const updateRes = await addOrUpdateTaskRequirement(updateData)
  1696. loading.close()
  1697. if (updateRes && updateRes.code === 200) {
  1698. this.$message.success('文件上传并更新成功!')
  1699. // 刷新报送资料列表
  1700. this.getTaskRequirementPage()
  1701. } else {
  1702. this.$message.error('文件上传成功,但更新资料失败')
  1703. }
  1704. } catch (error) {
  1705. console.error('文件上传失败:', error)
  1706. // this.$message.error('操作失败:' + (error.message || '未知错误'))
  1707. }
  1708. }
  1709. // 触发文件选择
  1710. input.click()
  1711. },
  1712. handleTemplateDownload(row) {
  1713. console.log('下载预置模版:', row)
  1714. if (!row.templateUrl && !row.fileUrl) {
  1715. this.$message.warning('该模版暂无文件可下载')
  1716. return
  1717. }
  1718. const downloadUrl = row.templateUrl || row.fileUrl
  1719. const link = document.createElement('a')
  1720. link.style.display = 'none'
  1721. link.href = downloadUrl
  1722. link.download = row.name ? `${row.name}_模版` : '模版文件'
  1723. document.body.appendChild(link)
  1724. link.click()
  1725. document.body.removeChild(link)
  1726. this.$message.success('开始下载模版')
  1727. },
  1728. handleDataUpload(row) {
  1729. // 预置模版:打开 CostAuditTable 弹窗进行模板选择
  1730. this.currentDataRequirementRow = row || null
  1731. this.loadCostTemplates()
  1732. this.selectedCostTemplates = []
  1733. this.costAuditDialogVisible = true
  1734. },
  1735. handleRemove(file, fileList) {
  1736. console.log(file, fileList)
  1737. },
  1738. handlePreview(file) {
  1739. console.log(file)
  1740. },
  1741. handleExceed(files, fileList) {
  1742. this.$message.warning(
  1743. `当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
  1744. files.length + fileList.length
  1745. } 个文件`
  1746. )
  1747. },
  1748. beforeRemove(file, fileList) {
  1749. return this.$confirm(`确定移除 ${file.name}?`)
  1750. },
  1751. // 成本调查表点击事件(可点击时触发)
  1752. handleSurveyClick(row) {
  1753. console.log('点击成本调查表:', row.name)
  1754. // 实际逻辑:跳转页面、打开弹窗等
  1755. },
  1756. // 在线填报
  1757. handleOnlineFill(row) {
  1758. console.log('在线填报:', row.name)
  1759. this.currentSurveyData = row
  1760. this.onlineFillDialogVisible = true
  1761. },
  1762. // 修改已上传的表
  1763. handleModify(row) {
  1764. console.log('修改:', row.name)
  1765. // 实际逻辑:打开修改表单
  1766. },
  1767. // 数据下载
  1768. handleDataDownload(row) {
  1769. console.log('数据下载:', row.name)
  1770. if (!row.fileUrl && !row.dataUrl) {
  1771. this.$message.warning('该数据暂无文件可下载')
  1772. return
  1773. }
  1774. const downloadUrl = row.dataUrl || row.fileUrl
  1775. const link = document.createElement('a')
  1776. link.style.display = 'none'
  1777. link.href = downloadUrl
  1778. link.download = row.name ? `${row.name}_数据` : '数据文件'
  1779. document.body.appendChild(link)
  1780. link.click()
  1781. document.body.removeChild(link)
  1782. this.$message.success('开始下载数据')
  1783. },
  1784. // 补充材料相关方法
  1785. handleAddMaterial() {
  1786. this.materialDialogVisible = true
  1787. this.resetMaterialForm()
  1788. },
  1789. // 重置补充材料表单
  1790. resetMaterialForm() {
  1791. this.materialForm = {
  1792. informationType: '',
  1793. informationName: '',
  1794. informationRequire: '',
  1795. formatRequired: '',
  1796. fileList: [],
  1797. fileUrl: '',
  1798. }
  1799. if (this.$refs.materialForm) {
  1800. this.$refs.materialForm.resetFields()
  1801. }
  1802. },
  1803. // 补充材料弹窗取消
  1804. handleMaterialCancel() {
  1805. this.materialDialogVisible = false
  1806. this.resetMaterialForm()
  1807. },
  1808. // 补充材料弹窗确定
  1809. handleMaterialSubmit() {
  1810. this.$refs.materialForm.validate((valid) => {
  1811. if (valid) {
  1812. // 设置 loading 状态
  1813. this.loading.materialSubmit = true
  1814. // 这里可以添加提交逻辑
  1815. // console.log('补充材料表单数据:', this.materialForm)
  1816. addOrUpdateTaskRequirement({
  1817. taskId: this.taskId,
  1818. projectId: this.projectId,
  1819. informationType: this.materialForm.informationType,
  1820. informationName: this.materialForm.informationName,
  1821. informationRequire: this.materialForm.informationRequire,
  1822. formatRequired: this.materialForm.formatRequired,
  1823. fileUrl: this.materialForm.fileUrl,
  1824. templateId: this.materialForm.templateId,
  1825. taskNode: this.localTaskInfo.currentNode,
  1826. })
  1827. .then((res) => {
  1828. // console.log('补充材料提交成功', res)
  1829. if (res && res.code === 200) {
  1830. this.loading.materialSubmit = false
  1831. Message.success('补充材料提交成功')
  1832. this.materialDialogVisible = false
  1833. this.resetMaterialForm()
  1834. this.getTaskRequirementPage()
  1835. } else {
  1836. Message.error('补充材料提交失败')
  1837. }
  1838. })
  1839. .catch((err) => {
  1840. console.error('补充材料提交失败', err)
  1841. Message.error('补充材料提交失败')
  1842. })
  1843. .finally(() => {
  1844. // 重置 loading 状态
  1845. this.loading.materialSubmit = false
  1846. })
  1847. } else {
  1848. Message.error('请完善表单信息')
  1849. return false
  1850. }
  1851. })
  1852. },
  1853. // 上传
  1854. // handleMaterialUpload(row, type) {
  1855. // let loading = null
  1856. // // 第一步:创建文件选择器
  1857. // const input = document.createElement('input')
  1858. // input.type = 'file'
  1859. // input.accept = '.pdf,.doc,.docx,.xls,.xlsx,.csv' // 允许的文件类型
  1860. // input.onchange = async (event) => {
  1861. // const file = event.target.files[0]
  1862. // if (!file) return
  1863. // try {
  1864. // // 校验文件大小(50MB)
  1865. // const maxSize = 50 * 1024 * 1024 // 50MB
  1866. // if (file.size > maxSize) {
  1867. // this.$message.error('文件大小不能超过50MB!')
  1868. // return
  1869. // }
  1870. // // 校验文件格式
  1871. // const allowedFormats = [
  1872. // '.pdf',
  1873. // '.doc',
  1874. // '.docx',
  1875. // '.xls',
  1876. // '.xlsx',
  1877. // 'csv',
  1878. // ]
  1879. // const fileName = file.name.toLowerCase()
  1880. // const isValidFormat = allowedFormats.some((format) =>
  1881. // fileName.endsWith(format)
  1882. // )
  1883. // if (!isValidFormat) {
  1884. // this.$message.error(
  1885. // '只允许上传.pdf,.doc,.docx,.xls,.xlsx,.csv格式的文件!'
  1886. // )
  1887. // return
  1888. // }
  1889. // // 显示遮罩层
  1890. // loading = this.$baseLoading(1, '文件上传中...')
  1891. // // 第三步:创建FormData并上传文件
  1892. // const formData = new FormData()
  1893. // formData.append('file', file)
  1894. // // 先调用上传API
  1895. // const uploadRes = await uploadFile('/api/file/v1/upload', formData)
  1896. // // 第四步:检查上传结果
  1897. // if (!uploadRes || !uploadRes.value) {
  1898. // // this.$message.error('文件上传失败!');
  1899. // return
  1900. // }
  1901. // // 第五步:文件上传成功后,再更新数据
  1902. // const fileInfo = uploadRes.value
  1903. // // 创建更新数据对象
  1904. // const updateData = {
  1905. // ...row,
  1906. // fileUrl: fileInfo?.savePath, // 更新扫描件URL
  1907. // }
  1908. // // 第六步:调用更新API
  1909. // // await updateCostProjectDocument(updateData)
  1910. // // // 第七步:更新成功,显示提示并刷新
  1911. // // this.$message.success('文件上传成功并更新数据!')
  1912. // // this.$emit('refresh', this.project.projectId) // 通知父组件刷新
  1913. // } catch (error) {
  1914. // // 错误处理
  1915. // this.$message.error('操作失败:' + (error.message || '未知错误'))
  1916. // } finally {
  1917. // // 关闭遮罩层
  1918. // loading.close()
  1919. // }
  1920. // }
  1921. // // 触发文件选择
  1922. // input.click()
  1923. // },
  1924. // 文件上传前验证
  1925. beforeMaterialUpload(file) {
  1926. // 预置模版不允许在此上传
  1927. if (this.isTemplateFormat) {
  1928. this.$message.warning(
  1929. '“预置模版”不支持直接上传,请按模版入口添加材料'
  1930. )
  1931. return false
  1932. }
  1933. const ext = '.' + file.name.split('.').pop().toLowerCase()
  1934. const mime = (file.type || '').toLowerCase()
  1935. // 文档格式
  1936. if (this.isDocumentFormat) {
  1937. const allowedExt = ['.pdf', '.doc', '.docx']
  1938. const allowedMime = [
  1939. 'application/pdf',
  1940. 'application/msword',
  1941. 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  1942. ]
  1943. const ok = allowedExt.includes(ext) || allowedMime.includes(mime)
  1944. if (!ok) {
  1945. this.$message.error('当前格式要求为文档,仅支持 pdf, doc, docx')
  1946. return false
  1947. }
  1948. }
  1949. // Excel 格式
  1950. if (this.isExcelFormat) {
  1951. const allowedExt = ['.xls', '.xlsx']
  1952. const allowedMime = [
  1953. 'application/vnd.ms-excel',
  1954. 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  1955. ]
  1956. const ok = allowedExt.includes(ext) || allowedMime.includes(mime)
  1957. if (!ok) {
  1958. this.$message.error('当前格式要求为表格,仅支持 xls, xlsx')
  1959. return false
  1960. }
  1961. }
  1962. // 检查文件大小 (50MB)
  1963. const isLt50M = file.size / 1024 / 1024 < 50
  1964. if (!isLt50M) {
  1965. this.$message.error('文件大小不能超过 50MB!')
  1966. return false
  1967. }
  1968. return true
  1969. },
  1970. // 自定义上传方法
  1971. async handleMaterialUpload(options) {
  1972. const { file, onProgress, onSuccess, onError } = options
  1973. // 检查是否已经上传了文件
  1974. if (
  1975. this.materialForm.fileList &&
  1976. this.materialForm.fileList.length >= 1
  1977. ) {
  1978. this.$message.warning('只能上传一个文件,请先删除已上传的文件')
  1979. // 手动触发onError回调
  1980. if (onError) {
  1981. onError(new Error('只能上传一个文件'))
  1982. }
  1983. return
  1984. }
  1985. const formData = new FormData()
  1986. formData.append('file', file)
  1987. try {
  1988. // 显示上传进度
  1989. if (onProgress) {
  1990. onProgress({ percent: 0 })
  1991. }
  1992. // 调用上传API
  1993. const uploadRes = await uploadFile('/api/file/v1/upload', formData, {
  1994. onUploadProgress: (progressEvent) => {
  1995. // 计算上传进度
  1996. if (progressEvent.total) {
  1997. const percent = Math.round(
  1998. (progressEvent.loaded * 100) / progressEvent.total
  1999. )
  2000. if (onProgress) {
  2001. onProgress({ percent })
  2002. }
  2003. }
  2004. },
  2005. })
  2006. // 检查上传结果
  2007. if (uploadRes && uploadRes.code === 200 && uploadRes.value) {
  2008. const fileInfo = uploadRes.value
  2009. // 构造文件信息对象,符合element-ui upload组件的格式
  2010. const fileObj = {
  2011. uid: file.uid,
  2012. name: file.name,
  2013. status: 'success',
  2014. size: file.size,
  2015. response: fileInfo,
  2016. url: fileInfo.savePath || fileInfo.url,
  2017. }
  2018. if (onSuccess) {
  2019. onSuccess(fileInfo, fileObj)
  2020. this.materialForm.fileUrl = fileInfo.savePath || fileInfo.url
  2021. }
  2022. this.$message.success(`${file.name} 上传成功`)
  2023. } else {
  2024. throw new Error(uploadRes?.message || '上传失败,请稍后重试')
  2025. }
  2026. } catch (error) {
  2027. console.error('文件上传失败:', error)
  2028. this.$message.error(`文件上传失败:${error.message || '未知错误'}`)
  2029. if (onError) {
  2030. onError(error)
  2031. }
  2032. }
  2033. },
  2034. // 打开预置模版弹窗
  2035. openLegalDialog() {
  2036. // 需求:改用 CostAuditTable 弹窗选择模版
  2037. this.loadCostTemplates()
  2038. this.selectedCostTemplates = []
  2039. this.costAuditDialogVisible = true
  2040. console.log(
  2041. '打开 CostAuditTable 弹窗选择模版',
  2042. this.costAuditDialogVisible
  2043. )
  2044. },
  2045. // 接收模版弹窗选择结果
  2046. handleLegalConfirm(payload) {
  2047. // 兼容不同返回字段,将关键信息落到表单中
  2048. const url =
  2049. payload?.templateUrl ||
  2050. payload?.url ||
  2051. payload?.savePath ||
  2052. payload?.fileUrl ||
  2053. ''
  2054. if (url) {
  2055. // 将选中的模版链接记录在fileUrl,后端若有专属字段可按需调整
  2056. this.materialForm.fileUrl = url
  2057. // 在UI上体现已选择(以文件列表形式展示一个只读项)
  2058. this.materialForm.fileList = [
  2059. {
  2060. uid: 'tpl-' + Date.now(),
  2061. name: payload?.name || payload?.templateName || '已选择的模版',
  2062. status: 'success',
  2063. url: url,
  2064. response: payload,
  2065. },
  2066. ]
  2067. this.$message.success('已选择模版')
  2068. } else {
  2069. this.$message.info('未获取到模版链接')
  2070. }
  2071. this.legalDialogVisible = false
  2072. },
  2073. // 拉取模板列表(CostAuditTable用)
  2074. loadCostTemplates() {
  2075. allcurrentCostSurveyList({
  2076. pageNum: this.costTemplatePagination.currentPage,
  2077. pageSize: this.costTemplatePagination.pageSize,
  2078. }).then((res) => {
  2079. this.costTemplateData = res?.value?.records || res?.value || []
  2080. this.costTemplatePagination.total =
  2081. res?.value?.total || this.costTemplateData.length || 0
  2082. })
  2083. },
  2084. handleCostTemplatePaginationChange({ currentPage, pageSize }) {
  2085. this.costTemplatePagination.currentPage = currentPage
  2086. this.costTemplatePagination.pageSize = pageSize
  2087. this.loadCostTemplates()
  2088. },
  2089. handleCostTemplateSelectionChange(val) {
  2090. if (Array.isArray(val) && val.length > 1) {
  2091. this.$message.warning('最多只能选择一个模板')
  2092. return
  2093. }
  2094. this.selectedCostTemplates = val || []
  2095. },
  2096. submitCostAuditTemplate() {
  2097. if (
  2098. !this.selectedCostTemplates ||
  2099. this.selectedCostTemplates.length !== 1
  2100. ) {
  2101. this.$message.error('请选择一个模板')
  2102. return
  2103. }
  2104. const chosen = this.selectedCostTemplates[0]
  2105. const url = chosen?.templateUrl || chosen?.url || chosen?.savePath || ''
  2106. // 记录到表单
  2107. this.materialForm.fileUrl = url
  2108. this.materialForm.templateId =
  2109. chosen?.surveyTemplateId || chosen?.templateId || chosen?.id || ''
  2110. this.materialForm.fileList = [
  2111. {
  2112. uid: 'tpl-' + Date.now(),
  2113. name: chosen?.surveyTemplateName || '已选择的模版',
  2114. status: 'success',
  2115. url: url,
  2116. response: chosen,
  2117. },
  2118. ]
  2119. this.$message.success('已选择模版')
  2120. this.costAuditDialogVisible = false
  2121. },
  2122. // 上传成功回调
  2123. handleMaterialUploadSuccess(response, file, fileList) {
  2124. // 更新文件列表,添加文件URL信息
  2125. this.materialForm.fileList = fileList.map((item) => {
  2126. if (item.uid === file.uid && response) {
  2127. return {
  2128. ...item,
  2129. url: response.savePath || response.url || item.url,
  2130. response: response,
  2131. }
  2132. }
  2133. return item
  2134. })
  2135. },
  2136. // 上传进度回调
  2137. handleMaterialUploadProgress(event, file, fileList) {
  2138. // 可以在这里显示上传进度,element-ui 会自动处理
  2139. },
  2140. // 上传失败回调
  2141. handleMaterialUploadError(err, file, fileList) {
  2142. console.error('文件上传错误:', err)
  2143. this.$message.error(`${file.name} 上传失败`)
  2144. // 从文件列表中移除失败的文件
  2145. this.materialForm.fileList = fileList.filter(
  2146. (item) => item.uid !== file.uid
  2147. )
  2148. },
  2149. // 超出文件数量限制
  2150. handleMaterialExceed(files, fileList) {
  2151. this.$message.warning(
  2152. `当前限制选择 5 个文件,本次选择了 ${files.length} 个文件,共选择了 ${fileList.length} 个文件`
  2153. )
  2154. },
  2155. // 移除文件
  2156. handleMaterialRemove(file, fileList) {
  2157. this.materialForm.fileList = fileList
  2158. this.$message.info(`${file.name} 已移除`)
  2159. },
  2160. // 成本调查表分页 - 页码改变
  2161. handleCostSurveyPageChange(page) {
  2162. this.costSurveyPagination.currentPage = page
  2163. // 调用接口重新获取数据
  2164. this.getCostSurveyList()
  2165. },
  2166. // 成本调查表分页 - 每页条数改变
  2167. handleCostSurveySizeChange(size) {
  2168. this.costSurveyPagination.pageSize = size
  2169. this.costSurveyPagination.currentPage = 1
  2170. // 调用接口重新获取数据
  2171. this.getCostSurveyList()
  2172. },
  2173. // 处理单记录调查表保存
  2174. handleSurveyFormSave(data) {
  2175. // 保存成功后刷新列表
  2176. this.getCostSurveyList()
  2177. },
  2178. // 获取监审期间数组(从立项信息中获取)
  2179. getAuditPeriodArray() {
  2180. // 优先从 formData.basicInfo.auditPeriodArray 获取
  2181. if (
  2182. this.formData &&
  2183. this.formData.basicInfo &&
  2184. this.formData.basicInfo.auditPeriodArray &&
  2185. Array.isArray(this.formData.basicInfo.auditPeriodArray)
  2186. ) {
  2187. const periods = this.formData.basicInfo.auditPeriodArray
  2188. .map((item) => item.value)
  2189. .filter((val) => val && val.trim())
  2190. if (periods.length > 0) {
  2191. return periods
  2192. }
  2193. }
  2194. // 其次从 taskInfo.auditPeriod 获取
  2195. if (this.taskInfo && this.taskInfo.auditPeriod) {
  2196. if (Array.isArray(this.taskInfo.auditPeriod)) {
  2197. return this.taskInfo.auditPeriod
  2198. } else if (typeof this.taskInfo.auditPeriod === 'string') {
  2199. // 如果是字符串,尝试解析
  2200. return this.taskInfo.auditPeriod
  2201. .split(',')
  2202. .map((p) => p.trim())
  2203. .filter((p) => p)
  2204. }
  2205. }
  2206. // 最后从 formData.basicInfo.auditPeriod 获取
  2207. if (
  2208. this.formData &&
  2209. this.formData.basicInfo &&
  2210. this.formData.basicInfo.auditPeriod
  2211. ) {
  2212. if (Array.isArray(this.formData.basicInfo.auditPeriod)) {
  2213. return this.formData.basicInfo.auditPeriod
  2214. } else if (typeof this.formData.basicInfo.auditPeriod === 'string') {
  2215. return this.formData.basicInfo.auditPeriod
  2216. .split(',')
  2217. .map((p) => p.trim())
  2218. .filter((p) => p)
  2219. }
  2220. }
  2221. return null
  2222. },
  2223. },
  2224. }
  2225. </script>
  2226. <style scoped lang="scss">
  2227. .drawer-title {
  2228. font-size: 18px;
  2229. font-weight: 600;
  2230. color: #303133;
  2231. }
  2232. .audit-task-manage-container {
  2233. padding: 20px;
  2234. height: 100%;
  2235. overflow-y: auto;
  2236. h3 {
  2237. text-align: center;
  2238. margin-top: 0;
  2239. margin-bottom: 20px;
  2240. font-size: 18px;
  2241. font-weight: bold;
  2242. }
  2243. }
  2244. .cost-opinion-section,
  2245. .feedback-section {
  2246. border: 1px solid #dcdcdc;
  2247. border-radius: 4px;
  2248. padding: 20px;
  2249. margin-bottom: 20px;
  2250. background-color: #f9f9f9;
  2251. }
  2252. .opinion-item,
  2253. .feedback-item {
  2254. margin-bottom: 20px;
  2255. display: flex;
  2256. align-items: center;
  2257. label {
  2258. width: 120px;
  2259. margin-bottom: 8px;
  2260. font-weight: bold;
  2261. color: #1549ad;
  2262. }
  2263. }
  2264. .file-info {
  2265. margin-bottom: 10px;
  2266. }
  2267. .file-info a {
  2268. color: #0066cc;
  2269. text-decoration: none;
  2270. }
  2271. .file-info a:hover {
  2272. text-decoration: underline;
  2273. }
  2274. .upload-btn {
  2275. background-color: #007bff;
  2276. color: #fff;
  2277. border: none;
  2278. border-radius: 4px;
  2279. padding: 8px 16px;
  2280. cursor: pointer;
  2281. }
  2282. .upload-btn:hover {
  2283. background-color: #0056b3;
  2284. }
  2285. .cost-period-container {
  2286. display: flex;
  2287. align-items: flex-start;
  2288. }
  2289. .add-cost-year-btn {
  2290. margin-right: 10px;
  2291. }
  2292. .delete-cost-year-btn {
  2293. margin-left: 10px;
  2294. }
  2295. .cost-years-wrapper {
  2296. flex: 1;
  2297. }
  2298. .cost-year-item {
  2299. margin-bottom: 10px;
  2300. display: flex;
  2301. align-items: center;
  2302. }
  2303. .ml10 {
  2304. margin-left: 10px;
  2305. }
  2306. .text-danger {
  2307. color: #d9001b;
  2308. }
  2309. // 类别头行样式
  2310. ::v-deep .category-header-row {
  2311. background-color: #f5f7fa !important;
  2312. td {
  2313. background-color: #f5f7fa !important;
  2314. padding: 12px 16px !important;
  2315. }
  2316. }
  2317. .category-header-cell {
  2318. font-weight: 700;
  2319. color: #303133;
  2320. padding-left: 16px;
  2321. }
  2322. // 侧边弹窗样式优化
  2323. ::v-deep .el-drawer__body {
  2324. overflow-y: auto;
  2325. padding: 0;
  2326. }
  2327. ::v-deep .el-drawer__header {
  2328. margin-bottom: 0;
  2329. padding: 20px;
  2330. border-bottom: 1px solid #e4e7ed;
  2331. }
  2332. ::v-deep .el-drawer__body {
  2333. padding: 0;
  2334. }
  2335. .document-edit-container {
  2336. display: flex;
  2337. .document-params {
  2338. width: 55%;
  2339. }
  2340. .document-preview {
  2341. width: 45%;
  2342. }
  2343. }
  2344. </style>