diff --git a/src/modules/01_metadataNew/components/insignia/InsigniaList.vue b/src/modules/01_metadataNew/components/insignia/InsigniaList.vue index 8ff7e51b4..909c98e87 100644 --- a/src/modules/01_metadataNew/components/insignia/InsigniaList.vue +++ b/src/modules/01_metadataNew/components/insignia/InsigniaList.vue @@ -13,18 +13,18 @@ const store = useInsigniaDataStore(); const router = useRouter(); const mixin = useCounterMixin(); -// const props = defineProps({ -// fetchData: { -// type: Function, -// default: () => "", -// }, -// }); const insigniaTypeName = defineModel("insigniaTypeName", { required: true, }); -const { dialogRemove, dialogConfirm, showLoader, hideLoader, messageError } = - mixin; +const { + dialogRemove, + dialogConfirm, + showLoader, + hideLoader, + messageError, + success, +} = mixin; const $q = useQuasar(); const columns = ref([ { @@ -216,26 +216,49 @@ async function addData() { }) .then(() => { fetchData(id.value); + success($q, "บันทึกข้อมูลสำเร็จ"); }) .catch((err) => { messageError($q, err); + }) + .finally(() => { + hideLoader(); }); } async function editData(idData: string) { - await http.put(config.API.insigniaNewIdOrg(idData), { - name: name.value, - isActive: isActive.value, - shortName: shortName.value, - note: note.value == "" ? "-" : note.value, - insigniaTypeId: id.value, - }); - fetchData(id.value); + await http + .put(config.API.insigniaNewIdOrg(idData), { + name: name.value, + isActive: isActive.value, + shortName: shortName.value, + note: note.value == "" ? "-" : note.value, + insigniaTypeId: id.value, + }) + .then(() => { + fetchData(id.value); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function deleteData(idData: string) { - await http.delete(config.API.insigniaNewIdOrg(idData)); - fetchData(id.value); + await http + .delete(config.API.insigniaNewIdOrg(idData)) + .then(() => { + fetchData(id.value); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } import { defineEmits } from "vue"; @@ -382,7 +405,7 @@ const dialogOrder = ref(false); - +
(false); - - - - +
+ +
+
+ +
+
+ +
+
+ +
@@ -463,7 +490,6 @@ const dialogOrder = ref(false); unelevated label="บันทึก" color="public" - class="q-px-md" > บันทึกข้อมูล diff --git a/src/modules/01_metadataNew/components/insignia/InsigniaType.vue b/src/modules/01_metadataNew/components/insignia/InsigniaType.vue index 9353c4022..216586c40 100644 --- a/src/modules/01_metadataNew/components/insignia/InsigniaType.vue +++ b/src/modules/01_metadataNew/components/insignia/InsigniaType.vue @@ -95,8 +95,6 @@ const visibleColumns = ref([ "isActive", ]); -// const row = ref([]); - async function fetchData() { showLoader(); await http @@ -125,24 +123,53 @@ function onclickDetail(id: string) { } async function addData() { - await http.post(config.API.insigniaTypeOrg, { - name: name.value, - isActive: isActive.value, - }); - fetchData(); + await http + .post(config.API.insigniaTypeOrg, { + name: name.value, + isActive: isActive.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function editData(id: string) { - await http.put(config.API.insigniaTypeNewIdOrg(id), { - name: name.value, - isActive: isActive.value, - }); - fetchData(); + await http + .put(config.API.insigniaTypeNewIdOrg(id), { + name: name.value, + isActive: isActive.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function deleteData(id: string) { - await http.delete(config.API.insigniaTypeNewIdOrg(id)); - fetchData(); + await http + .delete(config.API.insigniaTypeNewIdOrg(id)) + .then(() => { + fetchData(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } function validateForm() { @@ -287,7 +314,7 @@ async function onSubmit() { - + - +
+ +
@@ -333,7 +361,6 @@ async function onSubmit() { unelevated label="บันทึก" color="public" - class="q-px-md" > บันทึกข้อมูล