taskFillIn.vue 77 KB

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