From 85ef9a437fe32c569b55f6e8391fdefb76780840 Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期四, 11 九月 2025 16:09:48 +0800
Subject: [PATCH] 用印管理-阅读修改,自助服务平台页面调整

---
 src/api/personnelManagement/selfService.js               |   71 +++++
 src/api/collaborativeApproval/sealManagement.js          |   33 ++
 src/views/collaborativeApproval/planTemplate/index.vue   |   24 +
 src/views/inventoryManagement/stockWarning/index.vue     |    4 
 src/views/collaborativeApproval/knowledgeBase/index.vue  |   16 
 src/views/personnelManagement/selfService/index.vue      |  486 +++++++++++++++++++++++++++++-------
 src/views/collaborativeApproval/sealManagement/index.vue |  136 +++++++++-
 7 files changed, 642 insertions(+), 128 deletions(-)

diff --git a/src/api/collaborativeApproval/sealManagement.js b/src/api/collaborativeApproval/sealManagement.js
index 5a0293a..cb990b3 100644
--- a/src/api/collaborativeApproval/sealManagement.js
+++ b/src/api/collaborativeApproval/sealManagement.js
@@ -20,6 +20,23 @@
       ...query},
   });
 }
+// 鏌ヨ闃呰鐘舵�佸垪琛�
+export function getReadingStatusList(page,query) {
+  return request({
+    url: "/rulesRegulationsManagement/getReadingStatusList",
+    method: "get",
+    params: {
+      ...page,
+      ...query},
+  });
+}
+// 鏍规嵁瑙勫垯id鏌ヨ闃呰鐘舵�佸垪琛�
+export function getReadingStatusByRuleId(id) {
+  return request({
+    url: "/rulesRegulationsManagement/getReadingStatusByRuleId/"+id,
+    method: "get"
+  });
+}
 
 // 鏂板鍗扮珷鐢宠
 export function addSealApplication(data) {
@@ -37,6 +54,14 @@
     data: data,
   });
 }
+// 鏂板闃呰鐘舵��
+export function addReadingStatus(data) {
+  return request({
+    url: "/rulesRegulationsManagement/addReadingStatus",
+    method: "post",
+    data: data,
+  });
+}
 
 // 淇敼鍗扮珷鐢宠
 export function updateSealApplication(data) {
@@ -54,6 +79,14 @@
     data: data,
   });
 }
