fix bug ลา
This commit is contained in:
parent
cf36f1c150
commit
e726510691
3 changed files with 42 additions and 48 deletions
|
|
@ -60,48 +60,34 @@ const formRef: RehabilitationForm = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** ฟังก์ชั่นตรวจสอบความถูกต้องก่อน บันทึก */
|
/** ฟังก์ชั่นตรวจสอบความถูกต้องก่อน บันทึก */
|
||||||
function onValidate() {
|
async function onValidate() {
|
||||||
const hasError = [];
|
const formData = new FormData();
|
||||||
for (const key in formRef) {
|
if (formDataRehabilitation.leaveDocument.length > 0) {
|
||||||
if (Object.prototype.hasOwnProperty.call(formRef, key)) {
|
formDataRehabilitation.leaveDocument.forEach((file: File) => {
|
||||||
const property = formRef[key];
|
formData.append("leaveDocument", file);
|
||||||
if (property.value && typeof property.value.validate === "function") {
|
});
|
||||||
const isValid = property.value.validate();
|
|
||||||
hasError.push(isValid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (hasError.every((result) => result === true)) {
|
|
||||||
const formData = new FormData();
|
|
||||||
|
|
||||||
if (formDataRehabilitation.leaveDocument.length > 0) {
|
if (formDataRehabilitation.leaveDraftDocument) {
|
||||||
formDataRehabilitation.leaveDocument.forEach((file: File) => {
|
|
||||||
formData.append("leaveDocument", file);
|
|
||||||
});
|
|
||||||
// formData.append("leaveDocument", formDataRehabilitation.leaveDocument)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (formDataRehabilitation.leaveDraftDocument) {
|
|
||||||
formData.append(
|
|
||||||
"leaveDraftDocument",
|
|
||||||
formDataRehabilitation.leaveDraftDocument
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
formData.append("type", formDataRehabilitation.type); //
|
|
||||||
formData.append(
|
formData.append(
|
||||||
"leaveStartDate",
|
"leaveDraftDocument",
|
||||||
dateToISO(new Date(formDataRehabilitation.leaveStartDate))
|
formDataRehabilitation.leaveDraftDocument
|
||||||
); //
|
|
||||||
formData.append(
|
|
||||||
"leaveEndDate",
|
|
||||||
dateToISO(new Date(formDataRehabilitation.leaveEndDate))
|
|
||||||
);
|
);
|
||||||
formData.append("leaveWrote", formDataRehabilitation.leaveWrote); //
|
|
||||||
formData.append("leaveDetail", formDataRehabilitation.leaveDetail); //
|
|
||||||
formData.append("leaveTotal", formDataRehabilitation.leaveTotal); //
|
|
||||||
props.onSubmit(formData, isLeave.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formData.append("type", formDataRehabilitation.type); //
|
||||||
|
formData.append(
|
||||||
|
"leaveStartDate",
|
||||||
|
dateToISO(new Date(formDataRehabilitation.leaveStartDate))
|
||||||
|
);
|
||||||
|
formData.append(
|
||||||
|
"leaveEndDate",
|
||||||
|
dateToISO(new Date(formDataRehabilitation.leaveEndDate))
|
||||||
|
);
|
||||||
|
formData.append("leaveWrote", formDataRehabilitation.leaveWrote); //
|
||||||
|
formData.append("leaveDetail", formDataRehabilitation.leaveDetail); //
|
||||||
|
formData.append("leaveTotal", formDataRehabilitation.leaveTotal); //
|
||||||
|
props.onSubmit(formData, isLeave.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ส่วนของการประกาศและเลือกไฟล์เอกสารประกอบ */
|
/** ส่วนของการประกาศและเลือกไฟล์เอกสารประกอบ */
|
||||||
|
|
@ -118,6 +104,7 @@ const fileUploadDoc = async (files: any) => {
|
||||||
*/
|
*/
|
||||||
const isLeave = ref<boolean>(true);
|
const isLeave = ref<boolean>(true);
|
||||||
async function FetchCheck() {
|
async function FetchCheck() {
|
||||||
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.post(config.API.leaveCheck(), {
|
.post(config.API.leaveCheck(), {
|
||||||
type: dataStore.typeId ?? null,
|
type: dataStore.typeId ?? null,
|
||||||
|
|
@ -131,6 +118,9 @@ async function FetchCheck() {
|
||||||
})
|
})
|
||||||
.catch((e: any) => {
|
.catch((e: any) => {
|
||||||
messageError($q, e);
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,8 +151,6 @@ const leaveDocumentList = ref<any>();
|
||||||
const leaveDraftDocument = ref<string>();
|
const leaveDraftDocument = ref<string>();
|
||||||
const statusCheck = ref<string>("");
|
const statusCheck = ref<string>("");
|
||||||
watch(props.data, () => {
|
watch(props.data, () => {
|
||||||
console.log(props.data);
|
|
||||||
|
|
||||||
if (props.data) {
|
if (props.data) {
|
||||||
formDataRehabilitation.leaveWrote = props.data.leaveWrote;
|
formDataRehabilitation.leaveWrote = props.data.leaveWrote;
|
||||||
formDataRehabilitation.leaveStartDate = new Date(props.data.leaveStartDate);
|
formDataRehabilitation.leaveStartDate = new Date(props.data.leaveStartDate);
|
||||||
|
|
@ -187,6 +175,7 @@ onMounted(() => {
|
||||||
leaveDocumentList.value = props.data.leaveDocument;
|
leaveDocumentList.value = props.data.leaveDocument;
|
||||||
statusCheck.value = props.data.status;
|
statusCheck.value = props.data.status;
|
||||||
leaveId.value = props.data.id;
|
leaveId.value = props.data.id;
|
||||||
|
FetchCheck();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -196,7 +185,8 @@ onMounted(() => {
|
||||||
<q-icon name="mdi-numeric-3-circle" size="20px" color="primary" />
|
<q-icon name="mdi-numeric-3-circle" size="20px" color="primary" />
|
||||||
<div class="q-pl-sm text-weight-bold text-dark">กรอกข้อมูล</div>
|
<div class="q-pl-sm text-weight-bold text-dark">กรอกข้อมูล</div>
|
||||||
</div>
|
</div>
|
||||||
<form @submit.prevent="onValidate">
|
|
||||||
|
<q-form greedy @submit.prevent @validation-success="onValidate">
|
||||||
<q-card bordered class="q-pa-md bg-grey-1">
|
<q-card bordered class="q-pa-md bg-grey-1">
|
||||||
<div class="row q-pa-sm q-col-gutter-sm">
|
<div class="row q-pa-sm q-col-gutter-sm">
|
||||||
<q-input
|
<q-input
|
||||||
|
|
@ -504,5 +494,5 @@ onMounted(() => {
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</q-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import type {
|
||||||
} from "@/modules/05_leave/interface/response/leave";
|
} from "@/modules/05_leave/interface/response/leave";
|
||||||
|
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { date2Thai, messageError } = mixin;
|
const { date2Thai, messageError, showLoader, hideLoader } = mixin;
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const type = ref<string>("00000000-0000-0000-0000-000000000000");
|
const type = ref<string>("00000000-0000-0000-0000-000000000000");
|
||||||
const status = ref<string>("ALL");
|
const status = ref<string>("ALL");
|
||||||
|
|
@ -283,6 +283,7 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
|
|
||||||
//ดึงข้อมูล profile จาก API
|
//ดึงข้อมูล profile จาก API
|
||||||
async function fetchProfile() {
|
async function fetchProfile() {
|
||||||
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.post(config.API.leaveProfile(), { type: typeId.value })
|
.post(config.API.leaveProfile(), { type: typeId.value })
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
|
|
@ -311,6 +312,9 @@ export const useLeaveStore = defineStore("Leave", () => {
|
||||||
})
|
})
|
||||||
.catch((e: any) => {
|
.catch((e: any) => {
|
||||||
messageError($q, e);
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ async function fetchDataDetail(id: string) {
|
||||||
formData.dear = data.dear ?? "-";
|
formData.dear = data.dear ?? "-";
|
||||||
formData.leaveLast = data.leaveLast ?? "-";
|
formData.leaveLast = data.leaveLast ?? "-";
|
||||||
formData.leaveRange = data.leaveRange;
|
formData.leaveRange = data.leaveRange;
|
||||||
dataStore.fetchProfileOld(data);
|
await dataStore.fetchProfileOld(data);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -229,8 +229,8 @@ function onSubmit(formData: FormData, isLeave: boolean = true) {
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.put(config.API.leaveUserId(personalId.value), formData)
|
.put(config.API.leaveUserId(personalId.value), formData)
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
fetchDataDetail(personalId.value);
|
await fetchDataDetail(personalId.value);
|
||||||
success($q, "บันทึกสำเร็จ");
|
success($q, "บันทึกสำเร็จ");
|
||||||
})
|
})
|
||||||
.catch((e: any) => {
|
.catch((e: any) => {
|
||||||
|
|
@ -284,13 +284,13 @@ async function onClickDelete(id: string, docId: string) {
|
||||||
await http
|
await http
|
||||||
.delete(config.API.leaveDocumentId(id, docId))
|
.delete(config.API.leaveDocumentId(id, docId))
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
|
await fetchDataDetail(personalId.value);
|
||||||
success($q, "ลบไฟล์สำเร็จ");
|
success($q, "ลบไฟล์สำเร็จ");
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
fetchDataDetail(personalId.value);
|
|
||||||
hideLoader();
|
hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -298,8 +298,8 @@ async function onClickDelete(id: string, docId: string) {
|
||||||
/**เมื่อเริ่มโหลดหน้า
|
/**เมื่อเริ่มโหลดหน้า
|
||||||
* เรียกใช้งาน fetchData เพื่อดึงข้อมูล
|
* เรียกใช้งาน fetchData เพื่อดึงข้อมูล
|
||||||
*/
|
*/
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
fetchDataDetail(personalId.value);
|
await fetchDataDetail(personalId.value);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue