index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. <template>
  2. <div class="supervision-content-container content-container">
  3. <div v-if="activeView === 'list'">
  4. <!-- 搜索表单 -->
  5. <div class="search-panel">
  6. <el-form :inline="true" :model="searchForm" class="search-form">
  7. <el-form-item label="监审类别:">
  8. <el-cascader
  9. v-model="searchForm.catalogId"
  10. :options="catalogListOptions"
  11. v-bind="props"
  12. style="width: 100%"
  13. ></el-cascader>
  14. </el-form-item>
  15. <el-form-item label="状态:">
  16. <el-select
  17. v-model="searchForm.status"
  18. placeholder="请选择状态"
  19. clearable
  20. >
  21. <el-option
  22. v-for="item in statusOptions"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value"
  26. ></el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button
  31. type="primary"
  32. icon="el-icon-search"
  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="operation-bar">
  50. <!-- v-region-permission="{
  51. category: 'financeSheetManage',
  52. action: 'add',
  53. }" -->
  54. <el-button
  55. v-region-permission="{
  56. category: 'financeSheetManage',
  57. action: 'add',
  58. }"
  59. plain
  60. type="success"
  61. icon="el-icon-circle-plus"
  62. @click="handleAdd"
  63. >
  64. 添加
  65. </el-button>
  66. <el-button
  67. v-region-permission="{
  68. category: 'financeSheetManage',
  69. action: 'delete',
  70. }"
  71. plain
  72. type="danger"
  73. icon="el-icon-delete"
  74. :disabled="selectedRows.length === 0"
  75. @click="handleBatchDelete"
  76. >
  77. 删除
  78. </el-button>
  79. </div>
  80. <!-- 表格 -->
  81. <div class="table-container">
  82. <CostAuditTable
  83. ref="costAuditTable"
  84. :table-data="tableData"
  85. :columns="tableColumns"
  86. :show-selection="true"
  87. :show-index="true"
  88. :show-pagination="true"
  89. :pagination="pagination"
  90. :loading="loading"
  91. :table-props="{
  92. defaultSort: { prop: 'createTime', order: 'descending' },
  93. }"
  94. @selection-change="handleSelectionChange"
  95. @pagination-change="handlePaginationChange"
  96. >
  97. <template #catalogId="{ row }">
  98. <span class="table-name-link">
  99. {{ getCatalogNames(row) }}
  100. </span>
  101. </template>
  102. <!-- 财务表名称自定义单元格 -->
  103. <template #surveyTemplateName="{ row }">
  104. <span class="table-name-link" @click="handleViewDetail(row)">
  105. {{ row.surveyTemplateName }}
  106. </span>
  107. </template>
  108. <!-- 创建时间自定义单元格 -->
  109. <template #createTime="{ row }">
  110. <div>{{ row.createTime ? row.createTime.split(' ')[0] : '-' }}</div>
  111. <div>{{ row.createTime ? row.createTime.split(' ')[1] : '-' }}</div>
  112. </template>
  113. <!-- 操作列 -->
  114. <template #action="{ row }">
  115. <el-button
  116. v-region-permission="{
  117. category: 'financeSheetManage',
  118. action: 'view',
  119. }"
  120. type="text"
  121. size="mini"
  122. @click="handleViewDetail(row)"
  123. >
  124. 详情
  125. </el-button>
  126. <el-button
  127. v-region-permission="{
  128. category: 'financeSheetManage',
  129. action: 'edit',
  130. targetData: row,
  131. }"
  132. type="text"
  133. size="mini"
  134. @click="handleEdit(row)"
  135. >
  136. 修改
  137. </el-button>
  138. <el-button
  139. v-region-permission="{
  140. category: 'financeSheetManage',
  141. action: 'delete',
  142. targetData: row,
  143. }"
  144. class="delete-btn"
  145. type="text"
  146. size="mini"
  147. @click="handleDelete(row)"
  148. >
  149. 删除
  150. </el-button>
  151. <el-dropdown
  152. v-region-permission="{
  153. category: 'financeSheetManage',
  154. action: 'edit',
  155. targetData: row,
  156. }"
  157. class="ml10"
  158. trigger="click"
  159. >
  160. <el-button type="text" size="mini">
  161. 更多
  162. <i class="el-icon-arrow-down el-icon--right"></i>
  163. </el-button>
  164. <el-dropdown-menu slot="dropdown">
  165. <el-dropdown-item
  166. v-region-permission="{
  167. category: 'financeSheetManage',
  168. action: 'edit',
  169. targetData: row,
  170. }"
  171. @click.native="handleDropdownCommand('infoMaintain', row)"
  172. >
  173. 内容维护
  174. </el-dropdown-item>
  175. <el-dropdown-item
  176. v-region-permission="{
  177. category: 'financeSheetManage',
  178. action: 'edit',
  179. targetData: row,
  180. }"
  181. @click.native="handleDropdownCommand('status', row)"
  182. >
  183. {{ row.status === '0' ? '停用' : '启用' }}
  184. </el-dropdown-item>
  185. </el-dropdown-menu>
  186. </el-dropdown>
  187. </template>
  188. </CostAuditTable>
  189. </div>
  190. </div>
  191. <div v-if="activeView === 'infoMaintain'">
  192. <InfoMaintain
  193. ref="infoMaintain"
  194. @back="activeView = $event"
  195. ></InfoMaintain>
  196. </div>
  197. <!-- 添加/修改弹窗 -->
  198. <CostAuditDialog
  199. :title="dialogTitle"
  200. :visible.sync="dialogVisible"
  201. width="500px"
  202. :close-on-click-modal="false"
  203. :show-confirm-btn="dialogTitle !== '查看财务数据表'"
  204. :cancel-text="dialogTitle === '查看财务数据表' ? '关 闭' : '取 消'"
  205. :confirm-loading="submitLoading"
  206. @confirm="submitForm"
  207. @cancel="handleDialogCancel"
  208. @close="handleDialogClose"
  209. >
  210. <CostAuditForm
  211. ref="dataForm"
  212. form-type="dialog"
  213. :form-data="formData"
  214. :form-items="dialogFormItems"
  215. :rules="rules"
  216. :show-action-buttons="false"
  217. :label-width="'160px'"
  218. :form-props="{ disabled: dialogTitle === '查看财务数据表' }"
  219. @update:form-data="(val) => (formData = val)"
  220. >
  221. <template #catalogId>
  222. <el-cascader
  223. v-model="formData.catalogId"
  224. :options="catalogListOptions"
  225. v-bind="props"
  226. style="width: 100%"
  227. @change="handleCatalogChange"
  228. ></el-cascader>
  229. </template>
  230. <template #surveyTemplateName>
  231. <el-input
  232. v-model="formData.surveyTemplateName"
  233. v-pinyin-abbreviation="{
  234. target: 'formData.surveyTemplateNameYw',
  235. }"
  236. placeholder="请输入财务表名称"
  237. />
  238. </template>
  239. <template #surveyTemplateNameYw>
  240. <el-input
  241. v-model="formData.surveyTemplateNameYw"
  242. placeholder="请输入财务表英文名称"
  243. />
  244. </template>
  245. <template #templateType>
  246. <el-radio v-model="formData.templateType" label="1">单记录</el-radio>
  247. <el-radio v-model="formData.templateType" label="2">固定表</el-radio>
  248. <el-radio v-model="formData.templateType" label="3">动态表</el-radio>
  249. </template>
  250. <!-- <template #storageTable>
  251. <el-input
  252. v-model="formData.storageTable"
  253. placeholder="请输入财务表数据存储库表"
  254. />
  255. </template> -->
  256. <template #remarks>
  257. <el-input v-model="formData.remarks" type="textarea"
  258. placeholder="请输入说明,填写财务表的业务说明、填报指引等内容" type:
  259. rows='4' maxlength="200" />
  260. </template>
  261. </CostAuditForm>
  262. </CostAuditDialog>
  263. </div>
  264. </template>
  265. <script>
  266. import CostAuditTable from '@/components/costAudit/CostAuditTable.vue'
  267. import CostAuditForm from '@/components/costAudit/CostAuditForm.vue'
  268. import CostAuditDialog from '@/components/costAudit/CostAuditDialog.vue'
  269. import {
  270. getSurveyFdTemplate,
  271. addSurveyFdTemplate,
  272. delSurveyFdTemplateById,
  273. delSurveyFdTemplates,
  274. getSurveyFdList,
  275. editSurveyFdForm,
  276. changeSurveyFdStatus,
  277. } from '@/api/costSurveyFdTemplate'
  278. import { getCatalogDetail } from '@/api/catalogManage'
  279. import InfoMaintain from './infoMaintain.vue'
  280. import { catalogMixin, commonMixin } from '@/mixins/useDict'
  281. export default {
  282. name: 'FinanceSheetManage',
  283. components: {
  284. CostAuditTable,
  285. CostAuditForm,
  286. CostAuditDialog,
  287. InfoMaintain,
  288. },
  289. // 使用混入
  290. mixins: [catalogMixin, commonMixin],
  291. data() {
  292. return {
  293. activeView: 'list',
  294. // 搜索表单
  295. searchForm: {
  296. catalogId: '',
  297. contentType: '',
  298. status: '',
  299. },
  300. // 表格数据
  301. tableData: [],
  302. // 分页信息
  303. pagination: {
  304. currentPage: 1,
  305. pageSize: 50,
  306. total: 0,
  307. },
  308. // 加载状态
  309. loading: false,
  310. submitLoading: false,
  311. // 选中行
  312. selectedRows: [],
  313. // 弹窗相关
  314. dialogVisible: false,
  315. dialogTitle: '',
  316. isEdit: false,
  317. formData: {
  318. catalogId: '',
  319. contentType: '',
  320. surveyTemplateName: '',
  321. surveyTemplateNameYw: '',
  322. templateType: '1',
  323. storageTable: '',
  324. remarks: '',
  325. },
  326. CatalogNameMap: {},
  327. currentRow: null,
  328. // 表单验证规则
  329. rules: {
  330. catalogId: [
  331. { required: true, message: '请选择监审类别', trigger: 'change' },
  332. ],
  333. surveyTemplateName: [
  334. { required: true, message: '请输入财务表名称', trigger: 'blur' },
  335. { max: 50, message: '长度不能超过50个字符', trigger: 'blur' },
  336. ],
  337. surveyTemplateNameYw: [
  338. {
  339. required: true,
  340. message: '请输入财务表英文名称',
  341. trigger: 'blur',
  342. },
  343. { max: 30, message: '长度不能超过30个字符', trigger: 'blur' },
  344. {
  345. pattern: /^[a-zA-Z0-9_]+$/,
  346. message: '请输入字母或数字或下划线',
  347. trigger: 'blur',
  348. },
  349. ],
  350. storageTable: [
  351. {
  352. required: true,
  353. message: '请选择数据存储表名称',
  354. trigger: 'change',
  355. },
  356. ],
  357. },
  358. // -1草稿,0启用,1停用
  359. statusOptions: [
  360. { value: '-1', label: '草稿' },
  361. { value: '0', label: '启用' },
  362. { value: '1', label: '停用' },
  363. ],
  364. props: {
  365. filterable: true,
  366. placeholder: '请选择监审类别',
  367. style: 'width: 100%',
  368. showAllLevels: false,
  369. props: {
  370. multiple: false,
  371. children: 'children',
  372. checkStrictly: false,
  373. label: 'catalogName',
  374. value: 'id',
  375. emitPath: false,
  376. },
  377. },
  378. }
  379. },
  380. computed: {
  381. // 对话框表单项配置
  382. dialogFormItems() {
  383. return [
  384. {
  385. prop: 'catalogId',
  386. label: '监审类别:',
  387. type: 'cascader',
  388. slotName: 'catalogId',
  389. props: {
  390. placeholder: '请选择监审类别',
  391. style: { width: '100%' },
  392. },
  393. options: this.catalogIdOptions,
  394. },
  395. {
  396. prop: 'surveyTemplateName',
  397. label: '财务表名称:',
  398. type: 'input',
  399. props: {
  400. placeholder: '请输入财务表名称',
  401. },
  402. slotName: 'surveyTemplateName',
  403. },
  404. {
  405. prop: 'surveyTemplateNameYw',
  406. label: '财务表英文名称:',
  407. type: 'input',
  408. props: {
  409. placeholder: '请输入财务表英文名称',
  410. },
  411. slotName: 'surveyTemplateNameYw',
  412. },
  413. {
  414. prop: 'templateType',
  415. label: '表单样式:',
  416. slotName: 'templateType',
  417. },
  418. // {
  419. // prop: 'storageTable',
  420. // label: '财务表数据存储库表:',
  421. // type: 'input',
  422. // slotName: 'storageTable',
  423. // },
  424. {
  425. prop: 'remarks',
  426. label: '说明:',
  427. type: 'input',
  428. slotName: 'remarks',
  429. props: {
  430. type: 'textarea',
  431. rows: 4,
  432. maxlength: 200,
  433. placeholder: '请输入说明,填写财务表的业务说明、填报指引等内容',
  434. },
  435. },
  436. ]
  437. },
  438. // 表格列配置
  439. tableColumns() {
  440. return [
  441. {
  442. prop: 'catalogId',
  443. label: '监审类别',
  444. slotName: 'catalogId',
  445. },
  446. {
  447. prop: 'surveyTemplateName',
  448. label: '财务表名称',
  449. slotName: 'surveyTemplateName',
  450. },
  451. {
  452. prop: 'templateType',
  453. label: '模版类型',
  454. width: '100px',
  455. formatter: (row) => {
  456. return row.templateType == '1'
  457. ? '单记录'
  458. : row.templateType == '2'
  459. ? '固定表'
  460. : '动态表'
  461. },
  462. },
  463. // {
  464. // prop: 'storageTable',
  465. // label: '财务表数据存储表',
  466. // },
  467. {
  468. prop: 'status',
  469. label: '状态',
  470. width: '100px',
  471. formatter: (row) => {
  472. return row.status == '-1'
  473. ? '草稿'
  474. : row.status == '0'
  475. ? '启用'
  476. : '停用'
  477. },
  478. },
  479. {
  480. prop: 'createTime',
  481. label: '创建时间',
  482. slotName: 'createTime',
  483. width: '120px',
  484. sortable: true,
  485. },
  486. {
  487. prop: 'action',
  488. label: '操作',
  489. width: 240,
  490. align: 'center',
  491. fixed: 'right',
  492. slotName: 'action',
  493. },
  494. ]
  495. },
  496. },
  497. mounted() {
  498. if (!this.$permission.isAdminOrProvince()) {
  499. this.tableColumns.splice(this.tableColumns.length - 1, 1)
  500. }
  501. // 初始加载数据
  502. this.handleSearch()
  503. },
  504. methods: {
  505. handleCatalogChange(val) {
  506. // 设置表单数据
  507. this.$set(this.formData, 'catalogId', val)
  508. console.log(this.formData.catalogId)
  509. this.$nextTick(() => {
  510. if (this.$refs.dataForm && this.$refs.dataForm.$refs.formRef) {
  511. this.$refs.dataForm.$refs.formRef.clearValidate('catalogId')
  512. }
  513. })
  514. },
  515. // 初始化表单选项
  516. initFormOptions() {
  517. // 将选项数据同步到表单配置中
  518. this.searchFormItems[0].options = this.catalogIdOptions
  519. this.searchFormItems[1].options = this.contentTypeOptions
  520. this.searchFormItems[2].options = this.statusOptions
  521. this.dialogFormItems[0].options = this.catalogIdOptions
  522. this.dialogFormItems[1].options = this.contentTypeOptions
  523. this.dialogFormItems[4].options = this.storageTableOptions
  524. },
  525. // 加载选择器数据
  526. loadOpts() {},
  527. // 搜索
  528. handleSearch() {
  529. this.loading = true
  530. const params = {
  531. catalogId: this.searchForm.catalogId,
  532. page: this.pagination.currentPage,
  533. pageSize: this.pagination.pageSize,
  534. }
  535. getSurveyFdList(params)
  536. .then((res) => {
  537. if (res.rows.length > 0) {
  538. this.tableData = res.rows || []
  539. this.pagination.total = res.total || 0
  540. this.batchGetCatalogNames()
  541. }
  542. })
  543. .catch((error) => {
  544. console.error('搜索失败:', error)
  545. })
  546. .finally(() => {
  547. this.loading = false
  548. })
  549. },
  550. // 重置
  551. handleReset() {
  552. this.searchForm = {
  553. catalogId: '',
  554. contentType: '',
  555. status: '',
  556. }
  557. this.pagination.currentPage = 1
  558. this.handleSearch()
  559. },
  560. // 添加
  561. handleAdd() {
  562. this.getstorageTableOpt()
  563. this.dialogTitle = '添加财务数据表'
  564. this.isEdit = false
  565. this.formData = {
  566. catalogId: '',
  567. contentType: '',
  568. surveyTemplateName: '',
  569. surveyTemplateNameYw: '',
  570. templateType: '1',
  571. storageTable: '',
  572. remarks: '',
  573. }
  574. this.dialogVisible = true
  575. },
  576. getstorageTableOpt() {
  577. // getstorageTableOptions().then((res) => {
  578. // this.storageTableOptions = res.value
  579. // this.dialogFormItems[4].options = res.value
  580. // })
  581. },
  582. getCatalogNames(row) {
  583. if (!row.catalogId) return ''
  584. return row.catalogId
  585. .split(',')
  586. .map((id) => {
  587. const trimId = id.trim()
  588. return this.CatalogNameMap[trimId] || '未知名称'
  589. })
  590. .join(',')
  591. },
  592. // 获取监审类别名称
  593. batchGetCatalogNames() {
  594. this.tableData.forEach((row) => {
  595. const catalogIds = row.catalogId.split(',').map((id) => id.trim())
  596. catalogIds.forEach((catalogId) => {
  597. if (!catalogId) return
  598. getCatalogDetail(catalogId)
  599. .then((res) => {
  600. if (res && res.value && res.value.catalogName) {
  601. this.$set(
  602. this.CatalogNameMap,
  603. catalogId,
  604. res.value.catalogName
  605. )
  606. } else {
  607. this.$set(this.CatalogNameMap, catalogId, '无名称')
  608. }
  609. })
  610. .catch((err) => {
  611. console.error('获取获取失败', catalogId, err)
  612. this.$set(this.CatalogNameMap, catalogId, '获取失败')
  613. })
  614. })
  615. })
  616. },
  617. // 批量删除
  618. handleBatchDelete() {
  619. if (this.selectedRows.length === 0) {
  620. this.$message.warning('请先选择要删除的数据')
  621. return
  622. }
  623. this.$confirm(
  624. `确定要删除选中的 ${this.selectedRows.length} 条数据吗?`,
  625. '删除确认',
  626. {
  627. confirmButtonText: '确定',
  628. cancelButtonText: '取消',
  629. type: 'warning',
  630. }
  631. ).then(() => {
  632. const ids = this.selectedRows.map((row) => row.surveyTemplateId)
  633. this.loading = true
  634. delSurveyFdTemplates(ids)
  635. .then((res) => {
  636. if (res.code === 200) {
  637. this.$message.success('批量删除成功')
  638. this.selectedRows = []
  639. this.handleSearch()
  640. }
  641. })
  642. .catch((error) => {
  643. console.error('批量删除失败:', error)
  644. })
  645. .finally(() => {
  646. this.loading = false
  647. })
  648. })
  649. },
  650. // 表格选择变化
  651. handleSelectionChange(selection) {
  652. this.selectedRows = selection
  653. },
  654. // 查看详情
  655. handleViewDetail(row) {
  656. // 处理级联选择器多选回显数据
  657. // const result = this.formatRelatedItemsForDisplay({
  658. // catalogId: {
  659. // value: row.catalogId,
  660. // options: this.catalogListOptions,
  661. // id: 'id',
  662. // parentId: 'parentId',
  663. // },
  664. // })
  665. this.dialogVisible = true
  666. this.dialogTitle = `查看财务数据表`
  667. this.formData = {
  668. ...row,
  669. // catalogId: result.catalogId ? result.catalogId : [],
  670. }
  671. },
  672. // 修改
  673. handleEdit(row) {
  674. // 处理级联选择器多选回显数据
  675. // const result = this.formatRelatedItemsForDisplay({
  676. // catalogId: {
  677. // value: row.catalogId,
  678. // options: this.catalogListOptions,
  679. // id: 'id',
  680. // parentId: 'parentId',
  681. // },
  682. // })
  683. this.dialogTitle = '修改财务数据表'
  684. this.isEdit = true
  685. this.formData = {
  686. ...row,
  687. // catalogId: result.catalogId ? result.catalogId : [],
  688. }
  689. this.dialogVisible = true
  690. },
  691. // 删除
  692. handleDelete(row) {
  693. this.$confirm(
  694. `确定要删除 "${row.surveyTemplateName}" 吗?`,
  695. '删除确认',
  696. {
  697. confirmButtonText: '确定',
  698. cancelButtonText: '取消',
  699. type: 'warning',
  700. }
  701. ).then(() => {
  702. this.loading = true
  703. delSurveyFdTemplateById({ id: row.surveyTemplateId })
  704. .then((res) => {
  705. if (res.code === 200) {
  706. this.$message.success('删除成功')
  707. this.handleSearch()
  708. }
  709. })
  710. .catch((error) => {
  711. console.error('删除失败:', error)
  712. })
  713. .finally(() => {
  714. this.loading = false
  715. })
  716. })
  717. },
  718. // 下拉菜单命令处理
  719. handleDropdownCommand(command, row) {
  720. // infoMaintain
  721. switch (command) {
  722. case 'infoMaintain':
  723. // this.currentRow = row
  724. this.activeView = 'infoMaintain'
  725. this.$nextTick(() => {
  726. this.$refs.infoMaintain.getTemplateRow(row)
  727. })
  728. break
  729. case 'status':
  730. this.handleStatus(row)
  731. break
  732. default:
  733. break
  734. }
  735. },
  736. // 启动/停用状态
  737. handleStatus(row) {
  738. const action = row.status === '0' ? '停用' : '启用'
  739. this.$confirm(`确认要${action}该数据吗?`, '操作确认', {
  740. confirmButtonText: '确定',
  741. cancelButtonText: '取消',
  742. type: 'warning',
  743. })
  744. .then(() => {
  745. changeSurveyFdStatus(row.surveyTemplateId)
  746. .then((res) => {
  747. if (res.code === 200) {
  748. this.$message.success(`${action}成功`)
  749. this.handleSearch()
  750. }
  751. })
  752. .catch(() => {})
  753. })
  754. .catch(() => {
  755. this.$message({
  756. type: 'info',
  757. message: '已取消操作',
  758. })
  759. })
  760. },
  761. // 分页变化处理
  762. handlePaginationChange({ currentPage, pageSize }) {
  763. this.pagination.currentPage = currentPage
  764. this.pagination.pageSize = pageSize
  765. this.handleSearch()
  766. },
  767. // 弹窗关闭处理
  768. handleDialogClose() {
  769. // 重置表单验证状态
  770. if (this.$refs.dataForm) {
  771. this.$refs.dataForm.$refs.formRef.resetFields()
  772. }
  773. },
  774. // 弹窗取消处理
  775. handleDialogCancel() {
  776. this.dialogVisible = false
  777. },
  778. // 提交表单
  779. submitForm() {
  780. if (this.dialogTitle === '查看财务数据表') {
  781. return
  782. }
  783. // 处理级联选择器多选数据
  784. // const resultData = this.extractLastLevelValues({
  785. // catalogId: this.formData.catalogId,
  786. // })
  787. const data = {
  788. ...this.formData,
  789. // ...resultData,
  790. }
  791. this.$refs.dataForm
  792. .validate()
  793. .then(() => {
  794. this.submitLoading = true
  795. if (this.isEdit) {
  796. // 修改
  797. editSurveyFdForm(data)
  798. .then((res) => {
  799. if (res.code === 200) {
  800. this.$message.success('修改成功')
  801. this.dialogVisible = false
  802. this.handleSearch()
  803. }
  804. })
  805. .catch((error) => {
  806. console.error('修改失败:', error)
  807. })
  808. .finally(() => {
  809. this.submitLoading = false
  810. })
  811. } else {
  812. addSurveyFdTemplate(data)
  813. .then((res) => {
  814. if (res.code === 200) {
  815. this.$message.success('添加成功')
  816. this.dialogVisible = false
  817. this.handleSearch()
  818. }
  819. })
  820. .catch((error) => {
  821. console.error('添加失败:', error)
  822. })
  823. .finally(() => {
  824. this.submitLoading = false
  825. })
  826. }
  827. })
  828. .catch((error) => {
  829. console.error('表单验证失败:', error)
  830. })
  831. },
  832. },
  833. }
  834. </script>
  835. <style scoped lang="scss">
  836. @import '@/styles/costAudit.scss';
  837. </style>