index.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  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="el-icon-search"
  32. type="primary"
  33. @click="handleSearch"
  34. >
  35. 搜索
  36. </el-button>
  37. <el-button
  38. plain
  39. type="primary"
  40. icon="el-icon-refresh"
  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="el-icon-circle-plus"
  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="el-icon-delete"
  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="el-icon-arrow-left"></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="isWh">
  324. <el-radio-group v-model="formData.isWh">
  325. <el-radio label="0">是</el-radio>
  326. <el-radio label="1">否</el-radio>
  327. </el-radio-group>
  328. </el-form-item>
  329. </el-col>
  330. </el-row>
  331. <el-row :gutter="20">
  332. <el-col :span="24">
  333. <el-form-item label="说明:" prop="description">
  334. <el-input
  335. v-model="formData.description"
  336. type="textarea"
  337. placeholder="请输入说明"
  338. maxlength="200"
  339. show-word-limit
  340. :rows="4"
  341. ></el-input>
  342. </el-form-item>
  343. </el-col>
  344. </el-row>
  345. <!-- <el-form-item label="*数据来源:" prop="dataSourceType">
  346. <el-radio-group v-model="formData.dataSourceType">
  347. <el-radio label="database_table">数据库表</el-radio>
  348. </el-radio-group>
  349. </el-form-item>
  350. <el-form-item
  351. v-if="formData.dataSourceType === 'database_table'"
  352. label="数据库表:"
  353. prop="tableId"
  354. >
  355. <el-input
  356. v-model="formData.surveyTemplateName"
  357. style="width: 38%"
  358. disabled
  359. ></el-input>
  360. <el-button type="primary" @click="handleAddCostSurvey">
  361. 选择数据库表
  362. </el-button>
  363. <el-select
  364. v-model="formData.tableId"
  365. placeholder="请选择数据库表"
  366. >
  367. <el-option label="w_cbmx" :value="1"></el-option>
  368. </el-select>
  369. </el-form-item> -->
  370. </el-form>
  371. </div>
  372. <!-- 步骤2: 模板内容配置 - 左右布局 -->
  373. <div v-if="activeStep === 1" class="template-config-container">
  374. <div class="layout-wrapper">
  375. <!-- 左侧:上传模板和预览/修改标签页 -->
  376. <div class="left-panel">
  377. <!-- 上传模板按钮 -->
  378. <UploadComponent
  379. :upload-mode="'single'"
  380. :max-size="50 * 1024 * 1024"
  381. :allowed-types="['xlsx', 'xls', 'doc', 'docx', 'pdf']"
  382. :files-list="formData.fileUrl"
  383. action-url="/api/file/v1/tempUpload"
  384. button-text="上传模板"
  385. :is-disabled="isDisabled"
  386. @removeFile="removeFile"
  387. @saveFiles="saveFiles"
  388. />
  389. <!-- 预览/修改标签页 -->
  390. <template-preview-edit
  391. :active-tab="activeTab"
  392. :file-url="fileUrl"
  393. />
  394. </div>
  395. <!-- 右侧:数据项表格 -->
  396. <div class="right-panel">
  397. <div class="data-fields-section">
  398. <div class="data-fields-title">以下为数据项内容</div>
  399. <el-table
  400. :data="costDocumentTemplateFiles"
  401. border
  402. style="width: 100%"
  403. >
  404. <el-table-column prop="tableName" label="表名" align="center">
  405. <template slot-scope="scope">
  406. <el-input
  407. v-model="scope.row.tableName"
  408. clearable
  409. placeholder="请输入表名(英文)"
  410. :disabled="isDisabled"
  411. ></el-input>
  412. </template>
  413. </el-table-column>
  414. <el-table-column prop="colName" label="列名" align="center">
  415. <template slot-scope="scope">
  416. <el-input
  417. v-model="scope.row.colName"
  418. clearable
  419. placeholder="请输入列名(英文)"
  420. :disabled="isDisabled"
  421. ></el-input>
  422. </template>
  423. </el-table-column>
  424. <el-table-column
  425. prop="whereName"
  426. label="条件名"
  427. align="center"
  428. >
  429. <template slot-scope="scope">
  430. <el-input
  431. v-model="scope.row.whereName"
  432. clearable
  433. placeholder="请输入条件名"
  434. :disabled="isDisabled"
  435. ></el-input>
  436. </template>
  437. </el-table-column>
  438. <el-table-column
  439. prop="whereValue"
  440. label="条件值"
  441. align="center"
  442. >
  443. <template slot-scope="scope">
  444. <el-input
  445. v-model="scope.row.whereValue"
  446. clearable
  447. placeholder="请输入条件值"
  448. :disabled="isDisabled"
  449. ></el-input>
  450. </template>
  451. </el-table-column>
  452. <el-table-column
  453. prop="pinyin"
  454. label="拼音"
  455. align="center"
  456. width="120"
  457. show-overflow-tooltip
  458. ></el-table-column>
  459. <el-table-column
  460. prop="originalText"
  461. label="名称"
  462. align="center"
  463. width="120"
  464. show-overflow-tooltip
  465. ></el-table-column>
  466. <el-table-column
  467. prop="labelValue"
  468. label="标签"
  469. align="center"
  470. width="120"
  471. show-overflow-tooltip
  472. >
  473. <template slot-scope="scope">
  474. <span>
  475. {{ scope.row.labelValue }}
  476. </span>
  477. </template>
  478. </el-table-column>
  479. </el-table>
  480. </div>
  481. </div>
  482. </div>
  483. </div>
  484. </div>
  485. <!-- 操作按钮区域 -->
  486. <div class="edit-actions">
  487. <el-button
  488. v-if="activeStep === 1"
  489. type="primary"
  490. plain
  491. @click="handlePrevStep"
  492. >
  493. 上一步
  494. </el-button>
  495. <el-button
  496. v-if="activeStep === 0"
  497. type="primary"
  498. plain
  499. @click="handleNextStep"
  500. >
  501. 下一步
  502. </el-button>
  503. <el-button
  504. v-if="!isDisabled"
  505. type="primary"
  506. plain
  507. style="margin-left: 20px"
  508. @click="handleSave"
  509. >
  510. 保存
  511. </el-button>
  512. </div>
  513. </div>
  514. <!-- 成本调查表表单 -->
  515. <el-dialog
  516. title="关联成本调查表"
  517. :visible.sync="costSurveyDialogVisible"
  518. width="50%"
  519. :close-on-click-modal="false"
  520. >
  521. <cost-audit-table
  522. :table-data="selectCostSurveyData"
  523. :columns="selectCostSurveyColumns"
  524. :show-selection="true"
  525. :show-pagination="true"
  526. :pagination="selectCostSurveyPagination"
  527. @pagination-change="selectCostSurveyPaginationChange"
  528. @selection-change="selectCostSurveySelectionChange"
  529. >
  530. <!-- 创建时间自定义单元格 -->
  531. <template #createTime="{ row }">
  532. <div>{{ row.createTime ? row.createTime.split(' ')[0] : '-' }}</div>
  533. <div>{{ row.createTime ? row.createTime.split(' ')[1] : '-' }}</div>
  534. </template>
  535. </cost-audit-table>
  536. <div slot="footer" class="dialog-footer">
  537. <el-button @click="costSurveyDialogVisible = false">取消</el-button>
  538. <el-button
  539. type="primary"
  540. @click="submitCostSurveyForm('costSurveyForm')"
  541. >
  542. 确认
  543. </el-button>
  544. </div>
  545. </el-dialog>
  546. </div>
  547. </template>
  548. <script>
  549. import TemplatePreviewEdit from '@/components/costAudit/TemplatePreviewEdit.vue'
  550. import CostAuditTable from '@/components/costAudit/CostAuditTable.vue'
  551. import UploadComponent from '@/components/costAudit/UploadComponent.vue'
  552. import { dictMixin } from '@/mixins/useDict'
  553. import {
  554. getDocList,
  555. addDocumentTemplate,
  556. updateDocumentTemplate,
  557. batchDeleteDocumentTemplates,
  558. deleteDocumentTemplateById,
  559. queryByDocumentId,
  560. } from '@/api/auditReviewDocManage.js'
  561. import { getallCurrentCostSurveyList } from '@/api/catalogManage.js'
  562. export default {
  563. name: 'AuditReviewDocManage',
  564. components: {
  565. TemplatePreviewEdit,
  566. CostAuditTable,
  567. UploadComponent,
  568. },
  569. mixins: [dictMixin],
  570. data() {
  571. return {
  572. dictData: {
  573. documentType: [], //文书类型
  574. },
  575. loading: false,
  576. // 视图控制
  577. activeView: 'list', // list: 列表视图, detail: 详情视图, edit: 修改视图
  578. view: 'add',
  579. activeDetailTab: 'basic', // 详情页标签页
  580. isDisabled: false,
  581. // 搜索表单数据
  582. searchForm: {
  583. documentName: '',
  584. status: '',
  585. },
  586. // 表格数据
  587. tableData: [],
  588. // 当前页码
  589. currentPage: 1,
  590. // 每页显示条数
  591. pageSize: 50,
  592. // 总记录数
  593. total: 0,
  594. // 选中的行数据
  595. selectedRows: [],
  596. costSurveyDialogVisible: false,
  597. selectCostSurveyData: [],
  598. selectCostSurveyRow: [],
  599. selectCostSurveyPagination: {
  600. currentPage: 1,
  601. pageSize: 10,
  602. total: 0,
  603. },
  604. // 表单验证规则
  605. formRules: {
  606. documentName: [
  607. { required: true, message: '请输入监审文书名称', trigger: 'blur' },
  608. {
  609. max: 30,
  610. message: '监审文书名称不能超过30个字符',
  611. trigger: 'blur',
  612. },
  613. ],
  614. alias: [
  615. { required: true, message: '请输入监审文书别名', trigger: 'blur' },
  616. {
  617. max: 30,
  618. message: '监审文书别名不能超过30个字符',
  619. trigger: 'blur',
  620. },
  621. ],
  622. // dataSourceType: [
  623. // { required: true, message: '请选择数据来源', trigger: 'change' },
  624. // ],
  625. // tableId: [
  626. // { required: true, message: '请选择数据表', trigger: 'change' },
  627. // ],
  628. isWh: [
  629. { required: true, message: '请选择是否文号', trigger: 'change' },
  630. ],
  631. type: [{ required: true, message: '请选择类型', trigger: 'change' }],
  632. },
  633. // 修改模板相关数据
  634. activeStep: 0, // 当前步骤,0:基础信息填写,1:模板内容配置
  635. activeTab: 'preview', // 当前标签页,preview:预览,edit:修改
  636. uploadDialogVisible: false, // 上传模板对话框显示状态
  637. selectedFile: null, // 选中的上传文件
  638. uploadedFile: null, // 已上传的文件信息
  639. fileContent: null, // 文件内容
  640. tablePreviewData: [], // 表格预览数据(前几行)
  641. tableColumns: [], // 表格列名
  642. // fileUrl:
  643. // window.context.form +
  644. // '/profile/upload/20251014/卷宗封面_20251014173930_349.docx',
  645. // 表单数据
  646. formData: {
  647. documentName: '',
  648. alias: '',
  649. description: '',
  650. isWh: '1',
  651. type: '',
  652. fileUrl: '',
  653. },
  654. // 数据项列表
  655. costDocumentTemplateFiles: [],
  656. // 详情页数据
  657. detailData: {},
  658. detailUploadedFile: null,
  659. detailDataFields: [],
  660. fileUrl: '',
  661. }
  662. },
  663. computed: {
  664. // 表格列配置
  665. selectCostSurveyColumns() {
  666. return [
  667. // {
  668. // prop: 'catalogId',
  669. // label: '监审类别',
  670. // },
  671. {
  672. prop: 'surveyTemplateName',
  673. label: '调查表名称',
  674. },
  675. {
  676. prop: 'templateType',
  677. label: '模版类型',
  678. width: '100px',
  679. formatter: (row) => {
  680. return row.templateType == '1'
  681. ? '单记录'
  682. : row.templateType == '2'
  683. ? '固定表'
  684. : '动态表'
  685. },
  686. },
  687. {
  688. prop: 'storageTable',
  689. label: '调查表数据存储表',
  690. },
  691. {
  692. prop: 'status',
  693. label: '状态',
  694. width: '100px',
  695. formatter: (row) => {
  696. return row.status == '-1'
  697. ? '草稿'
  698. : row.status == '0'
  699. ? '启用'
  700. : '停用'
  701. },
  702. },
  703. {
  704. prop: 'createTime',
  705. label: '创建时间',
  706. slotName: 'createTime',
  707. width: '100px',
  708. },
  709. ]
  710. },
  711. },
  712. created() {
  713. // 组件创建时加载数据
  714. this.handleSearch()
  715. },
  716. methods: {
  717. handleTabChange(tabName) {
  718. this.activeTab = tabName
  719. },
  720. // 搜索按钮点击事件
  721. async handleSearch() {
  722. this.loading = true
  723. try {
  724. const params = {
  725. ...this.searchForm,
  726. page: this.currentPage,
  727. pageSize: this.pageSize,
  728. }
  729. const response = await getDocList(params)
  730. this.tableData = response.value.records || []
  731. this.total = response.value.total || 0
  732. } catch (error) {
  733. console.log(error)
  734. } finally {
  735. this.loading = false
  736. }
  737. },
  738. // 重置按钮点击事件
  739. handleReset() {
  740. this.searchForm = {
  741. documentName: '',
  742. status: '',
  743. }
  744. this.currentPage = 1
  745. this.handleSearch()
  746. },
  747. handleAddCostSurvey() {
  748. this.getCostSurveyOptions()
  749. this.costSurveyDialogVisible = true
  750. },
  751. // 获取成本调查表选项
  752. getCostSurveyOptions() {
  753. getallCurrentCostSurveyList({}).then((res) => {
  754. this.selectCostSurveyData = res.value.records
  755. this.selectCostSurveyPagination.total = res.value.total
  756. })
  757. },
  758. selectCostSurveyPaginationChange({ currentPage, pageSize }) {
  759. this.selectCostSurveyPagination.currentPage = currentPage
  760. this.selectCostSurveyPagination.pageSize = pageSize
  761. this.getCostSurveyOptions()
  762. },
  763. selectCostSurveySelectionChange(val) {
  764. if (val.length > 1) {
  765. this.$message.warning('只能选择一个成本调查表')
  766. return
  767. }
  768. this.selectCostSurveyRow = val
  769. },
  770. submitCostSurveyForm() {
  771. if (this.selectCostSurveyRow.length == 1) {
  772. this.formData.tableId = this.selectCostSurveyRow[0].surveyTemplateId
  773. this.formData.surveyTemplateName =
  774. this.selectCostSurveyRow[0].surveyTemplateName
  775. this.costSurveyDialogVisible = false
  776. } else {
  777. this.$message.warning('请选择一个成本调查表')
  778. }
  779. },
  780. // 添加按钮点击事件
  781. handleAdd() {
  782. this.resetForm()
  783. this.activeView = 'edit'
  784. this.view = 'add'
  785. this.isDisabled = false
  786. },
  787. // 修改按钮点击事件
  788. async handleEdit(row) {
  789. this.initEditData(row)
  790. this.activeView = 'edit'
  791. this.view = 'edit'
  792. this.isDisabled = false
  793. },
  794. getDocumentData() {
  795. if (this.formData.id) {
  796. queryByDocumentId({ documentId: this.formData.id }).then((res) => {
  797. this.costDocumentTemplateFiles = res.value || []
  798. })
  799. }
  800. },
  801. // 详情按钮点击事件
  802. async handleDetail(row) {
  803. this.initEditData(row)
  804. this.activeView = 'edit'
  805. this.view = 'detail'
  806. this.isDisabled = true
  807. },
  808. // 返回列表
  809. backToList() {
  810. this.activeView = 'list'
  811. this.handleSearch()
  812. },
  813. // 初始化修改数据
  814. initEditData(data) {
  815. // 重置表单
  816. this.resetForm()
  817. // 设置表单数据
  818. this.formData = {}
  819. this.formData = {
  820. ...data,
  821. surveyTemplateName: data.tableId,
  822. fileUrl: data.fileUrl ? [data.fileUrl] : [],
  823. }
  824. this.fileUrl = data.fileUrl
  825. this.activeStep = 0
  826. },
  827. // 选中行变化事件
  828. handleSelectionChange(val) {
  829. this.selectedRows = val
  830. },
  831. // 开关状态改变事件
  832. async handleSwitchChange(row) {
  833. try {
  834. const response = await updateDocumentTemplate({
  835. ...row,
  836. status: row.status,
  837. })
  838. if (response.code !== 200) {
  839. // 回滚状态
  840. row.status = !row.status
  841. } else {
  842. this.$message.success('修改成功')
  843. this.handleSearch()
  844. }
  845. } catch (error) {
  846. // 回滚状态
  847. row.status = !row.status
  848. }
  849. },
  850. // 单个删除按钮点击事件
  851. async handleDeleteRow(row) {
  852. this.$confirm('确定要删除该记录吗?', '提示', {
  853. confirmButtonText: '确定',
  854. cancelButtonText: '取消',
  855. type: 'warning',
  856. })
  857. .then(async () => {
  858. const response = await deleteDocumentTemplateById(row.id)
  859. this.$message.success('删除成功')
  860. // 重新加载数据
  861. this.handleSearch()
  862. })
  863. .catch(() => {
  864. this.$message.info('已取消删除')
  865. })
  866. },
  867. // 分页大小改变事件
  868. handleSizeChange(val) {
  869. this.pageSize = val
  870. this.currentPage = 1
  871. this.handleSearch()
  872. },
  873. // 当前页改变事件
  874. handleCurrentChange(val) {
  875. this.currentPage = val
  876. this.handleSearch()
  877. },
  878. // 删除按钮点击事件
  879. async handleDelete() {
  880. if (this.selectedRows.length === 0) {
  881. this.$message.warning('请先选择要删除的记录')
  882. return
  883. }
  884. this.$confirm('确定要删除选中的记录吗?', '提示', {
  885. confirmButtonText: '确定',
  886. cancelButtonText: '取消',
  887. type: 'warning',
  888. })
  889. .then(async () => {
  890. const ids = this.selectedRows.map((row) => row.id)
  891. const response = await batchDeleteDocumentTemplates({ ids })
  892. if (response.code === 200) {
  893. this.$message.success('删除成功')
  894. // 重新加载数据
  895. this.handleSearch()
  896. // 清空选中状态
  897. this.selectedRows = []
  898. }
  899. })
  900. .catch(() => {
  901. this.$message.info('已取消删除')
  902. })
  903. },
  904. // 复制标签到剪贴板
  905. copyToClipboard(tag) {
  906. const textarea = document.createElement('textarea')
  907. textarea.value = tag
  908. document.body.appendChild(textarea)
  909. textarea.select()
  910. document.execCommand('copy')
  911. document.body.removeChild(textarea)
  912. this.$message.success('标签已复制到剪贴板')
  913. },
  914. // 修改模板相关方法
  915. // 重置表单
  916. resetForm() {
  917. this.activeStep = 0
  918. this.formData = {
  919. documentName: '',
  920. alias: '',
  921. description: '',
  922. dataSourceType: 'database_table',
  923. tableId: 1,
  924. isWh: '1',
  925. type: '',
  926. }
  927. this.uploadedFile = null
  928. this.selectedFile = null
  929. this.fileContent = null
  930. this.tablePreviewData = []
  931. this.tableColumns = []
  932. this.costDocumentTemplateFiles = []
  933. // 重置表单验证
  934. if (this.$refs.basicForm) {
  935. this.$refs.basicForm.resetFields()
  936. }
  937. },
  938. // 处理下一步
  939. handleNextStep() {
  940. this.$refs.basicForm.validate((valid) => {
  941. if (valid) {
  942. if (this.view == 'detail' || this.view == 'edit') {
  943. this.getDocumentData()
  944. this.activeStep = 1
  945. } else {
  946. this.handleSave()
  947. }
  948. } else {
  949. this.$message.error('请填写完整的基础信息')
  950. return false
  951. }
  952. })
  953. },
  954. // 处理上一步
  955. handlePrevStep() {
  956. this.activeStep = 0
  957. this.$message.info('返回基础信息填写')
  958. },
  959. // 处理保存
  960. async handleSave() {
  961. // 准备保存数据
  962. const saveData = {
  963. ...this.formData,
  964. fileUrl: this.formData.fileUrl ? this.formData.fileUrl.join(',') : '',
  965. costDocumentTemplateFiles:
  966. this.costDocumentTemplateFiles.map((item) => {
  967. return {
  968. ...item,
  969. documentId: this.formData.id,
  970. }
  971. }) || [],
  972. }
  973. if (this.activeStep == 1) {
  974. if (!this.formData.fileUrl) {
  975. this.$message.error('请上传文件')
  976. }
  977. }
  978. let response
  979. if (!this.formData.id) {
  980. // 新增
  981. response = await addDocumentTemplate({
  982. ...saveData,
  983. })
  984. this.formData.id = response.value
  985. } else {
  986. // 修改
  987. response = await updateDocumentTemplate({
  988. ...saveData,
  989. id: this.formData.id,
  990. })
  991. }
  992. if (response.code === 200) {
  993. this.$message.success('保存成功')
  994. if (this.activeStep == 1) {
  995. // 保存成功后返回列表
  996. this.backToList()
  997. // 重新加载数据
  998. this.handleSearch()
  999. } else {
  1000. this.activeStep = 1
  1001. }
  1002. } else {
  1003. this.$message.error(response.msg || '保存失败')
  1004. }
  1005. },
  1006. // saveFiles 方法
  1007. saveFiles(data) {
  1008. this.formData.fileUrl = [data[0].savePath]
  1009. this.fileUrl = data[0].savePath
  1010. this.costDocumentTemplateFiles = data[0].bracketContentInfos.map(
  1011. (item) => {
  1012. return {
  1013. ...item,
  1014. labelValue: `{${item.pinyin}}`,
  1015. }
  1016. }
  1017. )
  1018. },
  1019. // removeFile 方法
  1020. removeFile(index, removedFile, currentFiles) {
  1021. this.formData.fileUrl = []
  1022. this.fileUrl = ''
  1023. },
  1024. // 下载文件
  1025. downloadFile() {
  1026. // 在实际项目中,这里应该调用下载API或使用文件URL直接下载
  1027. this.$message.info('文件下载功能已触发')
  1028. },
  1029. },
  1030. }
  1031. </script>
  1032. <style scoped lang="scss">
  1033. @import '@/styles/costAudit.scss';
  1034. /* 标题样式 */
  1035. .supervision-review-doc-manage h2 {
  1036. margin-bottom: 20px;
  1037. font-size: 18px;
  1038. color: #333;
  1039. }
  1040. /* 操作按钮区域样式 */
  1041. .action-buttons {
  1042. margin-bottom: 20px;
  1043. display: flex;
  1044. gap: 10px;
  1045. }
  1046. /* 表格容器样式 */
  1047. .table-container {
  1048. margin-bottom: 20px;
  1049. }
  1050. /* 分页样式 */
  1051. .pagination {
  1052. text-align: right;
  1053. margin-top: 20px;
  1054. }
  1055. /* 操作列按钮样式调整 */
  1056. .el-table .cell {
  1057. white-space: normal;
  1058. word-break: break-all;
  1059. }
  1060. /* 修改视图样式 */
  1061. .edit-view,
  1062. .detail-view {
  1063. max-width: 100%;
  1064. overflow-x: auto;
  1065. }
  1066. .edit-header,
  1067. .detail-header {
  1068. display: flex;
  1069. align-items: center;
  1070. margin-bottom: 20px;
  1071. }
  1072. .back-button {
  1073. margin-right: 20px;
  1074. }
  1075. .steps-container {
  1076. margin-bottom: 20px;
  1077. }
  1078. .step-content {
  1079. overflow-y: auto;
  1080. margin-bottom: 20px;
  1081. .form-container {
  1082. padding: 0 10px;
  1083. }
  1084. .template-config-container {
  1085. .layout-wrapper {
  1086. display: flex;
  1087. gap: 20px;
  1088. }
  1089. .left-panel {
  1090. flex: 1;
  1091. height: 100%;
  1092. }
  1093. .right-panel {
  1094. width: 50%;
  1095. display: flex;
  1096. flex-direction: column;
  1097. }
  1098. .upload-template-btn {
  1099. margin-bottom: 20px;
  1100. background-color: #409eff;
  1101. border-color: #409eff;
  1102. }
  1103. .data-fields-section {
  1104. flex: 1;
  1105. display: flex;
  1106. flex-direction: column;
  1107. .data-fields-title {
  1108. margin-bottom: 15px;
  1109. padding: 10px;
  1110. background-color: #f5f7fa;
  1111. border-radius: 4px;
  1112. font-size: 14px;
  1113. color: #666;
  1114. }
  1115. .el-table {
  1116. flex: 1;
  1117. min-height: 0;
  1118. }
  1119. .tag-item {
  1120. display: inline-block;
  1121. padding: 4px 8px;
  1122. background-color: #ecf5ff;
  1123. color: #409eff;
  1124. border-radius: 4px;
  1125. font-size: 12px;
  1126. }
  1127. }
  1128. }
  1129. }
  1130. /* 修改操作按钮区域居中显示 */
  1131. .edit-actions {
  1132. padding: 15px 0;
  1133. border-top: 1px solid #e4e7ed;
  1134. text-align: center;
  1135. }
  1136. .file-upload-tips {
  1137. margin-bottom: 15px;
  1138. padding: 10px;
  1139. background-color: #f0f9ff;
  1140. border: 1px solid #bae7ff;
  1141. border-radius: 4px;
  1142. color: #096dd9;
  1143. font-size: 14px;
  1144. }
  1145. /* 修改已完成步骤的样式 */
  1146. .el-step.is-finish {
  1147. .el-step__head {
  1148. /* 更改已完成步骤圆圈的背景色为白色 */
  1149. background-color: #ffffff;
  1150. border-color: #409eff;
  1151. /* 修改已完成步骤的数字为√ */
  1152. .el-step__icon-inner {
  1153. /* 隐藏默认的数字 */
  1154. opacity: 0;
  1155. position: relative;
  1156. /* 使用伪元素添加√符号 */
  1157. &::before {
  1158. content: '√';
  1159. opacity: 1;
  1160. position: absolute;
  1161. left: 50%;
  1162. top: 50%;
  1163. transform: translate(-50%, -50%);
  1164. color: #409eff;
  1165. font-weight: bold;
  1166. }
  1167. }
  1168. }
  1169. }
  1170. /* 响应式设计 */
  1171. @media (max-width: 768px) {
  1172. .edit-header,
  1173. .detail-header {
  1174. flex-direction: column;
  1175. align-items: flex-start;
  1176. }
  1177. .back-button {
  1178. margin-bottom: 10px;
  1179. }
  1180. .template-config-container .layout-wrapper {
  1181. flex-direction: column;
  1182. }
  1183. .template-config-container .right-panel {
  1184. width: 100%;
  1185. }
  1186. }
  1187. ::v-deep .el-button.is-disabled {
  1188. background-color: #f9f9f9 !important;
  1189. border-color: #f3f3f4 !important;
  1190. color: #cccccc !important;
  1191. }
  1192. /* 文字按钮样式 */
  1193. .el-button--text.delete-btn {
  1194. color: #f56c6c;
  1195. }
  1196. </style>