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 | 242 +++++++++++++++++++++++++++++------------------
1 files changed, 148 insertions(+), 94 deletions(-)
diff --git a/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue b/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue
index 019080b..4210196 100644
--- a/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue
+++ b/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue
@@ -53,6 +53,7 @@
form: <VoucherSubjectSettingI>{},
queryParams: <VoucherSubjectSettingI & PageQueryInterface>{
type: "0",
+ accountingItemsContains: [], // 蹇呴』鍒濆鍖栦负鏁扮粍
},
page: <PagesInterface>{
pageSize: 10,
@@ -106,62 +107,50 @@
],
},
// parentSubjectName: {
-
-
- // label: '涓婄骇绉戠洰鍚嶇О',
- // prop: 'parentSubjectCode',
- // type: 'cascader', // 绾ц仈閫夋嫨鍣�
- // dataType: 'string',
- // // dicUrl: '/api/cwgl/subject/tree',
- // placeholder: '璇烽�夋嫨涓婄骇绉戠洰鍚嶇О',
-
- // // --- 鎺у埗鏄剧ず閫昏緫 ---
- // hide: true, // 鍦ㄨ〃鏍煎垪涓殣钘�
- // search: false, // 鍦ㄦ悳绱㈡爮涓殣钘�
- // display: true, // 鍦ㄦ柊澧�/淇敼寮圭獥涓樉绀猴紙榛樿涓簍rue锛�
- // // --------------------
-
- // filterable: true, // 寮�鍚悳绱㈣繃婊�
- // checkStrictly: true, // 鍏佽閫夋嫨浠绘剰涓�绾э紙鍙�夌埗绾э級
- // emitPath: false, // 鎻愪氦鏃跺彧淇濈暀鏈�鍚庝竴绾х殑鍊�
- // props: {
- // label: 'name',
- // value: 'code',
- // children: 'children'
- // },
+ // label: '涓婄骇绉戠洰鍚嶇О2',
// minWidth: 150,
- // // rules: [
- // // {
- // // required: true,
- // // message: "涓婄骇绉戠洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"
- // // }
- // // ],
- // /* */
+ // search: true,
+ // rules: [
+ // {
+ // required: true,
+ // message: "绉戠洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"
+ // }
+ // ],
// },
- parentSubjectName: {
+ parentId: {
label: '涓婄骇绉戠洰鍚嶇О',
- minWidth: 150,
-
- search: true,
+ prop: 'parentId',
+ type: 'tree',
+ hide: true,
+ dicData: [],
+ props: {
+ label: 'fullName', // 鍏抽敭鐐癸細缁戝畾鎴戜滑棰勫鐞嗗ソ鐨勫叏璺緞瀛楁
+ value: 'id'
+ },
+ addDisabled: true,
+ editDisabled: true,
rules: [
- {
- required: true,
- message: "绉戠洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"
- }
- ],
+ { 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"
- }
- ],
+ // rules: [
+ // {
+ // required: true,
+ // message: "绉戠洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"
+ // }
+ // ],
},
// parentSubjectCode: {
// label: '涓婄骇绉戠洰浠g爜',
@@ -256,7 +245,6 @@
minWidth: 150,
type: 'select',
multiple: true,
- dataType: 'string',
dicUrl: '/system/dict/data/type/sys_accounting_item_name',
placeholder: '璇烽�夋嫨鏍哥畻椤圭洰锛堝彲澶氶�夛級',
props: {
@@ -390,7 +378,7 @@
}
})
// sys_accounting_type
-
+// listVoucherSubjectSetting
const { tableData, pageF, rowSave, rowUpdate, rowDel, beforeOpen, searchChange,
searchReset, selectionChange, onLoad, currentChange, sizeChange, handleDelete, handleExport, handleUpdate, refreshChange } = usePagePlus({
form: form,
@@ -400,6 +388,27 @@
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,
@@ -440,59 +449,101 @@
queryParams.value = newParams;
return newParams;
},
- handleBeforeOpenFunc: (type: string) => {
- if (!option.value?.column) return;
- const nameCol = option.value.column.parentSubjectName;
- const codeCol = option.value.column.parentSubjectCode;
+ handleBeforeOpenFunc: (type: string) => {
+ if (!option.value?.column) return;
- // --- 1. 鏂板閫昏緫淇敼 ---
- if (type === 'add') {
- if (isFromRow.value) {
- // 琛屽唴鈥滄柊澧炲瓙椤光�濈偣鍑�
- nameCol.disabled = true;
- codeCol.disabled = true;
- option.value.saveBtnText = '鏂板';
-
- // 璧嬪�煎綋鍓嶉〉绛剧殑璐﹀锛堣櫧鐒惰鍐呮柊澧為�氬父浼氬甫鍏ョ埗绾ц处濂楋紝浣嗚繖閲屾樉寮忓悓姝ヤ竴娆★級
- form.value.accountSet = activeAccountSet.value;
- } else {
- // 椤堕儴鈥滄柊澧炩�濇寜閽偣鍑�
- nameCol.disabled = false;
- codeCol.disabled = false;
- option.value.saveBtnText = '淇� 瀛�';
-
- // 銆愬叧閿慨澶嶃�戝厛娓呯┖鍙兘娈嬬暀鐨勬棫鏁版嵁锛堝 ID銆佺鐩唬鐮佺瓑锛�
- Object.keys(form.value).forEach(key => delete form.value[key]);
-
- // 銆愭牳蹇冭姹傘�戝皢椤电鐨勫�艰祴鍊肩粰琛ㄥ崟璐﹀瀛楁
- form.value.accountSet = activeAccountSet.value;
- form.value.type = activeAccountSet.value;
+ const codeCol = option.value.column.parentSubjectCode;
+ const parentIdCol = option.value.column.parentId;
-
- // 鍒濆鍖栧叾浠栧繀瑕佸瓧娈�
- form.value.accountingItems = [];
- form.value.enabled = "1"; // 榛樿鍚敤
- }
- }
+ // --- 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. 淇敼/鏌ョ湅閫昏緫锛堜繚鎸佸師鏍凤級 ---
- else if (type === 'edit' || type === 'view') {
- nameCol.disabled = true;
- codeCol.disabled = true;
- option.value.updateBtnText = '淇� 鏀�';
+ // --- 2. 鍔犺浇骞跺鐞嗗瓧鍏告暟鎹� ---
+ listVoucherSubjectSetting({ type: activeAccountSet.value }).then(res => {
+ // 灏嗘墎骞虫暟鎹浆涓烘爲缁撴瀯 (proxy.handleTree 鏄� Ruoyi 甯哥敤宸ュ叿)
+ const treeData = proxy.handleTree(res.rows, "id", "parentId");
+ // 鎵ц鍏ㄨ矾寰勬嫾鎺�
+ const fullPathTree = formatTreeData(treeData);
- if (typeof form.value.accountingItems === 'number') {
- form.value.accountingItems = decomposeAccountingItems(form.value.accountingItems);
- } else if (!form.value.accountingItems) {
- form.value.accountingItems = [];
- }
- }
+ // 缁勫悎鏈�缁堝瓧鍏革紝鍔犲叆鈥滈《绾р�濋�夐」
+ const fullDic = [
+ {
+ id: 0,
+ subjectName: '椤剁骇绉戠洰',
+ fullName: '椤剁骇绉戠洰',
+ children: fullPathTree
+ }
+ ];
+ if (parentIdCol) parentIdCol.dicData = fullDic;
- nextTick(() => {
- isFromRow.value = false;
- });
-},
+ // 寮傛鍥炶皟涓啀娆$‘淇濅唬鐮佸瓧娈垫樉绀�
+ 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) => {
@@ -509,6 +560,9 @@
rowUpdateBegin: (row: any, done: any, loading: any) => {
processAccountingItems(row);
delete row.accountingItemsContains;
+ if (row.parentSubjectCode == "椤剁骇绉戠洰浠g爜") {
+ row.parentSubjectCode = row.subjectCode;
+ }
done(row); // 鍚岀悊
},
})
--
Gitblit v1.8.0