yaowanxin
17 小时以前 85ef9a437fe32c569b55f6e8391fdefb76780840
用印管理-阅读修改,自助服务平台页面调整
已修改6个文件
已添加1个文件
770 ■■■■ 文件已修改
src/api/collaborativeApproval/sealManagement.js 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/personnelManagement/selfService.js 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/collaborativeApproval/knowledgeBase/index.vue 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/collaborativeApproval/planTemplate/index.vue 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/collaborativeApproval/sealManagement/index.vue 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/inventoryManagement/stockWarning/index.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/personnelManagement/selfService/index.vue 486 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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) {
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",
//     });
// }
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}
解决方案:${currentKnowledge.value.solution}
关键要点:${currentKnowledge.value.keyPoints}
创建人:${currentKnowledge.value.creator}
    çŸ¥è¯†æ ‡é¢˜ï¼š${currentKnowledge.value.title}
    çŸ¥è¯†ç±»åž‹ï¼š${getTypeLabel(currentKnowledge.value.type)}
    é€‚用场景:${currentKnowledge.value.scenario}
    é—®é¢˜æè¿°ï¼š${currentKnowledge.value.problem}
    è§£å†³æ–¹æ¡ˆï¼š${currentKnowledge.value.solution}
    å…³é”®è¦ç‚¹ï¼š${currentKnowledge.value.keyPoints}
    åˆ›å»ºäººï¼š${currentKnowledge.value.creator}
  `.trim();
  // å¤åˆ¶åˆ°å‰ªè´´æ¿
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('确定要删除这个计划吗?', '提示', {
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
    // //筛选出和currentUser同名的人员
    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
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>
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="扣款"  />
          <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: '正常' },
  { date: '2024-01-16', checkIn: '08:55', checkOut: '18:05', workHours: '9小时10分', status: '正常' },
  { 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: '正常'
})
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 = '正常'
    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 = '正常'
      }
    }).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 = '正常'
      }
    }).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 => {
          //筛选出和currentUser同名的人员
          // 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
    //过滤出当前月份的扣款合计
    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>