diff --git a/src/modules/01_metadataNew/components/personal/01ListPrefix.vue b/src/modules/01_metadataNew/components/personal/01ListPrefix.vue index ac074dfa6..2e982f834 100644 --- a/src/modules/01_metadataNew/components/personal/01ListPrefix.vue +++ b/src/modules/01_metadataNew/components/personal/01ListPrefix.vue @@ -57,7 +57,7 @@ const TABLE_COLUMNS = [ const $q = useQuasar(); const store = usePersonalDataStore(); const mixin = useCounterMixin(); -const { dialogRemove, messageError, showLoader, hideLoader } = mixin; +const { dialogRemove, messageError, showLoader, hideLoader, success } = mixin; const filterKeyword = ref(""); const dialog = ref(false); @@ -72,36 +72,11 @@ const visibleColumns = ref([ "lastUpdateFullName", ]); -const data = [ - { - id: "1", - name: "ว่าที่ร้อยตรี", - createdAt: new Date(), - lastUpdatedAt: new Date(), - lastUpdateFullName: "สาวิตรี ศรีสมัย", - }, - { - id: "2", - name: "นางสาว", - createdAt: new Date(), - lastUpdatedAt: new Date(), - lastUpdateFullName: "System Administrator", - }, - { - id: "3", - name: "นาย", - createdAt: new Date(), - lastUpdatedAt: new Date(), - lastUpdateFullName: "คณะกรรมการ ตรวจรับ", - }, -]; - async function fetchData() { showLoader(); await http .get(config.API.orgPrefix) .then(async (res) => { - console.log(res.data.result); store.save(res.data.result); }) .catch((err) => { @@ -113,22 +88,51 @@ async function fetchData() { } async function addData() { - await http.post(config.API.orgPrefix, { - name: prefix.value, - }); - fetchData(); + await http + .post(config.API.orgPrefix, { + name: prefix.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function editData(id: string) { - await http.put(config.API.orgPrefixId(id), { - name: prefix.value, - }); - fetchData(); + await http + .put(config.API.orgPrefixId(id), { + name: prefix.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function deleteData(id: string) { - await http.delete(config.API.orgPrefixId(id)); - fetchData(); + await http + .delete(config.API.orgPrefixId(id)) + .then(() => { + fetchData(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } onMounted(async () => { diff --git a/src/modules/01_metadataNew/components/personal/02ListRank.vue b/src/modules/01_metadataNew/components/personal/02ListRank.vue index 9463345fa..b2b1a0b7b 100644 --- a/src/modules/01_metadataNew/components/personal/02ListRank.vue +++ b/src/modules/01_metadataNew/components/personal/02ListRank.vue @@ -59,7 +59,7 @@ const columns = [ const store = usePersonalDataStore(); const router = useRouter(); const mixin = useCounterMixin(); -const { dialogRemove, messageError, showLoader, hideLoader } = mixin; +const { dialogRemove, messageError, showLoader, hideLoader, success } = mixin; const $q = useQuasar(); @@ -81,7 +81,6 @@ async function fetchData() { await http .get(config.API.orgRank) .then(async (res) => { - console.log(res.data.result); store.save(res.data.result); }) .catch((err) => { @@ -93,22 +92,51 @@ async function fetchData() { } async function addData() { - await http.post(config.API.orgRank, { - name: rank.value, - }); - fetchData(); + await http + .post(config.API.orgRank, { + name: rank.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function editData(id: string) { - await http.put(config.API.orgRankId(id), { - name: rank.value, - }); - fetchData(); + await http + .put(config.API.orgRankId(id), { + name: rank.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function deleteData(id: string) { - await http.delete(config.API.orgRankId(id)); - fetchData(); + await http + .delete(config.API.orgRankId(id)) + .then(() => { + fetchData(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } onMounted(async () => { diff --git a/src/modules/01_metadataNew/components/personal/03ListBloodGroup.vue b/src/modules/01_metadataNew/components/personal/03ListBloodGroup.vue index d0d095aec..a8a9eb0fc 100644 --- a/src/modules/01_metadataNew/components/personal/03ListBloodGroup.vue +++ b/src/modules/01_metadataNew/components/personal/03ListBloodGroup.vue @@ -13,7 +13,7 @@ import config from "@/app.config"; const store = usePersonalDataStore(); const router = useRouter(); const mixin = useCounterMixin(); -const { dialogRemove, messageError, showLoader, hideLoader } = mixin; +const { dialogRemove, messageError, showLoader, hideLoader, success } = mixin; const columns = [ { name: "bloodGroup", @@ -81,7 +81,6 @@ async function fetchData() { await http .get(config.API.orgBloodGroup) .then(async (res) => { - console.log(res.data.result); store.save(res.data.result); }) .catch((err) => { @@ -93,22 +92,51 @@ async function fetchData() { } async function addData() { - await http.post(config.API.orgBloodGroup, { - name: bloodGroup.value, - }); - fetchData(); + await http + .post(config.API.orgBloodGroup, { + name: bloodGroup.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function editData(id: string) { - await http.put(config.API.orgBloodGroupId(id), { - name: bloodGroup.value, - }); - fetchData(); + await http + .put(config.API.orgBloodGroupId(id), { + name: bloodGroup.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function deleteData(id: string) { - await http.delete(config.API.orgBloodGroupId(id)); - fetchData(); + await http + .delete(config.API.orgBloodGroupId(id)) + .then(() => { + fetchData(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } onMounted(async () => { diff --git a/src/modules/01_metadataNew/components/personal/04ListGender.vue b/src/modules/01_metadataNew/components/personal/04ListGender.vue index a27c46878..c0c185118 100644 --- a/src/modules/01_metadataNew/components/personal/04ListGender.vue +++ b/src/modules/01_metadataNew/components/personal/04ListGender.vue @@ -13,7 +13,7 @@ import config from "@/app.config"; const store = usePersonalDataStore(); const router = useRouter(); const mixin = useCounterMixin(); -const { dialogRemove, messageError, showLoader, hideLoader } = mixin; +const { dialogRemove, messageError, showLoader, hideLoader, success } = mixin; const columns = [ { name: "gender", @@ -81,7 +81,6 @@ async function fetchData() { await http .get(config.API.orgGender) .then(async (res) => { - console.log(res.data.result); store.save(res.data.result); }) .catch((err) => { @@ -93,22 +92,51 @@ async function fetchData() { } async function addData() { - await http.post(config.API.orgGender, { - name: gender.value, - }); - fetchData(); + await http + .post(config.API.orgGender, { + name: gender.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function editData(id: string) { - await http.put(config.API.orgGenderId(id), { - name: gender.value, - }); - fetchData(); + await http + .put(config.API.orgGenderId(id), { + name: gender.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function deleteData(id: string) { - await http.delete(config.API.orgGenderId(id)); - fetchData(); + await http + .delete(config.API.orgGenderId(id)) + .then(() => { + fetchData(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } onMounted(async () => { diff --git a/src/modules/01_metadataNew/components/personal/05ListReligion.vue b/src/modules/01_metadataNew/components/personal/05ListReligion.vue index e6254821c..483cde13f 100644 --- a/src/modules/01_metadataNew/components/personal/05ListReligion.vue +++ b/src/modules/01_metadataNew/components/personal/05ListReligion.vue @@ -13,7 +13,7 @@ import config from "@/app.config"; const store = usePersonalDataStore(); const router = useRouter(); const mixin = useCounterMixin(); -const { dialogRemove, messageError, showLoader, hideLoader } = mixin; +const { dialogRemove, messageError, showLoader, hideLoader, success } = mixin; const columns = [ { name: "religion", @@ -81,7 +81,6 @@ async function fetchData() { await http .get(config.API.orgReligion) .then(async (res) => { - console.log(res.data.result); store.save(res.data.result); }) .catch((err) => { @@ -93,22 +92,51 @@ async function fetchData() { } async function addData() { - await http.post(config.API.orgReligion, { - name: religion.value, - }); - fetchData(); + await http + .post(config.API.orgReligion, { + name: religion.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function editData(id: string) { - await http.put(config.API.orgReligionId(id), { - name: religion.value, - }); - fetchData(); + await http + .put(config.API.orgReligionId(id), { + name: religion.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function deleteData(id: string) { - await http.delete(config.API.orgReligionId(id)); - fetchData(); + await http + .delete(config.API.orgReligionId(id)) + .then(() => { + fetchData(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } onMounted(async () => { diff --git a/src/modules/01_metadataNew/components/personal/06ListRelationship.vue b/src/modules/01_metadataNew/components/personal/06ListRelationship.vue index 45b691e39..60c0f2cd2 100644 --- a/src/modules/01_metadataNew/components/personal/06ListRelationship.vue +++ b/src/modules/01_metadataNew/components/personal/06ListRelationship.vue @@ -12,7 +12,7 @@ import config from "@/app.config"; const store = usePersonalDataStore(); const router = useRouter(); const mixin = useCounterMixin(); -const { dialogRemove, messageError, showLoader, hideLoader } = mixin; +const { dialogRemove, messageError, showLoader, hideLoader, success } = mixin; const columns = [ { name: "relationship", @@ -110,7 +110,6 @@ async function fetchData() { await http .get(config.API.orgRelationship) .then(async (res) => { - console.log(res.data.result); store.save(res.data.result); }) .catch((err) => { @@ -122,22 +121,50 @@ async function fetchData() { } async function addData() { - await http.post(config.API.orgRelationship, { - name: relationship.value, - }); - fetchData(); + await http + .post(config.API.orgRelationship, { + name: relationship.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } - async function editData(id: string) { - await http.put(config.API.orgRelationshipId(id), { - name: relationship.value, - }); - fetchData(); + await http + .put(config.API.orgRelationshipId(id), { + name: relationship.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function deleteData(id: string) { - await http.delete(config.API.orgRelationshipId(id)); - fetchData(); + await http + .delete(config.API.orgRelationshipId(id)) + .then(() => { + fetchData(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } onMounted(async () => { diff --git a/src/modules/01_metadataNew/components/personal/07ListEducationLevel.vue b/src/modules/01_metadataNew/components/personal/07ListEducationLevel.vue index 8a7ebcaba..c2d2c382c 100644 --- a/src/modules/01_metadataNew/components/personal/07ListEducationLevel.vue +++ b/src/modules/01_metadataNew/components/personal/07ListEducationLevel.vue @@ -11,7 +11,7 @@ import config from "@/app.config"; const store = usePersonalDataStore(); const mixin = useCounterMixin(); -const { dialogRemove, messageError, showLoader, hideLoader } = mixin; +const { dialogRemove, messageError, showLoader, hideLoader, success } = mixin; const columns = [ { name: "name", @@ -91,7 +91,6 @@ async function fetchData() { await http .get(config.API.orgEducationLevel) .then(async (res) => { - console.log(res.data.result); store.save(res.data.result); }) .catch((err) => { @@ -103,24 +102,53 @@ async function fetchData() { } async function addData() { - await http.post(config.API.orgEducationLevel, { - name: educationLevel.value, - rank: educationRank.value, - }); - fetchData(); + await http + .post(config.API.orgEducationLevel, { + name: educationLevel.value, + rank: educationRank.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function editData(id: string) { - await http.put(config.API.orgEducationLevelId(id), { - name: educationLevel.value, - rank: educationRank.value, - }); - fetchData(); + await http + .put(config.API.orgEducationLevelId(id), { + name: educationLevel.value, + rank: educationRank.value, + }) + .then(() => { + fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } async function deleteData(id: string) { - await http.delete(config.API.orgEducationLevelId(id)); - fetchData(); + await http + .delete(config.API.orgEducationLevelId(id)) + .then(() => { + fetchData(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } onMounted(async () => { diff --git a/src/modules/01_metadataNew/components/personal/DialogForm.vue b/src/modules/01_metadataNew/components/personal/DialogForm.vue index 7b6e40557..0845140a6 100644 --- a/src/modules/01_metadataNew/components/personal/DialogForm.vue +++ b/src/modules/01_metadataNew/components/personal/DialogForm.vue @@ -63,7 +63,7 @@ async function onSubmit() {