|
@@ -27,25 +27,38 @@
|
|
|
<!-- <el-calendar v-model="calendarValue" /> -->
|
|
|
<el-calendar v-model="calendarValue">
|
|
|
<template #date-cell="{ data }">
|
|
|
- <div
|
|
|
- class="calendar-cell"
|
|
|
- @dblclick="handleDayDblClick(data.day)"
|
|
|
- >
|
|
|
- <el-checkbox
|
|
|
- :label="formatMonthDay(data.day)"
|
|
|
- :value="data.day"
|
|
|
- v-model="selectedDates"
|
|
|
- @click.stop
|
|
|
- />
|
|
|
- <div class="employee-names">
|
|
|
- <div v-for="(name, index) in (scheduleMap[data.day]?.names || [])" :key="index" class="employee-name" @dblclick.stop>
|
|
|
- {{ name }}
|
|
|
+ <div class="calendar-cell" @dblclick="handleDayDblClick(data.day)">
|
|
|
+ <div class="checkbox-status">
|
|
|
+ <el-checkbox
|
|
|
+ :label="formatMonthDay(data.day)"
|
|
|
+ :checked="selectedDates.includes(data.day)"
|
|
|
+ @change="(val) => handleDateToggle(data.day, val)"
|
|
|
+ @click.stop
|
|
|
+ />
|
|
|
+ <el-tag
|
|
|
+ v-if="scheduleMap[data.day]?.status !== undefined"
|
|
|
+ :type="scheduleMap[data.day].status == '0' ? 'warning' : 'success'"
|
|
|
+ size="small"
|
|
|
+ class="status-tag"
|
|
|
+ >
|
|
|
+ {{ scheduleMap[data.day].status == '0' ? '未确认' : '已确认' }}
|
|
|
+ </el-tag>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="employee-names">
|
|
|
+ <div
|
|
|
+ v-for="(name, index) in (scheduleMap[data.day]?.names || [])"
|
|
|
+ :key="index"
|
|
|
+ class="employee-name"
|
|
|
+ @dblclick.stop
|
|
|
+ >
|
|
|
+ {{ name }}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
- </el-calendar>
|
|
|
|
|
|
+ </el-calendar>
|
|
|
<el-pagination :current-page="state.page" :page-sizes="[10, 20, 50, 100]" :page-size="state.limit" :total="state.total" layout="total, sizes, prev, pager, next, jumper" @size-change="state.pageSizeChangeHandle" @current-change="state.pageCurrentChangeHandle"> </el-pagination>
|
|
|
<!-- 弹窗, 新增 / 修改 -->
|
|
|
<add-or-update ref="addOrUpdateRef" @refreshDataList="refreshAfterAdd">确定</add-or-update>
|
|
@@ -65,11 +78,13 @@ const view = reactive({
|
|
|
getDataListURL: "/emergency/schedule/page",
|
|
|
getDataListIsPage: true,
|
|
|
exportURL: "/emergency/schedule/export",
|
|
|
- deleteURL: "/emergency/schedule"
|
|
|
+ deleteURL: "/emergency/schedule",
|
|
|
+
|
|
|
});
|
|
|
|
|
|
const state = reactive({ ...useView(view), ...toRefs(view) });
|
|
|
|
|
|
+
|
|
|
//日历
|
|
|
const calendarValue = ref(new Date())
|
|
|
const selectedDates = ref<string[]>([]);
|
|
@@ -78,48 +93,33 @@ const formatMonthDay = (fullDate: string): string => {
|
|
|
return `${parts[1]}-${parts[2]}`;
|
|
|
};
|
|
|
|
|
|
-const employeeOptions = ref<{ id: string; name: string }[]>([]);
|
|
|
-// id->姓名
|
|
|
-const employeeIdMap = ref<Record<string, string>>({});
|
|
|
-// 日期->员工姓名数组
|
|
|
-const scheduleMap = ref<Record<string, { id: number; names: string[] }>>({});
|
|
|
+const scheduleMap = ref<Record<string, { id: number; names: string[]; status:string }>>({});
|
|
|
|
|
|
-// 构建id->姓名映射
|
|
|
-const fetchEmployeeOptions = async () => {
|
|
|
- const res = await baseService.get("/emergency/employee/page");
|
|
|
- employeeOptions.value = res.data.list || [];
|
|
|
-
|
|
|
- employeeIdMap.value = {};
|
|
|
- for (const item of employeeOptions.value) {
|
|
|
- employeeIdMap.value[item.id] = item.name;
|
|
|
- }
|
|
|
-};
|
|
|
const buildScheduleMap = (list: any[]) => {
|
|
|
scheduleMap.value = {};
|
|
|
for (const item of list) {
|
|
|
const day = item.scheduleDate;
|
|
|
- //保存的ids
|
|
|
- const ids = item.employeeIds || [];
|
|
|
- const names = ids.map((id: string) => employeeIdMap.value[id] || `员工姓名未知,id为${id}`);
|
|
|
- scheduleMap.value[day] = { id: item.id, names};
|
|
|
- console.log(list);
|
|
|
- console.log(scheduleMap.value);
|
|
|
+ scheduleMap.value[day] = {
|
|
|
+ id: item.id,
|
|
|
+ names: item.employeeNames || [],
|
|
|
+ status: item.status
|
|
|
+ };
|
|
|
+
|
|
|
}
|
|
|
};
|
|
|
import { onMounted } from 'vue'
|
|
|
onMounted(async () => {
|
|
|
- await fetchEmployeeOptions();
|
|
|
await state.getDataList();
|
|
|
buildScheduleMap(state.dataList || []);
|
|
|
|
|
|
-
|
|
|
+ console.log(state.dataList);
|
|
|
});
|
|
|
|
|
|
// 新增按钮
|
|
|
const addHandle = () => {
|
|
|
if (!selectedDates.value || selectedDates.value.length === 0) {
|
|
|
ElMessage({
|
|
|
- message: '请先选择一个或多个日期再新增排班',
|
|
|
+ message: '请选择操作项',
|
|
|
type: 'warning',
|
|
|
duration: 500,
|
|
|
});
|
|
@@ -128,12 +128,14 @@ const addHandle = () => {
|
|
|
// 批量添加
|
|
|
addOrUpdateHandle(undefined, undefined, selectedDates.value);
|
|
|
};
|
|
|
-//新增后清除已选中
|
|
|
+
|
|
|
const refreshAfterAdd = async () => {
|
|
|
- await fetchEmployeeOptions();
|
|
|
- await state.getDataList();
|
|
|
- buildScheduleMap(state.dataList || []);
|
|
|
selectedDates.value = [];
|
|
|
+ await state.getDataList();
|
|
|
+
|
|
|
+ console.log(state.dataList);
|
|
|
+ buildScheduleMap(state.dataList || []);
|
|
|
+ console.log(scheduleMap.value);
|
|
|
};
|
|
|
|
|
|
const addOrUpdateRef = ref();
|
|
@@ -153,6 +155,15 @@ const handleDayDblClick = (day: string) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const handleDateToggle = (day: string, checked: boolean) => {
|
|
|
+ const index = selectedDates.value.indexOf(day);
|
|
|
+ if (checked && index === -1) {
|
|
|
+ selectedDates.value.push(day);
|
|
|
+ } else if (!checked && index !== -1) {
|
|
|
+ selectedDates.value.splice(index, 1);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
// 审阅
|
|
|
const reviewHandle = (id?: string) => {
|
|
|
if (!id && state.dataListSelections && state.dataListSelections.length <= 0) {
|
|
@@ -205,6 +216,21 @@ const reviewHandle = (id?: string) => {
|
|
|
-webkit-user-select: none;
|
|
|
-moz-user-select: none;
|
|
|
}
|
|
|
+.checkbox-status {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 4px;
|
|
|
+ margin-bottom: 2px;
|
|
|
+}
|
|
|
+
|
|
|
+.status-tag {
|
|
|
+ font-size: 10px;
|
|
|
+ padding: 0 4px;
|
|
|
+ height: 20px;
|
|
|
+ user-select: none;
|
|
|
+ -webkit-user-select: none;
|
|
|
+ -moz-user-select: none;
|
|
|
+}
|
|
|
|
|
|
|
|
|
::v-deep(.el-calendar-day) {
|