+// 淇敼闃呰鐘舵��
+export function updateReadingStatus(data) {
+  return request({
+    url: "/rulesRegulationsManagement/updateReadingStatus",
+    method: "post",
+    data: data,
+  });
+}
 
 // 鍒犻櫎鍗扮珷鐢宠
 export function delSealApplication(query) {
diff --git a/src/api/personnelManagement/selfService.js b/src/api/personnelManagement/selfService.js
new file mode 100644
index 0000000..c95436a
--- /dev/null
+++ b/src/api/personnelManagement/selfService.js
@@ -0,0 +1,71 @@
+// 钖叕绠$悊
+import request from "@/utils/request";
+
+// 鏌ヨ鑰冨嫟鍒楄〃
+export function personalAttendanceRecordsListPage(query) {
+  return request({
+    url: "/staff/personalAttendanceRecords/listPage",
+    method: "get",
+    params: query,
+  });
+}
+// 鏌ヨ鍋囨湡鐢宠鍒楄〃
+export function holidayApplicationListPage(query) {
+  return request({
+    url: "/staff/holidayApplication/listPage",
+    method: "get",
+    params: query,
+  });
+}
+// 鏂板
+export function personalAttendanceRecordsAdd(query) {
+  return request({
+    url: "/staff/personalAttendanceRecords/add",
+    method: "post",
+    data: query,
+  });
+}
+// 鏂板鍋囨湡鐢宠
+export function holidayApplicationAdd(query) {
+  return request({
+    url: "/staff/holidayApplication/add",
+    method: "post",
+    data: query,
+  });
+}
+// 淇敼
+export function personalAttendanceRecordsUpdate(query) {
+  return request({
+    url: "/staff/personalAttendanceRecords/update",
+    method: "put",
+    data: query,
+  });
+}
+// 淇敼鍋囨湡鐢宠
+export function holidayApplicationUpdate(query) {
+  return request({
+    url: "/staff/holidayApplication/update",
+    method: "post",
+    data: query,
+  });
+}
+// 鍒犻櫎
+export function personalAttendanceRecordsDelete(id) {
+  return request({
+    url: "/staff/personalAttendanceRecords/delete/"+id,
+    method: "delete",
+  });
+}
+// 鍒犻櫎鍋囨湡鐢宠
+export function holidayApplicationDelete(id) {
+  return request({
+    url: "/staff/holidayApplication/delete/"+id,
+    method: "delete",
+  });
+}
+// export function del(id) {
+//     return request({
+//         url: "/staff/staffScheduling/del/"+id,
+//         method: "delete",
+//     });
+// }
\ No newline at end of file
diff --git a/src/views/collaborativeApproval/knowledgeBase/index.vue b/src/views/collaborativeApproval/knowledgeBase/index.vue
index ba572f5..0839c16 100644
--- a/src/views/collaborativeApproval/knowledgeBase/index.vue
+++ b/src/views/collaborativeApproval/knowledgeBase/index.vue
@@ -221,7 +221,7 @@
         <span class="dialog-footer">
           <el-button @click="viewDialogVisible = false">鍏抽棴</el-button>
           <el-button type="primary" @click="copyKnowledge">澶嶅埗鐭ヨ瘑</el-button>
-          <el-button type="success" @click="markAsFavorite">鏀惰棌</el-button>
+          <!-- <el-button type="success" @click="markAsFavorite">鏀惰棌@</el-button> -->
         </span>
       </template>
     </el-dialog>
@@ -657,13 +657,13 @@
 // 澶嶅埗鐭ヨ瘑
 const copyKnowledge = () => {
   const knowledgeText = `
-鐭ヨ瘑鏍囬锛�${currentKnowledge.value.title}
-鐭ヨ瘑绫诲瀷锛�${getTypeLabel(currentKnowledge.value.type)}
-閫傜敤鍦烘櫙锛�${currentKnowledge.value.scenario}
-闂鎻忚堪锛�${currentKnowledge.value.problem}
-瑙e喅鏂规锛�${currentKnowledge.value.solution}
-鍏抽敭瑕佺偣锛�${currentKnowledge.value.keyPoints}
-鍒涘缓浜猴細${currentKnowledge.value.creator}
+    鐭ヨ瘑鏍囬锛�${currentKnowledge.value.title}
+    鐭ヨ瘑绫诲瀷锛�${getTypeLabel(currentKnowledge.value.type)}
+    閫傜敤鍦烘櫙锛�${currentKnowledge.value.scenario}
+    闂鎻忚堪锛�${currentKnowledge.value.problem}
+    瑙e喅鏂规锛�${currentKnowledge.value.solution}
+    鍏抽敭瑕佺偣锛�${currentKnowledge.value.keyPoints}
+    鍒涘缓浜猴細${currentKnowledge.value.creator}
   `.trim();
 
   // 澶嶅埗鍒板壀璐存澘
diff --git a/src/views/collaborativeApproval/planTemplate/index.vue b/src/views/collaborativeApproval/planTemplate/index.vue
index 7c67f22..0af6d8b 100644
--- a/src/views/collaborativeApproval/planTemplate/index.vue
+++ b/src/views/collaborativeApproval/planTemplate/index.vue
@@ -131,7 +131,7 @@
                   <template #dropdown>
                     <el-dropdown-menu>
                       <!-- <el-dropdown-item command="share">鍏变韩@</el-dropdown-item> -->
-                      <!-- <el-dropdown-item command="copy">澶嶅埗@</el-dropdown-item> -->
+                      <el-dropdown-item command="copy">澶嶅埗</el-dropdown-item>
                       <el-dropdown-item command="delete" divided>鍒犻櫎</el-dropdown-item>
                     </el-dropdown-menu>
                   </template>
@@ -459,7 +459,27 @@
       ElMessage.success('璁″垝宸插叡浜�')
       break
     case 'copy':
-      ElMessage.success('璁″垝宸插鍒�')
+      const knowledgeText = `
+        璁″垝鏍囬锛�${plan.title}
+        璁″垝鎻忚堪锛�${plan.description}
+        璁″垝绾у埆锛�${getCurrentLevelText(plan.level)}
+        鏃堕棿鍛ㄦ湡锛�${getCurrentPeriodText(plan.period)}
+        寮�濮嬫椂闂达細${plan.startDate}
+        缁撴潫鏃堕棿锛�${plan.endDate}
+        璐熻矗浜猴細${plan.assignee}
+        浼樺厛绾э細${getPriorityText(plan.priority)}
+        鏍囩锛�${plan.tags.join(', ')}
+        鐘舵�侊細${getStatusText(plan.status)}
+        杩涘害锛�${plan.progress}%
+      `.trim();
+
+        // 澶嶅埗鍒板壀璐存澘
+        navigator.clipboard.writeText(knowledgeText).then(() => {
+          ElMessage.success("鐭ヨ瘑鍐呭宸插鍒跺埌鍓创鏉�");
+        }).catch(() => {
+          ElMessage.error("澶嶅埗澶辫触锛岃鎵嬪姩澶嶅埗");
+        });
+      // ElMessage.success('璁″垝宸插鍒�')
       break
     case 'delete':
       ElMessageBox.confirm('纭畾瑕佸垹闄よ繖涓鍒掑悧锛�', '鎻愮ず', {
diff --git a/src/views/collaborativeApproval/sealManagement/index.vue b/src/views/collaborativeApproval/sealManagement/index.vue
index 1f88715..4cf5a14 100644
--- a/src/views/collaborativeApproval/sealManagement/index.vue
+++ b/src/views/collaborativeApproval/sealManagement/index.vue
@@ -124,7 +124,7 @@
                   <el-button link type="primary" @click="handleEdit(scope.row)">缂栬緫</el-button>
                   <el-button link type="danger" @click="repealEdit(scope.row)">搴熷純</el-button>
                   <el-button link type="success" @click="viewVersionHistory(scope.row)">鐗堟湰鍘嗗彶</el-button>
-                  <!-- <el-button link type="warning" @click="viewReadStatus(scope.row)">闃呰鐘舵��</el-button> -->
+                  <el-button link type="warning" @click="viewReadStatus(scope.row)">闃呰鐘舵��</el-button>
                 </template>
               </el-table-column>
             </el-table>
@@ -262,6 +262,10 @@
           <h4>鍒跺害鍐呭</h4>
           <div class="regulation-content">{{ currentRegulationDetail.content }}</div>
         </div>
+        <!-- 濡傛灉tableData>0 鏄剧ず -->
+        <div style="margin: 10px 0;" v-if="tableData && tableData.length > 0" >
+          <el-button type="success" @click="resetForm(currentRegulationDetail)">纭鏌ョ湅</el-button>
+        </div>
       </div>
     </el-dialog>
 
@@ -286,7 +290,7 @@
       <el-table :data="readStatusList" style="width: 100%;margin-bottom: 10px">
         <el-table-column prop="employee" label="鍛樺伐濮撳悕" width="120" />
         <el-table-column prop="department" label="鎵�灞為儴闂�" width="150" />
-        <el-table-column prop="readTime" label="闃呰鏃堕棿" width="180" />
+        <el-table-column prop="createTime" label="闃呰鏃堕棿" width="180" />
         <el-table-column prop="confirmTime" label="纭鏃堕棿" width="180" />
         <el-table-column prop="status" label="鐘舵��" width="100">
           <template #default="scope">
@@ -304,12 +308,16 @@
 import { ref, reactive, onMounted } from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import { Plus } from '@element-plus/icons-vue'
-import { listSealApplication, addSealApplication, updateSealApplication,listRuleManagement,addRuleManagement,updateRuleManagement,delRuleManagement  } from '@/api/collaborativeApproval/sealManagement.js'
+import { listSealApplication, addSealApplication, updateSealApplication,listRuleManagement,addRuleManagement,updateRuleManagement,delRuleManagement,getReadingStatusByRuleId,getReadingStatusList,addReadingStatus,updateReadingStatus  } from '@/api/collaborativeApproval/sealManagement.js'
 import { el } from 'element-plus/es/locales.mjs'
+import { getUserProfile } from '@/api/system/user.js'
+import {staffJoinDel, staffJoinListPage} from "@/api/personnelManagement/onboarding.js";
 
 // 鍝嶅簲寮忔暟鎹�
+const currentUser = ref(null)
 const activeTab = ref('seal')
 const operationType = ref('add')
+const tableData = ref([])
 // 鐢ㄥ嵃鐢宠鐩稿叧
 const showSealApplyDialog = ref(false)
 const tableLoading = ref(false)
@@ -363,6 +371,16 @@
   requireConfirm: false
 })
 
+const readStatus = ref({
+  id: '',
+  ruleId: '',
+  employee: '',
+  department: '',
+  createTime: '',
+  confirmTime: '',
+  status: 'unconfirmed'
+})
+
 const regulationRules = {
   title: [{ required: true, message: '璇疯緭鍏ュ埗搴︽爣棰�', trigger: 'blur' }],
   category: [{ required: true, message: '璇烽�夋嫨鍒跺害鍒嗙被', trigger: 'change' }],
@@ -383,11 +401,10 @@
 
 const versionHistory = ref([])
 
-const readStatusList = ref([
-  { employee: '闄堝織寮�', department: '閿�鍞儴', readTime: '2025-01-11 10:30:00', confirmTime: '2025-01-11 10:35:00', status: 'confirmed' },
-  { employee: '鍒橀泤濠�', department: '鎶�鏈儴', readTime: '2025-01-11 14:20:00', confirmTime: '', status: 'unconfirmed' },
-  { employee: '鐜嬪缓鍥�', department: '璐㈠姟閮�', readTime: '2025-01-12 09:15:00', confirmTime: '2025-01-12 09:20:00', status: 'confirmed' }
-])
+const readStatusList = ref([])
+  // { employee: '闄堝織寮�', department: '閿�鍞儴', readTime: '2025-01-11 10:30:00', confirmTime: '2025-01-11 10:35:00', status: 'confirmed' },
+  // { employee: '鍒橀泤濠�', department: '鎶�鏈儴', readTime: '2025-01-11 14:20:00', confirmTime: '', status: 'unconfirmed' },
+  // { employee: '鐜嬪缓鍥�', department: '璐㈠姟閮�', readTime: '2025-01-12 09:15:00', confirmTime: '2025-01-12 09:20:00', status: 'confirmed' }
 
 // 鐢ㄥ嵃鐢宠鐘舵��
 const getStatusType = (status) => {
@@ -596,11 +613,33 @@
     ElMessage.success('宸叉嫆缁濈敵璇�')
   })
 }
-// 鏌ョ湅鍒跺害璇︽儏
-const viewRegulation = (row) => {
-  currentRegulationDetail.value = row
-  showRegulationDetailDialog.value = true
-}
+// 鑾峰彇鍦ㄨ亴鍛樺伐鍒楄〃
+const getList = () => {
+  tableLoading.value = true;
+      //鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛淇℃伅
+  getUserProfile().then(res => {
+    if(res.code == 200){
+      console.log(res.data.userName)
+      currentUser.value = res.data.userName
+    }
+  })
+  staffJoinListPage({staffState: 1}).then(res => {
+    tableLoading.value = false;
+    // tableData.value = res.data.records
+    // //绛涢�夊嚭鍜宑urrentUser鍚屽悕鐨勪汉鍛�
+    tableData.value = res.data.records.filter(item => item.staffName === currentUser.value)
+    console.log("tableData",tableData.value) 
+    page.total = res.data.total;
+      
+    if(tableData.value.length == 0){
+    ElMessage.error('褰撳墠鐢ㄦ埛鏈姞鍏ヤ换浣曢儴闂�')
+    }
+  }).catch(err => {
+    tableLoading.value = false;
+  })
+
+
+};
 
 // 鏌ョ湅鍒跺害鐗堟湰鍘嗗彶
 const viewVersionHistory = (row) => {
@@ -615,10 +654,81 @@
     }
   })
 }
