refactor(@vben/web-antd): remove store mocks and fix staff type checks
This commit is contained in:
@@ -40,12 +40,14 @@ const templateRows: Array<{
|
||||
|
||||
/** 将 HH:mm 字符串转换为时间组件值。 */
|
||||
function toPickerValue(time: string) {
|
||||
if (!time) return null;
|
||||
if (!time) return undefined;
|
||||
return dayjs(`2000-01-01 ${time}`);
|
||||
}
|
||||
|
||||
/** 将时间组件值转换为 HH:mm 字符串。 */
|
||||
function toTimeText(value: Dayjs | null) {
|
||||
function toTimeText(value: Dayjs | null | string | undefined) {
|
||||
if (!value) return '';
|
||||
if (typeof value === 'string') return value;
|
||||
return value ? value.format('HH:mm') : '';
|
||||
}
|
||||
|
||||
@@ -53,7 +55,7 @@ function toTimeText(value: Dayjs | null) {
|
||||
function handleTemplateTimeChange(payload: {
|
||||
field: 'endTime' | 'startTime';
|
||||
shiftType: Exclude<ShiftType, 'off'>;
|
||||
value: Dayjs | null;
|
||||
value: Dayjs | null | string;
|
||||
}) {
|
||||
props.onSetTemplateTime({
|
||||
shiftType: payload.shiftType,
|
||||
|
||||
@@ -42,13 +42,15 @@ function getDayShift(dayOfWeek: number) {
|
||||
|
||||
/** 转换时间组件值。 */
|
||||
function toPickerValue(time: string) {
|
||||
if (!time) return null;
|
||||
if (!time) return undefined;
|
||||
return dayjs(`2000-01-01 ${time}`);
|
||||
}
|
||||
|
||||
/** 时间组件值转字符串。 */
|
||||
function toTimeText(value: Dayjs | null) {
|
||||
return value ? value.format('HH:mm') : '';
|
||||
function toTimeText(value: Dayjs | null | string | undefined) {
|
||||
if (!value) return '';
|
||||
if (typeof value === 'string') return value;
|
||||
return value.format('HH:mm');
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -70,22 +70,13 @@ export function cloneStaffForm(
|
||||
|
||||
/** 按模板创建空白一周(默认休息)。 */
|
||||
export function createEmptyWeekShifts(
|
||||
templates: StoreShiftTemplatesDto,
|
||||
_templates: StoreShiftTemplatesDto,
|
||||
): StaffDayShiftDto[] {
|
||||
return DAY_OPTIONS.map((day) => {
|
||||
const fallbackShift = templates.morning;
|
||||
return {
|
||||
dayOfWeek: day.dayOfWeek,
|
||||
shiftType: 'off',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
...fallbackShift,
|
||||
};
|
||||
}).map((item) => ({
|
||||
dayOfWeek: item.dayOfWeek,
|
||||
shiftType: item.shiftType,
|
||||
startTime: item.shiftType === 'off' ? '' : item.startTime,
|
||||
endTime: item.shiftType === 'off' ? '' : item.endTime,
|
||||
return DAY_OPTIONS.map((day) => ({
|
||||
dayOfWeek: day.dayOfWeek,
|
||||
shiftType: 'off' as const,
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user