From c9cc00d09c756f126710168f81eb7ceba0959ec2 Mon Sep 17 00:00:00 2001
From: zhang_nuo <zhang_12370@163.com>
Date: 星期五, 21 八月 2026 11:17:31 +0800
Subject: [PATCH] feat(personnel,production): 新增年龄自动计算及工单数量支持小数

---
 src/views/personnelManagement/employeeRecord/components/NewOrEditFormDia.vue |   14 ++++
 src/views/personnelManagement/employeeRecord/index.vue                       |   89 ++++++++++++++++++-----------
 src/views/personnelManagement/employeeRecord/components/BasicInfoSection.vue |   18 ++++++
 src/views/productionManagement/workOrderManagement/index.vue                 |   17 +----
 4 files changed, 91 insertions(+), 47 deletions(-)

diff --git a/src/views/personnelManagement/employeeRecord/components/BasicInfoSection.vue b/src/views/personnelManagement/employeeRecord/components/BasicInfoSection.vue
index 0aa4f06..4ac0a1c 100644
--- a/src/views/personnelManagement/employeeRecord/components/BasicInfoSection.vue
+++ b/src/views/personnelManagement/employeeRecord/components/BasicInfoSection.vue
@@ -79,12 +79,14 @@
             placeholder="璇烽�夋嫨"
             style="width: 100%"
             clearable
+            @change="handleBirthDateChange"
           />
         </el-form-item>
       </el-col>
       <el-col :span="5">
         <el-form-item label="骞撮緞" prop="age">
           <el-input-number
+              disabled
             v-model="form.age"
             :min="0"
             :max="150"
@@ -158,6 +160,7 @@
 
 <script setup>
 import { toRefs } from "vue";
+import dayjs from "dayjs";
 
 const props = defineProps({
   form: { type: Object, required: true },
@@ -166,6 +169,21 @@
 });
 
 const { form, operationType, roleOptions } = toRefs(props);
+
+const calcAge = (birth) => {
+  if (!birth) return undefined;
+  const birthDay = dayjs(birth);
+  const now = dayjs();
+  let age = now.year() - birthDay.year();
+  if (now.month() < birthDay.month() || (now.month() === birthDay.month() && now.date() < birthDay.date())) {
+    age--;
+  }
+  return age;
+};
+
+const handleBirthDateChange = (val) => {
+  form.value.age = calcAge(val);
+};
 </script>
 
 <style scoped>
diff --git a/src/views/personnelManagement/employeeRecord/components/NewOrEditFormDia.vue b/src/views/personnelManagement/employeeRecord/components/NewOrEditFormDia.vue
index 2ad06fb..caa62e5 100644
--- a/src/views/personnelManagement/employeeRecord/components/NewOrEditFormDia.vue
+++ b/src/views/personnelManagement/employeeRecord/components/NewOrEditFormDia.vue
@@ -40,7 +40,9 @@
   onMounted,
   getCurrentInstance,
   nextTick,
+  computed,
 } from "vue";
+import dayjs from "dayjs";
 import FormDialog from "@/components/Dialog/FormDialog.vue";
 import { findPostOptions } from "@/api/system/post.js";
 import { deptTreeSelect, getUser } from "@/api/system/user.js";
@@ -160,6 +162,17 @@
 const { form, rules, postOptions, deptOptions } = toRefs(state);
 const roleOptions = ref([]);
 
+const calcAge = (birth) => {
+  if (!birth) return undefined;
+  const birthDay = dayjs(birth);
+  const now = dayjs();
+  let age = now.year() - birthDay.year();
+  if (now.month() < birthDay.month() || (now.month() === birthDay.month() && now.date() < birthDay.date())) {
+    age--;
+  }
+  return age;
+};
+
 const resetForm = () => {
   Object.assign(form.value, createDefaultForm());
   nextTick(() => {
@@ -238,6 +251,7 @@
       if (form.value.sysDeptId === 0) {
         form.value.sysDeptId = undefined;
       }
+      form.value.age = calcAge(form.value.birthDate);
     });
   }
 };
