From 32b983e2b22e0ebb39a6fd84c0f32b5e677534e7 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 18 五月 2026 10:54:20 +0800
Subject: [PATCH] 1

---
 src/views/financialManagement/generalLedger/index.vue |  176 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 155 insertions(+), 21 deletions(-)

diff --git a/src/views/financialManagement/generalLedger/index.vue b/src/views/financialManagement/generalLedger/index.vue
index fbe2210..a7b1d30 100644
--- a/src/views/financialManagement/generalLedger/index.vue
+++ b/src/views/financialManagement/generalLedger/index.vue
@@ -44,20 +44,62 @@
           <el-button type="primary"
                      @click="add"
                      icon="Plus">鏂板</el-button>
-          <el-button @click="handleOut"
-                     icon="Download">瀵煎嚭</el-button>
+          <!-- <el-button @click="handleOut"
+                     icon="Download">瀵煎嚭</el-button> -->
         </div>
       </div>
-      <PIMTable rowKey="id"
-                :column="columns"
-                :tableData="dataList"
-                :page="{
-          current: pagination.currentPage,
-          size: pagination.pageSize,
-          total: pagination.total,
-        }"
-                @pagination="changePage">
-      </PIMTable>
+      <el-table ref="tableRef"
+                v-loading="loading"
+                :data="dataList"
+                row-key="id"
+                :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
+                height="calc(100vh - 280px)"
+                border
+                stripe
+                highlight-current-row
+                class="subject-table">
+        <el-table-column label="绉戠洰缂栫爜" prop="subjectCode" width="140">
+          <template #default="scope">
+            <span class="subject-code">{{ scope.row.subjectCode }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="绉戠洰鍚嶇О" prop="subjectName" min-width="180">
+          <template #default="scope">
+            <span class="subject-name" :class="{ 'is-parent': scope.row.children?.length > 0 }">
+              {{ scope.row.subjectName }}
+            </span>
+          </template>
+        </el-table-column>
+        <el-table-column label="绉戠洰绫诲瀷" prop="subjectType" width="100" align="center">
+          <template #default="scope">
+            <el-tag size="small" :type="getSubjectTypeType(scope.row.subjectType)">
+              {{ scope.row.subjectType }}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="浣欓鏂瑰悜" prop="balanceDirection" width="100" align="center">
+          <template #default="scope">
+            <el-tag size="small" :type="scope.row.balanceDirection === '鍊熸柟' ? 'primary' : 'danger'">
+              {{ scope.row.balanceDirection }}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="鐘舵��" prop="status" width="80" align="center">
+          <template #default="scope">
+            <el-tag size="small" :type="scope.row.status === 0 || scope.row.status === '0' ? 'success' : 'info'">
+              {{ scope.row.status === 0 || scope.row.status === '0' ? '鍚敤' : '绂佺敤' }}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="澶囨敞" prop="remark" show-overflow-tooltip min-width="150" />
+        <el-table-column label="鎿嶄綔" align="center" fixed="right" width="240">
+          <template #default="scope">
+            <el-button link type="primary" icon="Plus" @click="addChild(scope.row)">鏂板</el-button>
+            <el-button link type="primary" icon="Edit" @click="edit(scope.row)">缂栬緫</el-button>
+            <el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)">鍒犻櫎</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
     </div>
     <FormDialog :title="dialogTitle"
                 v-model="dialogVisible"
@@ -68,6 +110,10 @@
                :rules="rules"
                ref="formRef"
                label-width="100px">
+        <el-form-item label="鐖剁骇绉戠洰">
+          <el-input :model-value="parentSubjectLabel"
+                    disabled />
+        </el-form-item>
         <el-form-item label="绉戠洰缂栫爜"
                       prop="subjectCode">
           <el-input v-model="form.subjectCode"
@@ -127,7 +173,7 @@
 </template>
 
 <script setup>
