| @@ -48,7 +48,7 @@ export type IndividualStaff = { | |||||
| phone2?: string | phone2?: string | ||||
| emergContactName: string; | emergContactName: string; | ||||
| emergContactPhone: string; | emergContactPhone: string; | ||||
| joinDate: string; | |||||
| joinDate: string | number[]; | |||||
| joinPosition: data; | joinPosition: data; | ||||
| departDate?: string; | departDate?: string; | ||||
| departReason?: string; | departReason?: string; | ||||
| @@ -62,9 +62,9 @@ const EditStaff: React.FC<formProps> = ({ Staff, combos, SalaryEffectiveInfo }) | |||||
| phone2: Staff.phone2, | phone2: Staff.phone2, | ||||
| emergContactName: Staff.emergContactName, | emergContactName: Staff.emergContactName, | ||||
| emergContactPhone: Staff.emergContactPhone, | emergContactPhone: Staff.emergContactPhone, | ||||
| joinDate: Staff.joinDate ? dayjs(Staff.joinDate).toString() : null, | |||||
| joinDate: Staff.joinDate ? dayjs(Staff.joinDate as string).format("YYYY-MM-DD") : null, | |||||
| joinPositionId: Staff.joinPosition?.id || null, | joinPositionId: Staff.joinPosition?.id || null, | ||||
| departDate: Staff.departDate ? dayjs(Staff.departDate).toString() : null, | |||||
| departDate: Staff.departDate ? dayjs(Staff.departDate as string).format("YYYY-MM-DD") : null, | |||||
| departReason: Staff.departReason, | departReason: Staff.departReason, | ||||
| remark: Staff.remark, | remark: Staff.remark, | ||||
| salaryEffectiveInfo: SalaryEffectiveInfo.map(item => { | salaryEffectiveInfo: SalaryEffectiveInfo.map(item => { | ||||
| @@ -56,6 +56,8 @@ const EditStaffWrapper: React.FC<Props> & SubComponents = async ({ | |||||
| salary: SalaryCombo.records, | salary: SalaryCombo.records, | ||||
| } | } | ||||
| Staff.data.joinDate = Staff.data.joinDate && dateArrayToString(Staff.data.joinDate) as string | |||||
| Staff.data.departDate = Staff.data.departDate && dateArrayToString(Staff.data.departDate) as string | |||||
| // [{id:0, salaryPoint: 1, date:"2021-05-05"}, {id:1, salaryPoint: 43, date:"2024-05-05"}] | // [{id:0, salaryPoint: 1, date:"2021-05-05"}, {id:1, salaryPoint: 43, date:"2024-05-05"}] | ||||
| console.log(Staff.data) | console.log(Staff.data) | ||||
| @@ -65,3 +67,17 @@ console.log(Staff.data) | |||||
| EditStaffWrapper.Loading = EditStaffLoading; | EditStaffWrapper.Loading = EditStaffLoading; | ||||
| export default EditStaffWrapper; | export default EditStaffWrapper; | ||||
| function dateArrayToString(dateArray: number[] | string): string { | |||||
| if (typeof dateArray === 'string'){ | |||||
| return dateArray | |||||
| } | |||||
| const [year, month, day] = dateArray; | |||||
| console.log(dateArray) | |||||
| // Ensure the month is in the correct range (0-11) | |||||
| const monthIndex = month; | |||||
| // Create the date string in the format "YYYY-MM-DD" | |||||
| return `${year}-${monthIndex.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`; | |||||
| } | |||||
| @@ -460,6 +460,8 @@ const StaffInfo: React.FC<Props> = ({ combos }) => { | |||||
| value={joinDate && joinDate !== undefined ? dayjs(joinDate) : null} | value={joinDate && joinDate !== undefined ? dayjs(joinDate) : null} | ||||
| onChange={(date) => { | onChange={(date) => { | ||||
| if (!date) return; | if (!date) return; | ||||
| dayjs(date).add(1, 'month') | |||||
| console.log(date) | |||||
| setValue("joinDate", date.format(INPUT_DATE_FORMAT)); | setValue("joinDate", date.format(INPUT_DATE_FORMAT)); | ||||
| }} | }} | ||||
| // slotProps={{ | // slotProps={{ | ||||
| @@ -509,6 +511,7 @@ const StaffInfo: React.FC<Props> = ({ combos }) => { | |||||
| value={departDate ? dayjs(departDate) : null} | value={departDate ? dayjs(departDate) : null} | ||||
| onChange={(date) => { | onChange={(date) => { | ||||
| if (!date) return; | if (!date) return; | ||||
| dayjs(date).add(1, 'month') | |||||
| setValue("departDate", date.format(INPUT_DATE_FORMAT)); | setValue("departDate", date.format(INPUT_DATE_FORMAT)); | ||||
| }} | }} | ||||
| slotProps={{ | slotProps={{ | ||||