|
@@ -27,30 +27,37 @@
|
|
<!-- <el-calendar v-model="calendarValue" /> -->
|
|
<!-- <el-calendar v-model="calendarValue" /> -->
|
|
<el-calendar v-model="calendarValue">
|
|
<el-calendar v-model="calendarValue">
|
|
<template #date-cell="{ data }">
|
|
<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
|
|
|
|
- /> -->
|
|
|
|
- <el-checkbox
|
|
|
|
- :label="formatMonthDay(data.day)"
|
|
|
|
- :checked="selectedDates.includes(data.day)"
|
|
|
|
- @change="(val) => handleDateToggle(data.day, val)"
|
|
|
|
- @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>
|
|
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</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>
|
|
<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>
|
|
<!-- 弹窗, 新增 / 修改 -->
|
|
<!-- 弹窗, 新增 / 修改 -->
|
|
@@ -71,7 +78,8 @@ const view = reactive({
|
|
getDataListURL: "/emergency/schedule/page",
|
|
getDataListURL: "/emergency/schedule/page",
|
|
getDataListIsPage: true,
|
|
getDataListIsPage: true,
|
|
exportURL: "/emergency/schedule/export",
|
|
exportURL: "/emergency/schedule/export",
|
|
- deleteURL: "/emergency/schedule"
|
|
|
|
|
|
+ deleteURL: "/emergency/schedule",
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
const state = reactive({ ...useView(view), ...toRefs(view) });
|
|
const state = reactive({ ...useView(view), ...toRefs(view) });
|
|
@@ -85,36 +93,22 @@ const formatMonthDay = (fullDate: string): string => {
|
|
return `${parts[1]}-${parts[2]}`;
|
|
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[]) => {
|
|
const buildScheduleMap = (list: any[]) => {
|
|
scheduleMap.value = {};
|
|
scheduleMap.value = {};
|
|
for (const item of list) {
|
|
for (const item of list) {
|
|
const day = item.scheduleDate;
|
|
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};
|
|
|
|
|
|
+ scheduleMap.value[day] = {
|
|
|
|
+ id: item.id,
|
|
|
|
+ names: item.employeeNames || [],
|
|
|
|
+ status: item.status
|
|
|
|
+ };
|
|
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
import { onMounted } from 'vue'
|
|
import { onMounted } from 'vue'
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
- await fetchEmployeeOptions();
|
|
|
|
await state.getDataList();
|
|
await state.getDataList();
|
|
buildScheduleMap(state.dataList || []);
|
|
buildScheduleMap(state.dataList || []);
|
|
|
|
|
|
@@ -137,11 +131,11 @@ const addHandle = () => {
|
|
|
|
|
|
const refreshAfterAdd = async () => {
|
|
const refreshAfterAdd = async () => {
|
|
selectedDates.value = [];
|
|
selectedDates.value = [];
|
|
- await fetchEmployeeOptions();
|
|
|
|
await state.getDataList();
|
|
await state.getDataList();
|
|
|
|
|
|
console.log(state.dataList);
|
|
console.log(state.dataList);
|
|
buildScheduleMap(state.dataList || []);
|
|
buildScheduleMap(state.dataList || []);
|
|
|
|
+ console.log(scheduleMap.value);
|
|
};
|
|
};
|
|
|
|
|
|
const addOrUpdateRef = ref();
|
|
const addOrUpdateRef = ref();
|
|
@@ -222,6 +216,21 @@ const reviewHandle = (id?: string) => {
|
|
-webkit-user-select: none;
|
|
-webkit-user-select: none;
|
|
-moz-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) {
|
|
::v-deep(.el-calendar-day) {
|