From 716b64bf299622a3d0dad0d3cc4e1e2e4306bd7f Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期三, 26 八月 2026 15:40:20 +0800
Subject: [PATCH] fix(monitor): 修正操作时间选择器的日期格式

---
 src/views/personnelManagement/monthlyStatistics/components/formDia.vue |   84 ++++++++++++++++++++++++++++++------------
 1 files changed, 60 insertions(+), 24 deletions(-)

diff --git a/src/views/personnelManagement/monthlyStatistics/components/formDia.vue b/src/views/personnelManagement/monthlyStatistics/components/formDia.vue
index 808c817..46515ed 100644
--- a/src/views/personnelManagement/monthlyStatistics/components/formDia.vue
+++ b/src/views/personnelManagement/monthlyStatistics/components/formDia.vue
@@ -36,6 +36,18 @@
               </el-form-item>
             </el-col>
             <el-col :span="6">
+              <el-form-item label="閫夋嫨宸ヨ祫鏈堜唤"
+                            prop="salaryMonth">
+                <el-date-picker v-model="form.salaryMonth"
+                                type="month"
+                                value-format="YYYY-MM"
+                                format="YYYY-MM"
+                                placeholder="璇烽�夋嫨宸ヨ祫鏈堜唤"
+                                style="width: 100%"
+                                clearable />
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
               <el-form-item label="閫夋嫨閮ㄩ棬"
                             prop="deptIds">
                 <el-select v-model="form.deptIds"
@@ -47,20 +59,9 @@
                   <el-option v-for="item in deptOptions"
                              :key="item.deptId"
                              :label="item.deptName"
-                             :value="item.deptId" />
+                             :value="item.deptId"
+                             :disabled="isDeptDisabled(item.deptId)" />
                 </el-select>
-              </el-form-item>
-            </el-col>
-            <el-col :span="6">
-              <el-form-item label="閫夋嫨宸ヨ祫鏈堜唤"
-                            prop="salaryMonth">
-                <el-date-picker v-model="form.salaryMonth"
-                                type="month"
-                                value-format="YYYY-MM"
-                                format="YYYY-MM"
-                                placeholder="璇烽�夋嫨宸ヨ祫鏈堜唤"
-                                style="width: 100%"
-                                clearable />
               </el-form-item>
             </el-col>
             <el-col :span="6">
@@ -344,18 +345,20 @@
     computed,
     getCurrentInstance,
     nextTick,
+    watch,
   } from "vue";
   import { ArrowUp } from "@element-plus/icons-vue";
   import FormDialog from "@/components/Dialog/FormDialog.vue";
   import { listDept } from "@/api/system/dept.js";
   import { staffOnJobList } from "@/api/personnelManagement/monthlyStatistics.js";
-  import { bankList } from "@/api/personnelManagement/bank.js";
-  import {
-    staffSalaryMainAdd,
-    staffSalaryMainUpdate,
-    staffSalaryMainCalculateSalary,
-    staffSalaryMainCalculateByEmployeeId,
-  } from "@/api/personnelManagement/staffSalaryMain.js";
+import { bankList } from "@/api/personnelManagement/bank.js";
+import {
+  staffSalaryMainAdd,
+  staffSalaryMainUpdate,
+  staffSalaryMainCalculateSalary,
+  staffSalaryMainCalculateByEmployeeId,
+  staffSalaryMainAvailableDepts,
+} from "@/api/personnelManagement/staffSalaryMain.js";
   import { userListNoPageByTenantId } from "@/api/system/user.js";
 
   const emit = defineEmits(["update:modelValue", "close"]);
@@ -378,6 +381,7 @@
   const addPersonVisible = ref(false);
   const taxDialogVisible = ref(false);
   const deptOptions = ref([]);
+  const availableDeptIds = ref(new Set());
   const deptStaffTree = ref([]);
   const employeeList = ref([]);
   const selectedEmployees = ref([]);
@@ -487,8 +491,6 @@
       pieceSalary: parseNum(row.pieceSalary),
       hourlySalary: parseNum(row.hourlySalary),
       otherIncome: parseNum(row.otherIncome),
-      socialPersonal: parseNum(row.socialPersonal),
-      fundPersonal: parseNum(row.fundPersonal),
       otherDeduct: parseNum(row.otherDeduct),
       socialSupplementAmount: parseNullableNum(row.socialSupplementAmount),
       remark: row.remark ?? "",
@@ -573,11 +575,32 @@
     return list;
   }
 
-  const loadDeptOptions = () => {
+  // 鍔犺浇鎵�鏈夐儴闂�
+  const loadAllDeptOptions = () => {
     listDept().then(res => {
       const tree = res.data ?? [];
       deptOptions.value = flattenDept(tree);
     });
+  };
+
+  // 鍔犺浇鍙敤閮ㄩ棬鍒楄〃锛堢敤浜庡垽鏂儴闂ㄦ槸鍚﹀彲閫夛級
+  const loadAvailableDepts = (salaryMonth) => {
+    if (!salaryMonth) {
+      availableDeptIds.value = new Set();
+      return;
+    }
+    staffSalaryMainAvailableDepts(salaryMonth).then(res => {
+      const availableDepts = Array.isArray(res.data) ? res.data : [];
+      availableDeptIds.value = new Set(availableDepts.map(d => d.deptId));
+    });
+  };
+
+  // 鍒ゆ柇閮ㄩ棬鏄惁绂佺敤
+  const isDeptDisabled = (deptId) => {
+    // 濡傛灉娌℃湁閫夋嫨鏈堜唤锛屾墍鏈夐儴闂ㄩ兘鍙��
+    if (!form.value.salaryMonth) return false;
+    // 濡傛灉宸查�夋嫨鏈堜唤锛屽彧鏈夊湪鍙敤閮ㄩ棬鍒楄〃涓殑閮ㄩ棬鎵嶅彲閫�
+    return !availableDeptIds.value.has(deptId);
   };
 
   // 鏋勫缓 閮ㄩ棬-浜哄憳 鏍戯紙鐢ㄤ簬鏂板浜哄憳寮圭獥锛�
@@ -621,9 +644,9 @@
   const openDialog = (type, row) => {
     nextTick(() => {
       resetRecalcState();
-      loadDeptOptions();
       loadBankOptions();
       loadUserList();
+      loadAllDeptOptions();
       employeeList.value = [];
       Object.assign(form.value, {
         id: undefined,
@@ -655,9 +678,22 @@
           employeeList.value = row.staffSalaryDetailList.map(e => normalizeEmployeeRow(e));
         }
       }
+      // 缂栬緫鐘舵�佷笖鏈夋湀浠芥椂锛屽姞杞藉彲鐢ㄩ儴闂ㄥ垪琛�
+      if (type === "edit" && form.value.salaryMonth) {
+        loadAvailableDepts(form.value.salaryMonth);
+      }
     });
   };
 
+  // 鐩戝惉宸ヨ祫鏈堜唤鍙樺寲锛屾竻绌洪儴闂ㄩ�夋嫨骞跺姞杞藉彲鐢ㄩ儴闂ㄥ垪琛�
+  watch(() => form.value.salaryMonth, (newMonth, oldMonth) => {
+    // 鍒囨崲鏈堜唤鏃舵竻绌哄凡閫夋嫨鐨勯儴闂�
+    if (newMonth !== oldMonth) {
+      form.value.deptIds = [];
+    }
+    loadAvailableDepts(newMonth);
+  });
+
   const openAddPerson = () => {
     loadDeptStaffTree();
     addPersonVisible.value = true;

--
Gitblit v1.9.3