- add common dialog (remove, confirm & message notify) และลองใช้ในส่วนของออกคำสั่ง

- เพิ่ม action สร้างข้อมูลทุกอันที่ส่งจากทะเบียนประวัติ
- fix bug call function in certificate
This commit is contained in:
Warunee Tamkoo 2023-08-11 23:47:18 +07:00
parent d09dbda153
commit d163ac8e1c
9 changed files with 341 additions and 1422 deletions

View file

@ -125,7 +125,7 @@ import config from "@/app.config";
const $q = useQuasar(); // noti quasar
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, date2Thai, dateText, success, dialogMessage } =
const { showLoader, hideLoader, messageError, date2Thai, dateText, success, dialogRemove } =
mixin;
const DataStore = useOrderPlacementDataStore();
@ -314,15 +314,9 @@ const redirectToPage = (id?: string, status?: string) => {
};
const clickDelete = (id: string) => {
dialogMessage(
dialogRemove(
$q,
"ยืนยันการลบข้อมูล",
"ต้องการลบข้อมูลนี้ใช่หรือไม่?",
"mdi-delete",
"ตกลง",
"red",
() => deleteData(id),
undefined
);
};

View file

@ -3,24 +3,10 @@
<q-form ref="myForm" class="q-pa-md">
<div class="row col-12 q-col-gutter-x-lg q-col-gutter-y-md">
<div class="col-xs-12 col-md-6">
<selector
:class="getClass(true)"
outlined
dense
lazy-rules
v-model="typeOrder"
:rules="[(val: string) => !!val || `${'กรุณาเลือกประเภทคำสั่ง'}`]"
hide-bottom-space
:label="`${'ประเภทคำสั่ง'}`"
@update:modelValue="clickEditRow"
emit-value
map-options
option-label="name"
:options="typeOrderOption"
option-value="id"
use-input
input-debounce="0"
/>
<selector :class="getClass(true)" outlined dense lazy-rules v-model="typeOrder"
:rules="[(val: string) => !!val || `${'กรุณาเลือกประเภทคำสั่ง'}`]" hide-bottom-space
:label="`${'ประเภทคำสั่ง'}`" @update:modelValue="clickEditRow" emit-value map-options option-label="name"
:options="typeOrderOption" option-value="id" use-input input-debounce="0" />
<!-- @filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'typeOrderOption'
) " -->
@ -29,73 +15,36 @@
<div class="col-xs-12 col-md-6">
<!-- :readonly="!edit"
:borderless="!edit" -->
<q-input
:class="getClass(true)"
outlined
dense
lazy-rules
v-model="nameOrder"
:rules="[(val) => !!val || `${'กรุณากรอกคำสั่งเรื่อง'}`]"
:label="`${'คำสั่งเรื่อง'}`"
@update:modelValue="clickEditRow"
hide-bottom-space
/>
<q-input :class="getClass(true)" outlined dense lazy-rules v-model="nameOrder"
:rules="[(val) => !!val || `${'กรุณากรอกคำสั่งเรื่อง'}`]" :label="`${'คำสั่งเรื่อง'}`"
@update:modelValue="clickEditRow" hide-bottom-space />
</div>
<div class="row col-xs-7 col-md-3 q-col-gutter-x-xs">
<div class="col-6">
<q-input
:class="getClass(true)"
outlined
dense
lazy-rules
v-model="command"
:rules="[(val) => !!val || `${'กรุณากรอกคำสั่ง'}`]"
:label="`${'คำสั่ง'}`"
@update:modelValue="clickEditRow"
hide-bottom-space
type="number"
/>
<q-input :class="getClass(true)" outlined dense lazy-rules v-model="command"
:rules="[(val) => !!val || `${'กรุณากรอกคำสั่ง'}`]" :label="`${'คำสั่ง'}`" @update:modelValue="clickEditRow"
hide-bottom-space type="number" />
</div>
<label class="col-1 flex justify-center items-center text-bold"
>/</label
>
<label class="col-1 flex justify-center items-center text-bold">/</label>
<div class="col-5">
<datepicker
v-model="dateYear"
:locale="'th'"
autoApply
year-picker
:enableTimePicker="false"
@update:modelValue="clickEditRow"
>
<datepicker v-model="dateYear" :locale="'th'" autoApply year-picker :enableTimePicker="false"
@update:modelValue="clickEditRow">
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
:model-value="dateYear + 543"
:rules="[(val) => !!val || `${'กรุณากรอก พ.ศ.'}`]"
:label="`${'พ.ศ.'}`"
dense
outlined
>
<q-input :model-value="dateYear + 543" :rules="[(val) => !!val || `${'กรุณากรอก พ.ศ.'}`]"
:label="`${'พ.ศ.'}`" dense outlined>
</q-input>
</template>
</datepicker>
</div>
</div>
<div class="col-xs-5 col-md-3">
<datepicker
menu-class-name="modalfix"
v-model="dateCommand"
:locale="'th'"
autoApply
borderless
:enableTimePicker="false"
week-start="0"
>
<datepicker menu-class-name="modalfix" v-model="dateCommand" :locale="'th'" autoApply borderless
:enableTimePicker="false" week-start="0">
<template #year="{ year }">
{{ year + 543 }}
</template>
@ -103,24 +52,12 @@
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
outlined
dense
class="full-width datepicker"
:model-value="
dateCommand != null ? date2Thai(dateCommand) : null
"
:label="`${'วันที่มีผลออกคำสั่ง'}`"
:rules="[
(val) => !!val || `${'กรุณาเลือกวันที่มีผลออกคำสั่ง'}`,
]"
>
<q-input outlined dense class="full-width datepicker" :model-value="dateCommand != null ? date2Thai(dateCommand) : null
" :label="`${'วันที่มีผลออกคำสั่ง'}`" :rules="[
(val) => !!val || `${'กรุณาเลือกวันที่มีผลออกคำสั่ง'}`,
]">
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)">
</q-icon>
</template>
</q-input>
@ -129,24 +66,10 @@
</div>
<div class="col-xs-12 col-md-6">
<selector
:class="getClass(true)"
outlined
dense
lazy-rules
v-model="byOrder"
:rules="[(val: string) => !!val || `${'กรุณาเลือกคำสั่งโดย'}`]"
hide-bottom-space
:label="`${'คำสั่งโดย'}`"
@update:modelValue="clickEditRow"
emit-value
map-options
option-label="name"
:options="byOrderOption"
option-value="id"
use-input
input-debounce="0"
/>
<selector :class="getClass(true)" outlined dense lazy-rules v-model="byOrder"
:rules="[(val: string) => !!val || `${'กรุณาเลือกคำสั่งโดย'}`]" hide-bottom-space :label="`${'คำสั่งโดย'}`"
@update:modelValue="clickEditRow" emit-value map-options option-label="name" :options="byOrderOption"
option-value="id" use-input input-debounce="0" />
<!-- @filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'byOrderOption'
) " -->
@ -154,55 +77,25 @@
<div class="col-xs-12 col-md-6">
<!-- :readonly="!edit"
:borderless="!edit" -->
<q-input
:class="getClass(true)"
outlined
dense
lazy-rules
v-model="nameCommand"
:rules="[(val) => !!val || `${'กรุณากรอกผู้มีอำนาจลงนาม'}`]"
:label="`${'ผู้มีอำนาจลงนาม'}`"
@update:modelValue="clickEditRow"
hide-bottom-space
/>
<q-input :class="getClass(true)" outlined dense lazy-rules v-model="nameCommand"
:rules="[(val) => !!val || `${'กรุณากรอกผู้มีอำนาจลงนาม'}`]" :label="`${'ผู้มีอำนาจลงนาม'}`"
@update:modelValue="clickEditRow" hide-bottom-space />
</div>
<div class="col-xs-12 col-md-6">
<!-- :readonly="!edit"
:borderless="!edit" -->
<q-input
:class="getClass(true)"
outlined
dense
lazy-rules
v-model="positionCommand"
:rules="[(val) => !!val || `${'กรุณากรอกตำแหน่งผู้มีอำนาจลงนาม'}`]"
:label="`${'ตำแหน่งผู้มีอำนาจลงนาม'}`"
@update:modelValue="clickEditRow"
hide-bottom-space
/>
<q-input :class="getClass(true)" outlined dense lazy-rules v-model="positionCommand"
:rules="[(val) => !!val || `${'กรุณากรอกตำแหน่งผู้มีอำนาจลงนาม'}`]" :label="`${'ตำแหน่งผู้มีอำนาจลงนาม'}`"
@update:modelValue="clickEditRow" hide-bottom-space />
</div>
<div class="col-12">
<q-separator />
</div>
<div class="col-xs-12 col-md-6">
<selector
:class="getClass(true)"
outlined
dense
lazy-rules
v-model="examRound"
:rules="[(val: string) => !!val || `${'กรุณาเลือกรอบการสอบ'}`]"
hide-bottom-space
:label="`${'รอบการสอบ'}`"
@update:modelValue="clickEditRow"
emit-value
map-options
option-label="examRoundName"
:options="examRoundOption"
option-value="examRoundValue"
use-input
input-debounce="0"
/>
<selector :class="getClass(true)" outlined dense lazy-rules v-model="examRound"
:rules="[(val: string) => !!val || `${'กรุณาเลือกรอบการสอบ'}`]" hide-bottom-space :label="`${'รอบการสอบ'}`"
@update:modelValue="clickEditRow" emit-value map-options option-label="examRoundName"
:options="examRoundOption" option-value="examRoundValue" use-input input-debounce="0" />
<!-- @filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'testOption'
) " -->
@ -216,39 +109,18 @@
filterSelector(inputValue, doneFn,'positionOption' ) " -->
</div>
<div class="col-xs-12 col-md-6">
<selector
:class="getClass(true)"
outlined
dense
lazy-rules
v-model="register"
:rules="[(val: string) => !!val || `${'กรุณาเลือกมติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)'}`]"
hide-bottom-space
:label="`${'มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)'}`"
@update:modelValue="clickEditRow"
emit-value
map-options
option-label="name"
:options="registerOption"
option-value="id"
use-input
input-debounce="0"
/>
<selector :class="getClass(true)" outlined dense lazy-rules v-model="register"
:rules="[(val: string) => !!val || `${'กรุณาเลือกมติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)'}`]" hide-bottom-space
:label="`${'มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)'}`" @update:modelValue="clickEditRow" emit-value
map-options option-label="name" :options="registerOption" option-value="id" use-input input-debounce="0" />
</div>
<!-- @filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'registerOption'
) " -->
<div class="col-xs-12 col-md-6">
<datepicker
menu-class-name="modalfix"
v-model="dateRegister"
:locale="'th'"
autoApply
borderless
:enableTimePicker="false"
week-start="0"
>
<datepicker menu-class-name="modalfix" v-model="dateRegister" :locale="'th'" autoApply borderless
:enableTimePicker="false" week-start="0">
<template #year="{ year }">
{{ year + 543 }}
</template>
@ -256,25 +128,13 @@
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
outlined
dense
class="full-width datepicker"
:model-value="
dateRegister != null ? date2Thai(dateRegister) : null
"
:label="`${'ลงวันที่ (เรื่อง รับสมัครสอบฯ)'}`"
:rules="[
(val) =>
!!val || `${'กรุณาเลือกลงวันที่ (เรื่อง รับสมัครสอบฯ)'}`,
]"
>
<q-input outlined dense class="full-width datepicker" :model-value="dateRegister != null ? date2Thai(dateRegister) : null
" :label="`${'ลงวันที่ (เรื่อง รับสมัครสอบฯ)'}`" :rules="[
(val) =>
!!val || `${'กรุณาเลือกลงวันที่ (เรื่อง รับสมัครสอบฯ)'}`,
]">
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)">
</q-icon>
</template>
</q-input>
@ -282,38 +142,18 @@
</datepicker>
</div>
<div class="col-xs-12 col-md-6">
<selector
:class="getClass(true)"
outlined
dense
lazy-rules
v-model="announce"
<selector :class="getClass(true)" outlined dense lazy-rules v-model="announce"
:rules="[(val: string) => !!val || `${'กรุณาเลือกมติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)'}`]"
hide-bottom-space
:label="`${'มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)'}`"
@update:modelValue="clickEditRow"
emit-value
map-options
option-label="name"
:options="announceOption"
option-value="id"
use-input
input-debounce="0"
/>
hide-bottom-space :label="`${'มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)'}`" @update:modelValue="clickEditRow"
emit-value map-options option-label="name" :options="announceOption" option-value="id" use-input
input-debounce="0" />
<!-- @filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'announceOption'
) " -->
</div>
<div class="col-xs-12 col-md-6">
<datepicker
menu-class-name="modalfix"
v-model="dateAnnounce"
:locale="'th'"
autoApply
borderless
:enableTimePicker="false"
week-start="0"
>
<datepicker menu-class-name="modalfix" v-model="dateAnnounce" :locale="'th'" autoApply borderless
:enableTimePicker="false" week-start="0">
<template #year="{ year }">
{{ year + 543 }}
</template>
@ -321,25 +161,13 @@
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
outlined
dense
class="full-width datepicker"
:model-value="
dateAnnounce != null ? date2Thai(dateAnnounce) : null
"
:label="`${'ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)'}`"
:rules="[
(val) =>
!!val || `${'กรุณาเลือกลงวันที่ (เรื่อง ผลการสอบแข่งขัน)'}`,
]"
>
<q-input outlined dense class="full-width datepicker" :model-value="dateAnnounce != null ? date2Thai(dateAnnounce) : null
" :label="`${'ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)'}`" :rules="[
(val) =>
!!val || `${'กรุณาเลือกลงวันที่ (เรื่อง ผลการสอบแข่งขัน)'}`,
]">
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)">
</q-icon>
</template>
</q-input>
@ -382,7 +210,7 @@ const {
showLoader,
hideLoader,
success,
dialogMessage,
dialogConfirm,
} = mixin;
const $q = useQuasar(); // noti quasar
const route = useRoute();
@ -576,9 +404,9 @@ const fecthExamRoundOption = async () => {
.get(config.API.examroundOrder())
.then((res) => {
examRoundOption.value = res.data.result;
console.log(examRoundOption.value);
// console.log(examRoundOption.value);
})
.catch((e) => {});
.catch((e) => { });
};
const submit = async () => {
const formdata = {
@ -599,13 +427,8 @@ const submit = async () => {
};
await myForm.value!.validate().then((result: boolean) => {
if (result) {
dialogMessage(
dialogConfirm(
$q,
"ยืนยันการบันทึกข้อมูล",
"ต้องการบันทึกข้อมูลนี้ใช่หรือไม่?",
"info",
"ตกลง",
"public",
() => {
if (!orderId) {
createListOrder(formdata);
@ -614,13 +437,12 @@ const submit = async () => {
updateOrder(formdata, orderIdString);
}
},
undefined
);
}
});
};
const createListOrder = async (formData: Object) => {
// console.log(formData);
showLoader();
await http
.post(config.API.createOrder(), formData)
.then((res) => {
@ -639,7 +461,7 @@ const createListOrder = async (formData: Object) => {
};
const updateOrder = async (formData: Object, orderId: string) => {
// console.log(formData);
showLoader();
await http
.put(config.API.detailOrder(orderId), formData)
.then((res) => {

View file

@ -183,7 +183,7 @@ const props = defineProps({
const next = () => props.next();
const previous = () => props.previous();
const mixin = useCounterMixin(); //
const { dialogMessage, messageError, showLoader, hideLoader, success } = mixin;
const { dialogMessageNotify, dialogConfirm, dialogRemove, messageError, showLoader, hideLoader, success } = mixin;
const route = useRoute();
const $q = useQuasar();
@ -306,15 +306,9 @@ const getData = async (id: string) => {
// };
const dialogDeleteData = async (id: string) => {
dialogMessage(
dialogRemove(
$q,
"ยืนยันการลบข้อมูล",
"ต้องการลบข้อมูลนี้ใช่หรือไม่?",
"mdi-delete",
"ตกลง",
"red",
() => deleteData(id),
undefined
);
};
@ -442,14 +436,10 @@ const putSalary = async (salary: any) => {
positionSalaryAmount: Number(salary.positionSalaryAmount),
monthSalaryAmount: Number(salary.mouthSalaryAmount),
};
dialogMessage(
dialogConfirm(
$q,
"ยืนยันการบันทึกข้อมูล",
"ต้องการบันทึกข้อมูลนี้ใช่หรือไม่?",
"info",
"ตกลง",
"public",
async () => {
showLoader()
await http
.put(config.API.salaryOrder(personalId.value), modalData.value)
.then((res: any) => {
@ -463,9 +453,9 @@ const putSalary = async (salary: any) => {
.finally(async () => {
await conditionData();
modal.value = false;
hideLoader()
});
},
undefined
);
};
@ -514,20 +504,15 @@ const saveModalAdd = () => {
if (myFormAdd.value !== null) {
myFormAdd.value.validate().then(async (result: boolean) => {
if (result && selected.value.length !== 0) {
dialogMessage(
dialogConfirm(
$q,
"ยืนยันการเพิ่มรายชื่อออกคำสั่ง",
"ต้องการยืนยันการเพิ่มรายชื่อออกคำสั่งนี้ใช่หรือไม่?",
"info",
"ตกลง",
"public",
() => {
let data = [];
data.push(...selected.value.map((e: any) => e.refRecordId));
// console.log(data);
addlist(data);
},
undefined
"ยืนยันการเพิ่มรายชื่อออกคำสั่ง",
"ต้องการยืนยันการเพิ่มรายชื่อออกคำสั่งนี้ใช่หรือไม่?",
);
}
@ -563,31 +548,18 @@ const click = (e: any) => {
const save = () => {
if (selected.value.length > 0) {
dialogMessage(
dialogConfirm(
$q,
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้ใช่หรือไม่?",
"info",
"ตกลง",
"public",
() => {
success($q, "บันทึกข้อมูลสำเร็จ");
next();
},
undefined
);
} else {
dialogMessage(
dialogMessageNotify(
$q,
"ข้อความแจ้งเตือน",
"กรุณาเลือกรายชื่อ",
"warning",
undefined,
"orange",
undefined,
undefined,
true
);
}
};

View file

@ -343,7 +343,7 @@ const previous = () => props.previous();
const $q = useQuasar();
const mixin = useCounterMixin(); //
const { dialogMessage, messageError, showLoader, hideLoader, success } = mixin;
const { dialogRemove, messageError, showLoader, hideLoader, success } = mixin;
const route = useRoute();
@ -598,22 +598,7 @@ const getClass = (val: boolean) => {
};
const clickClose = async () => {
// if (editRow.value == true) {
// dialogMessage(
// $q,
// "",
// "?",
// "mdi-help-circle-outline",
// "",
// "orange",
// () => (modal.value = false),
// undefined
// );
// } else {
modal.value = false;
// next.value = false;
// previous.value = false;
// }
};
const clickAdd = async () => {
@ -628,15 +613,9 @@ const clickAdd = async () => {
};
const clickDelete = (id: string) => {
dialogMessage(
dialogRemove(
$q,
"ยืนยันการลบข้อมูล",
"ต้องการลบข้อมูลนี้ใช่หรือไม่?",
"mdi-delete",
"ตกลง",
"red",
() => deleteData(id),
undefined
);
};

View file

@ -252,7 +252,7 @@ import http from "@/plugins/http";
import config from "@/app.config";
const mixin = useCounterMixin();
const { date2Thai, messageError, showLoader, hideLoader, dialogMessage } = mixin;
const { date2Thai, messageError, showLoader, hideLoader, dialogConfirm } = mixin;
const route = useRoute();
const $q = useQuasar();
@ -382,14 +382,8 @@ const save = () => {
if (myForm.value !== null) {
myForm.value!.validate().then((success: Boolean) => {
if (success) {
// yay, models are correct
dialogMessage(
dialogConfirm(
$q,
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้ใช่หรือไม่?",
"info",
"ตกลง",
"public",
async () => {
await putOrderData();
await postfileOrder();
@ -397,7 +391,6 @@ const save = () => {
await fetchAttachment(orderId.value);
await fecthstatusOrder(orderId.value);
},
undefined
);
}
@ -431,13 +424,8 @@ const postfileTailer = async () => {
await http.post(config.API.attachmentFileId(orderId.value), formData);
};
const clickExecute = async (id: string) => {
dialogMessage(
dialogConfirm(
$q,
"ยืนยันการออกคำสั่ง",
"ต้องการยืนยันการออกคำสั่งนี้ใช่หรือไม่?",
"info",
"ตกลง",
"public",
async () => {
await http
.put(config.API.executeOrder(id))
@ -448,7 +436,8 @@ const clickExecute = async (id: string) => {
messageError($q, e);
});
},
undefined
"ยืนยันการออกคำสั่ง",
"ต้องการยืนยันการออกคำสั่งนี้ใช่หรือไม่?",
);
};