+// 鏌ョ湅鍒跺害璇︽儏
+const viewRegulation = (row) => {
+  getList()
+  currentRegulationDetail.value = row
+  showRegulationDetailDialog.value = true
+  getReadingStatusByRuleId(row.id).then(res => {
+    if(res.code == 200){
+      readStatusList.value = res.data
+      if(readStatusList.value.length==0 && tableData.value.length>0){
+          const params = {
+          ruleId: row.id,
+          employee: tableData.value[0].staffName,
+          department: tableData.value[0].postJob,
+          status: 'unconfirmed'
+        }
+        addReadingStatus(params).then(res => {
+          if(res.code == 200){
+            ElMessage.success('鍒跺害闃呰鎴愬姛')
+          }
+        })
+      }
+    }
+  })
+  
+}
 // 鏌ョ湅鍒跺害闃呰鐘舵��
 const viewReadStatus = (row) => {
   showReadStatusDialog.value = true
+  //鏌ョ湅闃呰鐘舵�佸垪琛�
+  getReadingStatusByRuleId(row.id).then(res => {
+    if(res.code == 200){
+      readStatusList.value = res.data
+    }
+  })
 }
+
+//纭鏌ョ湅
+const resetForm = (row) => {
+  console.log("row",row)
+  row.readCount = row.readCount + 1
+  
+  updateRuleManagement(row).then(res => {
+    if(res.code == 200){
+      ElMessage.success('鏌ョ湅鏁伴噺淇敼鎴愬姛')
+      //淇敼闃呰鐘舵��
+      //鏍规嵁鍒跺害id鍜屽綋鍓嶇櫥褰曠殑鍛樺伐寰楀埌闃呰鐘舵��
+      // let item = readStatusList.value.filter(item => item.employee == tableData.value[0].staffName )
+      // if(item.length>0){
+      //   item[0].status = 'confirmed',
+      //   item[0].confirmTime = new Date().toISOString().replace('T', ' ').split('.')[0];
+      // }
+      // 绛涢�夊綋鍓嶅憳宸ュ搴旇鍒跺害鐨勯槄璇荤姸鎬佽褰�
+      let statusItem = readStatusList.value.find(item => item.employee === tableData.value[0].staffName && item.ruleId === row.id);
+
+      if (statusItem) {
+        // 濡傛灉鎵惧埌璁板綍锛屾洿鏂扮姸鎬佸拰纭鏃堕棿
+        statusItem.status = 'confirmed';
+        // 鏍煎紡鍖栨椂闂翠负"YYYY-MM-DD HH:mm:ss"鏍煎紡
+        const now = new Date();
+        statusItem.confirmTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
+        // statusItem.confirmTime = new Date().toISOString().replace('T', ' ').split('.')[0];
+        
+        updateReadingStatus(statusItem).then(res => {
+          if(res.code == 200){
+            ElMessage.success('鍒跺害闃呰鐘舵�佷慨鏀规垚鍔�')
+          }
+        })
+      }
+
+    }
+  })
+}
+
+
+
 // 鑾峰彇鍗扮珷鐢宠鍒楄〃鏁版嵁
 const getSealApplicationList = async () => {
   tableLoading.value = true
diff --git a/src/views/inventoryManagement/stockWarning/index.vue b/src/views/inventoryManagement/stockWarning/index.vue
index 4f0b849..89d396e 100644
--- a/src/views/inventoryManagement/stockWarning/index.vue
+++ b/src/views/inventoryManagement/stockWarning/index.vue
@@ -41,7 +41,7 @@
       <!-- 鎿嶄綔鎸夐挳 -->
       <div class="table-operations">
         <el-button type="primary" @click="handleAdd">鏂板棰勮瑙勫垯</el-button>
-        <!-- <el-button type="success" @click="handleBatchProcess">鎵归噺澶勭悊</el-button> -->
+        <!-- <el-button type="success" @click="handleBatchProcess">鎵归噺澶勭悊@</el-button> -->
         <el-button @click="handleExport">瀵煎嚭</el-button>
       </div>
       <el-table
@@ -120,7 +120,7 @@
         <el-table-column fixed="right" label="鎿嶄綔" width="200" align="center">
           <template #default="scope">
             <el-button link type="primary" size="small" @click="handleEdit(scope.row)">缂栬緫</el-button>
-            <el-button link type="success" size="small" @click="handleProcess(scope.row)">澶勭悊</el-button>
+            <el-button link type="success" size="small" @click="handleProcess(scope.row)">澶勭悊@</el-button>
             <el-button link type="danger" size="small" @click="handleDelete(scope.row)">鍒犻櫎</el-button>
           </template>
         </el-table-column>
diff --git a/src/views/personnelManagement/selfService/index.vue b/src/views/personnelManagement/selfService/index.vue
index 1f4fbea..926229a 100644
--- a/src/views/personnelManagement/selfService/index.vue
+++ b/src/views/personnelManagement/selfService/index.vue
@@ -26,7 +26,7 @@
             <el-button type="primary" @click="addAttendanceRecord">鏂板璁板綍</el-button>
           </div>
         </template>
-        <el-table :data="attendanceData" style="width: 100%">
+        <el-table :data="attendanceData" style="width: 100%" :loading="tableLoading">
           <el-table-column prop="date" label="鏃ユ湡"  />
           <el-table-column prop="checkIn" label="绛惧埌鏃堕棿"  />
           <el-table-column prop="checkOut" label="绛鹃��鏃堕棿"  />
@@ -41,7 +41,7 @@
           <el-table-column label="鎿嶄綔" width="150">
             <template #default="scope">
               <el-button size="small" @click="editAttendanceRecord(scope.row)">缂栬緫</el-button>
-              <el-button size="small" type="danger" @click="deleteAttendanceRecord(scope.$index)">鍒犻櫎</el-button>
+              <el-button size="small" type="danger" @click="deleteAttendanceRecord(scope.row)">鍒犻櫎</el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -52,15 +52,15 @@
         <template #header>
           <div class="card-header">
             <span>钖祫鍗曟煡璇�</span>
-            <el-date-picker v-model="salaryMonth" type="month" placeholder="閫夋嫨鏈堜唤" />
+            <el-date-picker v-model="payDateStr" type="month" placeholder="閫夋嫨鏈堜唤" value-format="YYYY-MM" format="YYYY-MM" @change="changMonth"/>
           </div>
         </template>
         <el-table :data="salaryData" style="width: 100%">
-          <el-table-column prop="month" label="鏈堜唤"  />
+          <el-table-column prop="payDate" label="鏈堜唤"  />
           <el-table-column prop="basicSalary" label="鍩烘湰宸ヨ祫"  />
           <el-table-column prop="bonus" label="濂栭噾"  />
           <el-table-column prop="deduction" label="鎵f"  />
-          <el-table-column prop="total" label="瀹炲彂宸ヨ祫"  />
+          <el-table-column prop="actualWages" label="瀹炲彂宸ヨ祫"  />
           <el-table-column prop="status" label="鐘舵��" >
             <template #default="scope">
               <el-tag :type="scope.row.status === '宸插彂鏀�' ? 'success' : 'warning'">
@@ -76,7 +76,7 @@
         <template #header>
           <div class="card-header">
             <span>鍋囨湡鐢宠绠$悊</span>
-            <el-button type="primary" @click="showLeaveDialog = true">鐢宠鍋囨湡</el-button>
+            <el-button type="primary" @click="openLeaveForm">鐢宠鍋囨湡</el-button>
           </div>
         </template>
         <el-table :data="leaveData" style="width: 100%">
@@ -95,7 +95,7 @@
           <el-table-column label="鎿嶄綔" width="150">
             <template #default="scope">
               <el-button size="small" @click="editLeaveRecord(scope.row)">缂栬緫</el-button>
-              <el-button size="small" type="danger" @click="deleteLeaveRecord(scope.$index)">鍒犻櫎</el-button>
+              <el-button size="small" type="danger" @click="deleteLeaveRecord(scope.row)">鍒犻櫎</el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -106,7 +106,7 @@
         <template #header>
           <div class="card-header">
             <span>涓汉淇℃伅缁存姢</span>
-            <el-button type="primary" @click="editProfile = true">缂栬緫淇℃伅</el-button>
+            <el-button type="primary" @click="editProfileForm">缂栬緫淇℃伅</el-button>
           </div>
         </template>
         <el-descriptions :column="2" border>
@@ -117,13 +117,13 @@
           <el-descriptions-item label="鍏ヨ亴鏃ユ湡">{{ profile.hireDate }}</el-descriptions-item>
           <el-descriptions-item label="鑱旂郴鐢佃瘽">{{ profile.phone }}</el-descriptions-item>
           <el-descriptions-item label="閭">{{ profile.email }}</el-descriptions-item>
-          <el-descriptions-item label="鍦板潃">{{ profile.address }}</el-descriptions-item>
+          <el-descriptions-item label="鍦板潃">{{ profile.adress }}</el-descriptions-item>
         </el-descriptions>
       </el-card>
     </div>
 
     <!-- 鍋囨湡鐢宠寮圭獥 -->
-    <el-dialog v-model="showLeaveDialog" title="鐢宠鍋囨湡" width="500px">
+    <el-dialog v-model="showLeaveDialog" :title="leaveOperationType === 'add' ? '鐢宠鍋囨湡' : '缂栬緫鍋囨湡'" width="500px">
       <el-form :model="leaveForm" label-width="100px">
         <el-form-item label="鍋囨湡绫诲瀷">
           <el-select v-model="leaveForm.type" placeholder="璇烽�夋嫨鍋囨湡绫诲瀷">
@@ -142,6 +142,13 @@
         <el-form-item label="鐢宠鍘熷洜">
           <el-input v-model="leaveForm.reason" type="textarea" rows="3" />
         </el-form-item>
+        <!-- <el-form-item label="瀹℃壒鐘舵��">
+          <el-select v-model="leaveForm.status" placeholder="璇烽�夋嫨瀹℃壒鐘舵��">
+            <el-option label="瀹℃壒涓�" value="瀹℃壒涓�" />
+            <el-option label="宸查�氳繃" value="宸查�氳繃" />
+            <el-option label="宸叉嫆缁�" value="宸叉嫆缁�" />
+          </el-select>
+        </el-form-item> -->
       </el-form>
       <template #footer>
         <el-button @click="showLeaveDialog = false">鍙栨秷</el-button>
@@ -149,11 +156,11 @@
       </template>
     </el-dialog>
 
-    <!-- 鏂板鑰冨嫟璁板綍寮圭獥 -->
-    <el-dialog v-model="showAttendanceDialog" title="鏂板鑰冨嫟璁板綍" width="500px">
+    <!-- 鏂板-缂栬緫鑰冨嫟璁板綍寮圭獥 -->
+    <el-dialog v-model="showAttendanceDialog" :title="operationType === 'add' ? '鏂板鑰冨嫟璁板綍' : '缂栬緫鑰冨嫟璁板綍'" width="500px">
       <el-form :model="attendanceForm" :rules="attendanceRules" ref="attendanceFormRef" label-width="100px">
         <el-form-item label="鏃ユ湡" prop="date">
-          <el-date-picker v-model="attendanceForm.date" type="date" placeholder="閫夋嫨鏃ユ湡" />
+          <el-date-picker v-model="attendanceForm.date" type="date" value-format="YYYY-MM-DD" format="YYYY-MM-DD" placeholder="閫夋嫨鏃ユ湡" />
         </el-form-item>
         <el-form-item label="绛惧埌鏃堕棿" prop="checkIn">
           <el-time-picker v-model="attendanceForm.checkIn" placeholder="閫夋嫨绛惧埌鏃堕棿" format="HH:mm" value-format="HH:mm" />
@@ -189,7 +196,7 @@
           <el-input v-model="profileForm.email" />
         </el-form-item>
         <el-form-item label="鍦板潃">
-          <el-input v-model="profileForm.address" type="textarea" rows="2" />
+          <el-input v-model="profileForm.adress" type="textarea" rows="2" />
         </el-form-item>
       </el-form>
       <template #footer>
@@ -201,14 +208,29 @@
 </template>
 
 <script setup>
-import { ref, reactive, watch } from 'vue'
-import { ElMessage } from 'element-plus'
+import { ref, reactive, watch, onMounted } from 'vue'
+import { ElMessage, ElMessageBox } from 'element-plus'
 import { 
   Calendar, 
   Money, 
   Clock, 
   User
 } from '@element-plus/icons-vue'
+import { personalAttendanceRecordsListPage, personalAttendanceRecordsAdd, personalAttendanceRecordsUpdate, personalAttendanceRecordsDelete, holidayApplicationListPage, holidayApplicationAdd, holidayApplicationUpdate, holidayApplicationDelete } from '@/api/personnelManagement/selfService'
+import { compensationListPage, compensationAdd, compensationUpdate, compensationDelete } from '@/api/personnelManagement/payrollManagement'
+
+const { proxy } = getCurrentInstance()
+import { getUserProfile } from '@/api/system/user.js'
+import {staffJoinUpdate, staffJoinListPage} from "@/api/personnelManagement/onboarding.js";
+import { fa, id } from 'element-plus/es/locales.mjs'
+
+const tableLoading = ref(false)
+// 鍒嗛〉鍙傛暟
+const page = reactive({
+  current: 1,
+  size: 10,
+  total: 0
+})
 
 // 褰撳墠瑙嗗浘
 const currentView = ref('attendance')
@@ -222,63 +244,84 @@
 ]
 
 // 鑰冨嫟鏁版嵁
