From 15b33b147a1b6b94e69f821fa2c8cc11bcbdf3f9 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 12 Sep 2024 17:11:00 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= =?UTF-8?q?=20=3D=3D>=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/18_command/api.command.ts | 8 +- .../components/Main/DialogFormCommand.vue | 86 ++++++--- .../18_command/components/Main/TableMain.vue | 172 +++++++++++++++--- .../18_command/components/Step/1_Detail.vue | 166 +++++++++++++---- .../components/Step/2_ListPersons.vue | 10 + .../components/Step/3_ReceivedCopy.vue | 10 + .../18_command/components/Step/4_Attached.vue | 12 +- .../18_command/interface/index/Main.ts | 7 +- .../18_command/interface/request/Main.ts | 25 ++- .../18_command/interface/response/Main.ts | 23 ++- src/modules/18_command/store/DetailStore.ts | 2 + src/modules/18_command/store/ListStore.ts | 10 +- src/modules/18_command/views/detail.vue | 87 +++++++-- src/modules/18_command/views/lists.vue | 95 +++++----- 14 files changed, 568 insertions(+), 145 deletions(-) diff --git a/src/api/18_command/api.command.ts b/src/api/18_command/api.command.ts index 17756dfbf..c9e8621b6 100644 --- a/src/api/18_command/api.command.ts +++ b/src/api/18_command/api.command.ts @@ -1,7 +1,11 @@ import env from "../index"; -const command = `${env.API_URI}/order`; +const command = `${env.API_URI}/org/command`; export default { - commandType: `${command}/order-type`, + commandType: `${command}Type/list`, //ประเภทคำสั่ง + commandList: `${command}/list`, //list รายการ + command, //สร้างคำสั่ง + commandAction: (commandId: string, type: string) => + `${command}/${type}/${commandId}`, }; diff --git a/src/modules/18_command/components/Main/DialogFormCommand.vue b/src/modules/18_command/components/Main/DialogFormCommand.vue index 4be1731ec..c9f6c3f61 100644 --- a/src/modules/18_command/components/Main/DialogFormCommand.vue +++ b/src/modules/18_command/components/Main/DialogFormCommand.vue @@ -6,7 +6,8 @@ import { useRouter } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; -import type { DataListCommand } from "@/modules/18_command/interface/response/Main"; +import type { FormCommand } from "@/modules/18_command/interface/request/Main"; +import type { DataCommandType } from "@/modules/18_command/interface/response/Main"; import DialogHeader from "@/components/DialogHeader.vue"; @@ -14,18 +15,19 @@ import { useCounterMixin } from "@/stores/mixin"; const $q = useQuasar(); const router = useRouter(); -const { dialogConfirm, showLoader, hideLoader, messageError } = +const { dialogConfirm, showLoader, hideLoader, messageError, success } = useCounterMixin(); const modal = defineModel("modal", { required: true }); const isCopy = defineModel("isCopy", { required: true }); +const commandId = defineModel("commandId", { default: "" }); const commandType = ref(""); const commandNo = ref(""); -const commandYear = ref(""); +const commandYear = ref(new Date().getFullYear()); -const listCommand = ref([]); -const commandOp = ref([]); +const listCommand = ref([]); +const commandOp = ref([]); async function fetchCommandType() { showLoader(); @@ -46,10 +48,29 @@ async function fetchCommandType() { function onSubmit() { dialogConfirm($q, () => { - !isCopy.value && router.push(`/command/edit/1234`); - console.log(commandNo.value); - console.log(commandYear.value); - onClose(); + showLoader(); + const body: FormCommand = { + commandYear: commandYear.value, + commandNo: commandNo.value, + commandTypeId: !isCopy.value ? commandType.value : undefined, + }; + const path = !isCopy.value + ? config.API.command + : config.API.commandAction(commandId.value, "copy"); + + http[!isCopy.value ? "post" : "put"](path, body) + .then(async (res) => { + const id = await res.data.result; + router.push(`/command/edit/${id}`); + success($q, "บันทึกข้อมูลสำเร็จ"); + onClose(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); }); } @@ -72,7 +93,7 @@ function filterSelector(val: string, update: Function, refData: string) { function onClose() { modal.value = false; commandNo.value = ""; - commandYear.value = ""; + commandYear.value = new Date().getFullYear(); } watch(modal, () => { @@ -130,7 +151,6 @@ watch(modal, () => { v-model="commandNo" hide-bottom-space :label="`${'คำสั่งเลขที่'}`" - :rules="[(val) => !!val || `${'กรุณากรอกคำสั่งเลขที่'}`]" lazy-rules /> @@ -138,17 +158,41 @@ watch(modal, () => { >/
- + :locale="'th'" + autoApply + year-picker + :enableTimePicker="false" + class="inputgreen" + > + + + +
diff --git a/src/modules/18_command/components/Main/TableMain.vue b/src/modules/18_command/components/Main/TableMain.vue index 8e60111e7..9cefdca9b 100644 --- a/src/modules/18_command/components/Main/TableMain.vue +++ b/src/modules/18_command/components/Main/TableMain.vue @@ -1,81 +1,113 @@ diff --git a/src/modules/18_command/components/Step/1_Detail.vue b/src/modules/18_command/components/Step/1_Detail.vue index 60f1a833f..7cc394c5f 100644 --- a/src/modules/18_command/components/Step/1_Detail.vue +++ b/src/modules/18_command/components/Step/1_Detail.vue @@ -1,27 +1,101 @@