แก้บัค

This commit is contained in:
AnandaTon 2023-07-27 14:07:53 +07:00
parent fde551b674
commit 6a048c23d9
3 changed files with 129 additions and 223 deletions

View file

@ -19,21 +19,23 @@
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
v-model="informaData.cardid"
dense
@update:model-value="changeCardID"
lazy-rules
:rules="[
(val:string) => !!val || `${'กรุณากรอก เลขบัตรประจำตัวประชาชน'}`,
(val:string) =>
val.length >= 13 ||
`${'กรุณากรอกเลขบัตรประจำตัวประชาชนให้ครบ'}`,
]"
:readonly="!edit"
:borderless="!edit"
@update:model-value="changeCardID"
:rules="[
(val:string) => !!val || `${'กรุณากรอก เลขบัตรประจำตัวประชาชน'}`,
(val:string) =>
val.length >= 13 ||
`${'กรุณากรอกเลขบัตรประจำตัวประชาชนให้ครบ'}`,
]"
label="เลขบัตรประจำตัวประชาชน"
maxlength="13"
mask="#############"
/>
<!-- :rules="[(val:any) =>val.length != 13 ||`${'กรุณากรอกเลขบัตรประจำตัวประชาชนให้ครบ'}`,]" -->
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
@ -378,7 +380,7 @@
class="q-px-md items-center"
color="light-blue-10"
label="บันทึก"
@click="saveData"
@click="saveData, router.go(-1)"
/>
</div>
<q-separator />
@ -433,7 +435,7 @@ const { loaderPage } = dataStore;
const profileStore = useProfileDataStore();
const { changeRetireText, changeBirth } = profileStore;
const edit = ref<boolean>(false);
const defaultCitizenData = ref<string | null>("");
const defaultCitizenData = ref<string>("");
const informaData = ref<Information>(defaultInformation);
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const tittleHistory = ref<string>("ประวัติแก้ไขข้อมูลส่วนตัว"); //
@ -673,7 +675,6 @@ const visibleColumnsHistory = ref<String[]>([
onMounted(async () => {
await fetchPerson();
await fetchData();
emit("update:statusEdit", false);
defaultAdd();
});
@ -681,28 +682,28 @@ onMounted(async () => {
const statusAdd = () => props.statusAdd;
const defaultAdd = () => {
if (props.statusAdd) {
edit.value = props.statusAdd;
informaData.value = {
cardid: null,
age: null,
prefix: null,
prefixId: null,
firstname: null,
lastname: null,
birthDate: new Date(),
genderId: null,
bloodId: null,
nationality: null,
ethnicity: null,
statusId: null,
religionId: null,
tel: null,
employeeType: null,
employeeClass: null,
profileType: null,
};
}
// if (props.statusAdd) {
edit.value = props.statusAdd;
informaData.value = {
cardid: null,
age: null,
prefix: null,
prefixId: null,
firstname: null,
lastname: null,
birthDate: new Date(),
genderId: null,
bloodId: null,
nationality: null,
ethnicity: null,
statusId: null,
religionId: null,
tel: null,
employeeType: null,
employeeClass: null,
profileType: null,
};
// }
};
const onCancel = async () => {
@ -777,18 +778,17 @@ const fetchPerson = async () => {
});
};
const changeCardID = (value: string | number | null) => {
const changeCardID = async (value: string | number | null) => {
if (value != null && typeof value == "string") {
if (value.length == 13 && value != defaultCitizenData.value) {
async () => {
await checkCitizen(value);
informaData.value.cardid = defaultCitizenData.value;
};
await checkCitizen(value);
// informaData.value.cardid = defaultCitizenData.value;
}
}
};
const checkCitizen = async (id: string) => {
console.log("String");
loaderPage(true);
await http
.get(config.API.profileCitizenId(id))
@ -968,7 +968,7 @@ const fetchData = async () => {
.get(config.API.profileInforId(route.params.id.toString()))
.then(async (res: any) => {
const data: ResponseObject = res.data.result;
defaultCitizenData.value = data.citizenId;
defaultCitizenData.value = data.citizenId == null ? "" : data.citizenId;
informaData.value.cardid = data.citizenId;
informaData.value.prefix = "";
informaData.value.prefixId = data.prefixId;
@ -1088,14 +1088,11 @@ const addData = async () => {
};
const saveData = async () => {
console.log(myform.value);
if (myform.value != null) {
await myform.value.validate().then(async (success: boolean) => {
if (success) {
if (props.statusAdd) {
await addData();
} else {
await editData();
}
await myform.value.validate().then(async (saveDataTest: Boolean) => {
if (saveDataTest) {
await addData();
}
});
}