-const attendanceData = ref([
-  { date: '2024-01-15', checkIn: '09:00', checkOut: '18:00', workHours: '9灏忔椂', status: '姝e父' },
-  { date: '2024-01-16', checkIn: '08:55', checkOut: '18:05', workHours: '9灏忔椂10鍒�', status: '姝e父' },
-  { date: '2024-01-17', checkIn: '09:15', checkOut: '18:00', workHours: '8灏忔椂45鍒�', status: '杩熷埌' }
-])
+const attendanceData = ref([])
 
 // 钖祫鏁版嵁
-const salaryData = ref([
-  { month: '2024-01', basicSalary: 8000, bonus: 1000, deduction: 200, total: 8800, status: '宸插彂鏀�' },
-  { month: '2023-12', basicSalary: 8000, bonus: 800, deduction: 150, total: 8650, status: '宸插彂鏀�' }
-])
+const salaryData = ref([])
+
 
 // 鍋囨湡鏁版嵁
-const leaveData = ref([
-  { type: '骞村亣', startDate: '2024-02-01', endDate: '2024-02-03', days: 3, reason: '鏄ヨ妭鍥炲', status: '宸查�氳繃' },
-  { type: '鐥呭亣', startDate: '2024-01-20', endDate: '2024-01-21', days: 2, reason: '鎰熷啋鍙戠儳', status: '瀹℃壒涓�' }
-])
-
+const leaveData = ref([])
+  
+const currentUser = ref()
+const user= ref()
 // 涓汉淇℃伅
 const profile = ref({
-  name: '寮犳捣娲�',
-  employeeId: 'EMP001',
-  department: '鎶�鏈儴',
-  position: '杞欢宸ョ▼甯�',
-  hireDate: '2023-03-01',
-  phone: '13800138000',
-  email: 'zhangsan@company.com',
-  address: '鍖椾含甯傛湞闃冲尯xxx琛楅亾xxx鍙�'
-})
+  id: '',
+  name: '',
+  employeeId: '',
+  department: '',
+  position: '',
+  hireDate: '',
+  phone: '',
+  email: '',
+  adress: ''
+  })
 
 // 寮圭獥鎺у埗
 const showLeaveDialog = ref(false)
 const editProfile = ref(false)
