diff --git a/src/modules/18_command/components/Step/1_Detail.vue b/src/modules/18_command/components/Step/1_Detail.vue index ff3f564a6..2a3f3b60f 100644 --- a/src/modules/18_command/components/Step/1_Detail.vue +++ b/src/modules/18_command/components/Step/1_Detail.vue @@ -61,7 +61,6 @@ let formData = reactive({ }); const commandVolume = ref(""); //เล่มที่ const commandChapter = ref(""); //ตอนที่ -const isIdofficer = ref(false); //เช็ค สกจ. const rows = ref>([]); const columns = ref([ @@ -114,17 +113,7 @@ const visibleColumns = ref>([ const modalAddOperator = ref(false); // แสดงเพิ่มรายชื่อลงนามในแนบท้ายคำสั่ง -/** ฟังก์ชันเช็ค สกจ.*/ -async function fetchCheckIdofficer() { - await http - .get(config.API.checkIdofficer) - .then((res) => { - isIdofficer.value = res.data.result; - }) - .catch((err) => { - messageError($q, err); - }); -} + /** * ฟังก์ชันบันทึกข้อมูลรายละเอียดคำสั่ง @@ -133,7 +122,7 @@ async function fetchCheckIdofficer() { async function onSubmit() { //ถ้าเป็น สกจ. ต้องเลือกประเภทคำสั่งด้วย if ( - isIdofficer.value && + store.isIdofficer && formData.isBangkok !== "BANGKOK" && formData.isBangkok !== "OFFICE" ) { @@ -225,7 +214,6 @@ function onDeleteData(id: string) { onMounted(async () => { try { showLoader(); - await fetchCheckIdofficer(); await fetchDataOperatorList(); formData.commandNo = props.formCommandList.commandNo; formData.commandYear = props.formCommandList.commandYear; @@ -235,7 +223,7 @@ onMounted(async () => { formData.issue = props.formCommandList.issue; formData.commandAffectDate = props.formCommandList.commandAffectDate; formData.commandExcecuteDate = props.formCommandList.commandExcecuteDate; - formData.isBangkok = !isIdofficer.value + formData.isBangkok = !store.isIdofficer ? null : props.formCommandList.isBangkok; commandCode.value = props.formCommandList.commandCode; @@ -500,7 +488,7 @@ onMounted(async () => {
{ const readonly = ref(false); const dataCommand = ref(); const status = ref(""); - const isSalary = ref(false) + const isSalary = ref(false); + const isIdofficer = ref(false); function checkStep(val: string) { status.value = val; switch (val) { @@ -39,6 +40,7 @@ export const useCommandDetail = defineStore("commandDetailStore", () => { readonly, status, dataCommand, - isSalary + isSalary, + isIdofficer, }; }); diff --git a/src/modules/18_command/views/detail.vue b/src/modules/18_command/views/detail.vue index 37ab3326f..5e41124dc 100644 --- a/src/modules/18_command/views/detail.vue +++ b/src/modules/18_command/views/detail.vue @@ -92,12 +92,25 @@ async function fetchDataCommandList() { }); } +/** ฟังก์ชันเช็ค สกจ.*/ +async function fetchCheckIdofficer() { + await http + .get(config.API.checkIdofficer) + .then((res) => { + store.isIdofficer = res.data.result; + }) + .catch((err) => { + messageError($q, err); + }); +} + /** * ทำงานเมื่อ Components ถูกเรียกใช้งาน * กำหนดค่า `store.readonly` เมื่อ route.name เป็น "commandViewDetailPage" จะอ่านข้อมูลได้อย่างเดียว */ onMounted(async () => { await fetchDataCommandList(); + await fetchCheckIdofficer(); store.readonly = route.name === "commandViewDetailPage" || formCommandList.status === "REPORTED" ||