Merge branch 'develop' into devTee

This commit is contained in:
setthawutttty 2024-12-24 10:13:07 +07:00
commit 33397332ff
3 changed files with 204 additions and 39 deletions

View file

@ -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() {
</div>
</q-timeline-entry>
<!-- เชอมตอและใส PIN -->
<!-- ขอขอม 9080 -->
<q-timeline-entry
title="เชื่อมต่อและใส่ PIN"
title="ตรวจสอบข้อมูล"
:icon="
store.step === 3
? 'mdi-pencil'
@ -170,6 +177,29 @@ function onClose() {
:color="store.step < 3 ? 'grey-4' : ''"
>
<div class="row" v-if="store.step === 3">
<div class="q-col-gutter-sm">
<q-btn
color="primary"
label="ดำเนินการต่อ"
@click="amiRequest"
/>
</div>
</div>
</q-timeline-entry>
<!-- เชอมตอและใส PIN -->
<q-timeline-entry
title="เชื่อมต่อและใส่ PIN"
:icon="
store.step === 4
? 'mdi-pencil'
: store.step > 4
? 'done'
: 'mdi-numeric-4'
"
:color="store.step < 4 ? 'grey-4' : ''"
>
<div class="row" v-if="store.step === 4">
<q-btn
color="primary"
label="ดำเนินการต่อ"

View file

@ -59,8 +59,11 @@ const qeditor = ref<string>("");
const title = ref<string>("");
const filter = ref<string>(""); //search data table
const filterAgency = ref<string>(""); //search data table
const provinceOptionsMain = ref<DataOption[]>([]);
const provinceOptions = ref<DataOption[]>([]);
const districtOptionsMain = ref<DataOption[]>([]);
const districtOptions = ref<DataOption[]>([]);
const subdistrictOptionsMain = ref<zipCodeOption[]>([]);
const subdistrictOptions = ref<zipCodeOption[]>([]);
const cmsGoverment = ref<CmsTable[]>([]);
const cmsAgency = ref<CmsTable[]>([]);
@ -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'
)"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-italic text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-select
@ -1037,8 +1084,22 @@ onMounted(async () => {
: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'
)"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-italic text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-select
@ -1056,9 +1117,23 @@ onMounted(async () => {
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'
)"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-italic text-grey">
ไมอม
</q-item-section>
</q-item>
</template></q-select
>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-input

View file

@ -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<string>("http://127.0.0.1:51548"); // API URL From Agent
@ -18,8 +18,10 @@ 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) {
console.log("[0] START fetchDeviceLists");
await fetch(`${apiURL.value}/smart-card/device`, {
method: "GET",
})
.then((response) => {
@ -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;
@ -41,18 +45,24 @@ 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) {
console.log("[1] อ่านบัตร");
await fetch(
`${apiURL.value}/smart-card/connect/?deviceName=${devices.value}`,
{
method: "GET",
}
)
.then((response) => {
if (response.ok) {
return response.json();
}
throw new Error("Something went wrong");
})
.then(async (data) => {
return;
.then((data) => {
console.log("readDevice===>", data);
getInfo(q);
})
.catch((error) => {
messageError(q, error);
@ -63,7 +73,9 @@ export const useLinkageStore = defineStore("linkageData", () => {
* @param {any} q this quasar
*/
async function getInfo(q: any) {
fetch(`${apiURL.value}/smart-card/info`, {
console.log("START getInfo");
await fetch(`${apiURL.value}/smart-card/info`, {
method: "GET",
})
.then(function (response) {
@ -73,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);
@ -86,7 +102,9 @@ export const useLinkageStore = defineStore("linkageData", () => {
* @param {any} q this quasar
*/
async function postReadIdCard(q: any) {
fetch(`${apiURL.value}/smart-card/read/`, {
console.log("START postReadIdCard");
await fetch(`${apiURL.value}/smart-card/read/`, {
method: "POST",
body: JSON.stringify({
fields: ["personalID", "engName", "expireDate"],
@ -102,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);
@ -113,8 +134,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",
@ -143,8 +164,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) => {
@ -166,8 +187,9 @@ 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) {
console.log("[4] START authentication");
await fetch(`${apiURL.value}/smart-card/authentication`, {
method: "GET",
})
.then((response) => {
@ -190,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({
@ -202,7 +226,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();
@ -210,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) => {
@ -236,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`, {
@ -267,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;
@ -277,12 +337,12 @@ export const useLinkageStore = defineStore("linkageData", () => {
})
.catch(async (error) => {
messageError(q, error);
hideLoader()
hideLoader();
});
}
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) => {