diff --git a/src/modules/11_discipline/components/2_InvestigateFacts/EditPage.vue b/src/modules/11_discipline/components/2_InvestigateFacts/EditPage.vue index cd6a310aa..f005f0c71 100644 --- a/src/modules/11_discipline/components/2_InvestigateFacts/EditPage.vue +++ b/src/modules/11_discipline/components/2_InvestigateFacts/EditPage.vue @@ -118,7 +118,8 @@ async function getDataComplaint() { await http .get( config.API.complaintbyGetId( - data.idComplaint ? data.idComplaint : store.complaintId,mainStore.pathComplaints(route.name as string) + data.idComplaint ? data.idComplaint : store.complaintId, + mainStore.pathComplaints(route.name as string) ) ) .then((res) => { @@ -155,7 +156,12 @@ async function getDataComplaint() { function getData() { showLoader(); http - .get(config.API.investigateByGetId(id.value,mainStore.pathInves(route.name as string))) + .get( + config.API.investigateByGetId( + id.value, + mainStore.pathInves(route.name as string) + ) + ) .then((res) => { const dataList = res.data.result; data.id = dataList.id; diff --git a/src/modules/11_discipline/components/2_InvestigateFacts/Form.vue b/src/modules/11_discipline/components/2_InvestigateFacts/Form.vue index a499c9917..0f27e8373 100644 --- a/src/modules/11_discipline/components/2_InvestigateFacts/Form.vue +++ b/src/modules/11_discipline/components/2_InvestigateFacts/Form.vue @@ -434,7 +434,7 @@ function changeFormData() { isSave.value = true; if (organization.value) { - formData.organizationId = organization.value.id; + formData.organizationId = organization.value.id as string; formData.organization = organization.value.name; } } @@ -1765,7 +1765,7 @@ onMounted(async () => { /> { /> (""); //ตัวแปรเก็บคำสั่งที่เลือก +const commandOp = ref([]); +const listCommand = ref([]); // เก็บคำสั่งทั้งหมด + +const modalCommand = ref(false); const optionsType = ref<[]>([]); const idPath = ref(route.params.id as string); const type = ref(""); const rows = ref([]); const selected = ref([]); +const modal = defineModel("modal", { required: true }); const props = defineProps({ data: { type: Object, @@ -45,7 +55,6 @@ const props = defineProps({ type: Array, default: [], }, - Modal: Boolean, closeModal: Function, getData: Function, rows2: Array, @@ -61,16 +70,15 @@ const checkSelected = computed(() => { //popup ยืนยันส่งัว function saveOrder() { - if (type.value) { - dialogConfirm( - $q, - () => Ordersave(), - `ยืนยัน${props.title}`, - `ต้องการยืนยัน${props.title}ใช่หรือไม่?` - ); - } else { - dialogMessageNotify($q, "กรุณาเลือกประเภทคำสั่ง"); - } + dialogConfirm( + $q, + async () => { + modalCommand.value = true; + modal.value = false; + }, + "ยืนยันส่งไปออกคำสั่ง", + "ต้องการยืนยันส่งไปออกคำสั่งใช่หรือไม่?" + ); } //ส่งไปออกคำสั่ง async function Ordersave() { @@ -111,51 +119,50 @@ function Reset() { emit("update:filterKeyword2", ""); } -//----(ดึงข้อมูลประเภทคำสั่ง)------// -async function fecthTypeOption() { - showLoader(); - await http - .get(config.API.typeOrder()) - .then((res) => { - optionsType.value = res.data.result.filter( - (e: OpType) => - e.commandCode === "C-PM-19" || - e.commandCode === "C-PM-20" || - e.commandCode === "C-PM-27" || - e.commandCode === "C-PM-28" || - e.commandCode === "C-PM-29" || - e.commandCode === "C-PM-30" || - e.commandCode === "C-PM-31" - ); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - hideLoader(); - }); +/** + * ฟิลเตอร์ คำสั่ง + * @param val ค่าจาก Input + * @param update Funtion quasar + */ +function filterSelector(val: string, update: Function) { + update(() => { + commandType.value = val ? "" : commandType.value; + commandOp.value = listCommand.value.filter( + (v: any) => v.name.indexOf(val) > -1 + ); + }); } -watchEffect(() => { - if (props.Modal === true) { - selected.value = []; - type.value = ""; - rows.value = props.data.persons.filter( - (item: any) => item.status === "NEW" - ); - } -}); - +/** + * เมื่อ props.modal เป็น true + * กำหนดให้ selected เป็นค่าว่างและกำหนด filter ประเภทตำแหน่งตามประเภทการสอบ + */ watch( - () => props.title, - () => { - fecthTypeOption(); + () => modal.value, + async () => { + if (modal.value === true) { + selected.value = []; + commandType.value = ""; + rows.value = props.data.persons ? props.data.persons : []; + + const data = await storeCommand.getCommandTypes(); + listCommand.value = data.filter( + (v: any) => + v.code == "C-PM-19" || + v.code == "C-PM-20" || + v.code == "C-PM-27" || + v.code == "C-PM-28" || + v.code == "C-PM-29" || + v.code == "C-PM-30" || + v.code == "C-PM-31" + ); + } } ); @@ -251,6 +264,7 @@ watch( keep-color color="primary" dense + :disable="commandType" v-model="props.selected" /> @@ -280,10 +294,17 @@ watch( + + + diff --git a/src/modules/11_discipline/components/4_Result/EditPage.vue b/src/modules/11_discipline/components/4_Result/EditPage.vue index 01498bedb..ec274c68b 100644 --- a/src/modules/11_discipline/components/4_Result/EditPage.vue +++ b/src/modules/11_discipline/components/4_Result/EditPage.vue @@ -367,7 +367,7 @@ onMounted(async () => { ("modal", { required: true }); const mixin = useCounterMixin(); const $q = useQuasar(); const { dialogConfirm, dialogMessageNotify } = mixin; + +const rows = ref([]); const props = defineProps({ title: { type: String, default: "ส่งไปสืบสวน", }, - modal: { - type: Boolean, - require: true, - }, close: { type: Function, require: true, @@ -48,6 +48,7 @@ const props = defineProps({ }, }); +const modalCommand = ref(false); const emit = defineEmits(["returnPerson"]); const selected = ref([]); const inspectionResults = ref(""); @@ -65,12 +66,11 @@ function onclickSend() { dialogConfirm( $q, async () => { - await emit("returnPerson", selected.value); - props.fetchData(); - props.close?.(); + modalCommand.value = true; + modal.value = false; }, - `ยืนยันการ${props.title}`, - `ต้องการยืนยันการ${props.title}หรือไม่` + "ยืนยันส่งไปออกคำสั่ง", + "ต้องการยืนยันส่งไปออกคำสั่งใช่หรือไม่?" ); } } @@ -78,18 +78,22 @@ function onclickSend() { /** ปิด pop up */ function onClickClose() { props.close?.(); + filter.value = ""; + selected.value = []; } -watch([() => props.modal], () => { - inspectionResults.value = props.modal ? "" : ""; - selected.value = props.modal ? [] : []; - if (props.modal === true) { - selected.value = props.checkedVal ? props.rows : []; +watch( + () => modal.value, + () => { + if (modal.value) { + inspectionResults.value = modal ? "" : ""; + selected.value = []; + } } -}); +);