API สำหรับส่งคนไปออกคำสั่ง
This commit is contained in:
parent
6d5794f124
commit
90c2956e74
16 changed files with 58 additions and 54 deletions
|
|
@ -31,7 +31,7 @@ const modal = defineModel<boolean>("modal", { required: true });
|
|||
|
||||
const props = defineProps({
|
||||
commandTypeCode: String, // ไอดีประเภทคำสั่ง
|
||||
personsId: Array, // ไอดีคนที่เลือกออกคำสั่งส่งมาเป็น array
|
||||
persons: Array, // ไอดีคนที่เลือกออกคำสั่งส่งมาเป็น array
|
||||
});
|
||||
|
||||
const commandOp = ref<ListCommand[]>([]); // ประเภทคำสั่ง
|
||||
|
|
@ -131,16 +131,22 @@ const columns = ref<QTableProps["columns"]>([
|
|||
*/
|
||||
function createCommand(isRedirect: boolean) {
|
||||
dialogConfirm($q, async () => {
|
||||
const data = props.personsId;
|
||||
const data = props?.persons?.map((e: any) => ({
|
||||
refId: e.id,
|
||||
prefix: e.prefix,
|
||||
firstName: e.firstName,
|
||||
lastName: e.lastName,
|
||||
citizenId: e.citizenId,
|
||||
}));
|
||||
const body = {
|
||||
commandYear: commandYear.value,
|
||||
commandNo: commandNo.value,
|
||||
commandTypeId: commandType.value,
|
||||
// persons: data,
|
||||
persons: data,
|
||||
};
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.command, body)
|
||||
.post(config.API.command + `/person`, body)
|
||||
.then(async (res) => {
|
||||
const id = await res.data.result;
|
||||
if (isRedirect) {
|
||||
|
|
@ -164,32 +170,36 @@ function createCommand(isRedirect: boolean) {
|
|||
*/
|
||||
function addPersonalToCommand(isRedirect: boolean) {
|
||||
dialogConfirm($q, async () => {
|
||||
const data = props.personsId;
|
||||
const data = props?.persons?.map((e: any) => ({
|
||||
refId: e.id,
|
||||
prefix: e.prefix,
|
||||
firstName: e.firstName,
|
||||
lastName: e.lastName,
|
||||
citizenId: e.citizenId,
|
||||
}));
|
||||
const body = {
|
||||
commandId: selected.value[0].id,
|
||||
persons: data,
|
||||
};
|
||||
console.log("🚀 ~ dialogConfirm ~ body:", body);
|
||||
// showLoader();
|
||||
// await http
|
||||
// .post(config.API.transferReport, body)
|
||||
// .then((res) => {
|
||||
// const id = res.data.result
|
||||
modal.value = false;
|
||||
if (isRedirect) {
|
||||
router.push("/command/edit/18477dcd-2f14-4e49-8fca-a446164e8b59");
|
||||
} else {
|
||||
modal.value = false;
|
||||
clearValue();
|
||||
}
|
||||
// router.push("/command/edit/" + id);
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.command + `/person`, body)
|
||||
.then(async (res) => {
|
||||
const id = await res.data.result;
|
||||
modal.value = false;
|
||||
if (isRedirect) {
|
||||
router.push(`/command/edit/${id}`);
|
||||
} else {
|
||||
modal.value = false;
|
||||
clearValue();
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -201,18 +211,6 @@ function onSubmit(isRedirect: boolean) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* เปลี่ยน tab เเละ clear ค่า tab ก่อนหน้า
|
||||
* @param type แยกประเภท
|
||||
*/
|
||||
function changeTab(type: string) {
|
||||
clearValue();
|
||||
selectCreate.value = type;
|
||||
if (type == "DRAF") {
|
||||
getListCommandDraf();
|
||||
}
|
||||
}
|
||||
|
||||
/** ปิด popup */
|
||||
function closeModal() {
|
||||
modal.value = false;
|
||||
|
|
@ -276,7 +274,7 @@ watch(
|
|||
);
|
||||
|
||||
watch(modal, () => {
|
||||
if (modal.value && props.personsId?.length !== 0) {
|
||||
if (modal.value && props.persons?.length !== 0) {
|
||||
fetchCommandType();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue