index.vue 25 KB

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