From 373177bf926ed54c22d221e1da6ef6370b7e2aa5 Mon Sep 17 00:00:00 2001
From: sen <sen@qq.com>
Date: 星期一, 02 二月 2026 13:55:24 +0800
Subject: [PATCH] 科目修改

---
 ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue |   97 +++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 74 insertions(+), 23 deletions(-)

diff --git a/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue b/ui/admin-ui3/src/views/cwgl/voucherSubjectSetting/index.vue
index 4210196..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>
@@ -66,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,
@@ -92,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',
@@ -143,8 +147,7 @@
     parentSubjectCode: {
       label: '涓婄骇绉戠洰浠g爜',
       minWidth: 150,
-
-      search: true,
+      hide: true,
       // rules: [
       //   {
       //     required: true,
@@ -224,7 +227,7 @@
       editDisplay: false,
     },
     accountingItemsContains: {
-      label: '鏍哥畻椤圭洰1',
+      label: '鏍哥畻椤圭洰',
       minWidth: 150,
       search: true,
       type: 'select', // 纭繚绫诲瀷涓� select
@@ -241,7 +244,7 @@
       }
     },
     accountingItems: {
-      label: '鏍哥畻椤圭洰2',
+      label: '鏍哥畻椤圭洰',
       minWidth: 150,
       type: 'select',
       multiple: true,
@@ -391,8 +394,13 @@
     // 銆愬叧閿慨澶嶇偣銆戯細鎷︽埅璇︽儏鎺ュ彛锛屽湪鏁版嵁杩涘叆 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) {
@@ -413,6 +421,34 @@
     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]);
@@ -549,11 +585,23 @@
     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);
     },
 
     // 淇敼淇濆瓨鍓嶇殑閫昏緫
@@ -561,7 +609,7 @@
       processAccountingItems(row);
       delete row.accountingItemsContains;
       if (row.parentSubjectCode == "椤剁骇绉戠洰浠g爜") {
-        row.parentSubjectCode = row.subjectCode; 
+        row.parentSubjectCode = row.subjectCode;
       }
       done(row); // 鍚岀悊
     },
@@ -621,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