index.vue 26 KB

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