From 28fc65c34d1642b007dc45b83782e23be58d718c Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期三, 08 七月 2026 16:43:58 +0800
Subject: [PATCH] 已进行排班并且人员已打卡的前提下,对应的班次配置不能编辑删除。
---
src/views/personnelManagement/attendanceCheckin/checkinRules/index.vue | 122 +++++++++++++++++++++++++++++++---------
1 files changed, 94 insertions(+), 28 deletions(-)
diff --git a/src/views/personnelManagement/attendanceCheckin/checkinRules/index.vue b/src/views/personnelManagement/attendanceCheckin/checkinRules/index.vue
index 9064274..9658b1f 100644
--- a/src/views/personnelManagement/attendanceCheckin/checkinRules/index.vue
+++ b/src/views/personnelManagement/attendanceCheckin/checkinRules/index.vue
@@ -13,30 +13,37 @@
</el-button>
</div>
</div>
- <!-- 鏌ヨ鏉′欢 -->
- <!-- <el-form :model="searchForm"
+ <el-form :model="searchForm"
:inline="true"
class="search-form mb16">
<el-form-item label="閮ㄩ棬锛�"
- prop="countId">
- <el-tree-select v-model="searchForm.countId"
+ prop="sysDeptId">
+ <el-tree-select v-model="searchForm.sysDeptId"
:data="deptOptions"
:props="{ value: 'id', label: 'label', children: 'children' }"
value-key="id"
placeholder="璇烽�夋嫨閮ㄩ棬"
check-strictly
+ clearable
style="width: 200px" />
</el-form-item>
- <el-form-item label="鍦扮偣锛�"
- prop="locationName">
- <el-input v-model="searchForm.locationName"
- placeholder="璇疯緭鍏ュ湴鐐瑰悕绉�"
- clearable
- style="width: 200px" />
+ <el-form-item label="鐝锛�"
+ prop="shift">
+ <el-select v-model="searchForm.shift"
+ placeholder="璇烽�夋嫨鐝"
+ clearable
+ style="width: 200px">
+ <el-option
+ v-for="item in shifts_list"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value"
+ />
+ </el-select>
</el-form-item>
<el-form-item>
<el-button type="primary"
- @click="fetchData">
+ @click="handleSearch">
<el-icon>
<Search />
</el-icon>
@@ -49,13 +56,14 @@
閲嶇疆
</el-button>
</el-form-item>
- </el-form> -->
+ </el-form>
<!-- 鐝鍒楄〃 -->
<el-card shadow="never"
class="mb16">
<el-table :data="tableData"
border
v-loading="tableLoading"
+ height="calc(100vh - 18.5em)"
style="width: 100%"
row-key="id">
<el-table-column type="index"
@@ -67,24 +75,45 @@
{{ getDeptNameById(scope.row.sysDeptId) }}
</template>
</el-table-column>
+ <el-table-column label="鐝">
+ <template #default="scope">
+ {{ getShiftNameByValue(scope.row.shift) }}
+ </template>
+ </el-table-column>
<el-table-column prop="locationName"
- label="鍦扮偣鍚嶇О" />
+ label="鍦扮偣鍚嶇О">
+ <template #default="scope">
+ {{ scope.row.locationName || "-" }}
+ </template>
+ </el-table-column>
<el-table-column prop="longitude"
- label="缁忓害" />
+ label="缁忓害">
+ <template #default="scope">
+ {{ scope.row.longitude ?? "-" }}
+ </template>
+ </el-table-column>
<el-table-column prop="latitude"
- label="绾害" />
+ label="绾害">
+ <template #default="scope">
+ {{ scope.row.latitude ?? "-" }}
+ </template>
+ </el-table-column>
<el-table-column prop="radius"
- label="鎵撳崱鑼冨洿(m)" />
+ label="鎵撳崱鑼冨洿(m)">
+ <template #default="scope">
+ {{ scope.row.radius ?? "-" }}
+ </template>
+ </el-table-column>
<el-table-column prop="startAt"
label="涓婄彮鏃堕棿">
<template #default="scope">
- {{ scope.row.startAt }}
+ {{ scope.row.startAt || "-" }}
</template>
</el-table-column>
<el-table-column prop="endAt"
label="涓嬬彮鏃堕棿">
<template #default="scope">
- {{ scope.row.endAt }}
+ {{ scope.row.endAt || "-" }}
</template>
</el-table-column>
<el-table-column label="鎿嶄綔"
@@ -93,12 +122,12 @@
align="center">
<template #default="scope">
<el-button type="primary"
- size="small"
link
+ :disabled="isRuleLocked(scope.row)"
@click="openForm('edit', scope.row)">缂栬緫</el-button>
<el-button type="danger"
- size="small"
link
+ :disabled="isRuleLocked(scope.row)"
@click="handleDelete(scope.row.id)">鍒犻櫎</el-button>
</template>
</el-table-column>
@@ -120,9 +149,16 @@
</template>
<script setup>
- import { ref, reactive, onMounted } from "vue";
+ import { ref, reactive, onMounted, getCurrentInstance } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
- import { Plus, Edit, Delete, Search, Refresh } from "@element-plus/icons-vue";
+ import {
+ Plus,
+ Edit,
+ Delete,
+ Search,
+ Refresh,
+ ArrowLeft,
+ } from "@element-plus/icons-vue";
import Pagination from "@/components/Pagination/index.vue";
import RuleForm from "./components/form.vue";
import { deptTreeSelect } from "@/api/system/user.js";
@@ -130,6 +166,7 @@
getAttendanceRules,
deleteAttendanceRule,
} from "@/api/personnelManagement/attendanceRules.js";
+ import { useDict } from "@/utils/dict";
const { proxy } = getCurrentInstance();
@@ -146,12 +183,14 @@
// 鏌ヨ琛ㄥ崟
const searchForm = reactive({
- countId: "",
- locationName: "",
+ sysDeptId: "",
+ shift: "",
});
// 閮ㄩ棬閫夐」
const deptOptions = ref([]);
+ // 鑾峰彇鐝瀛楀吀鍊�
+ const { shifts_list } = useDict("shifts_list");
// 寮圭獥鎺у埗
const dialogVisible = ref(false);
@@ -166,6 +205,17 @@
return `${String(date.getHours()).padStart(2, "0")}:${String(
date.getMinutes()
).padStart(2, "0")}`;
+ };
+
+ // 鏍规嵁鐝鍊艰幏鍙栫彮娆″悕绉�
+ const getShiftNameByValue = value => {
+ if (!value) return "";
+ const shift = shifts_list.value.find(item => item.value === value);
+ return shift ? shift.label : value;
+ };
+
+ const isRuleLocked = row => {
+ return Boolean(row?.usageLocked || row?.canEdit === false || row?.canDelete === false);
};
// 鑾峰彇閮ㄩ棬鍒楄〃
@@ -211,12 +261,18 @@
tableLoading.value = true;
getAttendanceRules({ ...page, ...searchForm })
.then(res => {
- tableData.value = res.data.records;
+ const records = Array.isArray(res?.data?.records) ? res.data.records : [];
+ tableData.value = records.filter(r => String(r?.id) !== "999");
page.total = res.data.total;
})
.finally(() => {
tableLoading.value = false;
});
+ };
+
+ const handleSearch = () => {
+ page.current = 1;
+ fetchData();
};
// 鍒嗛〉鍙樻洿
@@ -228,13 +284,18 @@
// 閲嶇疆鎼滅储
const resetSearch = () => {
- searchForm.countId = "";
- searchForm.locationName = "";
+ searchForm.sysDeptId = "";
+ searchForm.shift = "";
+ page.current = 1;
fetchData();
};
// 鎵撳紑琛ㄥ崟
const openForm = (type, row = {}) => {
+ if (type === "edit" && isRuleLocked(row)) {
+ ElMessage.warning("璇ョ彮娆¢厤缃凡琚帓鐝苟浜х敓鎵撳崱璁板綍锛屼笉鑳界紪杈�");
+ return;
+ }
operationType.value = type;
currentRow.value = row;
dialogVisible.value = true;
@@ -242,6 +303,11 @@
// 鍒犻櫎鐝
const handleDelete = id => {
+ const row = tableData.value.find(item => String(item.id) === String(id));
+ if (isRuleLocked(row)) {
+ ElMessage.warning("瀛樺湪宸叉帓鐝笖宸叉湁鎵撳崱璁板綍鐨勭彮娆¢厤缃紝涓嶈兘鍒犻櫎");
+ return;
+ }
ElMessageBox.confirm("纭畾瑕佸垹闄よ繖鏉$彮娆″悧锛�", "鍒犻櫎纭", {
confirmButtonText: "纭畾",
cancelButtonText: "鍙栨秷",
@@ -290,4 +356,4 @@
.mt10 {
margin-top: 10px;
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.9.3