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/index.vue |   89 ++++++++++++++++++++++++++++----------------
 1 files changed, 56 insertions(+), 33 deletions(-)

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;

--
Gitblit v1.9.3