-const salaryMonth = ref('')
+const payDateStr = ref('')
 
 // 琛ㄥ崟鏁版嵁
 const leaveForm = reactive({
+  id: '',
   type: '',
   startDate: '',
   endDate: '',
-  reason: ''
+  days: 0,
+  reason: '',
+  status: ''
 })
-
 const profileForm = reactive({
-  name: '',
-  phone: '',
-  email: '',
-  address: ''
+  name: "",
+  email: "",
+  adress: "",
+  phone: "",
+})
+const joinForm = reactive({
+  id: "",
+  staffNo: "",
+  staffName: "",
+  email: "",
+  adress: "",
+  sex: "",
+  nativePlace: "",
+  postJob: "",
+  firstStudy: "",
+  profession: "",
+  identityCard: "",
+  age: 0,
+  phone: "",
+  emergencyContact: "",
+  emergencyContactPhone: "",
+  contractTerm: 0,
+  contractStartTime: "",
+  contractEndTime: "",
+  staffState: 1,
 })
 
 // 鏂板鑰冨嫟璁板綍锛氬脊绐椾笌琛ㄥ崟
+const operationType = ref('add')
+const leaveOperationType = ref('add')
 const showAttendanceDialog = ref(false)
 const attendanceFormRef = ref(null)
 const attendanceForm = reactive({
+  id: '',
   date: '',
   checkIn: '',
   checkOut: '',
+  workHours: '',
   status: '姝e父'
 })
 const attendanceRules = {
@@ -305,6 +348,7 @@
 
 // 鏂板鑰冨嫟璁板綍锛堟墦寮�寮圭獥骞堕濉粯璁ゅ�硷級
 const addAttendanceRecord = () => {
+  operationType.value = 'add'
   attendanceForm.date = new Date().toISOString().split('T')[0]
   attendanceForm.checkIn = '09:00'
   attendanceForm.checkOut = '18:00'
@@ -324,11 +368,15 @@
   return m === 0 ? `${h}灏忔椂` : `${h}灏忔椂${m}鍒哷
 }
 
-// 鎻愪氦鏂板鑰冨嫟璁板綍
+// 缂栬緫鑰冨嫟璁板綍
+const editAttendanceRecord = (row) => {
+  operationType.value = 'edit'
+  Object.assign(attendanceForm, row)
+  showAttendanceDialog.value = true
+}
+// 鎻愪氦鏂板-缂栬緫鑰冨嫟璁板綍
 const submitAttendance = () => {
-  if (!attendanceFormRef.value) return
-  attendanceFormRef.value.validate((valid) => {
-    if (!valid) return
+  // if (!attendanceFormRef.value) return
     const workHours = computeWorkHours(attendanceForm.checkIn, attendanceForm.checkOut)
     const newRecord = {
       date: attendanceForm.date,
@@ -337,88 +385,320 @@
       workHours,
       status: attendanceForm.status
     }
-    attendanceData.value.unshift(newRecord)
-    showAttendanceDialog.value = false
-    // 閲嶇疆琛ㄥ崟
-    attendanceForm.date = ''
-    attendanceForm.checkIn = ''
-    attendanceForm.checkOut = ''
-    attendanceForm.status = '姝e父'
-    ElMessage.success('鑰冨嫟璁板綍娣诲姞鎴愬姛')
+  if (operationType.value === 'add') {
+    personalAttendanceRecordsAdd(newRecord)
+    .then(res => {
+      if (res.code === 200) {
+        ElMessage.success('鑰冨嫟璁板綍娣诲姞鎴愬姛')
+        getPersonalAttendanceRecordsList()
+        showAttendanceDialog.value = false
+        // 閲嶇疆琛ㄥ崟
+        attendanceForm.date = ''
+        attendanceForm.checkIn = ''
+        attendanceForm.checkOut = ''
+        attendanceForm.status = '姝e父'
+      }
+    }).catch(err => {
+      ElMessage.error('鑰冨嫟璁板綍娣诲姞澶辫触')
+    })
+  }else{
+    attendanceForm.workHours = computeWorkHours(attendanceForm.checkIn, attendanceForm.checkOut)
+    personalAttendanceRecordsUpdate(attendanceForm)
+    .then(res => {
+      if (res.code === 200) {
+        ElMessage.success('鑰冨嫟璁板綍鏇存柊鎴愬姛')
+        getPersonalAttendanceRecordsList()
+        showAttendanceDialog.value = false
+        // 閲嶇疆琛ㄥ崟
+        attendanceForm.date = ''
+        attendanceForm.checkIn = ''
+        attendanceForm.checkOut = ''
+        attendanceForm.status = '姝e父'
+      }
+    }).catch(err => {
+      ElMessage.error('鑰冨嫟璁板綍鏇存柊澶辫触')
+    })
+  }
+  // attendanceFormRef.value.validate((valid) => {
+  //   if (!valid) return
+    
+    
+  // })
+}
+// 鍒犻櫎鑰冨嫟璁板綍
+const deleteAttendanceRecord = (row) => {
+
+  ElMessageBox.confirm('纭畾鍒犻櫎璇ヨ�冨嫟璁板綍鍚楋紵', '鎻愮ず', {
+    confirmButtonText: '纭畾',
+    cancelButtonText: '鍙栨秷',
+    type: 'warning'
+  }).then(() => {
+    personalAttendanceRecordsDelete(row.id)
+    .then(res => {
+      if (res.code === 200) {
+        ElMessage.success('鑰冨嫟璁板綍鍒犻櫎鎴愬姛')
+        getPersonalAttendanceRecordsList()
+      }
+    }).catch(err => {
+      ElMessage.error('鑰冨嫟璁板綍鍒犻櫎澶辫触')
+    })
+  }).catch(() => {
+    ElMessage({
+      type: 'info',
+      message: '宸插彇娑堝垹闄�'
+    })
   })
 }
-
-// 缂栬緫鑰冨嫟璁板綍
-const editAttendanceRecord = (row) => {
-  ElMessage.info('缂栬緫鍔熻兘寮�鍙戜腑...')
+// 鐢宠鍋囨湡
+const openLeaveForm = () => {
+  leaveOperationType.value = 'add'
+  showLeaveDialog.value = true
+  // leaveForm.type = ''
+  // leaveForm.startDate = ''
+  // leaveForm.endDate = ''
+  // leaveForm.days = 0
+  // leaveForm.reason = ''
+  // leaveForm.status = 'warning'
 }
-
-// 鍒犻櫎鑰冨嫟璁板綍
-const deleteAttendanceRecord = (index) => {
-  attendanceData.value.splice(index, 1)
-  ElMessage.success('鑰冨嫟璁板綍鍒犻櫎鎴愬姛')
-}
-
 // 缂栬緫鍋囨湡璁板綍
 const editLeaveRecord = (row) => {
-  ElMessage.info('缂栬緫鍔熻兘寮�鍙戜腑...')
+  leaveOperationType.value = 'edit'
+  showLeaveDialog.value = true
+  Object.assign(leaveForm, row)
+  // ElMessage.info('缂栬緫鍔熻兘寮�鍙戜腑...')
 }
 
 // 鍒犻櫎鍋囨湡璁板綍
-const deleteLeaveRecord = (index) => {
-  leaveData.value.splice(index, 1)
-  ElMessage.success('鍋囨湡璁板綍鍒犻櫎鎴愬姛')
+const deleteLeaveRecord = (row) => {
+  ElMessageBox.confirm('纭畾鍒犻櫎璇ュ亣鏈熻褰曞悧锛�', '鎻愮ず', {
+    confirmButtonText: '纭畾',
+    cancelButtonText: '鍙栨秷',
+    type: 'warning'
+  }).then(() => {
+    holidayApplicationDelete(row.id)
+    .then(res => {
+      if (res.code === 200) {
+        ElMessage.success('鍋囨湡璁板綍鍒犻櫎鎴愬姛')
+        getHolidayApplicationList()
+      }
+    }).catch(err => {
+      ElMessage.error('鍋囨湡璁板綍鍒犻櫎澶辫触')
+    })
+  }).catch(() => {
+    ElMessage({
+      type: 'info',
+      message: '宸插彇娑堝垹闄�'
+    })
+  })
+}
+
+//璁$畻鍋囨湡澶╂暟
+const calculateDays = () => {
+  try {
+    if (leaveForm.startDate && leaveForm.endDate) {
+      const start = new Date(leaveForm.startDate)
+      const end = new Date(leaveForm.endDate)
+      leaveForm.startDate = start.toISOString().split('T')[0]
+      leaveForm.endDate = end.toISOString().split('T')[0]
+
+      if (isNaN(start.getTime()) || isNaN(end.getTime())) {
+        console.warn('鏃犳晥鐨勬棩鏈熸牸寮�')
+        return
+      }
+
+      const diffTime = Math.abs(end - start)
+      const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1
+      leaveForm.days = diffDays
+    }
+  } catch (error) {
+    console.error('璁$畻澶╂暟澶辫触:', error)
+  }
 }
 
 // 鎻愪氦鍋囨湡鐢宠
 const submitLeaveApplication = () => {
-  if (!leaveForm.type || !leaveForm.startDate || !leaveForm.endDate || !leaveForm.reason) {
-    ElMessage.warning('璇峰~鍐欏畬鏁翠俊鎭�')
-    return
-  }
-  
-  const newLeave = {
+  if (leaveOperationType.value === 'add') {
+    if (!leaveForm.type || !leaveForm.startDate || !leaveForm.endDate || !leaveForm.reason) {
+      ElMessage.warning('璇峰~鍐欏畬鏁翠俊鎭�')
+      return
+    }
+    calculateDays()
+    const newLeave = {
     type: leaveForm.type,
     startDate: leaveForm.startDate,
     endDate: leaveForm.endDate,
-    days: 3, // 绠�鍗曡绠�
+    days: leaveForm.days, // 绠�鍗曡绠�
     reason: leaveForm.reason,
     status: '瀹℃壒涓�'
+    }
+
+    holidayApplicationAdd(newLeave)
+    .then(res => {
+      if (res.code === 200) {
+        ElMessage.success('鍋囨湡鐢宠鎻愪氦鎴愬姛')
+        getHolidayApplicationList()
+        showLeaveDialog.value = false
+        // 閲嶇疆琛ㄥ崟
+        Object.keys(leaveForm).forEach(key => {
+          leaveForm[key] = ''
+        })
+      }
+    }).catch(err => {
+      ElMessage.error('鍋囨湡鐢宠鎻愪氦澶辫触')
+    })
+  }else{
+    calculateDays()
+    holidayApplicationUpdate(leaveForm)
+    .then(res => {
+      if (res.code === 200) {
+        ElMessage.success('鍋囨湡鐢宠鏇存柊鎴愬姛')
+        getHolidayApplicationList()
+        showLeaveDialog.value = false
+        // 閲嶇疆琛ㄥ崟
+        Object.keys(leaveForm).forEach(key => {
+          leaveForm[key] = ''
+        })
+      }
+    }).catch(err => {
+      ElMessage.error('鍋囨湡鐢宠鏇存柊澶辫触')
+    })
   }
-  
-  leaveData.value.unshift(newLeave)
-  showLeaveDialog.value = false
-  
-  // 閲嶇疆琛ㄥ崟
-  Object.keys(leaveForm).forEach(key => {
-    leaveForm[key] = ''
+}
+
+// 鑾峰彇涓汉淇℃伅
+const getProfile = () => {
+  tableLoading.value = true;
+  getUserProfile().then(res => {
+    if (res.code === 200) {
+      currentUser.value = res.data
+      // console.log("----",currentUser.value)
+        //寰楀埌浜哄憳鍒楄〃
+        staffJoinListPage({staffState: 1}).then(res => {
+          //绛涢�夊嚭鍜宑urrentUser鍚屽悕鐨勪汉鍛�
+          // let tableData = res.data.records
+          user.value = res.data.records.find(item => item.staffName === currentUser.value.userName)
+          // console.log("++++",user.value)
+          if(user.value){
+            profile.value.id=user.value.id
+            profile.value.name=user.value.staffName
+            profile.value.employeeId=user.value.staffNo
+            profile.value.phone=user.value.phone
+            profile.value.email=currentUser.value.email
+            profile.value.adress=user.value.adress
+            profile.value.position=user.value.postJob
+            profile.value.hireDate=user.value.createTime
+            profile.value.department=currentUser.value.deptNames
+          }
+          // console.log(profile.value)
+          // tableLoading.value = false;
+        }).catch(err => {})
+    }
+  }).catch(err => {
+    tableLoading.value = false;
+    ElMessage.error('鑾峰彇涓汉淇℃伅澶辫触')
   })
-  
-  ElMessage.success('鍋囨湡鐢宠鎻愪氦鎴愬姛')
 }
-
 // 淇濆瓨涓汉淇℃伅
-const saveProfile = () => {
-  Object.assign(profile.value, profileForm)
-  editProfile.value = false
-  ElMessage.success('涓汉淇℃伅淇濆瓨鎴愬姛')
-}
+const saveProfile = async () => {
+  tableLoading.value = true;
+  try {
+    const userRes = await getUserProfile();
+    if (userRes.code === 200) {
+      currentUser.value = userRes.data;
+      const staffListRes = await staffJoinListPage({ staffState: 1 });
+      user.value = staffListRes.data.records.find(item => item.staffName === currentUser.value.userName);
+      // console.log("++++", user.value);
 
-// 鍒濆鍖栦釜浜轰俊鎭〃鍗�
-const initProfileForm = () => {
+      Object.assign(joinForm, user.value);
+      joinForm.staffName = profileForm.name;
+      joinForm.phone = profileForm.phone;
+      joinForm.email = profileForm.email;
+      joinForm.adress = profileForm.adress; 
+      console.log(joinForm)
+      // 璋冪敤鏇存柊涓汉淇℃伅鐨勬帴鍙�
+      staffJoinUpdate(joinForm).then(res => {
+        if (res.code === 200) {
+          ElMessage.success('涓汉淇℃伅淇濆瓨鎴愬姛');
+          getProfile();
+          editProfile.value = false;
+        }
+      }).catch(err => {
+        ElMessage.error('涓汉淇℃伅淇濆瓨澶辫触');
+      })
+    }
+  } catch (err) {
+    ElMessage.error('鑾峰彇涓汉淇℃伅澶辫触');
+  } finally {
+    tableLoading.value = false;
+  }
+};
+
+// 缂栬緫涓汉淇℃伅
+const editProfileForm = () => {
+  editProfile.value = true;
   Object.assign(profileForm, {
     name: profile.value.name,
     phone: profile.value.phone,
     email: profile.value.email,
-    address: profile.value.address
+    adress: profile.value.adress, 
+  });
+};
+
+//鏈堜唤鏀瑰彉
+const changMonth = () => {
+  getCompensationList()
+}
+//鑾峰彇鑰冨嫟璁板綍鍒楄〃
+const getPersonalAttendanceRecordsList = async () => {
+  tableLoading.value = true
+  personalAttendanceRecordsListPage(page)
+  .then(res => {
+
+    attendanceData.value = res.data.records
+    page.value.total = res.data.total;
+    tableLoading.value = false;
+
+  }).catch(err => {
+    tableLoading.value = false;
   })
 }
+//钖祫鍗曟煡璇�
+const getCompensationList = async () => {
+  tableLoading.value = true
+  compensationListPage({...page,payDateStr:payDateStr.value})
+  .then(res => {
+    salaryData.value = res.data.records
+    //杩囨护鍑哄綋鍓嶆湀浠界殑鎵f鍚堣
+    salaryData.value.forEach(item => {
+      item.deduction =0 + item.deductionAbsenteeism+item.sickLeaveDeductions+item.deductionPersonalLeave+item.forgetClockDeduct,
+      item.bonus=0,
+      item.status='宸插彂鏀�'
+    })
 
-// 鐩戝惉缂栬緫涓汉淇℃伅寮圭獥
-watch(editProfile, (val) => {
-  if (val) {
-    initProfileForm()
-  }
+    page.value.total = res.data.total;
+    tableLoading.value = false;
+  }).catch(err => {
+    tableLoading.value = false;
+  })
+}
+//鑾峰彇鍋囨湡鐢宠鍒楄〃
+const getHolidayApplicationList = async () => {
+  tableLoading.value = true
+  holidayApplicationListPage(page)
+  .then(res => {
+    leaveData.value = res.data.records
+    page.value.total = res.data.total;
+    tableLoading.value = false;
+  }).catch(err => {
+    tableLoading.value = false;
+  })
+}
+onMounted(() => {
+  // 鍒濆鍖�
+  getPersonalAttendanceRecordsList()
+  getCompensationList()
+  getHolidayApplicationList()
+  getProfile()
 })
 </script>
 

--
Gitblit v1.9.3