Merge branch 'develop' into warunee-dev

This commit is contained in:
Warunee Tamkoo 2023-08-09 16:38:39 +07:00
commit 6d05f12adf
3 changed files with 86 additions and 27 deletions

View file

@ -70,6 +70,7 @@ export default {
//ข้อมูลเลือกรายชื่อออกคำสั่ง, ลบรายชื่อ
personsOrder: (orderId: string) => `${order}/order/persons/${orderId}`,
personsselectedOrder: (orderId: string) => `${order}/order/persons-selected/${orderId}`,
//เปลี่ยน status ของคำสั่งไปขั้นตอนถัดไป
nextOrder: (orderId: string) => `${order}/order/next/${orderId}`,

View file

@ -109,7 +109,7 @@ div
flat
round
color="red"
@click="dialogDeleteData(props.row.personId)"
@click="dialogDeleteData(props.row.personalId)"
icon="mdi-delete"
>
<q-tooltip>ลบขอม</q-tooltip>
@ -226,7 +226,7 @@ div
<q-separator />
<q-card-section class="q-pa-sm bg-grey-1">
<d-table
:rows="rows"
:rows="rows2"
:columns="columns"
:visible-columns="visibleColumns"
:filter="filter"
@ -370,7 +370,9 @@ const columns = ref<QTableProps["columns"]>([
},
]);
const rows = ref<ResponseData[]>([]);
const rows2 = ref<ResponseData[]>([]);
const selected = ref([]);
const orderId = ref<string>(route.params.orderid.toString());
onMounted(async () => {
await conditionData();
@ -390,17 +392,17 @@ const conditionData = async () => {
const getData = async (id: string) => {
showLoader();
await http
.get(config.API.personsOrder(id))
.get(config.API.personsselectedOrder(id))
.then((res) => {
const data = res.data.result;
// console.log(data);
console.log(data);
let list: ResponseData[] = [];
data.map((r: ResponseData) => {
list.push({
education: r.education ?? "",
idCard: r.idCard ?? "",
name: r.name ?? "",
personId: r.personId ?? "",
personalId: r.personalId ?? "",
selectStatus: r.selectStatus !== null ? r.selectStatus : false,
sequence: r.sequence !== null ? r.sequence : 0,
});
@ -456,8 +458,9 @@ const deleteData = async (id: string) => {
.catch((e) => {
messageError($q, e);
})
.finally(() => {
.finally(async () => {
hideLoader();
await conditionData();
});
};
@ -535,19 +538,74 @@ const modalOpenClose = () => {
}
};
const modalAddChange = () => {
const modalAddChange = async () => {
modalAdd.value = !modalAdd.value;
if (modalAdd.value == true) {
await fetchaddlist(orderId.value);
} else await conditionData();
};
const fetchaddlist = async (id: string) => {
showLoader();
await http
.get(config.API.personsOrder(id))
.then((res) => {
const data = res.data.result;
console.log(data);
let list = [];
list = data.map((r: ResponseData) => ({
education: r.education ?? "",
idCard: r.idCard ?? "",
name: r.name ?? "",
personalId: r.personalId ?? "",
selectStatus: r.selectStatus !== null ? r.selectStatus : false,
sequence: r.sequence !== null ? r.sequence : 0,
}));
rows2.value = list.filter((e: any) => e.selectStatus === false);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
const saveModalAdd = () => {
if (myFormAdd.value !== null) {
myFormAdd.value.validate().then(async (result: boolean) => {
if (result) {
modalAddChange();
if (result && selected.value.length !== 0) {
$q.dialog({
title: "ยืนยันการเพิ่มรายชื่อออกคำสั่ง",
message: "ต้องการยืนยันการเพิ่มรายชื่อออกคำสั่งนี้ใช่หรือไม่?",
cancel: {
flat: true,
color: "negative",
},
persistent: true,
}).onOk(async () => {
let data = [];
data.push(...selected.value.map((e: any) => e.personalId));
// console.log(data);
addlist(data);
});
}
});
}
};
const addlist = async (data: Object) => {
await http
.post(config.API.personsOrder(orderId.value), data)
.then(() => {
// console.log(res);
success($q, "บันทึกสำเร็จ");
})
.catch((e: any) => {
console.log(e);
messageError($q, e);
})
.finally(() => {
modalAddChange();
});
};
const click = (e: any) => {
console.log(e);
@ -555,28 +613,28 @@ const click = (e: any) => {
};
const save = () => {
// if (selected.value.length > 0) {
// next();
// } else {
// dialogMessage(
// $q,
// "",
// "",
// "warning",
// undefined,
// "orange",
// undefined,
// undefined,
// true
// );
// }
// if (selected.value.length > 0) {
// next();
// } else {
// dialogMessage(
// $q,
// "",
// "",
// "warning",
// undefined,
// "orange",
// undefined,
// undefined,
// true
// );
// }
next();
};
const selectData = (row: any) => {};
const refresh = async () => {
await conditionData();
// await conditionData();
modalAddChange();
selected.value = [];
};

View file

@ -2,7 +2,7 @@ interface ResponseData {
education: string;
idCard: string;
name: string;
personId: string;
personalId: string;
selectStatus: boolean;
sequence: number;
}