|  | @@ -36,18 +36,18 @@
 | 
	
		
			
				|  |  |                @click.stop
 | 
	
		
			
				|  |  |              />
 | 
	
		
			
				|  |  |              <el-tag
 | 
	
		
			
				|  |  | -              v-if="scheduleMap[data.day]?.status !== undefined"
 | 
	
		
			
				|  |  | -              :type="scheduleMap[data.day].status == '0' ? 'warning' : 'success'"
 | 
	
		
			
				|  |  | +              v-if="getScheduleStatus(data.day) !== null"
 | 
	
		
			
				|  |  | +              :type="getScheduleStatus(data.day) === 0 ? 'warning' : 'success'"
 | 
	
		
			
				|  |  |                size="small"
 | 
	
		
			
				|  |  |                class="status-tag"
 | 
	
		
			
				|  |  |              >
 | 
	
		
			
				|  |  | -              {{ scheduleMap[data.day].status == '0' ? '未确认' : '已确认' }}
 | 
	
		
			
				|  |  | +              {{ getScheduleStatus(data.day) === 0 ? '未确认' : '已确认' }}
 | 
	
		
			
				|  |  |              </el-tag>
 | 
	
		
			
				|  |  |            </div>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |            <div class="employee-names">
 | 
	
		
			
				|  |  |              <div
 | 
	
		
			
				|  |  | -              v-for="(name, index) in (scheduleMap[data.day]?.names || [])"
 | 
	
		
			
				|  |  | +              v-for="(name, index) in getScheduleNames(data.day)"
 | 
	
		
			
				|  |  |                :key="index"
 | 
	
		
			
				|  |  |                class="employee-name"
 | 
	
		
			
				|  |  |                @dblclick.stop
 | 
	
	
		
			
				|  | @@ -57,7 +57,6 @@
 | 
	
		
			
				|  |  |            </div>
 | 
	
		
			
				|  |  |          </div>
 | 
	
		
			
				|  |  |        </template>
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      </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>
 | 
	
		
			
				|  |  |      <!-- 弹窗, 新增 / 修改 -->
 | 
	
	
		
			
				|  | @@ -93,29 +92,21 @@ const formatMonthDay = (fullDate: string): string => {
 | 
	
		
			
				|  |  |    return `${parts[1]}-${parts[2]}`;
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -const scheduleMap = ref<Record<string, { id: number; names: string[]; status:string }>>({});
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -const buildScheduleMap = (list: any[]) => {
 | 
	
		
			
				|  |  | -  scheduleMap.value = {};
 | 
	
		
			
				|  |  | -  for (const item of list) {
 | 
	
		
			
				|  |  | -    const day = item.scheduleDate; 
 | 
	
		
			
				|  |  | -    scheduleMap.value[day] = { 
 | 
	
		
			
				|  |  | -      id: item.id,
 | 
	
		
			
				|  |  | -      names: item.employeeNames || [],
 | 
	
		
			
				|  |  | -      status: item.status
 | 
	
		
			
				|  |  | -    };
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +const getScheduleByDate = (date: string) => {
 | 
	
		
			
				|  |  | +  return state.dataList?.find(item => item.scheduleDate === date) || null;
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  | -import { onMounted } from 'vue'
 | 
	
		
			
				|  |  | -onMounted(async () => {
 | 
	
		
			
				|  |  | -  await state.getDataList();
 | 
	
		
			
				|  |  | -  buildScheduleMap(state.dataList || []);
 | 
	
		
			
				|  |  | -  
 | 
	
		
			
				|  |  | -  console.log(state.dataList);
 | 
	
		
			
				|  |  | -});
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -// 新增按钮
 | 
	
		
			
				|  |  | +const getScheduleStatus = (date: string): number | null => {
 | 
	
		
			
				|  |  | +  const item = getScheduleByDate(date);
 | 
	
		
			
				|  |  | +  return item?.status ?? null;
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const getScheduleNames = (date: string): string[] => {
 | 
	
		
			
				|  |  | +  const item = getScheduleByDate(date);
 | 
	
		
			
				|  |  | +  return item?.employeeNames || [];
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  const addHandle = () => {
 | 
	
		
			
				|  |  |    if (!selectedDates.value || selectedDates.value.length === 0) {
 | 
	
		
			
				|  |  |      ElMessage({
 | 
	
	
		
			
				|  | @@ -125,17 +116,38 @@ const addHandle = () => {
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |      return;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  // 批量添加
 | 
	
		
			
				|  |  | -  addOrUpdateHandle(undefined, undefined, selectedDates.value);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // 查找已存在排班的日期
 | 
	
		
			
				|  |  | +  const existingDates = selectedDates.value.filter(date =>
 | 
	
		
			
				|  |  | +    state.dataList?.some(item => item.scheduleDate === date)
 | 
	
		
			
				|  |  | +  );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  if (existingDates.length > 0) {
 | 
	
		
			
				|  |  | +    ElMessageBox.confirm(
 | 
	
		
			
				|  |  | +      `以下日期已有排班数据:\n${existingDates.join('、')}\n,是否继续新增?`,
 | 
	
		
			
				|  |  | +      '提示',
 | 
	
		
			
				|  |  | +      {
 | 
	
		
			
				|  |  | +        confirmButtonText: '继续',
 | 
	
		
			
				|  |  | +        cancelButtonText: '取消',
 | 
	
		
			
				|  |  | +        type: 'warning',
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    )
 | 
	
		
			
				|  |  | +    .then(() => {
 | 
	
		
			
				|  |  | +      addOrUpdateHandle(undefined, undefined, selectedDates.value);
 | 
	
		
			
				|  |  | +    })
 | 
	
		
			
				|  |  | +    .catch(() => {
 | 
	
		
			
				|  |  | +      // 用户取消,无需处理
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +  } else {
 | 
	
		
			
				|  |  | +    // 无冲突,直接新增
 | 
	
		
			
				|  |  | +    addOrUpdateHandle(undefined, undefined, selectedDates.value);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const refreshAfterAdd = async () => {
 | 
	
		
			
				|  |  |    selectedDates.value = [];  
 | 
	
		
			
				|  |  | -  await state.getDataList(); 
 | 
	
		
			
				|  |  | -  
 | 
	
		
			
				|  |  | +  state.getDataList(); 
 | 
	
		
			
				|  |  |    console.log(state.dataList);
 | 
	
		
			
				|  |  | -  buildScheduleMap(state.dataList || []);   
 | 
	
		
			
				|  |  | -  console.log(scheduleMap.value);
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const addOrUpdateRef = ref();
 | 
	
	
		
			
				|  | @@ -145,7 +157,7 @@ const addOrUpdateHandle = (id?: number, date?: string, dates?: string[]) => {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const handleDayDblClick = (day: string) => {
 | 
	
		
			
				|  |  | -  const schedule = scheduleMap.value[day];
 | 
	
		
			
				|  |  | +  const schedule = state.dataList?.find(item => item.scheduleDate === day);
 | 
	
		
			
				|  |  |    if (schedule && schedule.id) {
 | 
	
		
			
				|  |  |      // 已有排班记录,修改
 | 
	
		
			
				|  |  |      addOrUpdateHandle(schedule.id);
 | 
	
	
		
			
				|  | @@ -155,6 +167,7 @@ const handleDayDblClick = (day: string) => {
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  const handleDateToggle = (day: string, checked: boolean) => {
 | 
	
		
			
				|  |  |    const index = selectedDates.value.indexOf(day);
 | 
	
		
			
				|  |  |    if (checked && index === -1) {
 |