From 48032a9bf0b5e560fd438ae7ba12ad6f4c8183ed Mon Sep 17 00:00:00 2001
From: wujianwei <wjw@11.com>
Date: 星期一, 02 二月 2026 16:16:45 +0800
Subject: [PATCH] 新增日志
---
ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue | 337 ++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 221 insertions(+), 116 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..dc1f8f9 100644
--- a/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue
+++ b/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue
@@ -10,12 +10,12 @@
@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']"
+ <!-- <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>
+ </el-button> -->
<el-button type="warning" plain icon="Download" @click="handleExport"
v-hasPermi="['cwgl:voucherSubjectSetting:export']">瀵煎嚭
</el-button>
@@ -53,6 +53,7 @@
form: <VoucherSubjectSettingI>{},
queryParams: <VoucherSubjectSettingI & PageQueryInterface>{
type: "0",
+ accountingItemsContains: [], // 蹇呴』鍒濆鍖栦负鏁扮粍
},
page: <PagesInterface>{
pageSize: 10,
@@ -65,6 +66,10 @@
const option = ref({
pageKey: 'VoucherSubjectSetting',
rowKey: 'id',
+ tree: true, // 寮�鍚爲褰㈣〃鏍兼ā寮�
+ childrenHandler: 'children', // 鎸囧畾瀛愯妭鐐瑰瓧娈靛悕锛岄粯璁や负 children
+ expandAll: true, // 鏄惁榛樿灞曞紑鎵�鏈夎
+ viewBtn: false,
searchSpan: 5,
labelWidth: 150,
searchLabelWidth: 120,
@@ -91,10 +96,10 @@
// }
// ],
// },
+
accountSet: {
label: '璐﹀',
- search: true,
- minWidth: 120,
+ minWidth: 220,
addDisabled: true,
editDisabled: true,
type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/sys_accounting_type',
@@ -106,62 +111,49 @@
],
},
// 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,
-
- search: true,
- rules: [
- {
- required: true,
- message: "绉戠洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"
- }
- ],
+ disabled: true, // 璁剧疆涓虹鐢紝浠呬緵鏌ョ湅
+ // 濡傛灉甯屾湜鍦ㄨ〃鏍间篃鏄剧ず锛岃繖閲屼笉瑕佸啓 hide: true
+ },
+ parentSubjectCode: {
+ label: '涓婄骇绉戠洰浠g爜',
+ minWidth: 150,
+ hide: true,
+ // rules: [
+ // {
+ // required: true,
+ // message: "绉戠洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"
+ // }
+ // ],
},
// parentSubjectCode: {
// label: '涓婄骇绉戠洰浠g爜',
@@ -235,7 +227,7 @@
editDisplay: false,
},
accountingItemsContains: {
- label: '鏍哥畻椤圭洰1',
+ label: '鏍哥畻椤圭洰',
minWidth: 150,
search: true,
type: 'select', // 纭繚绫诲瀷涓� select
@@ -252,11 +244,10 @@
}
},
accountingItems: {
- label: '鏍哥畻椤圭洰2',
+ label: '鏍哥畻椤圭洰',
minWidth: 150,
type: 'select',
multiple: true,
- dataType: 'string',
dicUrl: '/system/dict/data/type/sys_accounting_item_name',
placeholder: '璇烽�夋嫨鏍哥畻椤圭洰锛堝彲澶氶�夛級',
props: {
@@ -390,7 +381,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,10 +391,64 @@
page: page.value,
getListApi: listVoucherSubjectSetting,
getDetailApi: getVoucherSubjectSetting,
+ // 銆愬叧閿慨澶嶇偣銆戯細鎷︽埅璇︽儏鎺ュ彛锛屽湪鏁版嵁杩涘叆 form 涔嬪墠瀹屾垚鏍煎紡鍖�
+ getDetailApi: (id: any) => {
+ return getVoucherSubjectSetting(id).then((res: any) => {
+ console.log(res);
+
+ if (res.code === 200 && res.data) {
+ // 1. 澶勭悊 accountingItems 鏁板瓧杞暟缁�
+ // 1. 濡傛灉 accountSet 鏄暟瀛楋紝杞负瀛楃涓�
+ res.data.accountSet = res.data.accountSet ? String(res.data.accountSet) : "0";
+
+ 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,
+ getListFunc: (res: any) => {
+ // 1. 杞崲鏍戠粨鏋�
+ tableData.value = proxy.handleTree(res.rows, "id");
+
+ // 2. 浣跨敤閫掑綊鍑芥暟灞曞紑鎵�鏈夊眰绾�
+ nextTick(() => {
+ if (crudRef.value) {
+ const tableMethods = crudRef.value.$refs.table;
+ if (tableMethods && tableData.value) {
+
+ // --- 瀹氫箟閫掑綊灞曞紑鍑芥暟 ---
+ const expandAllNodes = (list: any[]) => {
+ list.forEach(row => {
+ // 鍙鏈夊瓙鑺傜偣锛屽氨鎵ц灞曞紑鍔ㄤ綔
+ if (row.children && row.children.length > 0) {
+ tableMethods.toggleRowExpansion(row, true);
+ // 缁х画閫掑綊灞曞紑瀛愯妭鐐圭殑瀛愯妭鐐�
+ expandAllNodes(row.children);
+ }
+ });
+ };
+
+ // 鎵ц閫掑綊
+ expandAllNodes(tableData.value);
+ }
+ }
+ });
+ },
handleUpdateFunc: () => {
isFromRow.value = true; // 淇敼鎿嶄綔涔熻涓虹鐢ㄤ笂绾х鐩�
crudRef.value.rowEdit(selectionList.value[0]);
@@ -440,75 +485,132 @@
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) => {
processAccountingItems(row);
delete row.accountingItemsContains;
- // 濡傛灉 row 瀵硅薄閲屽甫浜� id锛屾柊澧炴帴鍙e彲鑳戒細鎶ラ敊鎴栧彉鎴愪慨鏀癸紝濡傛灉鏄《閮ㄦ柊澧烇紝纭繚娌℃湁 id
+
+ // --- 鏍稿績閫昏緫寮�濮� ---
if (!isFromRow.value) {
+ // 1. 纭繚娌℃湁 ID锛堥槻姝㈣鎿嶄綔锛�
delete row.id;
+
+ // 2. 濡傛灉鏄《绾х鐩紙parentId 涓� 0 鎴� 鏃狅級
+ if (row.parentId === 0 || !row.parentId) {
+ // 灏嗕笂绾х鐩唬鐮佽缃负褰撳墠濉啓鐨勭鐩唬鐮�
+ row.parentSubjectCode = row.subjectCode;
+ }
+ } else {
+ // 濡傛灉鏄鍐呮柊澧烇紝parentId 宸茬粡鏄埗鑺傜偣鐨� ID
}
- done(row); // 蹇呴』璋冪敤 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); // 鍚岀悊
},
})
@@ -567,22 +669,25 @@
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();
- }
+
+ // 1. 鍏堣Е鍙戞柊澧炲姩浣滐紝杩欎細寮瑰嚭绐楀彛骞跺垵濮嬪寲 form
+ crudRef.value.rowAdd();
+
+ // 2. 鍦� DOM 鏇存柊鍚庣殑涓嬩竴娆″惊鐜腑寮哄埗璧嬪��
+ nextTick(() => {
+ // 纭繚璧嬪�肩粰 data 鍝嶅簲寮忓璞′腑鐨� form
+ form.value.parentId = row.id;
+ form.value.parentSubjectCode = row.subjectCode;
+ form.value.accountSet = row.accountSet;
+ form.value.type = row.accountSet;
+ form.value.enabled = "1";
+ form.value.accountingItems = [];
});
-
-
};
</script>
--
Gitblit v1.8.0