From 2e340d09cf3e7c060216cb980c466586c27ecc2d Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 20 十一月 2025 17:21:53 +0800
Subject: [PATCH] 1.金鹰黄金-劳保统计页面展示数据修改

---
 src/views/lavorissue/statistics/index.vue |   14 +++++-
 src/views/lavorissue/ledger/index.vue     |    6 ++
 src/views/lavorissue/issue/index.vue      |    6 +-
 src/views/lavorissue/ledger/Modal.vue     |   65 ++++++++++++++++++++++++++++----
 4 files changed, 75 insertions(+), 16 deletions(-)

diff --git a/src/views/lavorissue/issue/index.vue b/src/views/lavorissue/issue/index.vue
index 78ead42..db52690 100644
--- a/src/views/lavorissue/issue/index.vue
+++ b/src/views/lavorissue/issue/index.vue
@@ -264,7 +264,7 @@
       })
     } else {
       // 鏂板鐢ㄥ搧
-      const currentId = currentPosition.value?.id ?? currentPosition.value?.raw?.id ?? currentDept.value?.id ?? currentDept.value?.raw?.id
+      const currentId = currentPosition.value?.id ?? currentDept.value?.raw?.id
       await addLaborConf({
         deptPositionId: currentId,
         dictId: addItemForm.dictId,
@@ -274,7 +274,7 @@
     }
     
     // 閲嶆柊鍔犺浇鐢ㄥ搧閰嶇疆鍒楄〃
-    const currentId = currentPosition.value?.id ?? currentPosition.value?.raw?.id ?? currentDept.value?.id ?? currentDept.value?.raw?.id
+    const currentId = currentPosition.value?.id ?? currentDept.value?.raw?.id
     await loadLaborConf(currentId)
     
     addItemDialogVisible.value = false
@@ -296,7 +296,7 @@
   try {
     await deleteLaborConf([row.id])
     // 閲嶆柊鍔犺浇鐢ㄥ搧閰嶇疆鍒楄〃
-    const currentId = currentPosition.value?.id ?? currentPosition.value?.raw?.id ?? currentDept.value?.id ?? currentDept.value?.raw?.id
+    const currentId = currentPosition.value?.id ?? currentDept.value?.raw?.id
     await loadLaborConf(currentId)
     ElMessage.success('鍒犻櫎鎴愬姛')
   } catch (e) {
diff --git a/src/views/lavorissue/ledger/Modal.vue b/src/views/lavorissue/ledger/Modal.vue
index f5b0e3a..1ed016f 100644
--- a/src/views/lavorissue/ledger/Modal.vue
+++ b/src/views/lavorissue/ledger/Modal.vue
@@ -2,9 +2,26 @@
   <el-dialog :title="modalOptions.title" v-model="visible" @close="close" width="60%">
     <el-form :model="form" label-width="100px" :rules="formRules" ref="formRef">
       <el-form-item label="宀椾綅鍚嶇О" prop="deptPositionId">
-        <el-select v-model="form.deptPositionId" placeholder="璇烽�夋嫨" clearable @change="handlePositionChange">
-          <el-option :label="item.name" :value="item.id" v-for="(item,index) in positionOptions" :key="item.id" />
-        </el-select>
+        <el-tree-select
+          v-model="form.deptPositionId"
+          :data="deptPositionTree"
+          :props="{ value: 'id', label: 'label', children: 'children' }"
+          placeholder="璇烽�夋嫨閮ㄩ棬鎴栧矖浣�"
+          clearable
+          check-strictly
+    :render-after-expand="false"
+    check-on-click-node
+          @change="handlePositionChange"
+        >
+          <template #default="{ data }">
+            <span>
+              <el-tag size="small" :type="data.type===1 ? 'success' : 'warning'" effect="plain" style="margin-right:4px;">
+                {{ data.type === 1 ? '閮ㄩ棬' : '宀椾綅' }}
+              </el-tag>
+              {{ data.label }}
+            </span>
+          </template>
+        </el-tree-select>
       </el-form-item>
       <el-form-item label="鍔充繚绫诲瀷" prop="dictType">
         <el-select v-model="form.dictType" placeholder="璇烽�夋嫨" clearable>
@@ -64,7 +81,7 @@
 import useUserStore from "@/store/modules/user";
 import {staffOnJobListPage} from "@/api/personnelManagement/employeeRecord.js";
 import { getDept } from "@/api/collaborativeApproval/approvalProcess.js";
-import { deptPositionListPage, getDeptPositionByDeptIdLabor } from "@/api/lavorissce/issue";
+import { getDeptPositionTree, getDeptPositionByDeptIdLabor } from "@/api/lavorissce/issue";
 import { deepCopySameProperties } from '@/utils/util'
 import { ElMessage } from "element-plus";
 
@@ -80,7 +97,7 @@
 
 const productOptions = ref([]);
 const personList = ref([]);
-const positionOptions = ref([]);
+const deptPositionTree = ref([]);
 const laborSuppliesOptions = ref([]);
 
 const formRules = {
@@ -167,12 +184,42 @@
   await nextTick()
   deepCopySameProperties(row, form)
 }
-async function loadPositions() {
-  const res = await deptPositionListPage({pageNum: -1, pageSize:-1})
-    positionOptions.value = res?.data?.records || res?.data || []
+// 灏嗛儴闂ㄥ矖浣嶆暟鎹浆鎹负鏍戝舰缁撴瀯
+function mapDeptToTree(d) {
+  const node = {
+    id: d.id,
+    label: d.name,
+    type: d.type,
+    children: [],
+  }
+  const kids = Array.isArray(d.children) ? d.children : []
+  for (const c of kids) {
+    if (c.type === 1) {
+      node.children.push(mapDeptToTree(c))
+    } else if (c.type === 2) {
+      node.children.push({
+        id: c.id,
+        label: c.name,
+        type: c.type,
+      })
+    }
+  }
+  return node
+}
+
+async function loadDeptPositionTree() {
+  try {
+    const res = await getDeptPositionTree()
+    const data = res?.data || res || []
+    deptPositionTree.value = data.map(d => mapDeptToTree(d))
+  } catch (e) {
+    console.error('鍔犺浇閮ㄩ棬宀椾綅鏍戝け璐�:', e)
+    deptPositionTree.value = []
+  }
 }
 
 async function handlePositionChange(deptPositionId) {
+  console.log('閫夋嫨鐨勫矖浣岻D:', deptPositionId)
   if (!deptPositionId) {
     laborSuppliesOptions.value = []
     form.dictId = undefined
@@ -183,7 +230,7 @@
 }
 
 onMounted(() => {
-  loadPositions()
+  loadDeptPositionTree()
   getPersonList()
 })
 
diff --git a/src/views/lavorissue/ledger/index.vue b/src/views/lavorissue/ledger/index.vue
index 6ba7553..b6408c1 100644
--- a/src/views/lavorissue/ledger/index.vue
+++ b/src/views/lavorissue/ledger/index.vue
@@ -108,6 +108,11 @@
     },
     [
       {
+        label: "閮ㄩ棬/宀椾綅",
+        align: "center",
+        prop: "deptName"
+      },
+      {
         label: "鍔充繚鍗曞彿",
         align: "center",
         prop: "orderNo",
@@ -122,7 +127,6 @@
         align: "center",
         prop: "staffNo"
       },
-
       {
         label: "鍔充繚绫诲瀷",
         align: "center",
diff --git a/src/views/lavorissue/statistics/index.vue b/src/views/lavorissue/statistics/index.vue
index 2c34f67..23c4851 100644
--- a/src/views/lavorissue/statistics/index.vue
+++ b/src/views/lavorissue/statistics/index.vue
@@ -40,12 +40,12 @@
       </div>
     </div>
     <div class="table_list">
-      <div class="actions">
+      <!-- <div class="actions">
         <div class="head" @click="handleQuery(1)">宸查鍙栧姵淇濇暟閲�:{{statisticsObj.ylqNum}}</div>
         <div class="head" @click="handleQuery(2)">鏈鍙栧姵淇濇暟閲�: {{ statisticsObj.wlqNum }}</div>
         <div class="head" @click="handleQuery(3)">瓒呮椂宸查鍙栧姵淇濇暟閲�: {{statisticsObj.csylqNum}}</div>
         <div class="head" @click="handleQuery(4)">瓒呮椂鏈鍙栧姵淇濇暟閲�: {{statisticsObj.cswlqNum}}</div>
-      </div>
+      </div> -->
       <el-table
           ref="tableRef"
           v-loading="tableLoading"
@@ -72,7 +72,15 @@
             width="60"
             fixed="left"
         />
-
+<!-- 鍥哄畾鍒楋細閮ㄩ棬/宀椾綅 -->
+        <el-table-column
+            label="閮ㄩ棬/宀椾綅"
+            prop="deptName"
+            width="120"
+            show-overflow-tooltip
+            align="center"
+            fixed="left"
+        />
         <!-- 鍥哄畾鍒楋細濮撳悕 -->
         <el-table-column
             label="濮撳悕"

--
Gitblit v1.9.3