-  import { ref, reactive, onMounted, getCurrentInstance } from "vue";
+  import { ref, reactive, onMounted, getCurrentInstance, nextTick } from "vue";
   import { ElMessage, ElMessageBox } from "element-plus";
   import FormDialog from "@/components/Dialog/FormDialog.vue";
   import {
@@ -201,8 +247,15 @@
       label: "鎿嶄綔",
       align: "center",
       fixed: "right",
-      width: "150",
+      width: "220",
       operation: [
+        {
+          name: "鏂板",
+          type: "primary",
+          clickFun: row => {
+            addChild(row);
+          },
+        },
         {
           name: "缂栬緫",
           type: "primary",
@@ -224,11 +277,15 @@
   const dataList = ref([]);
   const dialogVisible = ref(false);
   const dialogTitle = ref("");
+  const parentSubjectLabel = ref("椤剁骇绉戠洰");
   const formRef = ref(null);
+  const tableRef = ref(null);
   const isEdit = ref(false);
+  const loading = ref(false);
 
   const form = reactive({
     id: undefined,
+    parentId: null,
     subjectCode: "",
     subjectName: "",
     subjectType: "",
@@ -257,14 +314,17 @@
   };
 
   const getTableData = () => {
+    loading.value = true;
     const query = {
-      pageNum: pagination.currentPage,
-      pageSize: pagination.pageSize,
+      current: pagination.currentPage,
+      size: pagination.pageSize,
       ...filters,
     };
     listAccountSubject(query).then(response => {
-      dataList.value = response.data.records;
-      pagination.total = response.data.total;
+      dataList.value = response.data.records || [];
+      loading.value = false;
+    }).catch(() => {
+      loading.value = false;
     });
   };
 
@@ -282,11 +342,19 @@
     getTableData();
   };
 
-  const add = () => {
-    isEdit.value = false;
-    dialogTitle.value = "鏂板绉戠洰";
+  const buildParentSubjectLabel = parentRow => {
+    if (!parentRow) {
+      return "椤剁骇绉戠洰";
+    }
+    const code = parentRow.subjectCode || "";
+    const name = parentRow.subjectName || "";
+    return `${code} ${name}`.trim();
+  };
+
+  const resetForm = ({ parentId = null, parentRow = null } = {}) => {
     Object.assign(form, {
       id: undefined,
+      parentId,
       subjectCode: "",
       subjectName: "",
       subjectType: "",
@@ -294,13 +362,54 @@
       status: 0,
       remark: "",
     });
+    parentSubjectLabel.value = buildParentSubjectLabel(parentRow);
+  };
+
+  const add = () => {
+    isEdit.value = false;
+    dialogTitle.value = "鏂板绉戠洰";
+    resetForm({ parentId: null, parentRow: null });
     dialogVisible.value = true;
+  };
+
+  const addChild = row => {
+    isEdit.value = false;
+    dialogTitle.value = "鏂板瀛愮鐩�";
+    resetForm({ parentId: row.id, parentRow: row });
+    form.subjectType = row.subjectType || "";
+    form.balanceDirection = row.balanceDirection || "鍊熸柟";
+    dialogVisible.value = true;
+  };
+
+  const findSubjectById = (nodes, id) => {
+    for (const item of nodes || []) {
+      if (item.id === id) {
+        return item;
+      }
+      if (item.children && item.children.length > 0) {
+        const found = findSubjectById(item.children, id);
+        if (found) {
+          return found;
+        }
+      }
+    }
+    return null;
   };
 
   const edit = row => {
     isEdit.value = true;
     dialogTitle.value = "缂栬緫绉戠洰";
     Object.assign(form, row);
+    form.parentId = row.parentId ?? null;
+    const parentRow =
+      row.parentId === null || row.parentId === undefined
+        ? null
+        : findSubjectById(dataList.value, row.parentId);
+    parentSubjectLabel.value = parentRow
+      ? buildParentSubjectLabel(parentRow)
+      : row.parentId
+      ? `涓婄骇ID: ${row.parentId}`
+      : buildParentSubjectLabel(null);
     dialogVisible.value = true;
   };
 
@@ -361,4 +470,29 @@
     justify-content: space-between;
     margin-bottom: 15px;
   }
+
+  .subject-table {
+    border-radius: 8px;
+    overflow: hidden;
+
+    :deep(.el-table__row) {
+      transition: background-color 0.3s;
+    }
+
+    :deep(.el-table__row:hover) {
+      background-color: #f5f7fa;
+    }
+
+    .subject-code {
+      color: #606266;
+    }
+
+    .subject-name {
+      font-weight: 500;
+
+      &.is-parent {
+        color: #409eff;
+      }
+    }
+  }
 </style>

--
Gitblit v1.9.3