diff --git a/src/views/personnelManagement/employeeRecord/index.vue b/src/views/personnelManagement/employeeRecord/index.vue
index b8496e3..b5a7af7 100644
--- a/src/views/personnelManagement/employeeRecord/index.vue
+++ b/src/views/personnelManagement/employeeRecord/index.vue
@@ -12,21 +12,21 @@
             :prefix-icon="Search"
         />
         <span class="search_title search_title2">閮ㄩ棬锛�</span>
-          <el-tree-select
+        <el-tree-select
             v-model="searchForm.sysDeptId"
             :data="deptOptions"
             check-strictly
             :render-after-expand="false"
             style="width: 240px"
             placeholder="璇烽�夋嫨"
-          />
-          <span class="search_title search_title2">鍏ヨ亴鏃ユ湡锛�</span>
-          <el-date-picker
+        />
+        <span class="search_title search_title2">鍏ヨ亴鏃ユ湡锛�</span>
+        <el-date-picker
             v-model="searchForm.contractStartTime"
             value-format="YYYY-MM-DD"
             format="YYYY-MM-DD"
             placeholder="璇烽�夋嫨"
-          />
+        />
         <!-- <span  style="margin-left: 10px" class="search_title">鍚堝悓缁撴潫鏃ユ湡锛�</span> -->
         <!-- <el-date-picker  v-model="searchForm.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange"
                          placeholder="璇烽�夋嫨" clearable @change="changeDaterange" /> -->
@@ -56,24 +56,27 @@
         <template #positiveDate="{ row }">
           <span :class="getPositiveDateClass(row.positiveDate)">{{ row.positiveDate }}</span>
         </template>
+        <template #age="{ row }">
+          <span>{{ calcAge(row.birthDate) }}</span>
+        </template>
       </PIMTable>
     </div>
     <show-form-dia ref="formDia" @close="handleQuery"></show-form-dia>
     <new-or-edit-form-dia ref="formDiaNewOrEditFormDia" @close="handleQuery"></new-or-edit-form-dia>
-    
+
     <!-- 瀵煎叆瀵硅瘽妗� -->
     <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
       <el-upload
-        ref="uploadRef"
-        :limit="1"
-        accept=".xlsx, .xls"
-        :headers="upload.headers"
-        :action="upload.url"
-        :disabled="upload.isUploading"
-        :on-progress="handleFileUploadProgress"
-        :on-success="handleFileSuccess"
-        :auto-upload="false"
-        drag
+          ref="uploadRef"
+          :limit="1"
+          accept=".xlsx, .xls"
+          :headers="upload.headers"
+          :action="upload.url"
+          :disabled="upload.isUploading"
+          :on-progress="handleFileUploadProgress"
+          :on-success="handleFileSuccess"
+          :auto-upload="false"
+          drag
       >
         <el-icon class="el-icon--upload"><upload-filled /></el-icon>
         <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
@@ -96,7 +99,7 @@
 
 <script setup>
 import { Search, UploadFilled } from "@element-plus/icons-vue";
-import {onMounted, ref} from "vue";
+import {onMounted, ref, reactive, toRefs, nextTick, getCurrentInstance} from "vue";
 import {ElMessageBox} from "element-plus";
 import { deptTreeSelect } from "@/api/system/user.js";
 import {batchDeleteStaffOnJobs, staffOnJobListPage} from "@/api/personnelManagement/staffOnJob.js";
