แก้ไข กรณี แก้ไข + ยกเลิก

This commit is contained in:
setthawutttty 2023-09-26 16:08:56 +07:00
parent 016f256d38
commit 4959e0847e
6 changed files with 54 additions and 27 deletions

View file

@ -55,7 +55,7 @@ const responseData = ref<ResponseDataDetail>({
const edit = ref<boolean>(false);
const organizationPositionOld = ref<string>("");
const positionTypeOld = ref<string>("");
const myform = ref<any>();
const myForm = ref<QForm | null>(null);
const positionLevelOld = ref<string>("");
const posNo = ref<string>("");
const salary = ref<number>(0);
@ -111,13 +111,20 @@ const fecthOther = async () => {
//-----(edit)-----//
const clickEdit = async () => {
await myform.value.validate().then(async (success: boolean) => {
if (success) {
dialogConfirm($q, () => saveOther());
} else {
}
});
if (myForm.value !== null) {
myForm.value.validate().then((success: any) => {
if (success) {
dialogConfirm(
$q,
async () => await saveOther(),
"ต้องการแก้ไขข้อมูลหรือไม่?",
"แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย"
);
}
});
}
};
//-----(update)-----//
const saveOther = async () => {
let data = {
@ -145,6 +152,11 @@ const saveOther = async () => {
await fecthOther();
});
};
const cancel = () => {
edit.value = false;
fecthOther();
myForm.value?.resetValidation()
};
const getClass = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
@ -227,12 +239,12 @@ onMounted(async () => {
<q-btn outline color="public" dense class="q-px-sm" label="บันทึก"
style="width: 80px" @click="clickEdit" />
<q-btn outline color="red" dense class="q-px-sm" label="ยกเลิก"
style="width: 80px" @click="(edit = !edit), fecthOther()" />
style="width: 80px" @click="cancel()" />
</div>
</div>
</div>
<div class="col-12"><q-separator /></div>
<q-form ref="myform">
<q-form ref="myForm">
<div class="row col-12 q-pa-md">
<div class="col-12 row bg-white q-col-gutter-md">
<div class="col-xs-12 row items-center">