From 97b07f9e381b0767df49504bed0b9746512cd853 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Mon, 23 Dec 2024 15:01:32 +0700 Subject: [PATCH 1/5] updated --- src/stores/linkage.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/stores/linkage.ts b/src/stores/linkage.ts index 930a045ec..a3c701c1e 100644 --- a/src/stores/linkage.ts +++ b/src/stores/linkage.ts @@ -2,7 +2,7 @@ import { ref } from "vue"; import { defineStore } from "pinia"; import { useCounterMixin } from "./mixin"; -const { messageError, success,hideLoader } = useCounterMixin(); +const { messageError, success, hideLoader } = useCounterMixin(); export const useLinkageStore = defineStore("linkageData", () => { const apiURL = ref("http://127.0.0.1:51548"); // API URL From Agent @@ -89,7 +89,16 @@ export const useLinkageStore = defineStore("linkageData", () => { fetch(`${apiURL.value}/smart-card/read/`, { method: "POST", body: JSON.stringify({ - fields: ["personalID", "engName", "expireDate"], + fields: [ + "personalID", + "thaiName", + "engName", + "dateOfBirth", + "addressOnCard", + "faceImage", + "issueDate", + "expireDate", + ], }), headers: { "Content-Type": "application/json", @@ -277,7 +286,7 @@ export const useLinkageStore = defineStore("linkageData", () => { }) .catch(async (error) => { messageError(q, error); - hideLoader() + hideLoader(); }); } From 79453457d1158c823df80b90f0c5a39b95bf033a Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Mon, 23 Dec 2024 15:25:28 +0700 Subject: [PATCH 2/5] updated --- src/stores/linkage.ts | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/stores/linkage.ts b/src/stores/linkage.ts index a3c701c1e..adab103c6 100644 --- a/src/stores/linkage.ts +++ b/src/stores/linkage.ts @@ -18,8 +18,8 @@ export const useLinkageStore = defineStore("linkageData", () => { /** ยิง API เพื่อดึงรายการข้อมูลเครื่องอ่านบัตร * @param {any} q ค่า this ของ quasar */ - function fetchDeviceLists(q: any) { - fetch(`${apiURL.value}/smart-card/device`, { + async function fetchDeviceLists(q: any) { + await fetch(`${apiURL.value}/smart-card/device`, { method: "GET", }) .then((response) => { @@ -41,10 +41,13 @@ export const useLinkageStore = defineStore("linkageData", () => { /** connect device ที่เลือก * @param {any} q ค่า this ของ quasar */ - function readDevice(q: any) { - fetch(`${apiURL.value}/smart-card/connect/?deviceName=${devices.value}`, { - method: "GET", - }) + async function readDevice(q: any) { + await fetch( + `${apiURL.value}/smart-card/connect/?deviceName=${devices.value}`, + { + method: "GET", + } + ) .then((response) => { if (response.ok) { return response.json(); @@ -63,7 +66,7 @@ export const useLinkageStore = defineStore("linkageData", () => { * @param {any} q ค่า this ของ quasar */ async function getInfo(q: any) { - fetch(`${apiURL.value}/smart-card/info`, { + await fetch(`${apiURL.value}/smart-card/info`, { method: "GET", }) .then(function (response) { @@ -86,7 +89,7 @@ export const useLinkageStore = defineStore("linkageData", () => { * @param {any} q ค่า this ของ quasar */ async function postReadIdCard(q: any) { - fetch(`${apiURL.value}/smart-card/read/`, { + await fetch(`${apiURL.value}/smart-card/read/`, { method: "POST", body: JSON.stringify({ fields: [ @@ -122,8 +125,8 @@ export const useLinkageStore = defineStore("linkageData", () => { /** setting ami environment * @param {any} q ค่า this ของ quasar */ - function amiEnvironment(q: any) { - fetch(`${apiURL.value}/ami/environment`, { + async function amiEnvironment(q: any) { + await fetch(`${apiURL.value}/ami/environment`, { method: "POST", body: JSON.stringify({ host: "lkbmabk.bma.go.th", @@ -152,8 +155,8 @@ export const useLinkageStore = defineStore("linkageData", () => { * connect ami * @param q ค่า this ของ quasar */ - function amiConnect(q: any) { - fetch(`${apiURL.value}/ami/connect`, { + async function amiConnect(q: any) { + await fetch(`${apiURL.value}/ami/connect`, { method: "GET", }) .then((response) => { @@ -175,8 +178,8 @@ export const useLinkageStore = defineStore("linkageData", () => { * card authentication * @param q ค่า this ของ quasar */ - function authentication(q: any) { - fetch(`${apiURL.value}/smart-card/authentication`, { + async function authentication(q: any) { + await fetch(`${apiURL.value}/smart-card/authentication`, { method: "GET", }) .then((response) => { @@ -211,7 +214,7 @@ export const useLinkageStore = defineStore("linkageData", () => { "Content-Type": "application/json", }, }; - fetch(`${apiURL.value}/smart-card/verify`, requestOptions) + await fetch(`${apiURL.value}/smart-card/verify`, requestOptions) .then((response) => { if (response.ok) { return response.json(); @@ -290,8 +293,8 @@ export const useLinkageStore = defineStore("linkageData", () => { }); } - function disconnect(q: any) { - fetch(`${apiURL.value}/smart-card/disconnect`, { + async function disconnect(q: any) { + await fetch(`${apiURL.value}/smart-card/disconnect`, { method: "GET", }) .then((response) => { From b0adc9307d1e192ccbc17c75204c044da48e92b9 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 23 Dec 2024 17:07:17 +0700 Subject: [PATCH 3/5] =?UTF-8?q?fix=20=E0=B8=95=E0=B8=B1=E0=B9=89=E0=B8=87?= =?UTF-8?q?=E0=B8=84=E0=B9=88=E0=B8=B2=E0=B9=80=E0=B8=A7=E0=B9=87=E0=B8=9A?= =?UTF-8?q?=E0=B9=84=E0=B8=8B=E0=B8=95=E0=B9=8C=E0=B8=A3=E0=B8=B0=E0=B8=9A?= =?UTF-8?q?=E0=B8=9A=E0=B8=AA=E0=B8=A3=E0=B8=A3=E0=B8=AB=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../03_recruiting/views/03_editor/index.vue | 89 +++++++++++++++++-- 1 file changed, 82 insertions(+), 7 deletions(-) diff --git a/src/modules/03_recruiting/views/03_editor/index.vue b/src/modules/03_recruiting/views/03_editor/index.vue index 861574658..bfe9a11b6 100644 --- a/src/modules/03_recruiting/views/03_editor/index.vue +++ b/src/modules/03_recruiting/views/03_editor/index.vue @@ -59,8 +59,11 @@ const qeditor = ref(""); const title = ref(""); const filter = ref(""); //search data table const filterAgency = ref(""); //search data table +const provinceOptionsMain = ref([]); const provinceOptions = ref([]); +const districtOptionsMain = ref([]); const districtOptions = ref([]); +const subdistrictOptionsMain = ref([]); const subdistrictOptions = ref([]); const cmsGoverment = ref([]); const cmsAgency = ref([]); @@ -570,6 +573,7 @@ async function fetchProvince() { option.push({ id: r.id.toString(), name: r.name.toString() }); }); provinceOptions.value = option; + provinceOptionsMain.value = option; }) .catch((e: any) => { messageError($q, e); @@ -595,6 +599,7 @@ async function fetchDistrict(id: string | null) { option.push({ id: r.id.toString(), name: r.name.toString() }); }); districtOptions.value = option; + districtOptionsMain.value = option; }) .catch((e: any) => { messageError($q, e); @@ -625,6 +630,7 @@ async function fetchSubDistrict(id: string | null) { }); }); subdistrictOptions.value = option; + subdistrictOptionsMain.value = option; }) .catch((e: any) => { messageError($q, e); @@ -737,6 +743,33 @@ function getClass(val: boolean) { }; } +function filterSelector(val: string, update: Function, refData: string) { + switch (refData) { + case "province": + update(() => { + provinceOptions.value = provinceOptionsMain.value.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + case "district": + update(() => { + districtOptions.value = districtOptionsMain.value.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + case "subdistrict": + update(() => { + subdistrictOptions.value = subdistrictOptionsMain.value.filter( + (v: zipCodeOption) => v.name.indexOf(val) > -1 + ); + }); + default: + break; + } +} + onMounted(async () => { await fetchData(); await fetchProvince(); @@ -1017,8 +1050,22 @@ onMounted(async () => { :options="provinceOptions" option-value="id" :label="`${'จังหวัด'}`" - @update:model-value="(value:any) => selectProvince(value)" - /> + use-input + hide-selected + fill-input + @update:model-value="(value:string) => selectProvince(value)" + @filter="(inputValue: string, + doneFn: Function) => filterSelector(inputValue, doneFn, 'province' + )" + > + +
{ :options="districtOptions" option-value="id" :label="`${'เขต / อำเภอ'}`" - @update:model-value="(value:any) => selectDistrict(value)" - /> + use-input + hide-selected + fill-input + @update:model-value="(value:string) => selectDistrict(value)" + @filter="(inputValue: string, + doneFn: Function) => filterSelector(inputValue, doneFn, 'district' + )" + > + +
{ option-label="name" :options="subdistrictOptions" option-value="id" - :label="`${'แขวง/ตำบล '}`" - @update:model-value="(value:any) => selectSubDistrict(value)" - /> + :label="`${'แขวง/ตำบล'}`" + use-input + hide-selected + fill-input + @update:model-value="(value:string) => selectSubDistrict(value)" + @filter="(inputValue: string, + doneFn: Function) => filterSelector(inputValue, doneFn, 'subdistrict' + )" + > +
Date: Mon, 23 Dec 2024 20:32:57 +0700 Subject: [PATCH 4/5] updated --- src/stores/linkage.ts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/stores/linkage.ts b/src/stores/linkage.ts index adab103c6..6223740c8 100644 --- a/src/stores/linkage.ts +++ b/src/stores/linkage.ts @@ -92,16 +92,7 @@ export const useLinkageStore = defineStore("linkageData", () => { await fetch(`${apiURL.value}/smart-card/read/`, { method: "POST", body: JSON.stringify({ - fields: [ - "personalID", - "thaiName", - "engName", - "dateOfBirth", - "addressOnCard", - "faceImage", - "issueDate", - "expireDate", - ], + fields: ["personalID", "engName", "expireDate"], }), headers: { "Content-Type": "application/json", From b4efa1204f6b1fd84706e68a4d03e75045fd3156 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Tue, 24 Dec 2024 00:01:38 +0700 Subject: [PATCH 5/5] tested linkage add step --- src/components/LoginLinkage.vue | 42 ++++++++++++++++--- src/stores/linkage.ts | 71 +++++++++++++++++++++++++++++---- 2 files changed, 100 insertions(+), 13 deletions(-) diff --git a/src/components/LoginLinkage.vue b/src/components/LoginLinkage.vue index 0decc70f6..56cf1b10f 100644 --- a/src/components/LoginLinkage.vue +++ b/src/components/LoginLinkage.vue @@ -23,14 +23,21 @@ async function fetchDeviceLists() { async function readDevice() { showLoader(); await store.readDevice($q); - await store.getInfo($q); // ดึงข้อมูล CID - await store.postReadIdCard($q); // ดึงข้อมูล id card จากเครื่องอ่านบัตร - await store.amiEnvironment($q); - await store.amiConnect($q); + // await store.getInfo($q); // ดึงข้อมูล CID + // await store.postReadIdCard($q); // ดึงข้อมูล id card จากเครื่องอ่านบัตร + // await store.amiEnvironment($q); + // await store.amiConnect($q); + hideLoader(); +} + +// 3. ขอข้อมูล x-Key (9080) +async function amiRequest() { + showLoader(); await store.amiRequest($q, 9080); hideLoader(); } +// 4. เชื่อมต่อและใส่ PIN async function verifyPin() { showLoader(); await store.authentication($q); @@ -157,9 +164,9 @@ function onClose() {
- +
+
+ +
+
+
+ + + +
{ * @param {any} q ค่า this ของ quasar */ async function fetchDeviceLists(q: any) { + console.log("[0] START fetchDeviceLists"); + await fetch(`${apiURL.value}/smart-card/device`, { method: "GET", }) @@ -29,6 +31,8 @@ export const useLinkageStore = defineStore("linkageData", () => { throw new Error("Something went wrong"); }) .then(async (data) => { + console.log("fetchDeviceLists===>", data); + devicesOp.value = await data.devices; devicesData.value = await data.devices; step.value = 2; @@ -42,6 +46,8 @@ export const useLinkageStore = defineStore("linkageData", () => { * @param {any} q ค่า this ของ quasar */ async function readDevice(q: any) { + console.log("[1] อ่านบัตร"); + await fetch( `${apiURL.value}/smart-card/connect/?deviceName=${devices.value}`, { @@ -54,8 +60,9 @@ export const useLinkageStore = defineStore("linkageData", () => { } throw new Error("Something went wrong"); }) - .then(async (data) => { - return; + .then((data) => { + console.log("readDevice===>", data); + getInfo(q); }) .catch((error) => { messageError(q, error); @@ -66,6 +73,8 @@ export const useLinkageStore = defineStore("linkageData", () => { * @param {any} q ค่า this ของ quasar */ async function getInfo(q: any) { + console.log("START getInfo"); + await fetch(`${apiURL.value}/smart-card/info`, { method: "GET", }) @@ -76,8 +85,12 @@ export const useLinkageStore = defineStore("linkageData", () => { throw new Error("Something went wrong"); }) .then(async (data) => { + console.log("getInfo===>", data); CID.value = await data.cid; - return; + + console.log("cid===>", CID.value); + + postReadIdCard(q); }) .catch((error) => { messageError(q, error); @@ -89,6 +102,8 @@ export const useLinkageStore = defineStore("linkageData", () => { * @param {any} q ค่า this ของ quasar */ async function postReadIdCard(q: any) { + console.log("START postReadIdCard"); + await fetch(`${apiURL.value}/smart-card/read/`, { method: "POST", body: JSON.stringify({ @@ -105,8 +120,11 @@ export const useLinkageStore = defineStore("linkageData", () => { throw new Error("Something went wrong"); }) .then(async (data) => { + console.log("postReadIdCard===>", data); PID.value = await data.personalID; - return; + console.log("personalID===>", PID.value); + await amiEnvironment(q); + await amiConnect(q); }) .catch((error) => { messageError(q, error); @@ -170,6 +188,7 @@ export const useLinkageStore = defineStore("linkageData", () => { * @param q ค่า this ของ quasar */ async function authentication(q: any) { + console.log("[4] START authentication"); await fetch(`${apiURL.value}/smart-card/authentication`, { method: "GET", }) @@ -193,6 +212,8 @@ export const useLinkageStore = defineStore("linkageData", () => { * @param q ค่า this ของ quasar */ async function verifyPin(q: any) { + console.log("START verifyPin"); + const requestOptions = { method: "POST", body: JSON.stringify({ @@ -213,7 +234,12 @@ export const useLinkageStore = defineStore("linkageData", () => { throw new Error("Something went wrong"); }) .then(async (data) => { + console.log("verifyPin===>", data); + envelopGMXs.value = await data.crossAuthen.envelope; + + console.log("envelopGMXs===>", envelopGMXs.value); + await amiRequest(q, 9081); }) .catch((error) => { @@ -239,16 +265,41 @@ export const useLinkageStore = defineStore("linkageData", () => { serviceCode?: string ) { let message = ""; + console.log("code===>", code); + if (code === 9080) { + console.log("[3] START amiRequest"); + + console.log("PID===>", PID.value); + console.log("CID===>", CID.value); + console.log("officeid===>", officeid.value); + message = `${code}${PID.value}${CID.value}${officeid.value}`; + + console.log("message===>", message); } else if (code === 9081) { - const x = xKey.value; - const y = envelopGMXs.value; + const x = await xKey.value; + const y = await envelopGMXs.value; + console.log("PID===>", PID.value); + console.log("CID===>", CID.value); + console.log("x===>", x); + console.log("y===>", y); message = `${code}${PID.value}${CID.value}${x}${y}`; + + console.log("message===>", message); } else if (code === 5000) { - const T = tKey.value; + const T = await tKey.value; + + console.log("T===>", T); + console.log("officeCode===>", officeCode.value); + console.log("versionCode===>", versionCode.value); + console.log("serviceCode===>", serviceCode); + console.log("idcard===>", idcard); + message = `${code}${T}${officeCode.value}${versionCode.value}${serviceCode}${idcard}`; + + console.log("message===>", message); } await fetch(`${apiURL.value}/ami/request`, { @@ -270,9 +321,15 @@ export const useLinkageStore = defineStore("linkageData", () => { if (code === 9080) { xKey.value = await removeText; + + console.log("xKey===>", xKey.value); + step.value = 3; } else if (code === 9081) { tKey.value = removeText; + + console.log("tKey===>", tKey.value); + step.value = 4; } else if (code === 5000) { return removeText;