@@ -109,6 +112,8 @@
 const data = reactive({
   searchForm: {
     staffName: "",
+    sysDeptId: undefined,
+    contractStartTime: undefined,
     entryDate: undefined, // 褰曞叆鏃ユ湡
     entryDateStart: undefined,
     entryDateEnd: undefined,
@@ -185,6 +190,8 @@
   {
     label: "骞撮緞",
     prop: "age",
+    dataType: "slot",
+    slot: "age"
   },
   {
     label: "绫嶈疮",
@@ -244,6 +251,23 @@
   url: import.meta.env.VITE_APP_BASE_API + "/staff/staffOnJob/import"
 })
 
+/**
+ * 鏍规嵁鍑虹敓鏃ユ湡瀛楃涓茶绠楀懆宀�
+ * @param {String} birth  YYYY鈥慚M鈥慏D
+ * @returns {string|number}
+ */
+const calcAge = (birth) => {
+  if (!birth) return "-";
+  const birthDay = dayjs(birth);
+  const now = dayjs();
+  let age = now.year() - birthDay.year();
+  // 鐢熸棩杩樻病杩囷紝鍑忎竴宀�
+  if (now.month() < birthDay.month() || (now.month() === birthDay.month() && now.date() < birthDay.date())) {
+    age--;
+  }
+  return age;
+};
+
 // 鍒ゆ柇杞鏃ユ湡鏄惁鍦�7澶╁唴
 const getPositiveDateClass = (positiveDate) => {
   if (!positiveDate) return '';
@@ -261,24 +285,23 @@
 };
 
 const fetchDeptOptions = () => {
-    deptTreeSelect().then(response => {
-      console.log(response.data)
-      deptOptions.value = filterDisabledDept(
+  deptTreeSelect().then(response => {
+    deptOptions.value = filterDisabledDept(
         JSON.parse(JSON.stringify(response.data))
-      );
-    });
-  };
+    );
+  });
+};
 const filterDisabledDept = deptList => {
-    return deptList.filter(dept => {
-      if (dept.disabled) {
-        return false;
-      }
-      if (dept.children && dept.children.length) {
-        dept.children = filterDisabledDept(dept.children);
-      }
-      return true;
-    });
-  };
+  return deptList.filter(dept => {
+    if (dept.disabled) {
+      return false;
+    }
+    if (dept.children && dept.children.length) {
+      dept.children = filterDisabledDept(dept.children);
+    }
+    return true;
+  });
+};
 const changeDaterange = (value) => {
   searchForm.value.entryDateStart = undefined;
   searchForm.value.entryDateEnd = undefined;
diff --git a/src/views/productionManagement/workOrderManagement/index.vue b/src/views/productionManagement/workOrderManagement/index.vue
index 40b06e2..a0ed7fc 100644
--- a/src/views/productionManagement/workOrderManagement/index.vue
+++ b/src/views/productionManagement/workOrderManagement/index.vue
@@ -133,7 +133,7 @@
           <el-input v-model.number="reportForm.quantity"
                     type="number"
                     min="0"
-                    step="1"
+                    step="0.001"
                     style="width: 300px"
                     placeholder="璇疯緭鍏ョ敓浜у悎鏍兼暟閲�"
                     @input="handleQuantityInput" />
@@ -446,7 +446,7 @@
     }
     const num = Number(value);
     // 鏁存暟涓斿ぇ浜庣瓑浜�1
-    if (isNaN(num) || !Number.isInteger(num) || num < 0) {
+    if (isNaN(num) || num < 0) {
       callback(new Error("鐢熶骇鍚堟牸鏁伴噺蹇呴』澶т簬绛変簬0"));
       return;
     }
@@ -461,7 +461,7 @@
     }
     const num = Number(value);
     // 鏁存暟涓斿ぇ浜庣瓑浜�0
-    if (isNaN(num) || !Number.isInteger(num) || num < 0) {
+    if (isNaN(num) || num < 0) {
       callback(new Error("鎶ュ簾鏁伴噺蹇呴』澶т簬绛変簬0"));
       return;
     }
@@ -487,17 +487,6 @@
     // 濡傛灉灏忎簬1锛屾竻闄�
     if (num < 0) {
       reportForm.quantity = null;
-      return;
-    }
-    // 濡傛灉鏄皬鏁板彇鏁存暟閮ㄥ垎
-    if (!Number.isInteger(num)) {
-      const intValue = Math.floor(num);
-      // 濡傛灉鍙栨暣鍚庡皬浜�1锛屾竻闄�
-      if (intValue < 0) {
-        reportForm.quantity = null;
-        return;
-      }
-      reportForm.quantity = intValue;
       return;
     }
     reportForm.quantity = num;

--
Gitblit v1.9.3