From 93f8c736fd50a80a72d633e888e2d65904bcd7fc Mon Sep 17 00:00:00 2001
From: sen <sen@qq.com>
Date: 星期日, 01 二月 2026 18:34:27 +0800
Subject: [PATCH] 修改
---
ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue | 812 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 620 insertions(+), 192 deletions(-)
diff --git a/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue b/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue
index 2f6873e..4210196 100644
--- a/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue
+++ b/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue
@@ -1,214 +1,642 @@
<template>
- <basicContainer >
- <avue-crud
- :option="option"
- :table-loading="pageF.loading"
- :data="tableData"
- :page="page"
- :permission="permissionList"
- :before-open="beforeOpen"
- v-model="form"
- ref="crudRef"
- @row-update="rowUpdate"
- @row-save="rowSave"
- @refresh-change="refreshChange"
- @row-del="rowDel"
- @search-change="searchChange"
- @search-reset="searchReset"
- @selection-change="selectionChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @on-load="onLoad"
- >
+ <basicContainer>
+ <el-tabs v-model="activeAccountSet" @tab-click="handleTabClick">
+ <el-tab-pane label="鐝犳捣姹囩晠" name="0"></el-tab-pane>
+ <el-tab-pane label="骞跨彔鐗╂祦璐告槗" name="1"></el-tab-pane>
+ </el-tabs>
+ <avue-crud :option="option" :table-loading="pageF.loading" :data="tableData" :page="page"
+ :permission="permissionList" :before-open="beforeOpen" v-model="form" ref="crudRef" @row-update="rowUpdate"
+ @row-save="rowSave" @refresh-change="refreshChange" @row-del="rowDel" @search-change="searchChange"
+ @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
+ @size-change="sizeChange" @on-load="onLoad">
<template #menu-left>
- <el-button
- type="success"
- icon="Edit"
- :disabled="pageF.single"
- v-hasPermi="['cwgl:voucherSubjectSetting:edit']"
- @click="handleUpdate">淇敼
+ <el-button type="success" icon="Edit" :disabled="pageF.single" v-hasPermi="['cwgl:voucherSubjectSetting:edit']"
+ @click="handleUpdate">淇敼
</el-button>
- <el-button
- type="danger"
- icon="Delete"
- :disabled="pageF.multiple"
- @click="handleDelete"
- v-hasPermi="['cwgl:voucherSubjectSetting:remove']"
- >鍒犻櫎
+ <el-button type="danger" icon="Delete" :disabled="pageF.multiple" @click="handleDelete"
+ v-hasPermi="['cwgl:voucherSubjectSetting:remove']">鍒犻櫎
</el-button>
- <el-button
- type="warning"
- plain
- icon="Download"
- @click="handleExport"
- v-hasPermi="['cwgl:voucherSubjectSetting:export']"
- >瀵煎嚭
+ <el-button type="warning" plain icon="Download" @click="handleExport"
+ v-hasPermi="['cwgl:voucherSubjectSetting:export']">瀵煎嚭
</el-button>
+ </template>
+ <template #menu="{ row, index, size }">
+ <el-button type="primary" text icon="Plus" @click="handleRowAdd(row)">鏂板瀛愰」</el-button>
</template>
</avue-crud>
</basicContainer>
</template>
<script setup name="voucherSubjectSetting" lang="ts">
- import {VoucherSubjectSettingI,addVoucherSubjectSetting, delVoucherSubjectSetting, exportVoucherSubjectSetting, getVoucherSubjectSetting, listVoucherSubjectSetting, updateVoucherSubjectSetting} from "@/api/cwgl/voucherSubjectSetting";
- import useCurrentInstance from "@/utils/useCurrentInstance";
- import {computed,reactive, ref, toRefs} from "vue";
- import {PagesInterface, PageQueryInterface} from "@/utils/globalInterface";
- import {usePagePlus} from "@/hooks/usePagePlus";
- import {hasPermission} from "@/utils/permissionUtils";
+import { VoucherSubjectSettingI, addVoucherSubjectSetting, delVoucherSubjectSetting, exportVoucherSubjectSetting, getVoucherSubjectSetting, listVoucherSubjectSetting, updateVoucherSubjectSetting } from "@/api/cwgl/voucherSubjectSetting";
+import useCurrentInstance from "@/utils/useCurrentInstance";
+import { computed, reactive, ref, toRefs } from "vue";
+import { PagesInterface, PageQueryInterface } from "@/utils/globalInterface";
+import { usePagePlus } from "@/hooks/usePagePlus";
+import { hasPermission } from "@/utils/permissionUtils";
- const { proxy } = useCurrentInstance();
- const crudRef = ref();
+const { proxy } = useCurrentInstance();
+const crudRef = ref();
- const permissionList = computed(()=>{
- return {
- addBtn: hasPermission(["cwgl:voucherSubjectSetting:add"]),
- delBtn: hasPermission(["cwgl:voucherSubjectSetting:remove"]),
- editBtn: hasPermission(["cwgl:voucherSubjectSetting:edit"]),
- viewBtn: hasPermission(["cwgl:voucherSubjectSetting:query"]),
- }
- })
-
- const data = reactive({
- form:<VoucherSubjectSettingI>{},
- queryParams:<VoucherSubjectSettingI&PageQueryInterface>{},
- page: <PagesInterface>{
- pageSize: 10,
- total: 0,
- currentPage: 1,
+const permissionList = computed(() => {
+ return {
+ addBtn: hasPermission(["cwgl:voucherSubjectSetting:add"]),
+ delBtn: hasPermission(["cwgl:voucherSubjectSetting:remove"]),
+ editBtn: hasPermission(["cwgl:voucherSubjectSetting:edit"]),
+ viewBtn: hasPermission(["cwgl:voucherSubjectSetting:query"]),
+ }
+})
+// 璁板綍鏄惁鏉ヨ嚜琛屽唴鎿嶄綔
+const isFromRow = ref(false);
+const activeAccountSet = ref("0");
+const data = reactive({
+ form: <VoucherSubjectSettingI>{},
+ queryParams: <VoucherSubjectSettingI & PageQueryInterface>{
+ type: "0",
+ accountingItemsContains: [], // 蹇呴』鍒濆鍖栦负鏁扮粍
+ },
+ page: <PagesInterface>{
+ pageSize: 10,
+ total: 0,
+ currentPage: 1,
+ },
+ selectionList: [],
+})
+const { queryParams, form, page, selectionList } = toRefs(data);
+const option = ref({
+ pageKey: 'VoucherSubjectSetting',
+ rowKey: 'id',
+ searchSpan: 5,
+ labelWidth: 150,
+ searchLabelWidth: 120,
+ column: {
+ // id: {
+ // label: '绉戠洰ID11',
+ // },
+ // parentId: {
+ // label: '鐖剁鐩甀D',
+ // },
+ // ancestors: {
+ // label: '绁栫骇鍒楄〃',
+ // type: 'textarea', minRows: 3, maxRows: 5,
+ // },
+ // type: {
+ // label: '甯愬绫诲瀷',
+ // search: true,
+ // minWidth: 120,
+ // type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/sys_accounting_type',
+ // rules: [
+ // {
+ // required: true,
+ // message: "甯愬绫诲瀷涓嶈兘涓虹┖", trigger: "change"
+ // }
+ // ],
+ // },
+ accountSet: {
+ label: '璐﹀',
+ search: true,
+ minWidth: 120,
+ addDisabled: true,
+ editDisabled: true,
+ type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/sys_accounting_type',
+ rules: [
+ {
+ required: true,
+ message: "甯愬绫诲瀷涓嶈兘涓虹┖", trigger: "change"
+ }
+ ],
},
- selectionList:[],
- })
- const {queryParams,form,page,selectionList} = toRefs(data);
- const option = ref({
- pageKey: 'VoucherSubjectSetting',
- rowKey: 'id',
- column: {
- id: {
- label: '绉戠洰ID',
- },
- parentId: {
- label: '鐖剁鐩甀D',
- },
- ancestors: {
- label: '绁栫骇鍒楄〃',
- type: 'textarea', minRows: 3, maxRows: 5,
- },
- accountSet: {
- label: '璐﹀',
- rules: [
- {
- required: true,
- message: "璐﹀涓嶈兘涓虹┖", trigger: "blur" }
- ], },
- subjectCode: {
- label: '绉戠洰浠g爜',
- rules: [
- {
- required: true,
- message: "绉戠洰浠g爜涓嶈兘涓虹┖", trigger: "blur" }
- ], },
- subjectName: {
- label: '绉戠洰鍚嶇О',
- rules: [
- {
- required: true,
- message: "绉戠洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur" }
- ], },
- subjectType: {
- label: '绉戠洰绫诲埆',
- rules: [
- {
- required: true,
- message: "绉戠洰绫诲埆涓嶈兘涓虹┖", trigger: "change"
- }
- ], },
- enabled: {
- label: '鍚敤',
- },
- balanceDirection: {
- label: '浣欓鏂瑰悜',
- rules: [
- {
- required: true,
- message: "浣欓鏂瑰悜涓嶈兘涓虹┖", trigger: "blur" }
- ], },
- accountingItems: {
- label: '鏍哥畻椤圭洰',
- type: 'textarea', minRows: 3, maxRows: 5,
- },
- quantityAmountAccounting: {
- label: '鏁伴噺閲戦鏍哥畻',
- },
- cashSubject: {
- label: '鐜伴噾绉戠洰',
- },
- bankSubject: {
- label: '閾惰绉戠洰',
- },
- cashFlowSubject: {
- label: '鐜伴噾娴侀噺绉戠洰',
- },
- expenseName: {
- label: '璐圭敤鍚嶇О',
- },
- mnemonicCode: {
- label: '鍔╄鐮�',
- },
- foreignCurrencyAccounting: {
- label: '澶栧竵鏍哥畻',
- },
- unitOfMeasurement: {
- label: '璁¢噺鍗曚綅',
- },
- orderNum: {
- label: '鏄剧ず椤哄簭',
- },
- status: {
- label: '鐘舵��',
- },
- delFlag: {
- label: '鍒犻櫎鏍囧織',
- },
- createBy: {
- label: '鍒涘缓鑰�',
- },
- createTime: {
- label: '鍒涘缓鏃堕棿',
- },
- updateBy: {
- label: '鏇存柊鑰�',
- },
- updateTime: {
- label: '鏇存柊鏃堕棿',
- },
- remark: {
- label: '澶囨敞',
- type: 'textarea', minRows: 3, maxRows: 5,
- },
- }
- })
+ // parentSubjectName: {
+ // label: '涓婄骇绉戠洰鍚嶇О2',
+ // minWidth: 150,
- const { tableData,pageF,rowSave,rowUpdate,rowDel,beforeOpen,searchChange,
- searchReset,selectionChange,onLoad,currentChange,sizeChange,handleDelete,handleExport,handleUpdate,refreshChange} = usePagePlus({
- form:form,
- option:option,
- queryParams:queryParams,
- idKey:'id',
- page:page.value,
- getListApi:listVoucherSubjectSetting,
- getDetailApi:getVoucherSubjectSetting,
- exportApi:exportVoucherSubjectSetting,
- deleteApi:delVoucherSubjectSetting,
- addApi:addVoucherSubjectSetting,
- updateApi:updateVoucherSubjectSetting,
- handleUpdateFunc:()=>{
+ // search: true,
+ // rules: [
+ // {
+ // required: true,
+ // message: "绉戠洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"
+ // }
+ // ],
+ // },
+ parentId: {
+ label: '涓婄骇绉戠洰鍚嶇О',
+ prop: 'parentId',
+ type: 'tree',
+ hide: true,
+ dicData: [],
+ props: {
+ label: 'fullName', // 鍏抽敭鐐癸細缁戝畾鎴戜滑棰勫鐞嗗ソ鐨勫叏璺緞瀛楁
+ value: 'id'
+ },
+ addDisabled: true,
+ editDisabled: true,
+ rules: [
+ { required: true, message: "涓婄骇绉戠洰涓嶈兘涓虹┖", trigger: "change" }
+ ]
+ },
+ parentSubjectCode: {
+ label: '涓婄骇绉戠洰浠g爜',
+ minWidth: 150,
+ disabled: true, // 璁剧疆涓虹鐢紝浠呬緵鏌ョ湅
+ // 濡傛灉甯屾湜鍦ㄨ〃鏍间篃鏄剧ず锛岃繖閲屼笉瑕佸啓 hide: true
+ },
+ parentSubjectCode: {
+ label: '涓婄骇绉戠洰浠g爜',
+ minWidth: 150,
+
+ search: true,
+ // rules: [
+ // {
+ // required: true,
+ // message: "绉戠洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"
+ // }
+ // ],
+ },
+ // parentSubjectCode: {
+ // label: '涓婄骇绉戠洰浠g爜',
+ // minWidth: 150,
+ // display: true,
+ // hide: true, // 鍦ㄨ〃鏍煎垪涓殣钘�
+ // search: false, // 鍦ㄦ悳绱㈡爮涓殣钘�
+ // display: true, // 鍦ㄦ柊澧�/淇敼寮圭獥涓樉绀猴紙榛樿涓簍rue锛�
+ // addDisabled: true, // 鏂板鏃剁疆鐏帮紝涓嶅彲缂栬緫
+ // editDisabled: true, // 淇敼鏃剁疆鐏帮紝涓嶅彲缂栬緫
+ // // readonly: true, // 鎴栬�呬娇鐢ㄥ彧璇诲睘鎬э紙鍙栧喅浜� UI 闇�姹傦級
+ // // rules: [
+ // // {
+ // // required: true,
+ // // message: "涓婄骇绉戠洰浠g爜涓嶈兘涓虹┖", trigger: "blur"
+ // // }
+ // // ],
+ // },
+ subjectName: {
+ label: '绉戠洰鍚嶇О',
+ minWidth: 150,
+
+ search: true,
+ rules: [
+ {
+ required: true,
+ message: "绉戠洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"
+ }
+ ],
+ },
+ subjectCode: {
+ label: '绉戠洰浠g爜',
+ minWidth: 150,
+ search: true,
+ rules: [
+ {
+ required: true,
+ message: "绉戠洰浠g爜涓嶈兘涓虹┖", trigger: "blur"
+ }
+ ],
+ },
+ balanceDirection: {
+ label: '浣欓鏂瑰悜',
+ search: true,
+ minWidth: 120,
+ type: 'radio',
+ dicUrl: '/system/dict/data/type/sys_balance_direction',
+ rules: [
+ {
+ required: true,
+ message: "浣欓鏂瑰悜涓嶈兘涓虹┖", trigger: "blur"
+ }
+ ],
+ },
+ enabled: {
+ label: '鏄惁鍚敤',
+ minWidth: 120,
+ type: 'radio', dicUrl: '/system/dict/data/type/sys_whether_type',
+ rules: [
+ {
+ required: true,
+ message: "鏄惁鍚敤涓嶈兘涓虹┖", trigger: "change"
+ }
+ ],
+ search: true,
+ },
+ accountingItemsDesc: {
+ label: '鏍哥畻椤圭洰',
+ minWidth: 150,
+ addDisplay: false,
+ editDisplay: false,
+ },
+ accountingItemsContains: {
+ label: '鏍哥畻椤圭洰1',
+ minWidth: 150,
+ search: true,
+ type: 'select', // 纭繚绫诲瀷涓� select
+ multiple: true, // 寮�鍚閫�
+ addDisplay: false, // 鍦ㄦ柊澧炴椂闅愯棌
+ editDisplay: false,
+ hide: true,
+ dataType: 'string',
+ dicUrl: '/system/dict/data/type/sys_accounting_item_name',
+ placeholder: '璇烽�夋嫨鏍哥畻椤圭洰锛堝彲澶氶�夛級',
+ props: {
+ label: 'dictLabel',
+ value: 'dictValue'
+ }
+ },
+ accountingItems: {
+ label: '鏍哥畻椤圭洰2',
+ minWidth: 150,
+ type: 'select',
+ multiple: true,
+ dicUrl: '/system/dict/data/type/sys_accounting_item_name',
+ placeholder: '璇烽�夋嫨鏍哥畻椤圭洰锛堝彲澶氶�夛級',
+ props: {
+ label: 'dictLabel',
+ value: 'dictValue'
+ },
+ // --- 鍏抽敭淇敼 ---
+ hide: true, // 鍦ㄨ〃鏍煎垪涓殣钘�
+ search: false, // 鍦ㄦ悳绱㈡爮涓殣钘�
+ display: true, // 纭繚鍦ㄥ脊绐楄〃鍗曚腑渚濈劧鏄剧ず锛堥粯璁ゅ嵆涓� true锛�
+ // ----------------
+ minWidth: 150
+ },
+ subjectType: {
+ label: '绉戠洰绫诲埆',
+ minWidth: 150,
+ minWidth: 120,
+ type: 'select', dicUrl: '/system/dict/data/type/sys_subject_category',
+ rules: [
+ {
+ required: true,
+ message: "绉戠洰绫诲埆涓嶈兘涓虹┖", trigger: "change"
+ }
+ ],
+ search: true,
+ },
+ quantityAmountAccounting: {
+ label: '鏁伴噺閲戦鏍哥畻',
+ minWidth: 120,
+ type: 'radio', dicUrl: '/system/dict/data/type/sys_right_wrong',
+ rules: [
+ {
+ required: true,
+ message: "鏁伴噺閲戦鏍哥畻涓嶈兘涓虹┖", trigger: "change"
+ }
+ ],
+ },
+ unitOfMeasurement: {
+ label: '璁¢噺鍗曚綅',
+ minWidth: 150,
+
+ },
+ expenseName: {
+ label: '璐圭敤鍚嶇О',
+ minWidth: 120,
+ type: 'select', dicUrl: '/system/dict/data/type/sys_name_harge',
+ rules: [
+ {
+ required: true,
+ message: "璐圭敤鍚嶇О涓嶈兘涓虹┖", trigger: "change"
+ }
+ ],
+ search: true,
+
+ },
+ mnemonicCode: {
+ label: '鍔╄鐮�',
+ minWidth: 150,
+
+ },
+ foreignCurrencyAccounting: {
+ label: '澶栧竵鏍哥畻',
+ minWidth: 150,
+ type: 'select', dicUrl: '/system/dict/data/type/sys_foreign_verification',
+ },
+ cashSubject: {
+ label: '鐜伴噾绉戠洰',
+ minWidth: 150,
+ type: 'radio', dicUrl: '/system/dict/data/type/sys_right_wrong',
+
+
+ },
+ bankSubject: {
+ label: '閾惰绉戠洰',
+ minWidth: 150,
+ type: 'radio', dicUrl: '/system/dict/data/type/sys_right_wrong',
+
+ },
+ cashFlowSubject: {
+ label: '鐜伴噾娴侀噺绉戠洰',
+ minWidth: 150,
+ type: 'radio', dicUrl: '/system/dict/data/type/sys_right_wrong',
+
+ },
+ contactUnit: {
+ label: '寰�鏉ュ崟浣�',
+ minWidth: 150,
+ type: 'radio', dicUrl: '/system/dict/data/type/sys_right_wrong',
+
+ },
+ department: {
+ label: '閮ㄩ棬',
+ minWidth: 150,
+ type: 'radio', dicUrl: '/system/dict/data/type/sys_right_wrong',
+
+ },
+ productName: {
+ label: '鍝佸悕',
+ minWidth: 150,
+ type: 'radio', dicUrl: '/system/dict/data/type/sys_right_wrong',
+
+ },
+
+
+ // orderNum: {
+ // label: '鏄剧ず椤哄簭',
+ // },
+ // status: {
+ // label: '鐘舵��',
+ // },
+ // delFlag: {
+ // label: '鍒犻櫎鏍囧織',
+ // },
+ // createBy: {
+ // label: '鍒涘缓鑰�',
+ // },
+ // createTime: {
+ // label: '鍒涘缓鏃堕棿',
+ // },
+ // updateBy: {
+ // label: '鏇存柊鑰�',
+ // },
+ // updateTime: {
+ // label: '鏇存柊鏃堕棿',
+ // },
+ // remark: {
+ // label: '澶囨敞',
+ // type: 'textarea', minRows: 3, maxRows: 5,
+ // },
+
+ }
+})
+// sys_accounting_type
+// listVoucherSubjectSetting
+const { tableData, pageF, rowSave, rowUpdate, rowDel, beforeOpen, searchChange,
+ searchReset, selectionChange, onLoad, currentChange, sizeChange, handleDelete, handleExport, handleUpdate, refreshChange } = usePagePlus({
+ form: form,
+ option: option,
+ queryParams: queryParams,
+ idKey: 'id',
+ page: page.value,
+ getListApi: listVoucherSubjectSetting,
+ getDetailApi: getVoucherSubjectSetting,
+ // 銆愬叧閿慨澶嶇偣銆戯細鎷︽埅璇︽儏鎺ュ彛锛屽湪鏁版嵁杩涘叆 form 涔嬪墠瀹屾垚鏍煎紡鍖�
+ getDetailApi: (id: any) => {
+ return getVoucherSubjectSetting(id).then((res: any) => {
+ if (res.code === 200 && res.data) {
+ // 1. 澶勭悊 accountingItems 鏁板瓧杞暟缁�
+ if (typeof res.data.accountingItems === 'number') {
+ res.data.accountingItems = decomposeAccountingItems(res.data.accountingItems);
+ } else if (!res.data.accountingItems) {
+ res.data.accountingItems = [];
+ }
+
+ // 2. 澶勭悊 accountingItemsContains 纭繚鏄暟缁�
+ if (!Array.isArray(res.data.accountingItemsContains)) {
+ res.data.accountingItemsContains = [];
+ }
+
+
+ }
+ return res;
+ });
+ },
+ exportApi: exportVoucherSubjectSetting,
+ deleteApi: delVoucherSubjectSetting,
+ addApi: addVoucherSubjectSetting,
+ updateApi: updateVoucherSubjectSetting,
+ handleUpdateFunc: () => {
+ isFromRow.value = true; // 淇敼鎿嶄綔涔熻涓虹鐢ㄤ笂绾х鐩�
crudRef.value.rowEdit(selectionList.value[0]);
},
- handleSelectionChangeFunc:(selection:any)=>{
+ handleSelectionChangeFunc: (selection: any) => {
selectionList.value = selection;
- }
+ },
+ getBeginListFunc: (params = {}) => {
+ let newParams = { ...params };
+ newParams.type = activeAccountSet.value;
+
+ // 澶勭悊 accountingItems 鍙傛暟
+ if (newParams.accountingItemsContains) {
+ if (Array.isArray(newParams.accountingItemsContains)) {
+ // 濡傛灉鏄暟缁勶紝鎸夊師閫昏緫澶勭悊
+ newParams.accountingItemsContains = newParams.accountingItemsContains.join(',');
+ } else {
+ // 濡傛灉鏄瓧绗︿覆锛屾鏌ユ槸鍚︿负閫楀彿鍒嗛殧鐨勬暟瀛�
+ const itemsStr = String(newParams.accountingItemsContains).trim();
+ if (itemsStr && itemsStr.includes(',')) {
+ // 鍒嗗壊瀛楃涓诧紝杞崲涓烘暟瀛楀苟鐩稿姞
+ const sum = itemsStr
+ .split(',')
+ .map(item => parseInt(item.trim(), 10))
+ .filter(num => !isNaN(num))
+ .reduce((acc, curr) => acc + curr, 0);
+
+ // 浣跨敤鐩稿姞鍚庣殑缁撴灉
+ newParams.accountingItemsContains = sum > 0 ? sum.toString() : '';
+ }
+ }
+ }
+
+ queryParams.value = newParams;
+ return newParams;
+ },
+
+ handleBeforeOpenFunc: (type: string) => {
+ if (!option.value?.column) return;
+
+ const codeCol = option.value.column.parentSubjectCode;
+ const parentIdCol = option.value.column.parentId;
+
+ // --- 1. 瀹氫箟鍚嶇О閫掑綊澶勭悊鍣� ---
+ const formatTreeData = (list: any[], parentName = '') => {
+ return list.map(item => {
+ // 鎷兼帴鍏ㄨ矾寰勶細鐖剁骇鍚嶇О > 褰撳墠鍚嶇О
+ const currentFullName = parentName ? `${parentName} > ${item.subjectName}` : item.subjectName;
+ const newItem = {
+ ...item,
+ fullName: currentFullName
+ };
+ // 濡傛灉鏈夊瓙鑺傜偣锛岀户缁�掑綊
+ if (newItem.children && newItem.children.length > 0) {
+ newItem.children = formatTreeData(newItem.children, currentFullName);
+ }
+ return newItem;
+ });
+ };
+
+ // --- 2. 鍔犺浇骞跺鐞嗗瓧鍏告暟鎹� ---
+ listVoucherSubjectSetting({ type: activeAccountSet.value }).then(res => {
+ // 灏嗘墎骞虫暟鎹浆涓烘爲缁撴瀯 (proxy.handleTree 鏄� Ruoyi 甯哥敤宸ュ叿)
+ const treeData = proxy.handleTree(res.rows, "id", "parentId");
+ // 鎵ц鍏ㄨ矾寰勬嫾鎺�
+ const fullPathTree = formatTreeData(treeData);
+
+ // 缁勫悎鏈�缁堝瓧鍏革紝鍔犲叆鈥滈《绾р�濋�夐」
+ const fullDic = [
+ {
+ id: 0,
+ subjectName: '椤剁骇绉戠洰',
+ fullName: '椤剁骇绉戠洰',
+ children: fullPathTree
+ }
+ ];
+ if (parentIdCol) parentIdCol.dicData = fullDic;
+
+ // 寮傛鍥炶皟涓啀娆$‘淇濅唬鐮佸瓧娈垫樉绀�
+ if (String(form.value.parentId) === "0" || !form.value.parentId) {
+ form.value.parentSubjectCode = "椤剁骇绉戠洰浠g爜";
+ }
+ });
+
+ // --- 3. 澶勭悊涓嶅悓妯″紡涓嬬殑鏄剧ず閫昏緫 ---
+ if (type !== 'add') {
+ // 銆愪慨鏀�/鏌ョ湅銆�
+ if (String(form.value.parentId) === "0" || !form.value.parentId) {
+ form.value.parentSubjectCode = "椤剁骇绉戠洰浠g爜";
+ }
+ if (parentIdCol) { parentIdCol.display = true; parentIdCol.disabled = true; }
+ if (codeCol) { codeCol.display = true; codeCol.disabled = true; }
+ } else {
+ // 銆愭柊澧炪��
+ if (isFromRow.value) {
+ // 琛屽唴鏂板瀛愰」
+ if (parentIdCol) { parentIdCol.display = true; parentIdCol.disabled = true; }
+ if (codeCol) { codeCol.display = true; codeCol.disabled = true; }
+ } else {
+ // 椤堕儴鏂板 (榛樿鏄《绾х鐩�)
+ if (parentIdCol) parentIdCol.display = false;
+ if (codeCol) codeCol.display = false;
+
+ const currentSet = activeAccountSet.value;
+ Object.assign(form.value, {
+ id: undefined,
+ parentId: 0,
+ parentSubjectCode: "鏃�",
+ accountSet: currentSet,
+ type: currentSet,
+ accountingItems: [],
+ enabled: "1"
+ });
+ }
+ }
+
+ // --- 4. 鏍煎紡鍖栧閫夊瓧娈� ---
+ const fieldsToFix = ['accountingItems', 'accountingItemsContains'];
+ fieldsToFix.forEach(field => {
+ const val = form.value[field];
+ if (typeof val === 'number') {
+ form.value[field] = decomposeAccountingItems(val);
+ } else if (!Array.isArray(val)) {
+ form.value[field] = [];
+ }
+ });
+
+ nextTick(() => {
+ isFromRow.value = false;
+ });
+ },
+
+ // 鏂板淇濆瓨鍓嶇殑閫昏緫
+ rowSaveBegin: (row: any, done: any, loading: any) => {
+ processAccountingItems(row);
+ delete row.accountingItemsContains;
+ // 濡傛灉 row 瀵硅薄閲屽甫浜� id锛屾柊澧炴帴鍙e彲鑳戒細鎶ラ敊鎴栧彉鎴愪慨鏀癸紝濡傛灉鏄《閮ㄦ柊澧烇紝纭繚娌℃湁 id
+ if (!isFromRow.value) {
+ delete row.id;
+ }
+ done(row); // 蹇呴』璋冪敤 done 骞朵紶鍏ュ鐞嗗悗鐨� row 鎵嶄細缁х画璇锋眰鎺ュ彛
+ },
+
+ // 淇敼淇濆瓨鍓嶇殑閫昏緫
+ rowUpdateBegin: (row: any, done: any, loading: any) => {
+ processAccountingItems(row);
+ delete row.accountingItemsContains;
+ if (row.parentSubjectCode == "椤剁骇绉戠洰浠g爜") {
+ row.parentSubjectCode = row.subjectCode;
+ }
+ done(row); // 鍚岀悊
+ },
})
+const processAccountingItems = (row: any) => {
+ if (!row.accountingItems) {
+ row.accountingItems = 0;
+ return;
+ }
+ // 1. 濡傛灉宸茬粡鏄暟缁勶紙姝e父澶氶�夌粍浠惰繑鍥炵殑缁撴灉锛�
+ if (Array.isArray(row.accountingItems)) {
+ row.accountingItems = row.accountingItems
+ .map(item => parseInt(String(item), 10))
+ .filter(num => !isNaN(num))
+ .reduce((acc, curr) => acc + curr, 0);
+ }
+ // 2. 濡傛灉鏄�楀彿鍒嗛殧鐨勫瓧绗︿覆
+ else if (typeof row.accountingItems === 'string' && row.accountingItems.includes(',')) {
+ row.accountingItems = row.accountingItems
+ .split(',')
+ .map(item => parseInt(item.trim(), 10))
+ .filter(num => !isNaN(num))
+ .reduce((acc, curr) => acc + curr, 0);
+ }
+ // 3. 濡傛灉宸茬粡鏄暟瀛楋紝淇濇寔涓嶅彉
+ console.log('杞崲鍚庣殑鎻愪氦鍊�:', row.accountingItems);
+};
+const handleTabClick = (tab: any) => {
+ const selectedTabName = tab.props.name;
+ console.log("Tab鐐瑰嚮鐨勫��:", selectedTabName);
+ activeAccountSet.value = selectedTabName;
+ queryParams.value.type = selectedTabName;
+ const nextParams = {
+ ...queryParams.value,
+ type: selectedTabName
+ };
+
+ // 4. 閲嶇疆鍒嗛〉骞跺姞杞�
+ page.value.currentPage = 1;
+ onLoad(page.value, nextParams);
+}
+
+/**
+ * 鎷嗗垎鍑芥暟锛氬皢 3 杞崲涓� ['1', '2']
+ */
+function decomposeAccountingItems(num: number): string[] {
+ const result: string[] = [];
+ let bit = 1;
+ while (bit <= num) {
+ if ((num & bit) === bit) {
+ result.push(bit.toString());
+ }
+ bit <<= 1; // 浣嶇Щ杩愮畻锛岀瓑鍚屼簬 bit *= 2
+ }
+ return result;
+}
+
+/**
+ * 澶勭悊琛屽唴鈥滄柊澧炩�濈偣鍑�
+ */
+const handleRowAdd = (row: any) => {
+ isFromRow.value = true;
+ getVoucherSubjectSetting(row.id).then((res: any) => {
+ if (res.code == 200) {
+ form.value = res.data;
+ form.value.parentId = form.value.id;
+ const num = form.value.accountingItems;
+ form.value.accountingItems = decomposeAccountingItems(num);
+ // 瑙﹀彂 Avue 鐨勫唴缃柊澧炲脊绐�
+ crudRef.value.rowAdd();
+ }
+ });
+
+
+};
</script>
--
Gitblit v1.8.0