รวมไฟล์แก้งานงวด2

This commit is contained in:
Kittapath 2023-07-10 10:10:46 +07:00
parent 79889c9464
commit 2249097b07
89 changed files with 11287 additions and 7048 deletions

View file

@ -5,12 +5,11 @@
header="ข้อมูลที่อยู่"
icon="mdi-map-marker"
:save="saveData"
:history="!statusAdd()"
:history="true"
:changeBtn="changeBtn"
:disable="statusEdit"
:cancel="refreshData"
:historyClick="clickHistory"
:addEmployee="statusAdd()"
/>
<q-form ref="myform">
<div class="row col-12 items-center q-col-gutter-x-xs q-col-gutter-y-xs">
@ -312,10 +311,6 @@ const props = defineProps({
type: Boolean,
required: true,
},
statusAdd: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(["update:statusEdit"]);
@ -512,28 +507,8 @@ const visibleColumnsHistory = ref<String[]>([
onMounted(async () => {
await getNewData();
emit("update:statusEdit", false);
defaultAdd();
});
const statusAdd = () => props.statusAdd;
const defaultAdd = () => {
if (props.statusAdd) {
edit.value = props.statusAdd;
addressData.value = {
address: null,
provinceId: null,
districtId: null,
subdistrictId: null,
addressC: null,
provinceIdC: null,
districtIdC: null,
subdistrictIdC: null,
same: "0",
};
}
};
const filterSelector = (val: any, update: Function, refData: string) => {
switch (refData) {
case "provinceOps":
@ -581,39 +556,37 @@ const filterSelector = (val: any, update: Function, refData: string) => {
* งชนดอมลประวแกไขขอมลทเลอก
*/
const clickHistory = async () => {
if (route.params.id) {
modalHistory.value = true;
loaderPage(true);
await http
.get(config.API.profileAdrsHisId(route.params.id.toString()))
.then((res) => {
let data = res.data.result;
rowsHistory.value = [];
data.map((e: RequestItemsHistoryObject) => {
rowsHistory.value.push({
currentAddress: e.currentAddress,
currentDistrict: e.currentDistrict,
currentProvince: e.currentProvince,
currentSubDistrict: e.currentSubDistrict,
currentZipCode: e.currentZipCode,
registrationSame: e.registrationSame,
registrationAddress: e.registrationAddress,
registrationDistrict: e.registrationDistrict,
registrationProvince: e.registrationProvince,
registrationSubDistrict: e.registrationSubDistrict,
registrationZipCode: e.registrationZipCode,
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
modalHistory.value = true;
loaderPage(true);
await http
.get(config.API.profileAdrsHisId(route.params.id.toString()))
.then((res) => {
let data = res.data.result;
rowsHistory.value = [];
data.map((e: RequestItemsHistoryObject) => {
rowsHistory.value.push({
currentAddress: e.currentAddress,
currentDistrict: e.currentDistrict,
currentProvince: e.currentProvince,
currentSubDistrict: e.currentSubDistrict,
currentZipCode: e.currentZipCode,
registrationSame: e.registrationSame,
registrationAddress: e.registrationAddress,
registrationDistrict: e.registrationDistrict,
registrationProvince: e.registrationProvince,
registrationSubDistrict: e.registrationSubDistrict,
registrationZipCode: e.registrationZipCode,
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
};
const refreshData = async () => {
@ -633,29 +606,27 @@ const getNewData = async () => {
};
const fetchData = async () => {
if (route.params.id) {
loaderPage(true);
await http
.get(config.API.profileAdrsId(route.params.id.toString()))
.then((res) => {
const data: ResponseObject = res.data.result;
addressData.value.address = data.registrationAddress;
addressData.value.addressC = data.currentAddress;
addressData.value.districtId = data.registrationDistrictId;
addressData.value.districtIdC = data.currentDistrictId;
addressData.value.provinceId = data.registrationProvinceId;
addressData.value.provinceIdC = data.currentProvinceId;
addressData.value.subdistrictId = data.registrationSubDistrictId;
addressData.value.subdistrictIdC = data.currentSubDistrictId;
addressData.value.same = data.registrationSame ? "1" : "0";
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
}
loaderPage(true);
await http
.get(config.API.profileAdrsId(route.params.id.toString()))
.then((res) => {
const data: ResponseObject = res.data.result;
addressData.value.address = data.registrationAddress;
addressData.value.addressC = data.currentAddress;
addressData.value.districtId = data.registrationDistrictId;
addressData.value.districtIdC = data.currentDistrictId;
addressData.value.provinceId = data.registrationProvinceId;
addressData.value.provinceIdC = data.currentProvinceId;
addressData.value.subdistrictId = data.registrationSubDistrictId;
addressData.value.subdistrictIdC = data.currentSubDistrictId;
addressData.value.same = data.registrationSame ? "1" : "0";
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
};
const editData = async () => {
@ -705,34 +676,12 @@ const editData = async () => {
const saveData = async () => {
await myform.value.validate().then(async (success: boolean) => {
if (success) {
if (props.statusAdd) {
await addData();
} else {
await editData();
}
await editData();
} else {
}
});
};
const addData = async () => {
// loaderPage(true);
// await http
// .put(config.API.profileInforId(route.params.id.toString()), body)
// .then((res) => {
// success($q, "");
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// edit.value = false;
// emit("update:statusEdit", false);
// await fetchData();
// await changeBirth(informaData.value.birthDate ?? new Date());
// });
};
const selectProvince = async (e: string | null, name: string) => {
if (e != null) {
if (name == "1") {

View file

@ -285,10 +285,6 @@ const props = defineProps({
type: String,
required: true,
},
statusAdd: {
type: Boolean,
default: false,
},
});
const $q = useQuasar();
@ -320,9 +316,7 @@ const tittleHistory = ref<string>("ประวัติแก้ไขใบอ
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const checkValidate = ref<boolean>(false); //validate data
const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const profileId = ref<string>(route.params.id.toString());
const rows = ref<RequestItemsObject[]>([]);
const filter = ref<string>(""); //search data table
const visibleColumns = ref<String[]>([]);
@ -490,33 +484,31 @@ onMounted(async () => {
});
const fetchData = async () => {
if (profileId.value !== "") {
loaderPage(true);
await http
.get(config.API.profileCertId(profileId.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: ResponseObject) => {
rows.value.push({
id: e.id,
certificateNo: e.certificateNo,
issuer: e.issuer,
issueDate: new Date(e.issueDate),
expireDate: new Date(e.expireDate),
certificateType: e.certificateType,
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
loaderPage(true);
await http
.get(config.API.profileCertId(profileId.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: ResponseObject) => {
rows.value.push({
id: e.id,
certificateNo: e.certificateNo,
issuer: e.issuer,
issueDate: new Date(e.issueDate),
expireDate: new Date(e.expireDate),
certificateType: e.certificateType,
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
};
/**
@ -603,28 +595,26 @@ const clickSave = async () => {
* นทกเพมขอม
*/
const saveData = async () => {
if (profileId.value !== "") {
loaderPage(true);
await http
.post(config.API.profileCertId(profileId.value), {
id: id.value,
certificateNo: certificateNo.value,
issuer: issuer.value,
issueDate: dateToISO(issueDate.value),
expireDate: dateToISO(expireDate.value),
certificateType: certificateType.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
}
loaderPage(true);
await http
.post(config.API.profileCertId(profileId.value), {
id: id.value,
certificateNo: certificateNo.value,
issuer: issuer.value,
issueDate: dateToISO(issueDate.value),
expireDate: dateToISO(expireDate.value),
certificateType: certificateType.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**

View file

@ -5,24 +5,62 @@
header="ข้อมูลครอบครัว"
icon="mdi-account-group"
:save="saveData"
:history="!statusAdd()"
:history="true"
:changeBtn="changeBtn"
:disable="statusEdit"
:cancel="refreshData"
:historyClick="historyData"
:addEmployee="statusAdd()"
/>
<q-form ref="myform" class="col-12">
<div class="row col-12 items-center q-col-gutter-x-xs q-col-gutter-y-xs">
<div class="col-xs-12 text-weight-bold"> ดา</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<div class="col-12 row q-pb-sm q-pt-md">
<div class="col-xs-2 col-sm-1 text-weight-bold"> ดา</div>
<div class="q-gutter-sm">
<q-radio
v-model="familyData.liveM"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="1"
label="มีชีวิต"
dense
color="blue"
:disable="!edit"
/>
<q-radio
v-model="familyData.liveM"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="0"
color="red"
label="เสียชีวิต"
dense
:disable="!edit"
/>
</div>
</div>
<div class="col-xs-6 col-sm-2 col-md-2">
<q-input
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="familyData.citizenIdM"
:label="`${'เลขที่บัตรประชาชน'}`"
maxlength="13"
mask="#############"
/>
</div>
<div class="col-xs-12 col-sm-2 col-md-2">
<selector
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
:readonly="!edit"
:borderless="!edit"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
:outlined="edit"
dense
lazy-rules
@ -32,7 +70,7 @@
option-label="name"
:options="Ops.prefixOps"
option-value="id"
:label="`${'คำนำหน้า'}`"
:label="`${'คำนำหน้าชื่อ'}`"
use-input
input-debounce="0"
@filter="(inputValue:any,
@ -69,7 +107,7 @@
:label="`${'นามสกุล'}`"
/>
</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<div class="col-xs-12 col-sm-2 col-md-2">
<q-input
:class="getClass(edit)"
hide-bottom-space
@ -84,15 +122,54 @@
</div>
<div class="col-12 q-pt-md q-pb-sm"><q-separator /></div>
<div class="col-xs-12 text-weight-bold"> มารดา</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<div class="row col-12 q-py-sm">
<div class="col-xs-2 col-sm-1 text-weight-bold"> มารดา</div>
<div class="q-gutter-sm">
<q-radio
v-model="familyData.liveF"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="1"
label="มีชีวิต"
color="blue"
dense
:disable="!edit"
/>
<q-radio
v-model="familyData.liveF"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="0"
label="เสียชีวิต"
color="red"
dense
:disable="!edit"
/>
</div>
</div>
<div class="col-xs-6 col-sm-2 col-md-2">
<q-input
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="familyData.citizenIdF"
:label="`${'เลขที่บัตรประชาชน'}`"
maxlength="13"
mask="#############"
/>
</div>
<div class="col-xs-12 col-sm-2 col-md-2">
<selector
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
:readonly="!edit"
:borderless="!edit"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
:outlined="edit"
dense
lazy-rules
@ -102,7 +179,7 @@
option-label="name"
:options="Ops.prefixOps"
option-value="id"
:label="`${'คำนำหน้า'}`"
:label="`${'คำนำหน้าชื่อ'}`"
use-input
input-debounce="0"
@filter="(inputValue:any,
@ -139,7 +216,7 @@
:label="`${'นามสกุล'}`"
/>
</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<div class="col-xs-12 col-sm-2 col-md-2">
<q-input
:class="getClass(edit)"
hide-bottom-space
@ -153,27 +230,75 @@
/>
</div>
<div class="col-12 q-pt-md q-pb-sm"><q-separator /></div>
<div class="col-xs-12 q-col-gutter-x-sm items-center flex q-my-sm">
<label class="text-weight-bold"> สมรส</label>
<q-radio
v-model="familyData.same"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="1"
label="มี"
dense
:disable="!edit"
@update:model-value="selectRadio"
<div class="row col-12 q-py-sm">
<div class="col-xs-2 col-sm-1 text-weight-bold"> สมรส</div>
<div class="q-gutter-sm">
<q-radio
v-model="familyData.same"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="1"
label="มี"
dense
:disable="!edit"
@update:model-value="selectRadio"
/>
<q-radio
v-model="familyData.same"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="0"
label="ไม่มี"
color="grey-9"
dense
:disable="!edit"
@update:model-value="selectRadio"
/>
</div>
<q-separator
vertical
color="grey-4"
size="2px"
class="q-mx-md"
v-if="familyData.same == '1'"
/>
<q-radio
v-model="familyData.same"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="0"
label="ไม่มี"
<div class="q-gutter-sm" v-if="familyData.same == '1'">
<q-radio
v-model="familyData.liveC"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="1"
label="มีชีวิต"
color="blue"
dense
:disable="!edit"
/>
<q-radio
v-model="familyData.liveC"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="0"
label="เสียชีวิต"
color="red"
dense
:disable="!edit"
/>
</div>
</div>
<div class="col-xs-6 col-sm-2 col-md-2" v-if="familyData.same == '1'">
<q-input
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
dense
:disable="!edit"
@update:model-value="selectRadio"
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="familyData.citizenIdC"
:label="`${'เลขที่บัตรประชาชน'}`"
maxlength="13"
mask="#############"
/>
</div>
@ -184,7 +309,7 @@
:class="getClass(edit)"
:readonly="!edit"
:borderless="!edit"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
:outlined="edit"
dense
lazy-rules
@ -194,7 +319,7 @@
option-label="name"
:options="Ops.prefixOps"
option-value="id"
:label="`${'คำนำหน้า'}`"
:label="`${'คำนำหน้าชื่อ'}`"
use-input
input-debounce="0"
@filter="(inputValue:any,
@ -203,7 +328,7 @@
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3" v-if="familyData.same == '1'">
<div class="col-xs-6 col-sm-2 col-md-2" v-if="familyData.same == '1'">
<q-input
:class="getClass(edit)"
hide-bottom-space
@ -245,7 +370,7 @@
:label="`${'นามสกุล(เดิม)'}`"
/>
</div>
<div class="col-xs-12 col-sm-3 col-md-3" v-if="familyData.same == '1'">
<div class="col-xs-12 col-sm-2 col-md-2" v-if="familyData.same == '1'">
<q-input
:class="getClass(edit)"
hide-bottom-space
@ -261,7 +386,9 @@
<div class="col-12 q-pt-md q-pb-sm"><q-separator /></div>
</div>
<div class="row col-12 items-center q-col-gutter-x-xs q-col-gutter-y-xs">
<div
class="row col-12 items-center q-col-gutter-x-xs q-col-gutter-y-xs q-mb-sm"
>
<div class="col-xs-12 q-col-gutter-x-sm items-center flex">
<label class="text-weight-bold"> ตร</label>
<div>
@ -282,35 +409,70 @@
<div
class="row col-12 items-center q-col-gutter-xs"
v-for="items in familyData.childrens"
:key="items.id"
v-for="(items, index) in familyData.childrens"
:key="index"
>
<q-btn
v-if="edit"
size="12px"
flat
round
:disable="!edit"
:color="!edit ? 'grey-7' : 'red'"
@click="deleteChildren(items)"
icon="mdi-delete-outline"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
<div
:class="
edit
? 'col-xs-10 col-sm-2 col-md-2'
: 'col-xs-12 col-sm-3 col-md-3'
"
>
<div class="col-12 row q-gutter-sm q-pb-xs">
<q-avatar class="bg-grey-2" size="28px">{{ index + 1 }}</q-avatar>
<q-radio
v-model="items.childrenLive"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="1"
label="มีชีวิต"
color="blue"
dense
:disable="!edit"
/>
<q-radio
v-model="items.childrenLive"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="0"
label="เสียชีวิต"
color="red"
dense
:disable="!edit"
/>
</div>
<div>
<q-btn
v-if="edit"
flat
dense
size="12px"
round
:disable="!edit"
:color="!edit ? 'grey-7' : 'red'"
@click="deleteChildren(items)"
icon="mdi-delete-outline"
>
<q-tooltip>ลบขอม {{ index + 1 }}</q-tooltip>
</q-btn>
</div>
<div class="col-xs-6 col-sm-2 col-md-2">
<q-input
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="items.childrenCitizenId"
:label="`${'เลขที่บัตรประชาชน'}`"
maxlength="13"
mask="#############"
/>
</div>
<div class="col-xs-12 col-sm-2 col-md-2">
<selector
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
:readonly="!edit"
:borderless="!edit"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
:outlined="edit"
dense
lazy-rules
@ -320,7 +482,7 @@
option-label="name"
:options="Ops.prefixOps"
option-value="id"
:label="`${'คำนำหน้า'}`"
:label="`${'คำนำหน้าชื่อ'}`"
use-input
input-debounce="0"
@filter="(inputValue:any,
@ -356,7 +518,13 @@
:label="`${'นามสกุล'}`"
/>
</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<div
:class="
edit
? 'col-xs-10 col-sm-1 col-md-1'
: 'col-xs-12 col-sm-2 col-md-2'
"
>
<q-input
:class="getClass(edit)"
hide-bottom-space
@ -369,6 +537,12 @@
:label="`${'อาชีพ'}`"
/>
</div>
<div
class="col-12 q-my-sm"
v-if="index + 1 < familyData.childrens.length"
>
<q-separator v-if="edit" inset />
</div>
</div>
</div>
</q-form>
@ -390,15 +564,50 @@
}`
}}
</div>
<div class="col-xs-12 text-weight-bold"> ดา</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<div class="col-xs-12 text-weight-bold">
ดา
<q-radio
v-model="familyDataHistory[indexRow].fatherLive"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="1"
label="มีชีวิต"
dense
:disable="true"
/>
<q-radio
v-model="familyDataHistory[indexRow].fatherLive"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="0"
label="เสียชีวิต"
dense
:disable="true"
/>
</div>
<div class="col-xs-6 col-sm-2 col-md-2">
<q-input
:class="getClass(false)"
hide-bottom-space
:outlined="false"
dense
lazy-rules
:readonly="true"
:borderless="true"
v-model="familyDataHistory[indexRow].fatherCitizenId"
:label="`${'เลขที่บัตรประชาชน'}`"
maxlength="13"
mask="#############"
/>
</div>
<div class="col-xs-12 col-sm-2 col-md-2">
<selector
:hide-dropdown-icon="true"
hide-bottom-space
:class="getClass(false)"
:readonly="true"
:borderless="true"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
:outlined="false"
dense
lazy-rules
@ -408,7 +617,7 @@
option-label="name"
:options="Ops.prefixOps"
option-value="id"
:label="`${'คำนำหน้า'}`"
:label="`${'คำนำหน้าชื่อ'}`"
use-input
input-debounce="0"
@filter="(inputValue:any,
@ -445,7 +654,7 @@
:label="`${'นามสกุล'}`"
/>
</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<div class="col-xs-12 col-sm-2 col-md-2">
<q-input
:class="getClass(false)"
hide-bottom-space
@ -460,15 +669,50 @@
</div>
<div class="col-12 q-pt-md q-pb-sm"><q-separator /></div>
<div class="col-xs-12 text-weight-bold"> มารดา</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<div class="col-xs-12 text-weight-bold">
มารดา
<q-radio
v-model="familyDataHistory[indexRow].motherLive"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="1"
label="มีชีวิต"
dense
:disable="true"
/>
<q-radio
v-model="familyDataHistory[indexRow].motherLive"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="0"
label="เสียชีวิต"
dense
:disable="true"
/>
</div>
<div class="col-xs-6 col-sm-2 col-md-2">
<q-input
:class="getClass(false)"
hide-bottom-space
:outlined="false"
dense
lazy-rules
:readonly="true"
:borderless="true"
v-model="familyDataHistory[indexRow].motherCitizenId"
:label="`${'เลขที่บัตรประชาชน'}`"
maxlength="13"
mask="#############"
/>
</div>
<div class="col-xs-12 col-sm-2 col-md-2">
<selector
:hide-dropdown-icon="true"
hide-bottom-space
:class="getClass(false)"
:readonly="true"
:borderless="true"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
:outlined="false"
dense
lazy-rules
@ -478,7 +722,7 @@
option-label="name"
:options="Ops.prefixOps"
option-value="id"
:label="`${'คำนำหน้า'}`"
:label="`${'คำนำหน้าชื่อ'}`"
use-input
input-debounce="0"
@filter="(inputValue:any,
@ -515,7 +759,7 @@
:label="`${'นามสกุล'}`"
/>
</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<div class="col-xs-12 col-sm-2 col-md-2">
<q-input
:class="getClass(false)"
hide-bottom-space
@ -547,14 +791,62 @@
unchecked-icon="panorama_fish_eye"
val="0"
label="ไม่มี"
color="grey-9"
dense
:disable="true"
@update:model-value="selectRadio"
/>
<q-separator
vertical
color="grey-4"
size="2px"
class="q-mx-md"
v-if="familyData.same == '1'"
/>
<div class="q-gutter-sm" v-if="familyData.same == '1'">
<q-radio
v-model="familyDataHistory[indexRow].coupleLive"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="1"
label="มีชีวิต"
color="blue"
dense
:disable="true"
/>
<q-radio
v-model="familyDataHistory[indexRow].coupleLive"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="0"
label="เสียชีวิต"
color="red"
dense
:disable="true"
/>
</div>
</div>
<div
class="col-xs-6 col-sm-2 col-md-2"
v-if="familyDataHistory[indexRow].couple == '1'"
>
<q-input
:class="getClass(false)"
hide-bottom-space
:outlined="false"
dense
lazy-rules
:readonly="true"
:borderless="true"
v-model="familyDataHistory[indexRow].coupleCitizenId"
:label="`${'เลขที่บัตรประชาชน'}`"
maxlength="13"
mask="#############"
/>
</div>
<div
class="col-xs-12 col-sm-3 col-md-3"
class="col-xs-12 col-sm-2 col-md-2"
v-if="familyDataHistory[indexRow].couple == '1'"
>
<selector
@ -563,7 +855,7 @@
:class="getClass(false)"
:readonly="true"
:borderless="true"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
:outlined="false"
dense
lazy-rules
@ -573,7 +865,7 @@
option-label="name"
:options="Ops.prefixOps"
option-value="id"
:label="`${'คำนำหน้า'}`"
:label="`${'คำนำหน้าชื่อ'}`"
use-input
input-debounce="0"
@filter="(inputValue:any,
@ -617,7 +909,7 @@
/>
</div>
<div
class="col-xs-6 col-sm-3 col-md-3"
class="col-xs-6 col-sm-2 col-md-2"
v-if="familyDataHistory[indexRow].couple == '1'"
>
<q-input
@ -634,7 +926,7 @@
/>
</div>
<div
class="col-xs-12 col-sm-3 col-md-3"
class="col-xs-12 col-sm-2 col-md-2"
v-if="familyDataHistory[indexRow].couple == '1'"
>
<q-input
@ -662,14 +954,51 @@
v-for="items in familyDataHistory[indexRow].childrens"
:key="items.id"
>
<div class="col-xs-12 col-sm-3 col-md-3">
<div class="col-12 row q-gutter-sm q-pb-xs">
<q-radio
v-model="items.childrenLive"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="1"
label="มีชีวิต"
color="blue"
dense
:disable="true"
/>
<q-radio
v-model="items.childrenLive"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="0"
label="เสียชีวิต"
color="red"
dense
:disable="true"
/>
</div>
<div class="col-xs-6 col-sm-2 col-md-2">
<q-input
:class="getClass(false)"
hide-bottom-space
:outlined="false"
dense
lazy-rules
:readonly="true"
:borderless="true"
v-model="items.childrenCitizenId"
:label="`${'เลขที่บัตรประชาชน'}`"
maxlength="13"
mask="#############"
/>
</div>
<div class="col-xs-6 col-sm-2 col-md-2">
<selector
:hide-dropdown-icon="true"
hide-bottom-space
:class="getClass(false)"
:readonly="true"
:borderless="true"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
:outlined="false"
dense
lazy-rules
@ -679,7 +1008,7 @@
option-label="name"
:options="Ops.prefixOps"
option-value="id"
:label="`${'คำนำหน้า'}`"
:label="`${'คำนำหน้าชื่อ'}`"
use-input
input-debounce="0"
@filter="(inputValue:any,
@ -715,7 +1044,7 @@
:label="`${'นามสกุล'}`"
/>
</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<div class="col-xs-12 col-sm-2 col-md-2">
<q-input
:class="getClass(false)"
hide-bottom-space
@ -785,10 +1114,6 @@ const props = defineProps({
type: Function,
default: () => console.log("not function"),
},
statusAdd: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(["update:statusEdit"]);
@ -815,16 +1140,22 @@ const familyData = ref<Family>({
lastnameC: null,
lastnameCOld: null,
occupationC: null,
liveC: null,
citizenIdC: null,
prefixM: null,
prefixIdM: null,
firstnameM: null,
lastnameM: null,
occupationM: null,
liveM: null,
citizenIdM: null,
prefixF: null,
prefixIdF: null,
firstnameF: null,
lastnameF: null,
occupationF: null,
liveF: null,
citizenIdF: null,
same: "0",
childrens: [],
});
@ -840,37 +1171,8 @@ onMounted(async () => {
await fetchPrefix();
await fetchData();
emit("update:statusEdit", false);
defaultAdd();
});
const statusAdd = () => props.statusAdd;
const defaultAdd = () => {
if (props.statusAdd) {
edit.value = props.statusAdd;
familyData.value = {
prefixC: null,
prefixIdC: null,
firstnameC: null,
lastnameC: null,
lastnameCOld: null,
occupationC: null,
prefixM: null,
prefixIdM: null,
firstnameM: null,
lastnameM: null,
occupationM: null,
prefixF: null,
prefixIdF: null,
firstnameF: null,
lastnameF: null,
occupationF: null,
same: "0",
childrens: [],
};
}
};
const historyData = async () => {
await fetchHistory();
};
@ -918,6 +1220,8 @@ const addChildren = async () => {
childrenFirstName: "",
childrenLastName: "",
childrenCareer: "",
childrenLive: "1",
childrenCitizenId: "",
});
familyData.value.childrens.sort(
@ -948,14 +1252,20 @@ const fetchHistory = async () => {
coupleLastName: row.coupleLastName,
coupleLastNameOld: row.coupleLastNameOld,
coupleCareer: row.coupleCareer,
coupleLive: row.coupleLive ? "1" : "0",
coupleCitizenId: row.coupleCitizenId,
fatherPrefixId: row.fatherPrefixId,
fatherFirstName: row.fatherFirstName,
fatherLastName: row.fatherLastName,
fatherCareer: row.fatherCareer,
fatherLive: row.fatherLive ? "1" : "0",
fatherCitizenId: row.fatherCitizenId,
motherPrefixId: row.motherPrefixId,
motherFirstName: row.motherFirstName,
motherLastName: row.motherLastName,
motherCareer: row.motherCareer,
motherLive: row.motherLive ? "1" : "0",
motherCitizenId: row.motherCitizenId,
childrens: row.childrens,
createdFullName: row.createdFullName,
createdAt: new Date(row.createdAt),
@ -989,55 +1299,61 @@ const fetchHistory = async () => {
};
const fetchData = async () => {
if (route.params.id) {
loaderPage(true);
await http
.get(config.API.profileFamiId(route.params.id.toString()))
.then((res) => {
const data: ResponseObject = res.data.result;
familyData.value.prefixC = "";
familyData.value.prefixIdC = data.couplePrefixId;
familyData.value.firstnameC = data.coupleFirstName;
familyData.value.lastnameC = data.coupleLastName;
familyData.value.lastnameCOld = data.coupleLastNameOld;
familyData.value.occupationC = data.coupleCareer;
familyData.value.prefixM = "";
familyData.value.prefixIdM = data.fatherPrefixId;
loaderPage(true);
await http
.get(config.API.profileFamiId(route.params.id.toString()))
.then((res) => {
const data: ResponseObject = res.data.result;
familyData.value.prefixC = "";
familyData.value.prefixIdC = data.couplePrefixId;
familyData.value.firstnameC = data.coupleFirstName;
familyData.value.lastnameC = data.coupleLastName;
familyData.value.lastnameCOld = data.coupleLastNameOld;
familyData.value.occupationC = data.coupleCareer;
familyData.value.liveC = data.coupleLive ? "1" : "0";
familyData.value.citizenIdC = data.coupleCitizenId;
familyData.value.firstnameM = data.fatherFirstName;
familyData.value.lastnameM = data.fatherLastName;
familyData.value.occupationM = data.fatherCareer;
familyData.value.prefixF = "";
familyData.value.prefixIdF = data.motherPrefixId;
familyData.value.prefixM = "";
familyData.value.prefixIdM = data.fatherPrefixId;
familyData.value.firstnameM = data.fatherFirstName;
familyData.value.lastnameM = data.fatherLastName;
familyData.value.occupationM = data.fatherCareer;
familyData.value.liveM = data.fatherLive ? "1" : "0";
familyData.value.citizenIdM = data.fatherCitizenId;
familyData.value.firstnameF = data.motherFirstName;
familyData.value.lastnameF = data.motherLastName;
familyData.value.occupationF = data.motherCareer;
familyData.value.same = data.couple ? "1" : "0";
familyData.value.prefixF = "";
familyData.value.prefixIdF = data.motherPrefixId;
familyData.value.firstnameF = data.motherFirstName;
familyData.value.lastnameF = data.motherLastName;
familyData.value.occupationF = data.motherCareer;
familyData.value.liveF = data.motherLive ? "1" : "0";
familyData.value.citizenIdF = data.motherCitizenId;
familyData.value.same = data.couple ? "1" : "0";
if (data.childrens.length > 0) {
let dataChild: childrenFamily[] = [];
data.childrens.map((row: childrenFamily, index: number) => {
dataChild.push({
id: `${index + 1}`,
childrenPrefixId: row.childrenPrefixId,
childrenFirstName: row.childrenFirstName,
childrenLastName: row.childrenLastName,
childrenCareer: row.childrenCareer,
});
if (data.childrens.length > 0) {
let dataChild: childrenFamily[] = [];
data.childrens.map((row: childrenFamily, index: number) => {
dataChild.push({
id: `${index + 1}`,
childrenPrefixId: row.childrenPrefixId,
childrenFirstName: row.childrenFirstName,
childrenLastName: row.childrenLastName,
childrenCareer: row.childrenCareer,
childrenLive: row.childrenLive,
childrenCitizenId: row.childrenCitizenId,
});
familyData.value.childrens = dataChild;
} else {
familyData.value.childrens = [];
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
});
}
});
familyData.value.childrens = dataChild;
} else {
familyData.value.childrens = [];
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
loaderPage(false);
});
};
const editData = async () => {
@ -1049,14 +1365,20 @@ const editData = async () => {
coupleLastName: familyData.value.lastnameC,
coupleLastNameOld: familyData.value.lastnameCOld,
coupleCareer: familyData.value.occupationC,
coupleLive: familyData.value.liveC == "1",
coupleCitizenId: familyData.value.citizenIdC,
fatherPrefixId: familyData.value.prefixIdM,
fatherFirstName: familyData.value.firstnameM,
fatherLastName: familyData.value.lastnameM,
fatherCareer: familyData.value.occupationM,
fatherLive: familyData.value.liveM == "1",
fatherCitizenId: familyData.value.citizenIdM,
motherPrefixId: familyData.value.prefixIdF,
motherFirstName: familyData.value.firstnameF,
motherLastName: familyData.value.lastnameF,
motherCareer: familyData.value.occupationF,
motherLive: familyData.value.liveF == "1",
motherCitizenId: familyData.value.citizenIdF,
childrens: familyData.value.childrens,
createdFullName: "-",
createdAt: new Date(),
@ -1076,32 +1398,10 @@ const editData = async () => {
});
};
const addData = async () => {
// loaderPage(true);
// await http
// .put(config.API.profileInforId(route.params.id.toString()), body)
// .then((res) => {
// success($q, "");
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// edit.value = false;
// emit("update:statusEdit", false);
// await fetchData();
// await changeBirth(informaData.value.birthDate ?? new Date());
// });
};
const saveData = async () => {
await myform.value?.validate().then(async (success: boolean) => {
if (success) {
if (props.statusAdd) {
await addData();
} else {
await editData();
}
await editData();
} else {
}
});
@ -1123,6 +1423,8 @@ const selectRadio = (e: boolean, i: any) => {
familyData.value.lastnameC = "";
familyData.value.lastnameCOld = "";
familyData.value.occupationC = "";
familyData.value.liveC = "";
familyData.value.citizenIdC = "";
}
};

View file

@ -25,7 +25,7 @@
:label="`${'สังกัด'}`"
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<div class="col-xs-6 col-sm-3 col-md-3" v-if="employeeClass != 'temp'">
<q-input
:class="getClass(false)"
hide-bottom-space
@ -85,7 +85,7 @@
:label="`${'ประเภท'}`"
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<div class="col-xs-6 col-sm-3 col-md-3" v-if="employeeClass != 'temp'">
<q-input
:class="getClass(false)"
hide-bottom-space
@ -149,8 +149,18 @@
:readonly="!edit"
:borderless="!edit"
:model-value="date2Thai(new Date(govermentData.containDate))"
:rules="[(val) => !!val || `${'กรุณาเลือก วันที่บรรจุ'}`]"
:label="`${'วันที่บรรจุ'}`"
:rules="[
(val) =>
!!val ||
`${
profileType == 'officer'
? 'กรุณาเลือกวันที่บรรจุ'
: 'กรุณาเลือกวันที่แต่งตั้ง'
}`,
]"
:label="`${
profileType == 'officer' ? 'วันที่บรรจุ' : 'วันที่แต่งตั้ง'
}`"
>
<template v-slot:prepend>
<q-icon
@ -193,9 +203,19 @@
:borderless="!edit"
:model-value="date2Thai(new Date(govermentData.workDate))"
:rules="[
(val) => !!val || `${'กรุณาเลือก เริ่มปฎิบัติราชการ'}`,
(val) =>
!!val ||
`${
profileType == 'officer'
? 'กรุณาเลือกเริ่มปฎิบัติราชการ'
: 'กรุณาเลือกวันที่จ้างและแต่งตั้งมีผล'
}`,
]"
:label="`${'เริ่มปฎิบัติราชการ'}`"
:label="`${
profileType == 'officer'
? 'เริ่มปฎิบัติราชการ'
: 'วันที่จ้างและแต่งตั้งมีผล'
}`"
>
<template v-slot:prepend>
<q-icon
@ -211,7 +231,7 @@
</template>
</datepicker>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="col-xs-6 col-sm-6 col-md-6" v-if="profileType == 'officer'">
<q-input
:class="getClass(edit)"
hide-bottom-space
@ -330,6 +350,14 @@ const props = defineProps({
type: Boolean,
required: true,
},
profileType: {
type: String,
required: true,
},
employeeClass: {
type: String,
required: true,
},
});
const emit = defineEmits(["update:statusEdit"]);

View file

@ -5,12 +5,11 @@
header="ข้อมูลส่วนตัว"
icon="mdi-account"
:save="saveData"
:history="!statusAdd()"
:history="true"
:changeBtn="changeBtn"
:disable="statusEdit"
:cancel="onCancel"
:historyClick="clickHistory"
:addEmployee="statusAdd()"
/>
<q-form ref="myform" class="col-12">
<div class="row col-12 items-center q-col-gutter-x-sm q-col-gutter-y-sm">
@ -25,7 +24,6 @@
:borderless="!edit"
v-model="informaData.cardid"
@update:model-value="changeCardID"
maxlength="13"
:rules="[
(val:string) => !!val || `${'กรุณากรอก เลขบัตรประจำตัวประชาชน'}`,
(val:string) =>
@ -33,6 +31,7 @@
`${'กรุณากรอกเลขบัตรประจำตัวประชาชนให้ครบ'}`,
]"
label="เลขบัตรประจำตัวประชาชน"
maxlength="13"
mask="#############"
/>
</div>
@ -43,7 +42,7 @@
:class="getClass(edit)"
:readonly="!edit"
:borderless="!edit"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
:outlined="edit"
dense
lazy-rules
@ -53,7 +52,7 @@
option-label="name"
:options="Ops.prefixOps"
option-value="id"
:label="`${'คำนำหน้า'}`"
:label="`${'คำนำหน้าชื่อ'}`"
use-input
input-debounce="0"
@filter="(inputValue:any,
@ -116,11 +115,7 @@
lazy-rules
:readonly="!edit"
:borderless="!edit"
:model-value="
informaData.birthDate == null
? ''
: date2Thai(informaData.birthDate)
"
:model-value="date2Thai(informaData.birthDate)"
:rules="[(val:string) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี เกิด'}`]"
:label="`${'วัน/เดือน/ปี เกิด'}`"
>
@ -158,7 +153,6 @@
:class="getClass(edit)"
:readonly="!edit"
:borderless="!edit"
:rules="[(val:string) => !!val || `${'กรุณาเลือก เพศ'}`]"
:outlined="edit"
dense
lazy-rules
@ -183,7 +177,6 @@
:class="getClass(edit)"
:readonly="!edit"
:borderless="!edit"
:rules="[(val:string) => !!val || `${'กรุณาเลือก สถานภาพ'}`]"
:outlined="edit"
dense
lazy-rules
@ -211,7 +204,6 @@
:readonly="!edit"
:borderless="!edit"
v-model="informaData.nationality"
:rules="[(val:string) => !!val || `${'กรุณากรอก สัญชาติ'}`]"
:label="`${'สัญชาติ'}`"
/>
</div>
@ -225,7 +217,6 @@
:readonly="!edit"
:borderless="!edit"
v-model="informaData.ethnicity"
:rules="[(val:string) => !!val || `${'กรุณากรอก เชื้อชาติ'}`]"
:label="`${'เชื้อชาติ'}`"
/>
</div>
@ -236,7 +227,6 @@
:class="getClass(edit)"
:readonly="!edit"
:borderless="!edit"
:rules="[(val:string) => !!val || `${'กรุณาเลือก ศาสนา'}`]"
:outlined="edit"
dense
lazy-rules
@ -368,6 +358,7 @@
unchecked-icon="panorama_fish_eye"
val="0"
label="ไม่มี"
color="grey-9"
dense
:disable="!edit"
/>
@ -377,6 +368,11 @@
v-if="same == '1'"
v-model:statusEdit="edit"
:fetchDataInformation="fetchDataComponent"
:perfixId="informaData.prefixId == null ? '' : informaData.prefixId"
:firstname="
informaData.firstname == null ? '' : informaData.firstname
"
:lastname="informaData.lastname == null ? '' : informaData.lastname"
/>
</div>
</div>
@ -443,10 +439,6 @@ const props = defineProps({
type: Function,
default: () => console.log("not function"),
},
statusAdd: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(["update:statusEdit"]);
@ -515,7 +507,7 @@ const columnsHistory = ref<QTableColumn[]>([
{
name: "prefix",
align: "left",
label: "คำนำหน้า",
label: "คำนำหน้าชื่อ",
sortable: true,
field: "prefix",
headerStyle: "font-size: 14px",
@ -701,36 +693,8 @@ onMounted(async () => {
await fetchPerson();
await fetchData();
emit("update:statusEdit", false);
defaultAdd();
});
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: null,
genderId: null,
bloodId: null,
nationality: null,
ethnicity: null,
statusId: null,
religionId: null,
tel: null,
employeeType: null,
employeeClass: null,
profileType: null,
};
}
};
const onCancel = async () => {
if (myform.value != null) {
myform.value.reset();
@ -858,52 +822,50 @@ const checkCitizen = async (id: string) => {
* งชนดอมลประวแกไขขอมลทเลอก
*/
const clickHistory = async () => {
if (route.params.id) {
modalHistory.value = true;
loaderPage(true);
await http
.get(config.API.profileInforHisId(route.params.id.toString()))
.then((res) => {
let data = res.data.result;
rowsHistory.value = [];
data.map((e: RequestItemsHistoryObject) => {
rowsHistory.value.push({
citizenId: e.citizenId,
prefix: e.prefix,
firstName: e.firstName,
lastName: e.lastName,
birthDate: new Date(e.birthDate),
gender: e.gender,
relationship: e.relationship,
bloodGroup: e.bloodGroup,
nationality: e.nationality,
race: e.race,
religion: e.religion,
telephoneNumber: e.telephoneNumber,
employeeType:
e.employeeType == "gov"
? "งบประมาณเงินอุดหนุนรัฐบาล"
: e.employeeType == "bkk"
? "งบประมาณกรุงเทพมหานคร"
: "-",
employeeClass:
e.employeeClass == "perm"
? "ลูกจ้างประจำ"
: e.employeeClass == "temp"
? "ลูกจ้างชั่วคราว"
: "-",
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
modalHistory.value = true;
loaderPage(true);
await http
.get(config.API.profileInforHisId(route.params.id.toString()))
.then((res) => {
let data = res.data.result;
rowsHistory.value = [];
data.map((e: RequestItemsHistoryObject) => {
rowsHistory.value.push({
citizenId: e.citizenId,
prefix: e.prefix,
firstName: e.firstName,
lastName: e.lastName,
birthDate: new Date(e.birthDate),
gender: e.gender,
relationship: e.relationship,
bloodGroup: e.bloodGroup,
nationality: e.nationality,
race: e.race,
religion: e.religion,
telephoneNumber: e.telephoneNumber,
employeeType:
e.employeeType == "gov"
? "งบประมาณเงินอุดหนุนรัฐบาล"
: e.employeeType == "bkk"
? "งบประมาณกรุงเทพมหานคร"
: "-",
employeeClass:
e.employeeClass == "perm"
? "ลูกจ้างประจำ"
: e.employeeClass == "temp"
? "ลูกจ้างชั่วคราว"
: "-",
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
};
const filterSelector = (val: any, update: Function, refData: string) => {
@ -1000,49 +962,44 @@ const calRetire = async (birth: Date) => {
};
const fetchData = async () => {
if (route.params.id) {
loaderPage(true);
await http
.get(config.API.profileInforId(route.params.id.toString()))
.then(async (res: any) => {
const data: ResponseObject = res.data.result;
defaultCitizenData.value = data.citizenId;
informaData.value.cardid = data.citizenId;
informaData.value.prefix = "";
informaData.value.prefixId = data.prefixId;
informaData.value.firstname = data.firstName;
informaData.value.lastname = data.lastName;
informaData.value.birthDate = new Date(data.birthDate);
informaData.value.genderId = data.genderId;
informaData.value.bloodId = data.bloodGroupId;
informaData.value.nationality = data.nationality;
informaData.value.ethnicity = data.race;
informaData.value.statusId = data.relationshipId;
informaData.value.religionId = data.religionId;
informaData.value.tel = data.telephoneNumber;
informaData.value.age = data.age;
informaData.value.employeeType = data.employeeType;
informaData.value.employeeClass = data.employeeClass;
informaData.value.profileType = data.profileType;
dateBefore.value = new Date(data.birthDate);
same.value = data.changeName == true ? "1" : "0";
await calRetire(new Date(dateToISO(new Date(data.birthDate))));
if (
data.profileType == "officer" &&
columnsHistory.value.length >= 15
) {
columnsHistory.value.splice(13, 1);
columnsHistory.value.splice(12, 1);
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
// loaderPage(false);
await props.fetchDataProfile();
});
}
loaderPage(true);
await http
.get(config.API.profileInforId(route.params.id.toString()))
.then(async (res: any) => {
const data: ResponseObject = res.data.result;
defaultCitizenData.value = data.citizenId;
informaData.value.cardid = data.citizenId;
informaData.value.prefix = "";
informaData.value.prefixId = data.prefixId;
informaData.value.firstname = data.firstName;
informaData.value.lastname = data.lastName;
informaData.value.birthDate = new Date(data.birthDate);
informaData.value.genderId = data.genderId;
informaData.value.bloodId = data.bloodGroupId;
informaData.value.nationality = data.nationality;
informaData.value.ethnicity = data.race;
informaData.value.statusId = data.relationshipId;
informaData.value.religionId = data.religionId;
informaData.value.tel = data.telephoneNumber;
informaData.value.age = data.age;
informaData.value.employeeType = data.employeeType;
informaData.value.employeeClass = data.employeeClass;
informaData.value.profileType = data.profileType;
dateBefore.value = new Date(data.birthDate);
same.value = data.changeName == true ? "1" : "0";
await calRetire(new Date(dateToISO(new Date(data.birthDate))));
if (data.profileType == "officer" && columnsHistory.value.length >= 15) {
columnsHistory.value.splice(13, 1);
columnsHistory.value.splice(12, 1);
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
// loaderPage(false);
await props.fetchDataProfile();
});
};
const editData = async () => {
@ -1055,10 +1012,7 @@ const editData = async () => {
nationality: informaData.value.nationality,
race: informaData.value.ethnicity,
religionId: informaData.value.religionId,
birthDate:
informaData.value.birthDate == null
? dateToISO(new Date())
: dateToISO(informaData.value.birthDate),
birthDate: dateToISO(informaData.value.birthDate) ?? dateToISO(new Date()),
bloodGroupId: informaData.value.bloodId,
relationshipId: informaData.value.statusId,
telephoneNumber: informaData.value.tel,
@ -1086,33 +1040,11 @@ const editData = async () => {
});
};
const addData = async () => {
// loaderPage(true);
// await http
// .put(config.API.profileInforId(route.params.id.toString()), body)
// .then((res) => {
// success($q, "");
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// edit.value = false;
// emit("update:statusEdit", false);
// await fetchData();
// await changeBirth(informaData.value.birthDate ?? new Date());
// });
};
const saveData = async () => {
if (myform.value != null) {
await myform.value.validate().then(async (success: boolean) => {
if (success) {
if (props.statusAdd) {
await addData();
} else {
await editData();
}
await editData();
} else {
}
});

View file

@ -100,7 +100,7 @@
:class="getClass(edit)"
:readonly="!edit"
:borderless="!edit"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
:outlined="edit"
dense
lazy-rules
@ -110,7 +110,7 @@
option-label="name"
:options="Ops.prefixOps"
option-value="id"
:label="`${'คำนำหน้า'}`"
:label="`${'คำนำหน้าชื่อ'}`"
use-input
input-debounce="0"
@filter="(inputValue:any,
@ -124,7 +124,7 @@
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:readonly="!edit || status == 'lastName'"
:borderless="!edit"
v-model="firstName"
:rules="[(val) => !!val || `${'กรุณากรอกชื่อ'}`]"
@ -139,7 +139,7 @@
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:readonly="!edit || status == 'firstName'"
:borderless="!edit"
v-model="lastName"
:rules="[(val) => !!val || `${'กรุณากรอกนามสกุล'}`]"
@ -324,6 +324,18 @@ const props = defineProps({
type: Function,
default: () => console.log("not function"),
},
perfixId: {
type: String,
required: true,
},
firstname: {
type: String,
required: true,
},
lastname: {
type: String,
required: true,
},
});
const $q = useQuasar();
@ -362,9 +374,7 @@ const tittleHistory = ref<string>("ประวัติแก้ไขประ
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const checkValidate = ref<boolean>(false); //validate data
const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const profileId = ref<string>(route.params.id.toString());
const file = ref<string | null>(null);
const fileUpload = ref<any>([]);
const rows = ref<RequestItemsObject[]>([]);
@ -411,7 +421,7 @@ const columns = ref<QTableProps["columns"]>([
{
name: "prefix",
align: "left",
label: "คำนำหน้า",
label: "คำนำหน้าชื่อ",
sortable: true,
field: "prefix",
headerStyle: "font-size: 14px",
@ -457,7 +467,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
{
name: "prefix",
align: "left",
label: "คำนำหน้า",
label: "คำนำหน้าชื่อ",
sortable: true,
field: "prefix",
headerStyle: "font-size: 14px",
@ -540,34 +550,32 @@ onMounted(async () => {
});
const fetchData = async () => {
if (profileId.value !== "") {
loaderPage(true);
await http
.get(config.API.profileChangeNameId(profileId.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: ResponseObject) => {
rows.value.push({
id: e.id,
prefix: e.prefix,
prefixId: e.prefixId,
firstName: e.firstName,
lastName: e.lastName,
status: e.status,
file: e.file,
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
loaderPage(true);
await http
.get(config.API.profileChangeNameId(profileId.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: ResponseObject) => {
rows.value.push({
id: e.id,
prefix: e.prefix,
prefixId: e.prefixId,
firstName: e.firstName,
lastName: e.lastName,
status: e.status,
file: e.file,
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
};
/**
@ -669,19 +677,44 @@ const clickSave = async () => {
if (modalEdit.value) {
await editData();
} else {
await checkSave();
await saveData();
}
}
});
};
const checkSave = async () => {
/**
* นทกเพมขอม
*/
const saveData = async () => {
if (fileUpload.value.length > 0) {
if (profileId.value !== "") {
await saveData();
} else {
await saveDataEmployee();
}
const blob = fileUpload.value.slice(0, fileUpload.value[0].size);
const newFile = new File(blob, nameFile.value, {
type: fileUpload.value[0].type,
});
const formData = new FormData();
formData.append("", newFile);
if (prefixId.value != undefined)
formData.append("prefixId", prefixId.value);
if (firstName.value != undefined)
formData.append("firstName", firstName.value);
if (lastName.value != undefined)
formData.append("lastName", lastName.value);
if (status.value != undefined) formData.append("status", status.value);
loaderPage(true);
await http
.post(config.API.profileChangeNameId(profileId.value), formData)
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
await props.fetchDataInformation();
});
} else {
dialogMessage(
$q,
@ -697,41 +730,6 @@ const checkSave = async () => {
}
};
/**
* นทกเพมขอม
*/
const saveData = async () => {
const blob = fileUpload.value.slice(0, fileUpload.value[0].size);
const newFile = new File(blob, nameFile.value, {
type: fileUpload.value[0].type,
});
const formData = new FormData();
formData.append("", newFile);
if (prefixId.value != undefined) formData.append("prefixId", prefixId.value);
if (firstName.value != undefined)
formData.append("firstName", firstName.value);
if (lastName.value != undefined) formData.append("lastName", lastName.value);
if (status.value != undefined) formData.append("status", status.value);
loaderPage(true);
await http
.post(config.API.profileChangeNameId(profileId.value), formData)
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
await props.fetchDataInformation();
});
};
const saveDataEmployee = async () => {
console.log("saveDataEmployee");
};
/**
* นทกแกไขขอม
*/
@ -845,9 +843,9 @@ const addData = () => {
modalEdit.value = false;
modal.value = true;
edit.value = true;
prefixId.value = "";
firstName.value = "";
lastName.value = "";
prefixId.value = props.perfixId;
firstName.value = props.firstname;
lastName.value = props.lastname;
status.value = "";
file.value = "";
};

View file

@ -43,7 +43,7 @@
size="12px"
flat
round
v-if="edit && !addEmployee"
v-if="edit"
:color="!edit ? 'grey-7' : 'red'"
@click="ClickCancel"
icon="mdi-undo"
@ -125,7 +125,6 @@ const props = defineProps({
type: Boolean,
defualt: false,
},
disable: {
type: Boolean,
defualt: false,
@ -158,10 +157,6 @@ const props = defineProps({
type: Function,
default: () => console.log("not function"),
},
addEmployee: {
type: Boolean,
defualt: false,
},
});
const emit = defineEmits(["update:edit"]);