From 6af59e5892d27b722e5e493c388e4853b612020c Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Wed, 25 Sep 2024 10:22:03 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20ui=20?= =?UTF-8?q?=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=84=E0=B8=B3?= =?UTF-8?q?=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/DialogCreateCommand.vue | 118 +++++++----------- src/modules/18_command/store/Main.ts | 28 +++-- 2 files changed, 61 insertions(+), 85 deletions(-) diff --git a/src/modules/18_command/components/DialogCreateCommand.vue b/src/modules/18_command/components/DialogCreateCommand.vue index 166f8ced1..c9215b008 100644 --- a/src/modules/18_command/components/DialogCreateCommand.vue +++ b/src/modules/18_command/components/DialogCreateCommand.vue @@ -14,6 +14,7 @@ import type { DataCommandType, DataListCommand, } from "@/modules/18_command/interface/response/Main"; +import type { ListCommand } from "@/modules/18_command/interface/index/Main"; import DialogHeader from "@/components/DialogHeader.vue"; @@ -33,13 +34,12 @@ const { const modal = defineModel("modal", { required: true }); const props = defineProps({ - commandTypeId: String, // ไอดีประเภทคำสั่ง + commandTypeCode: String, // ไอดีประเภทคำสั่ง personsId: Array, // ไอดีคนที่เลือกออกคำสั่งส่งมาเป็น array }); +const commandOp = ref([]); // ประเภทคำสั่ง const commandType = ref(""); //ประเภทคำสั่ง -const commandOp = ref([]); //ตัวเลือกคำสั่ง -const listCommand = ref([]); //ตัวเลือกคำสั่ง const commandNo = ref(""); const commandYear = ref(new Date().getFullYear()); @@ -135,29 +135,28 @@ const columns = ref([ */ function createCommand() { dialogConfirm($q, async () => { - // const data = props.personsId; - // const body = { - // commandYear: commandYear.value, - // commandNo: commandNo.value, - // commandTypeId: commandType.value, - // persons: data, - // }; - // showLoader(); - // await http - // .post(config.API.transferReport, body) - // .then(async (res) => { - // const id = await res.data.result; - // modal.value = false; - router.push("/command/edit/736c178f-9c11-44bc-b6e0-ef47ea06ffe9"); - // router.push(`/command/edit/${id}`); - clearValue(); - // }) - // .catch((e) => { - // messageError($q, e); - // }) - // .finally(() => { - // hideLoader(); - // }); + const data = props.personsId; + const body = { + commandYear: commandYear.value, + commandNo: commandNo.value, + commandTypeId: commandType.value, + // persons: data, + }; + showLoader(); + await http + .post(config.API.command, body) + .then(async (res) => { + const id = await res.data.result; + modal.value = false; + clearValue(); + router.push(`/command/edit/${id}`); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); }); } @@ -198,22 +197,6 @@ function onSubmit() { } } -function filterSelector(val: string, update: Function, refData: string) { - switch (refData) { - case "OrderTypeOption": - update(() => { - commandType.value = val ? "" : commandType.value; - commandOp.value = listCommand.value.filter( - (v: any) => v.name.indexOf(val) > -1 - ); - }); - break; - - default: - break; - } -} - /** * เปลี่ยน tab เเละ clear ค่า tab ก่อนหน้า * @param type แยกประเภท @@ -238,8 +221,8 @@ function clearValue() { commandYear.value = new Date().getFullYear(); selectCreate.value = "NEW"; - selected.value = [] - filter.value = '' + selected.value = []; + filter.value = ""; } const selectCreate = ref("NEW"); @@ -269,20 +252,12 @@ async function getListCommandDraf() { /** ดึงข้อมูลคำสั่ง */ async function fetchCommandType() { - showLoader(); - await http - .get(config.API.commandType) - .then(async (res) => { - const data = await res.data.result; - listCommand.value = data; - commandOp.value = data; - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); + const data = await storeCommand.getCommandTypes(); // ยิงไป get ที่ store + // filter เฉพาะ code ของคำสั่งที่เลือก + commandOp.value = await data.filter( + (v: any) => v.code == props.commandTypeCode + ); + commandType.value = commandOp.value[0].id; } function updatePagination(newPagination: any) { @@ -305,17 +280,13 @@ watch(modal, () => {