index.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311
  1. <template>
  2. <div class="supervision-review-doc-manage content-container">
  3. <!-- 列表视图 -->
  4. <div v-if="activeView === 'list'" class="list-view">
  5. <!-- 搜索区域 -->
  6. <div class="search-area">
  7. <el-form :inline="true" size="small">
  8. <!-- 文本名称输入框 -->
  9. <el-form-item label="文书名称:">
  10. <el-input
  11. v-model="searchForm.documentName"
  12. placeholder="请输入文书名称"
  13. clearable
  14. ></el-input>
  15. </el-form-item>
  16. <!-- 是否启用下拉选择 -->
  17. <el-form-item label="是否启用:">
  18. <el-select
  19. v-model="searchForm.status"
  20. placeholder="全部"
  21. clearable=""
  22. >
  23. <el-option label="全部" value=""></el-option>
  24. <el-option label="启用" value="1"></el-option>
  25. <el-option label="停用" value="0"></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <!-- 搜索和重置按钮 -->
  29. <el-form-item>
  30. <el-button
  31. icon="iconfont-5039297 icon-chaxun"
  32. type="primary"
  33. @click="handleSearch"
  34. >
  35. 搜索
  36. </el-button>
  37. <el-button
  38. plain
  39. type="primary"
  40. icon="iconfont-5039297 icon-zhongzhi"
  41. @click="handleReset"
  42. >
  43. 重置
  44. </el-button>
  45. </el-form-item>
  46. </el-form>
  47. </div>
  48. <!-- 操作按钮区域 -->
  49. <div class="action-buttons">
  50. <el-button
  51. v-region-permission="{
  52. category: 'auditReviewDocManage',
  53. action: 'add',
  54. }"
  55. plain
  56. type="success"
  57. icon="iconfont-5039297 icon-zengjia1"
  58. @click="handleAdd"
  59. >
  60. 添加
  61. </el-button>
  62. <el-button
  63. v-region-permission="{
  64. category: 'auditReviewDocManage',
  65. action: 'delete',
  66. }"
  67. plain
  68. type="danger"
  69. icon="iconfont-5039297 icon-shanchu1"
  70. :disabled="selectedRows.length === 0"
  71. @click="handleDelete"
  72. >
  73. 删除
  74. </el-button>
  75. </div>
  76. <!-- 数据表格 -->
  77. <div class="table-container">
  78. <el-table
  79. v-loading="loading"
  80. :data="tableData"
  81. border
  82. style="width: 100%"
  83. align="center"
  84. @selection-change="handleSelectionChange"
  85. >
  86. <template slot="empty">
  87. <Empty></Empty>
  88. </template>
  89. <!-- 多选列 -->
  90. <el-table-column
  91. type="selection"
  92. width="55"
  93. show-overflow-tooltip
  94. align="center"
  95. ></el-table-column>
  96. <!-- 序号列 -->
  97. <el-table-column
  98. type="index"
  99. label="序号"
  100. width="60"
  101. show-overflow-tooltip
  102. align="center"
  103. ></el-table-column>
  104. <!-- 监审文书名称列 -->
  105. <el-table-column
  106. prop="documentName"
  107. label="监审文书名称"
  108. show-overflow-tooltip
  109. align="center"
  110. >
  111. <template slot-scope="scope">
  112. <div class="text-ellipsis">{{ scope.row.documentName }}</div>
  113. </template>
  114. </el-table-column>
  115. <!-- 别名列 -->
  116. <el-table-column
  117. prop="alias"
  118. label="别名"
  119. show-overflow-tooltip
  120. align="center"
  121. >
  122. <template slot-scope="scope">
  123. <div class="text-ellipsis">{{ scope.row.alias }}</div>
  124. </template>
  125. </el-table-column>
  126. <!-- 类型列 -->
  127. <el-table-column
  128. prop="type"
  129. label="类型"
  130. width="120"
  131. show-overflow-tooltip
  132. align="center"
  133. >
  134. <template slot-scope="scope">
  135. <span>
  136. {{ getDictName('documentType', scope.row.type) }}
  137. </span>
  138. </template>
  139. </el-table-column>
  140. <!-- 是否启用列(开关) -->
  141. <el-table-column
  142. prop="status"
  143. label="是否启用"
  144. width="120"
  145. show-overflow-tooltip
  146. align="center"
  147. >
  148. <template slot-scope="scope">
  149. <el-switch
  150. v-model="scope.row.status"
  151. v-region-permission="{
  152. category: 'auditReviewDocManage',
  153. action: 'edit',
  154. displayMode: 'disabled',
  155. }"
  156. active-color="#13ce66"
  157. active-value="1"
  158. inactive-value="0"
  159. @change="handleSwitchChange(scope.row)"
  160. ></el-switch>
  161. </template>
  162. </el-table-column>
  163. <!-- 创建人列 -->
  164. <el-table-column
  165. prop="createBy"
  166. label="创建人"
  167. width="120"
  168. show-overflow-tooltip
  169. align="center"
  170. ></el-table-column>
  171. <!-- 最后更新时间列 -->
  172. <el-table-column
  173. prop="updateTime"
  174. label="最后更新时间"
  175. width="120"
  176. show-overflow-tooltip
  177. align="center"
  178. >
  179. <template slot-scope="scope">
  180. <div>
  181. {{
  182. scope.row.updateTime ? scope.row.updateTime.split(' ')[0] : ''
  183. }}
  184. </div>
  185. <div>
  186. {{
  187. scope.row.updateTime ? scope.row.updateTime.split(' ')[1] : ''
  188. }}
  189. </div>
  190. </template>
  191. </el-table-column>
  192. <!-- 操作列 -->
  193. <el-table-column
  194. label="操作"
  195. width="180"
  196. show-overflow-tooltip
  197. align="center"
  198. >
  199. <template slot-scope="scope">
  200. <el-button
  201. v-region-permission="{
  202. category: 'auditReviewDocManage',
  203. action: 'view',
  204. }"
  205. type="text"
  206. size="mini"
  207. @click="handleDetail(scope.row)"
  208. >
  209. 详情
  210. </el-button>
  211. <el-button
  212. v-region-permission="{
  213. category: 'auditReviewDocManage',
  214. action: 'edit',
  215. }"
  216. type="text"
  217. size="mini"
  218. @click="handleEdit(scope.row)"
  219. >
  220. 修改
  221. </el-button>
  222. <el-button
  223. v-region-permission="{
  224. category: 'auditReviewDocManage',
  225. action: 'delete',
  226. }"
  227. type="text"
  228. size="mini"
  229. class="delete-btn"
  230. @click="handleDeleteRow(scope.row)"
  231. >
  232. 删除
  233. </el-button>
  234. </template>
  235. </el-table-column>
  236. </el-table>
  237. </div>
  238. <!-- 分页组件 -->
  239. <div class="pagination">
  240. <el-pagination
  241. :current-page="currentPage"
  242. :page-sizes="[50, 100]"
  243. :page-size="pageSize"
  244. layout="total, sizes, prev, pager, next, jumper"
  245. :total="total"
  246. @size-change="handleSizeChange"
  247. @current-change="handleCurrentChange"
  248. ></el-pagination>
  249. </div>
  250. </div>
  251. <!-- 修改视图 -->
  252. <div v-else-if="activeView === 'edit'" class="edit-view">
  253. <div class="edit-header">
  254. <el-button plain type="primary" @click="backToList">
  255. <i class="iconfont-5039297 icon-fanhui"></i>
  256. 返回列表
  257. </el-button>
  258. </div>
  259. <h2 v-if="!isDisabled">
  260. {{ formData.id ? '修改文书模板' : '添加文书模板' }}
  261. </h2>
  262. <h2 v-else>详情</h2>
  263. <!-- 步骤条导航 -->
  264. <el-steps :active="activeStep" align-center class="steps-container">
  265. <el-step title="基础信息填写"></el-step>
  266. <el-step title="模板内容配置"></el-step>
  267. </el-steps>
  268. <!-- 步骤内容区域 -->
  269. <div class="step-content">
  270. <!-- 步骤1: 基础信息填写 -->
  271. <div v-if="activeStep === 0" class="form-container">
  272. <el-form
  273. ref="basicForm"
  274. :model="formData"
  275. :rules="formRules"
  276. label-width="120px"
  277. class="basic-info-form"
  278. :disabled="isDisabled"
  279. >
  280. <el-row :gutter="20">
  281. <el-col :span="12">
  282. <el-form-item label="监审文书名称:" prop="documentName">
  283. <el-input
  284. v-model="formData.documentName"
  285. v-pinyin-abbreviation="{
  286. target: 'formData.alias',
  287. }"
  288. placeholder="请输入监审文书名称"
  289. maxlength="50"
  290. show-word-limit
  291. ></el-input>
  292. </el-form-item>
  293. </el-col>
  294. <el-col :span="12">
  295. <el-form-item label="监审文书别名:" prop="alias">
  296. <el-input
  297. v-model="formData.alias"
  298. placeholder="请输入监审文书别名"
  299. maxlength="50"
  300. show-word-limit
  301. ></el-input>
  302. </el-form-item>
  303. </el-col>
  304. </el-row>
  305. <el-row :gutter="20">
  306. <el-col :span="12">
  307. <el-form-item label="类型:" prop="type">
  308. <el-select
  309. v-model="formData.type"
  310. style="width: 100%"
  311. placeholder="请选择类型"
  312. >
  313. <el-option
  314. v-for="item in dictData['documentType']"
  315. :key="item.key"
  316. :label="item.name"
  317. :value="item.key"
  318. ></el-option>
  319. </el-select>
  320. </el-form-item>
  321. </el-col>
  322. <el-col :span="12">
  323. <el-form-item label="模板类型:" prop="documentType">
  324. <el-select
  325. v-model="formData.documentType"
  326. style="width: 100%"
  327. placeholder="请选择类型"
  328. @change="handleDocumentTypeChange"
  329. >
  330. <el-option
  331. v-for="item in dictData['documentTemplateType']"
  332. :key="item.key"
  333. :label="item.name"
  334. :value="item.key"
  335. ></el-option>
  336. </el-select>
  337. </el-form-item>
  338. </el-col>
  339. </el-row>
  340. <el-row :gutter="20">
  341. <el-col :span="12">
  342. <el-form-item label="是否需要文号:" prop="isWh">
  343. <el-radio-group v-model="formData.isWh">
  344. <el-radio label="0">是</el-radio>
  345. <el-radio label="1">否</el-radio>
  346. </el-radio-group>
  347. </el-form-item>
  348. </el-col>
  349. <el-col :span="12">
  350. <el-form-item label="说明:" prop="description">
  351. <el-input
  352. v-model="formData.description"
  353. type="textarea"
  354. placeholder="请输入说明"
  355. maxlength="200"
  356. show-word-limit
  357. :rows="4"
  358. ></el-input>
  359. </el-form-item>
  360. </el-col>
  361. </el-row>
  362. <!-- <el-form-item label="*数据来源:" prop="dataSourceType">
  363. <el-radio-group v-model="formData.dataSourceType">
  364. <el-radio label="database_table">数据库表</el-radio>
  365. </el-radio-group>
  366. </el-form-item>
  367. <el-form-item
  368. v-if="formData.dataSourceType === 'database_table'"
  369. label="数据库表:"
  370. prop="tableId"
  371. >
  372. <el-input
  373. v-model="formData.surveyTemplateName"
  374. style="width: 38%"
  375. disabled
  376. ></el-input>
  377. <el-button type="primary" @click="handleAddCostSurvey">
  378. 选择数据库表
  379. </el-button>
  380. <el-select
  381. v-model="formData.tableId"
  382. placeholder="请选择数据库表"
  383. >
  384. <el-option label="w_cbmx" :value="1"></el-option>
  385. </el-select>
  386. </el-form-item> -->
  387. </el-form>
  388. </div>
  389. <!-- 步骤2: 模板内容配置 - 左右布局 -->
  390. <div v-if="activeStep === 1" class="template-config-container">
  391. <div class="layout-wrapper">
  392. <!-- 左侧:上传模板和预览/修改标签页 -->
  393. <div class="left-panel">
  394. <!-- 上传模板按钮 -->
  395. <UploadComponent
  396. :upload-mode="'single'"
  397. :max-size="50 * 1024 * 1024"
  398. :allowed-types="['xlsx', 'xls', 'doc', 'docx', 'pdf']"
  399. :files-list="formData.fileUrl"
  400. action-url="/api/file/v1/tempUpload"
  401. button-text="上传模板"
  402. :is-disabled="isDisabled"
  403. @removeFile="removeFile"
  404. @saveFiles="saveFiles"
  405. />
  406. <!-- 预览/修改标签页 -->
  407. <template-preview-edit
  408. :active-tab="activeTab"
  409. :file-url="fileUrl"
  410. />
  411. </div>
  412. <!-- 右侧:数据项表格 -->
  413. <div class="right-panel">
  414. <div class="data-fields-section">
  415. <div class="data-fields-title">以下为数据项内容</div>
  416. <el-table
  417. :data="costDocumentTemplateFiles"
  418. border
  419. style="width: 100%"
  420. >
  421. <el-table-column prop="tableName" label="表名" align="center">
  422. <template slot-scope="scope">
  423. <el-input
  424. v-model="scope.row.tableName"
  425. clearable
  426. placeholder="请输入表名(英文)"
  427. :disabled="isDisabled"
  428. ></el-input>
  429. </template>
  430. </el-table-column>
  431. <el-table-column prop="colName" label="列名" align="center">
  432. <template slot-scope="scope">
  433. <el-input
  434. v-model="scope.row.colName"
  435. clearable
  436. placeholder="请输入列名(英文)"
  437. :disabled="isDisabled"
  438. ></el-input>
  439. </template>
  440. </el-table-column>
  441. <el-table-column
  442. prop="whereName"
  443. label="条件名"
  444. align="center"
  445. >
  446. <template slot-scope="scope">
  447. <el-input
  448. v-model="scope.row.whereName"
  449. clearable
  450. placeholder="请输入条件名"
  451. :disabled="isDisabled"
  452. ></el-input>
  453. </template>
  454. </el-table-column>
  455. <el-table-column
  456. prop="whereValue"
  457. label="条件值"
  458. align="center"
  459. >
  460. <template slot-scope="scope">
  461. <el-input
  462. v-model="scope.row.whereValue"
  463. clearable
  464. placeholder="请输入条件值"
  465. :disabled="isDisabled"
  466. ></el-input>
  467. </template>
  468. </el-table-column>
  469. <el-table-column
  470. prop="pinyin"
  471. label="拼音"
  472. align="center"
  473. width="120"
  474. show-overflow-tooltip
  475. ></el-table-column>
  476. <el-table-column
  477. prop="originalText"
  478. label="名称"
  479. align="center"
  480. width="120"
  481. show-overflow-tooltip
  482. ></el-table-column>
  483. <el-table-column
  484. prop="labelValue"
  485. label="标签"
  486. align="center"
  487. width="120"
  488. show-overflow-tooltip
  489. >
  490. <template slot-scope="scope">
  491. <span>
  492. {{ scope.row.labelValue }}
  493. </span>
  494. </template>
  495. </el-table-column>
  496. </el-table>
  497. </div>
  498. </div>
  499. </div>
  500. </div>
  501. </div>
  502. <!-- 操作按钮区域 -->
  503. <div class="edit-actions">
  504. <el-button
  505. v-if="activeStep === 1"
  506. type="primary"
  507. plain
  508. @click="handlePrevStep"
  509. >
  510. 上一步
  511. </el-button>
  512. <el-button
  513. v-if="activeStep === 0"
  514. type="primary"
  515. plain
  516. @click="handleNextStep"
  517. >
  518. 下一步
  519. </el-button>
  520. <el-button
  521. v-if="!isDisabled"
  522. type="primary"
  523. plain
  524. style="margin-left: 20px"
  525. @click="handleSave"
  526. >
  527. 保存
  528. </el-button>
  529. </div>
  530. </div>
  531. <!-- 成本调查表表单 -->
  532. <el-dialog
  533. title="关联成本调查表"
  534. :visible.sync="costSurveyDialogVisible"
  535. width="50%"
  536. :close-on-click-modal="false"
  537. >
  538. <cost-audit-table
  539. :table-data="selectCostSurveyData"
  540. :columns="selectCostSurveyColumns"
  541. :show-selection="true"
  542. :show-pagination="true"
  543. :pagination="selectCostSurveyPagination"
  544. @pagination-change="selectCostSurveyPaginationChange"
  545. @selection-change="selectCostSurveySelectionChange"
  546. >
  547. <!-- 创建时间自定义单元格 -->
  548. <template #createTime="{ row }">
  549. <div>{{ row.createTime ? row.createTime.split(' ')[0] : '-' }}</div>
  550. <div>{{ row.createTime ? row.createTime.split(' ')[1] : '-' }}</div>
  551. </template>
  552. </cost-audit-table>
  553. <div slot="footer" class="dialog-footer">
  554. <el-button @click="costSurveyDialogVisible = false">取消</el-button>
  555. <el-button
  556. type="primary"
  557. @click="submitCostSurveyForm('costSurveyForm')"
  558. >
  559. 确认
  560. </el-button>
  561. </div>
  562. </el-dialog>
  563. </div>
  564. </template>
  565. <script>
  566. import TemplatePreviewEdit from '@/components/costAudit/TemplatePreviewEdit.vue'
  567. import CostAuditTable from '@/components/costAudit/CostAuditTable.vue'
  568. import UploadComponent from '@/components/costAudit/UploadComponent.vue'
  569. import { dictMixin } from '@/mixins/useDict'
  570. import {
  571. getDocList,
  572. addDocumentTemplate,
  573. updateDocumentTemplate,
  574. batchDeleteDocumentTemplates,
  575. deleteDocumentTemplateById,
  576. queryByDocumentId,
  577. } from '@/api/auditReviewDocManage.js'
  578. import { getallCurrentCostSurveyList } from '@/api/catalogManage.js'
  579. export default {
  580. name: 'AuditReviewDocManage',
  581. components: {
  582. TemplatePreviewEdit,
  583. CostAuditTable,
  584. UploadComponent,
  585. },
  586. mixins: [dictMixin],
  587. data() {
  588. return {
  589. dictData: {
  590. documentType: [], //文书类型
  591. documentTemplateType: [], //文书模板类型
  592. },
  593. loading: false,
  594. // 视图控制
  595. activeView: 'list', // list: 列表视图, detail: 详情视图, edit: 修改视图
  596. view: 'add',
  597. activeDetailTab: 'basic', // 详情页标签页
  598. isDisabled: false,
  599. // 搜索表单数据
  600. searchForm: {
  601. documentName: '',
  602. status: '',
  603. },
  604. // 表格数据
  605. tableData: [],
  606. // 当前页码
  607. currentPage: 1,
  608. // 每页显示条数
  609. pageSize: 50,
  610. // 总记录数
  611. total: 0,
  612. // 选中的行数据
  613. selectedRows: [],
  614. costSurveyDialogVisible: false,
  615. selectCostSurveyData: [],
  616. selectCostSurveyRow: [],
  617. selectCostSurveyPagination: {
  618. currentPage: 1,
  619. pageSize: 10,
  620. total: 0,
  621. },
  622. // 表单验证规则
  623. formRules: {
  624. documentName: [
  625. { required: true, message: '请输入监审文书名称', trigger: 'blur' },
  626. {
  627. max: 30,
  628. message: '监审文书名称不能超过30个字符',
  629. trigger: 'blur',
  630. },
  631. ],
  632. alias: [
  633. { required: true, message: '请输入监审文书别名', trigger: 'blur' },
  634. {
  635. max: 30,
  636. message: '监审文书别名不能超过30个字符',
  637. trigger: 'blur',
  638. },
  639. ],
  640. documentType: [
  641. { required: true, message: '请选择模板类型', trigger: 'change' },
  642. ],
  643. // dataSourceType: [
  644. // { required: true, message: '请选择数据来源', trigger: 'change' },
  645. // ],
  646. // tableId: [
  647. // { required: true, message: '请选择数据表', trigger: 'change' },
  648. // ],
  649. isWh: [
  650. { required: true, message: '请选择是否文号', trigger: 'change' },
  651. ],
  652. type: [{ required: true, message: '请选择类型', trigger: 'change' }],
  653. },
  654. // 修改模板相关数据
  655. activeStep: 0, // 当前步骤,0:基础信息填写,1:模板内容配置
  656. activeTab: 'preview', // 当前标签页,preview:预览,edit:修改
  657. uploadDialogVisible: false, // 上传模板对话框显示状态
  658. selectedFile: null, // 选中的上传文件
  659. uploadedFile: null, // 已上传的文件信息
  660. fileContent: null, // 文件内容
  661. tablePreviewData: [], // 表格预览数据(前几行)
  662. tableColumns: [], // 表格列名
  663. // fileUrl:
  664. // window.context.form +
  665. // '/profile/upload/20251014/卷宗封面_20251014173930_349.docx',
  666. // 表单数据
  667. formData: {
  668. documentName: '',
  669. alias: '',
  670. description: '',
  671. isWh: '1',
  672. type: '',
  673. fileUrl: '',
  674. },
  675. // 数据项列表
  676. costDocumentTemplateFiles: [],
  677. // 详情页数据
  678. detailData: {},
  679. detailUploadedFile: null,
  680. detailDataFields: [],
  681. fileUrl: '',
  682. }
  683. },
  684. computed: {
  685. // 表格列配置
  686. selectCostSurveyColumns() {
  687. return [
  688. // {
  689. // prop: 'catalogId',
  690. // label: '监审类别',
  691. // },
  692. {
  693. prop: 'surveyTemplateName',
  694. label: '调查表名称',
  695. },
  696. {
  697. prop: 'templateType',
  698. label: '模版类型',
  699. width: '100px',
  700. formatter: (row) => {
  701. return row.templateType == '1'
  702. ? '单记录'
  703. : row.templateType == '2'
  704. ? '固定表'
  705. : '动态表'
  706. },
  707. },
  708. {
  709. prop: 'storageTable',
  710. label: '调查表数据存储表',
  711. },
  712. {
  713. prop: 'status',
  714. label: '状态',
  715. width: '100px',
  716. formatter: (row) => {
  717. return row.status == '-1'
  718. ? '草稿'
  719. : row.status == '0'
  720. ? '启用'
  721. : '停用'
  722. },
  723. },
  724. {
  725. prop: 'createTime',
  726. label: '创建时间',
  727. slotName: 'createTime',
  728. width: '100px',
  729. },
  730. ]
  731. },
  732. },
  733. created() {
  734. // 组件创建时加载数据
  735. this.handleSearch()
  736. },
  737. methods: {
  738. handleTabChange(tabName) {
  739. this.activeTab = tabName
  740. },
  741. // 搜索按钮点击事件
  742. async handleSearch() {
  743. this.loading = true
  744. try {
  745. const params = {
  746. ...this.searchForm,
  747. page: this.currentPage,
  748. pageSize: this.pageSize,
  749. }
  750. const response = await getDocList(params)
  751. this.tableData = response.value.records || []
  752. this.total = response.value.total || 0
  753. } catch (error) {
  754. console.log(error)
  755. } finally {
  756. this.loading = false
  757. }
  758. },
  759. // 重置按钮点击事件
  760. handleReset() {
  761. this.searchForm = {
  762. documentName: '',
  763. status: '',
  764. }
  765. this.currentPage = 1
  766. this.handleSearch()
  767. },
  768. handleAddCostSurvey() {
  769. this.getCostSurveyOptions()
  770. this.costSurveyDialogVisible = true
  771. },
  772. // 获取成本调查表选项
  773. getCostSurveyOptions() {
  774. getallCurrentCostSurveyList({}).then((res) => {
  775. this.selectCostSurveyData = res.value.records
  776. this.selectCostSurveyPagination.total = res.value.total
  777. })
  778. },
  779. selectCostSurveyPaginationChange({ currentPage, pageSize }) {
  780. this.selectCostSurveyPagination.currentPage = currentPage
  781. this.selectCostSurveyPagination.pageSize = pageSize
  782. this.getCostSurveyOptions()
  783. },
  784. selectCostSurveySelectionChange(val) {
  785. if (val.length > 1) {
  786. this.$message.warning('只能选择一个成本调查表')
  787. return
  788. }
  789. this.selectCostSurveyRow = val
  790. },
  791. submitCostSurveyForm() {
  792. if (this.selectCostSurveyRow.length == 1) {
  793. this.formData.tableId = this.selectCostSurveyRow[0].surveyTemplateId
  794. this.formData.surveyTemplateName =
  795. this.selectCostSurveyRow[0].surveyTemplateName
  796. this.costSurveyDialogVisible = false
  797. } else {
  798. this.$message.warning('请选择一个成本调查表')
  799. }
  800. },
  801. // 添加按钮点击事件
  802. handleAdd() {
  803. this.resetForm()
  804. this.activeView = 'edit'
  805. this.view = 'add'
  806. this.isDisabled = false
  807. },
  808. // 修改按钮点击事件
  809. async handleEdit(row) {
  810. this.initEditData(row)
  811. this.activeView = 'edit'
  812. this.view = 'edit'
  813. this.isDisabled = false
  814. },
  815. getDocumentData() {
  816. if (this.formData.id) {
  817. queryByDocumentId({ documentId: this.formData.id }).then((res) => {
  818. this.costDocumentTemplateFiles = res.value || []
  819. })
  820. }
  821. },
  822. // 详情按钮点击事件
  823. async handleDetail(row) {
  824. this.initEditData(row)
  825. this.activeView = 'edit'
  826. this.view = 'detail'
  827. this.isDisabled = true
  828. },
  829. // 返回列表
  830. backToList() {
  831. this.activeView = 'list'
  832. this.handleSearch()
  833. },
  834. // 初始化修改数据
  835. initEditData(data) {
  836. // 重置表单
  837. this.resetForm()
  838. // 设置表单数据
  839. this.formData = {}
  840. this.formData = {
  841. ...data,
  842. surveyTemplateName: data.tableId,
  843. fileUrl: data.fileUrl ? [data.fileUrl] : [],
  844. }
  845. this.fileUrl = data.fileUrl
  846. this.activeStep = 0
  847. },
  848. // 选中行变化事件
  849. handleSelectionChange(val) {
  850. this.selectedRows = val
  851. },
  852. // 开关状态改变事件
  853. async handleSwitchChange(row) {
  854. try {
  855. const response = await updateDocumentTemplate({
  856. ...row,
  857. status: row.status,
  858. })
  859. if (response.code !== 200) {
  860. // 回滚状态
  861. row.status = !row.status
  862. } else {
  863. this.$message.success('修改成功')
  864. this.handleSearch()
  865. }
  866. } catch (error) {
  867. // 回滚状态
  868. row.status = !row.status
  869. }
  870. },
  871. // 处理模板类型变化
  872. handleDocumentTypeChange(value) {
  873. // 根据选中的documentType查找对应的documentTypeName
  874. const documentTemplateType = this.dictData['documentTemplateType'] || []
  875. const selectedType = documentTemplateType.find(
  876. (item) => item.key === value
  877. )
  878. if (selectedType) {
  879. this.formData.documentTypeName = selectedType.name
  880. } else {
  881. this.formData.documentTypeName = ''
  882. }
  883. },
  884. // 单个删除按钮点击事件
  885. async handleDeleteRow(row) {
  886. this.$confirm('确定要删除该记录吗?', '提示', {
  887. confirmButtonText: '确定',
  888. cancelButtonText: '取消',
  889. type: 'warning',
  890. })
  891. .then(async () => {
  892. const response = await deleteDocumentTemplateById(row.id)
  893. this.$message.success('删除成功')
  894. // 重新加载数据
  895. this.handleSearch()
  896. })
  897. .catch(() => {
  898. this.$message.info('已取消删除')
  899. })
  900. },
  901. // 分页大小改变事件
  902. handleSizeChange(val) {
  903. this.pageSize = val
  904. this.currentPage = 1
  905. this.handleSearch()
  906. },
  907. // 当前页改变事件
  908. handleCurrentChange(val) {
  909. this.currentPage = val
  910. this.handleSearch()
  911. },
  912. // 删除按钮点击事件
  913. async handleDelete() {
  914. if (this.selectedRows.length === 0) {
  915. this.$message.warning('请先选择要删除的记录')
  916. return
  917. }
  918. this.$confirm('确定要删除选中的记录吗?', '提示', {
  919. confirmButtonText: '确定',
  920. cancelButtonText: '取消',
  921. type: 'warning',
  922. })
  923. .then(async () => {
  924. const ids = this.selectedRows.map((row) => row.id)
  925. const response = await batchDeleteDocumentTemplates({ ids })
  926. if (response.code === 200) {
  927. this.$message.success('删除成功')
  928. // 重新加载数据
  929. this.handleSearch()
  930. // 清空选中状态
  931. this.selectedRows = []
  932. }
  933. })
  934. .catch(() => {
  935. this.$message.info('已取消删除')
  936. })
  937. },
  938. // 复制标签到剪贴板
  939. copyToClipboard(tag) {
  940. const textarea = document.createElement('textarea')
  941. textarea.value = tag
  942. document.body.appendChild(textarea)
  943. textarea.select()
  944. document.execCommand('copy')
  945. document.body.removeChild(textarea)
  946. this.$message.success('标签已复制到剪贴板')
  947. },
  948. // 修改模板相关方法
  949. // 重置表单
  950. resetForm() {
  951. this.activeStep = 0
  952. this.formData = {
  953. documentName: '',
  954. alias: '',
  955. description: '',
  956. dataSourceType: 'database_table',
  957. tableId: 1,
  958. isWh: '1',
  959. type: '',
  960. documentType: '',
  961. documentTypeName: '',
  962. }
  963. this.uploadedFile = null
  964. this.selectedFile = null
  965. this.fileContent = null
  966. this.tablePreviewData = []
  967. this.tableColumns = []
  968. this.costDocumentTemplateFiles = []
  969. // 重置表单验证
  970. if (this.$refs.basicForm) {
  971. this.$refs.basicForm.resetFields()
  972. }
  973. },
  974. // 处理下一步
  975. handleNextStep() {
  976. this.$refs.basicForm.validate((valid) => {
  977. if (valid) {
  978. if (this.view == 'detail' || this.view == 'edit') {
  979. this.getDocumentData()
  980. this.activeStep = 1
  981. } else {
  982. this.handleSave()
  983. }
  984. } else {
  985. this.$message.error('请填写完整的基础信息')
  986. return false
  987. }
  988. })
  989. },
  990. // 处理上一步
  991. handlePrevStep() {
  992. this.activeStep = 0
  993. this.$message.info('返回基础信息填写')
  994. },
  995. // 处理保存
  996. async handleSave() {
  997. // 准备保存数据
  998. const saveData = {
  999. ...this.formData,
  1000. fileUrl: this.formData.fileUrl ? this.formData.fileUrl.join(',') : '',
  1001. costDocumentTemplateFiles:
  1002. this.costDocumentTemplateFiles.map((item) => {
  1003. return {
  1004. ...item,
  1005. documentId: this.formData.id,
  1006. }
  1007. }) || [],
  1008. }
  1009. if (this.activeStep == 1) {
  1010. if (!this.formData.fileUrl) {
  1011. this.$message.error('请上传文件')
  1012. }
  1013. }
  1014. let response
  1015. if (!this.formData.id) {
  1016. // 新增
  1017. response = await addDocumentTemplate({
  1018. ...saveData,
  1019. })
  1020. this.formData.id = response.value
  1021. } else {
  1022. // 修改
  1023. response = await updateDocumentTemplate({
  1024. ...saveData,
  1025. id: this.formData.id,
  1026. })
  1027. }
  1028. if (response.code === 200) {
  1029. this.$message.success('保存成功')
  1030. if (this.activeStep == 1) {
  1031. // 保存成功后返回列表
  1032. this.backToList()
  1033. // 重新加载数据
  1034. this.handleSearch()
  1035. } else {
  1036. this.activeStep = 1
  1037. }
  1038. } else {
  1039. this.$message.error(response.msg || '保存失败')
  1040. }
  1041. },
  1042. // saveFiles 方法
  1043. saveFiles(data) {
  1044. this.formData.fileUrl = [data[0].savePath]
  1045. this.fileUrl = data[0].savePath
  1046. this.costDocumentTemplateFiles = data[0].bracketContentInfos.map(
  1047. (item) => {
  1048. return {
  1049. ...item,
  1050. labelValue: `{${item.pinyin}}`,
  1051. }
  1052. }
  1053. )
  1054. },
  1055. // removeFile 方法
  1056. removeFile(index, removedFile, currentFiles) {
  1057. this.formData.fileUrl = []
  1058. this.fileUrl = ''
  1059. },
  1060. // 下载文件
  1061. downloadFile() {
  1062. // 在实际项目中,这里应该调用下载API或使用文件URL直接下载
  1063. this.$message.info('文件下载功能已触发')
  1064. },
  1065. },
  1066. }
  1067. </script>
  1068. <style scoped lang="scss">
  1069. @import '@/styles/costAudit.scss';
  1070. /* 标题样式 */
  1071. .supervision-review-doc-manage h2 {
  1072. margin-bottom: 20px;
  1073. font-size: 18px;
  1074. color: #333;
  1075. }
  1076. /* 操作按钮区域样式 */
  1077. .action-buttons {
  1078. margin-bottom: 20px;
  1079. display: flex;
  1080. gap: 10px;
  1081. }
  1082. /* 表格容器样式 */
  1083. .table-container {
  1084. margin-bottom: 20px;
  1085. }
  1086. /* 分页样式 */
  1087. .pagination {
  1088. text-align: right;
  1089. margin-top: 20px;
  1090. }
  1091. /* 操作列按钮样式调整 */
  1092. .el-table .cell {
  1093. white-space: normal;
  1094. word-break: break-all;
  1095. }
  1096. /* 修改视图样式 */
  1097. .edit-view,
  1098. .detail-view {
  1099. max-width: 100%;
  1100. overflow-x: auto;
  1101. }
  1102. .edit-header,
  1103. .detail-header {
  1104. display: flex;
  1105. align-items: center;
  1106. margin-bottom: 20px;
  1107. }
  1108. .back-button {
  1109. margin-right: 20px;
  1110. }
  1111. .steps-container {
  1112. margin-bottom: 20px;
  1113. }
  1114. .step-content {
  1115. overflow-y: auto;
  1116. margin-bottom: 20px;
  1117. .form-container {
  1118. padding: 0 10px;
  1119. }
  1120. .template-config-container {
  1121. .layout-wrapper {
  1122. display: flex;
  1123. gap: 20px;
  1124. }
  1125. .left-panel {
  1126. flex: 1;
  1127. height: 100%;
  1128. }
  1129. .right-panel {
  1130. width: 50%;
  1131. display: flex;
  1132. flex-direction: column;
  1133. }
  1134. .upload-template-btn {
  1135. margin-bottom: 20px;
  1136. background-color: #409eff;
  1137. border-color: #409eff;
  1138. }
  1139. .data-fields-section {
  1140. flex: 1;
  1141. display: flex;
  1142. flex-direction: column;
  1143. .data-fields-title {
  1144. margin-bottom: 15px;
  1145. padding: 10px;
  1146. background-color: #f5f7fa;
  1147. border-radius: 4px;
  1148. font-size: 14px;
  1149. color: #666;
  1150. }
  1151. .el-table {
  1152. flex: 1;
  1153. min-height: 0;
  1154. }
  1155. .tag-item {
  1156. display: inline-block;
  1157. padding: 4px 8px;
  1158. background-color: #ecf5ff;
  1159. color: #409eff;
  1160. border-radius: 4px;
  1161. font-size: 12px;
  1162. }
  1163. }
  1164. }
  1165. }
  1166. /* 修改操作按钮区域居中显示 */
  1167. .edit-actions {
  1168. padding: 15px 0;
  1169. border-top: 1px solid #e4e7ed;
  1170. text-align: center;
  1171. }
  1172. .file-upload-tips {
  1173. margin-bottom: 15px;
  1174. padding: 10px;
  1175. background-color: #f0f9ff;
  1176. border: 1px solid #bae7ff;
  1177. border-radius: 4px;
  1178. color: #096dd9;
  1179. font-size: 14px;
  1180. }
  1181. /* 修改已完成步骤的样式 */
  1182. .el-step.is-finish {
  1183. .el-step__head {
  1184. /* 更改已完成步骤圆圈的背景色为白色 */
  1185. background-color: #ffffff;
  1186. border-color: #409eff;
  1187. /* 修改已完成步骤的数字为√ */
  1188. .el-step__icon-inner {
  1189. /* 隐藏默认的数字 */
  1190. opacity: 0;
  1191. position: relative;
  1192. /* 使用伪元素添加√符号 */
  1193. &::before {
  1194. content: '√';
  1195. opacity: 1;
  1196. position: absolute;
  1197. left: 50%;
  1198. top: 50%;
  1199. transform: translate(-50%, -50%);
  1200. color: #409eff;
  1201. font-weight: bold;
  1202. }
  1203. }
  1204. }
  1205. }
  1206. /* 响应式设计 */
  1207. @media (max-width: 768px) {
  1208. .edit-header,
  1209. .detail-header {
  1210. flex-direction: column;
  1211. align-items: flex-start;
  1212. }
  1213. .back-button {
  1214. margin-bottom: 10px;
  1215. }
  1216. .template-config-container .layout-wrapper {
  1217. flex-direction: column;
  1218. }
  1219. .template-config-container .right-panel {
  1220. width: 100%;
  1221. }
  1222. }
  1223. ::v-deep .el-button.is-disabled {
  1224. background-color: #f9f9f9 !important;
  1225. border-color: #f3f3f4 !important;
  1226. color: #cccccc !important;
  1227. }
  1228. /* 文字按钮样式 */
  1229. .el-button--text.delete-btn {
  1230. color: #f56c6c;
  1231. }
  1232. </style>