taskFillIn.vue 78 KB

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