From 7bac2037be78b88bdc25b82c5615598a5ca03fe6 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 22 Aug 2023 15:58:34 +0700 Subject: [PATCH] =?UTF-8?q?api=20=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=AF?= =?UTF-8?q?=20=E0=B8=AA=E0=B9=88=E0=B8=A7=E0=B8=99=E0=B8=88=E0=B8=B1?= =?UTF-8?q?=E0=B8=94=E0=B8=81=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/07_insignia/api.insignia.ts | 6 +- .../07_insignia/components/2_Manage/Tab1.vue | 229 +++++++----------- .../07_insignia/components/2_Manage/Tab2.vue | 110 +-------- .../07_insignia/components/2_Manage/Tab3.vue | 108 +-------- .../components/2_Manage/listManage.vue | 17 +- src/modules/07_insignia/store.ts | 66 ++++- 6 files changed, 179 insertions(+), 357 deletions(-) diff --git a/src/api/07_insignia/api.insignia.ts b/src/api/07_insignia/api.insignia.ts index db50f6aac..fd15b5c1b 100644 --- a/src/api/07_insignia/api.insignia.ts +++ b/src/api/07_insignia/api.insignia.ts @@ -6,7 +6,7 @@ const insignia = `${env.API_URI}/insignia`; const Organization = `${env.API_URI}/Organization` export default { getRoundInsignia: (id: string) => `${insignia}/period/${id}`, - listRoundInsignia: (type: string) => `${insignia}/period/${type}`, + listRoundInsignia: () => `${insignia}/period/`, editRoundInsignia: (id: string) => `${insignia}/period/${id}`, RoundInsignia: (id: string) => `${insignia}/period/${id}`, requestInsignia: (insigniaPeriodId: string) => `${insignia}/request/${insigniaPeriodId}`, @@ -18,8 +18,8 @@ export default { insigniaManage: (type: string) => `${insignia}/manage/${type}`, insigniaCreate: () => `${insignia}/request`, insigniaList: (insigniaPeriodId: any, ocId: string, role: string, status: any) => `${insignia}/request/${insigniaPeriodId}/${ocId}/${role}/${status}`, - insigniaReject: (profileId: string) => `${insignia}/status/reject/${profileId}`, - insigniaDelete: (profileId: string) => `${insignia}/status/delete/${profileId}`, + insigniaReject: (profileId: string) => `${insignia}/request/status/reject/${profileId}`, + insigniaDelete: (profileId: string) => `${insignia}/request/status/delete/${profileId}`, insigniaEdit: (profileId: string) => `${insignia}/request/${profileId}`, insigniaAgency: () => `${insignia}/request/agency`, insigniaDashboard: (insigniaPeriodId: string) => `${insignia}/request/dashboard/${insigniaPeriodId}`, diff --git a/src/modules/07_insignia/components/2_Manage/Tab1.vue b/src/modules/07_insignia/components/2_Manage/Tab1.vue index 418e6ea82..d8dad1344 100644 --- a/src/modules/07_insignia/components/2_Manage/Tab1.vue +++ b/src/modules/07_insignia/components/2_Manage/Tab1.vue @@ -31,7 +31,6 @@ const visibleColumns = ref([ "position", "level", "salary", - "organization", "insigniaType", "insigniaSend", "insigniaLevel", @@ -93,15 +92,7 @@ const columns = ref([ headerStyle: "font-size: 14px", style: "font-size: 14px", }, - { - name: "organization", - align: "left", - label: "หน่วยงาน", - sortable: true, - field: "organization", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, + { name: "insigniaType", align: "left", @@ -139,61 +130,6 @@ const columns = ref([ style: "font-size: 14px", }, ]); -// ข้อมูลตาราง (จำลอง) -const rows = ref([ - { - no: "1", - citizenId: "1xxxxxxxxxx", - name: "นายใจดี ยอดใจ ", - position: "นักวิชาการพัสดุ", - level: "1", - salary: "15000", - organization: "บริหาร", - insigniaType: "ทวีติยาภรณ์ช้างเผือก", - insigniaSend: "ตริตาภรณ์ช้างเผือก", - insigniaLevel: "ต่ำกว่าสายสะพาย", - dateSend: "31 ม.ค. 2566", - }, - { - no: "2", - citizenId: "1xxxxxxxxxx", - name: "นายจักกริน บัณฑิต", - position: "นักวิชาการพัสดุ", - level: "ปฏิบัติการ", - salary: "15000", - organization: "บริหาร", - insigniaType: "ทวีติยาภรณ์ช้างเผือก", - insigniaSend: "ตริตาภรณ์ช้างเผือก", - insigniaLevel: "ต่ำกว่าสายสะพาย", - dateSend: "31 ม.ค. 2566", - }, - { - no: "3", - citizenId: "1xxxxxxxxxx", - name: "นางสาวกัณฐิมา กาฬสินธุ์", - position: "นักจัดการงานทั่วไป", - level: "ปฏิบัติการ", - salary: "15000", - organization: "บริหาร", - insigniaType: "ทวีติยาภรณ์ช้างเผือก", - insigniaSend: "ตริตาภรณ์ช้างเผือก", - insigniaLevel: "ต่ำกว่าสายสะพาย", - dateSend: "31 ม.ค. 2566", - }, - { - no: "4", - citizenId: "1xxxxxxxxxx", - name: "นางสาวเมขลา กระจ่างมนตรี", - position: "นักจัดการงานทั่วไป", - level: "ปฏิบัติการ", - salary: "15000", - organization: "บริหาร", - insigniaType: "ทวีติยาภรณ์ช้างเผือก", - insigniaSend: "ตริตาภรณ์ช้างเผือก", - insigniaLevel: "ต่ำกว่าสายสะพาย", - dateSend: "31 ม.ค. 2566", - }, -]); const columns2 = ref([ { @@ -232,7 +168,7 @@ const columns2 = ref([ align: "left", }, ]); -// ข้อมูลตาราง (จำลอง) + const rows2 = ref([]); const Note = ref(""); @@ -254,12 +190,11 @@ const props = defineProps({ type: Function, }, }); -const typeinsignia = ref("all"); -const typeinsigniaOptions = reactive([{ id: "all", name: "ทั้งหมด" }]); -const typeinsigniaValues: Set = new Set(); + onMounted(async () => { organizationOptions.value = DataStore.optionsTypeOc; - organization.value = organizationOptions.value[0].id; + organization.value = organizationOptions.value[2].id; + DataStore.typeOc = organization.value; // if (props.fecthInsigniaAll) { // await props.fecthInsigniaAll(props.roundId, props.tab); // } @@ -271,7 +206,6 @@ onMounted(async () => { "officer", props.tab ); - filtertypeInsignia(); } } }); @@ -345,7 +279,7 @@ const clickAdd = async (id: string) => { dialogConfirm( $q, async () => { - addlistperson(id); + await addlistperson(id); }, "ยืนยันการเพิ่มรายชื่อขอพระราชทานเครื่องราชฯ", "ต้องการยืนยันการเพิ่มรายชื่อขอพระราชทานเครื่องราชฯ นี้หรือไม่ ?" @@ -389,7 +323,11 @@ const addlistperson = async (id: string) => { // actionModal.value = action; // modalNote.value = true; // }; -const clickmodalEdit = () => { +const clickmodalEdit = (props: any) => { + insignia.value = ""; + insigniaType.value = ""; + person.value = props; + console.log(person.value); modalEdit.value = true; fecthInsignia(); fecthInsigniaType(); @@ -398,62 +336,95 @@ const clickSave = () => { dialogConfirm( $q, async () => { - await listEdit(); + await listEdit(person.value.id); }, "ยืนยันการแก้ไขเครื่องราชฯ ที่ยื่นขอ", "ต้องการยืนยันการแก้ไขเครื่องราชฯ ที่ยื่นขอนี้หรือไม่ ?" ); }; -const listEdit = async () => { - let data = { insigniaId: organization.value }; - console.log(data); +const listEdit = async (profileId: string) => { + let data: any = { + insigniaId: insignia.value, + insigniaTypeId: insigniaType.value, + }; await http - .get(config.API.insigniaEdit(), data) + .put(config.API.insigniaEdit(profileId), data) .then(() => { success($q, "แก้ไขเครื่องราชฯ ที่ยื่นขอสำเร็จ"); }) .catch((err) => { messageError($q, err); + }) + .finally(async () => { + modalEdit.value = false; + if (props.fecthInsigniaByOc) { + await props.fecthInsigniaByOc( + props.roundId, + organization.value, + "officer", + props.tab + ); + } }); }; -const clickReject = () => { +const clickReject = (profileId: string) => { dialogConfirm( $q, async () => { - await listreject(); + await listreject(profileId); }, "ยืนยันการย้ายข้อมูล", "ต้องการยืนยันการย้ายข้อมูลนี้หรือไม่ ?" ); }; -const listreject = async () => { +const listreject = async (profileId: string) => { await http - .get(config.API.insigniaReject()) + .get(config.API.insigniaReject(profileId)) .then(() => { success($q, "ย้ายข้อมูลสำเร็จ"); }) .catch((err) => { messageError($q, err); + }) + .finally(async () => { + if (props.fecthInsigniaByOc) { + await props.fecthInsigniaByOc( + props.roundId, + organization.value, + "officer", + props.tab + ); + } }); }; -const clickDelete = () => { +const clickDelete = (profileId: string) => { dialogRemove( $q, async () => { - await listdelete(); + await listdelete(profileId); }, "ยืนยันการลบออกข้ออมูล", "ต้องการยืนยันการลบข้อมูลนี้หรือไม่ ?" ); }; -const listdelete = async () => { +const listdelete = async (profileId: string) => { await http - .get(config.API.insigniaDelete()) + .get(config.API.insigniaDelete(profileId)) .then(() => { success($q, "ลบข้อมูลสำเร็จ"); }) .catch((err) => { messageError($q, err); + }) + .finally(async () => { + if (props.fecthInsigniaByOc) { + await props.fecthInsigniaByOc( + props.roundId, + organization.value, + "officer", + props.tab + ); + } }); }; const insignia = ref(""); @@ -477,32 +448,6 @@ const fecthInsigniaType = async () => { .catch((err) => {}); }; -const listinsignia = ref([]); -const filtertypeInsignia = async () => { - listinsignia.value = rows.value; - for (const data of listinsignia.value) { - const Type = data.insigniaType; - if (Type !== null && !typeinsigniaValues.has(Type)) { - typeinsigniaOptions.push({ - id: Type.toString(), - name: Type.toString(), - }); - typeinsigniaValues.add(Type); - } - } -}; -const searchFilterTable = async () => { - if (typeinsignia.value !== undefined && typeinsignia.value !== null) { - if (typeinsignia.value === "all") { - rows.value = listinsignia.value; - } else { - rows.value = listinsignia.value.filter( - (e) => e.insigniaType === typeinsignia.value - ); - } - } -}; - const filterKeyword = ref(""); const filterKeyword2 = ref(""); const filterRef = ref(null); @@ -538,6 +483,7 @@ const paginationLabel2 = (start: string, end: string, total: string) => {
+ { @update:model-value="changtypeOc" /> { :outlined="true" :hide-dropdown-icon="false" style="min-width: 150px" - @update:model-value="searchFilterTable" + @update:model-value="DataStore.searchFilterTable" />
@@ -632,7 +578,7 @@ const paginationLabel2 = (start: string, end: string, total: string) => { { {{ props.row.salary }} - - {{ props.row.organization }} - + {{ props.row.insigniaType }} @@ -718,7 +662,7 @@ const paginationLabel2 = (start: string, end: string, total: string) => { { { /> -
-
- -
{ :outlined="true" :hide-dropdown-icon="false" style="min-width: 150px" - @update:model-value="changtypeOc" + /> +
+
+
diff --git a/src/modules/07_insignia/components/2_Manage/Tab2.vue b/src/modules/07_insignia/components/2_Manage/Tab2.vue index 9bec42a41..f3a5127e8 100644 --- a/src/modules/07_insignia/components/2_Manage/Tab2.vue +++ b/src/modules/07_insignia/components/2_Manage/Tab2.vue @@ -31,7 +31,7 @@ const visibleColumns = ref([ "position", "level", "salary", - "organization", + "insigniaType", "insigniaSend", "insigniaLevel", @@ -92,15 +92,6 @@ const columns = ref([ headerStyle: "font-size: 14px", style: "font-size: 14px", }, - { - name: "organization", - align: "left", - label: "หน่วยงาน", - sortable: true, - field: "organization", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, { name: "insigniaType", align: "left", @@ -139,63 +130,11 @@ const columns = ref([ }, ]); // ข้อมูลตาราง (จำลอง) -const rows = ref([ - { - no: "1", - citizenId: "1xxxxxxxxxx", - name: "นายใจดี ยอดใจ ", - position: "นักวิชาการพัสดุ", - level: "1", - salary: "15000", - organization: "บริหาร", - insigniaType: "ทวีติยาภรณ์ช้างเผือก", - insigniaSend: "ตริตาภรณ์ช้างเผือก", - insigniaLevel: "ต่ำกว่าสายสะพาย", - dateSend: "31 ม.ค. 2566", - }, - { - no: "2", - citizenId: "1xxxxxxxxxx", - name: "นายจักกริน บัณฑิต", - position: "นักวิชาการพัสดุ", - level: "ปฏิบัติการ", - salary: "15000", - organization: "บริหาร", - insigniaType: "ทวีติยาภรณ์ช้างเผือก", - insigniaSend: "ตริตาภรณ์ช้างเผือก", - insigniaLevel: "ต่ำกว่าสายสะพาย", - dateSend: "31 ม.ค. 2566", - }, - { - no: "3", - citizenId: "1xxxxxxxxxx", - name: "นางสาวกัณฐิมา กาฬสินธุ์", - position: "นักจัดการงานทั่วไป", - level: "ปฏิบัติการ", - salary: "15000", - organization: "บริหาร", - insigniaType: "ทวีติยาภรณ์ช้างเผือก", - insigniaSend: "ตริตาภรณ์ช้างเผือก", - insigniaLevel: "ต่ำกว่าสายสะพาย", - dateSend: "31 ม.ค. 2566", - }, - { - no: "4", - citizenId: "1xxxxxxxxxx", - name: "นางสาวเมขลา กระจ่างมนตรี", - position: "นักจัดการงานทั่วไป", - level: "ปฏิบัติการ", - salary: "15000", - organization: "บริหาร", - insigniaType: "ทวีติยาภรณ์ช้างเผือก", - insigniaSend: "ตริตาภรณ์ช้างเผือก", - insigniaLevel: "ต่ำกว่าสายสะพาย", - dateSend: "31 ม.ค. 2566", - }, -]); + onMounted(async () => { organizationOptions.value = DataStore.optionsTypeOc; organization.value = organizationOptions.value[0].id; + DataStore.typeOc = organization.value; // if (props.fecthInsigniaAll) { // await props.fecthInsigniaAll(props.roundId, props.tab); // } @@ -207,7 +146,6 @@ onMounted(async () => { "officer", props.tab ); - filtertypeInsignia(); } } }); @@ -222,35 +160,6 @@ const changtypeOc = () => { } }; -const typeinsignia = ref("all"); -const typeinsigniaOptions = reactive([{ id: "all", name: "ทั้งหมด" }]); -const typeinsigniaValues: Set = new Set(); -const listinsignia = ref([]); -const filtertypeInsignia = async () => { - listinsignia.value = rows.value; - for (const data of listinsignia.value) { - const Type = data.insigniaType; - if (Type !== null && !typeinsigniaValues.has(Type)) { - typeinsigniaOptions.push({ - id: Type.toString(), - name: Type.toString(), - }); - typeinsigniaValues.add(Type); - } - } -}; -const searchFilterTable = async () => { - if (typeinsignia.value !== undefined && typeinsignia.value !== null) { - if (typeinsignia.value === "all") { - rows.value = listinsignia.value; - } else { - rows.value = listinsignia.value.filter( - (e) => e.insigniaType === typeinsignia.value - ); - } - } -}; - const filterKeyword = ref(""); const filterRef = ref(null); const resetFilter = () => { @@ -272,6 +181,7 @@ const paginationLabel = (start: string, end: string, total: string) => {