ปรับเเก้

This commit is contained in:
STW_TTTY\stwtt 2024-05-17 16:37:55 +07:00
parent d395bcbab5
commit 763f73d872
12 changed files with 1464 additions and 368 deletions

View file

@ -52,6 +52,7 @@ const {
dialogConfirm,
} = mixin;
const edit = ref<boolean>(false);
const onEdit = ref<boolean>(false);
const addressData = ref<AddressType>(props.data);
const myform = ref<any>();
const Ops = ref<AddressOps>({
@ -133,9 +134,21 @@ const filterSelector = (val: any, update: Function, refData: string) => {
const refreshData = async () => {
myform.value.reset();
// await props.fetch();
await fetchProvince();
await getNewData();
if (onEdit.value) {
dialogConfirm(
$q,
async () => {
emit("update:statusEdit", false);
await props.fetch("Address");
edit.value = false;
onEdit.value = false;
},
`ข้อมูลมีการแก้ไข`,
`ยืนยันยกเลิกการแก้ไขใช่หรือไม่?`
);
} else {
edit.value = false;
}
};
const getNewData = async () => {
@ -145,7 +158,7 @@ const getNewData = async () => {
//
const editData = async () => {
dialogConfirm($q, async() => {
dialogConfirm($q, async () => {
const body = {
registrationSame: addressData.value.registSame == "1",
registrationAddress: addressData.value.registAddress,
@ -189,8 +202,7 @@ const editData = async () => {
.finally(async () => {
edit.value = false;
emit("update:statusEdit", false);
await getNewData();
await props.fetch();
await props.fetch("Address");
// await fetchProvince();
});
});
@ -326,7 +338,7 @@ const fetchDistrict = async (id: string | null, position: string) => {
if (id != null && id != "") {
showLoader();
await http
.get(config.API.orgProvince+`/${id}`)
.get(config.API.orgProvince + `/${id}`)
.then(async (res) => {
const data = res.data.result.districts;
let option: optionData[] = [];
@ -372,7 +384,7 @@ const fetchSubDistrict = async (id: string | null, position: string) => {
if (id != null && id != "") {
showLoader();
await http
.get(config.API.orgDistrict+`/${id}`)
.get(config.API.orgDistrict + `/${id}`)
.then(async (res) => {
const data = res.data.result.subDistricts;
let option: zipCodeOption[] = [];
@ -420,7 +432,6 @@ const fetchSubDistrict = async (id: string | null, position: string) => {
const changeBtn = async () => {
if (edit.value == true) {
if (props.statusEdit === true) {
edit.value = false;
props.notiNoEdit();
} else {
emit("update:statusEdit", true);

View file

@ -29,6 +29,12 @@ const props = defineProps({
type: Object as PropType<Family>,
default: FamilyDataDefualt,
},
Ops: {
type: Object as PropType<any>,
},
OpsFilter: {
type: Object as PropType<any>,
},
});
const emit = defineEmits(["update:statusEdit"]);
@ -45,26 +51,18 @@ const {
dialogConfirm,
} = mixin;
const edit = ref<boolean>(false);
const onEdit = ref<boolean>(false);
const myform = ref<QForm | null>(null);
const familyData = ref<Family>(props.data);
const Ops = ref<any>({
prefixOps: [],
});
const OpsFilter = ref<any>({
prefixOps: [],
});
onMounted(async () => {
await fetchPrefix();
emit("update:statusEdit", false);
});
const filterSelector = (val: any, update: Function, refData: string) => {
update(() => {
Ops.value[`${refData}`] = OpsFilter.value[`${refData}`].filter(
props.Ops[`${refData}`] = props.OpsFilter[`${refData}`].filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
@ -74,29 +72,21 @@ const refreshData = async () => {
if (myform.value != null) {
myform.value.reset();
}
emit("update:statusEdit", false);
await props.fetch();
};
const fetchPrefix = async () => {
showLoader();
await http
.get(config.API.profileNewMetaMain)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.prefixs.map((r: any) => {
option.push({ id: r.name.toString(), name: r.name.toString() });
});
Ops.value.prefixOps = option;
OpsFilter.value.prefixOps = option;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
if (onEdit.value) {
dialogConfirm(
$q,
async () => {
emit("update:statusEdit", false);
await props.fetch("Family");
edit.value = false;
onEdit.value = false;
},
`ข้อมูลมีการแก้ไข`,
`ยืนยันยกเลิกการแก้ไขใช่หรือไม่?`
);
} else {
edit.value = false;
}
};
const editData = async () => {
@ -153,7 +143,7 @@ const editData = async () => {
hideLoader();
edit.value = false;
emit("update:statusEdit", false);
await props.fetch();
await props.fetch("Family");
});
});
};

View file

@ -9,10 +9,6 @@ import type {
} from "@/modules/05_placement/components/PersonalDetail/profileType";
import { defaultInformation } from "@/modules/05_placement/components/PersonalDetail/profileType";
import type {
InformationOps,
optionData,
} from "@/modules/05_placement/interface/index/Main";
import HeaderTop from "@/modules/05_placement/components/PersonalDetail/Information/top.vue";
import http from "@/plugins/http";
@ -40,6 +36,12 @@ const props = defineProps({
type: Object as PropType<Information>,
default: defaultInformation,
},
Ops: {
type: Object as PropType<any>,
},
OpsFilter: {
type: Object as PropType<any>,
},
});
const emit = defineEmits(["update:statusEdit"]);
@ -63,39 +65,8 @@ const edit = ref<boolean>(false);
const informaData = ref<Information>(props.data);
const age = ref<boolean>(true);
const myform = ref<QForm | null>(null);
const Ops = ref<InformationOps>({
prefixOps: [],
genderOps: [],
bloodOps: [],
statusOps: [],
religionOps: [],
employeeClassOps: [
{ id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" },
{ id: "bkk", name: "งบประมาณกรุงเทพมหานคร" },
],
employeeTypeOps: [
{ id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" },
{ id: "bkk", name: "งบประมาณกรุงเทพมหานคร" },
],
});
const OpsFilter = ref<InformationOps>({
prefixOps: [],
genderOps: [],
bloodOps: [],
statusOps: [],
religionOps: [],
employeeClassOps: [
{ id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" },
{ id: "bkk", name: "งบประมาณกรุงเทพมหานคร" },
],
employeeTypeOps: [
{ id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" },
{ id: "bkk", name: "งบประมาณกรุงเทพมหานคร" },
],
});
onMounted(async () => {
await fetchPerson();
emit("update:statusEdit", false);
});
@ -103,127 +74,72 @@ const onCancel = async () => {
if (myform.value != null) {
myform.value.reset();
}
await props.fetch();
};
if (onEdit.value) {
dialogConfirm(
$q,
async () => {
emit("update:statusEdit", false);
await props.fetch("Information");
edit.value = false;
onEdit.value = false;
},
`ข้อมูลมีการแก้ไข`,
`ยืนยันยกเลิกการแก้ไขใช่หรือไม่?`
);
/**
* get รายการ อมลเกยวกบบคคล
*/
const fetchPerson = async () => {
showLoader();
await http
.get(config.API.profileNewMetaMain)
.then((res) => {
const data = res.data.result;
//
let optionbloodGroups: optionData[] = [];
data.bloodGroups.map((r: any) => {
optionbloodGroups.push({
id: r.name ?? "",
name: r.name ?? "",
});
});
Ops.value.bloodOps = optionbloodGroups;
OpsFilter.value.bloodOps = optionbloodGroups;
//
let optiongenders: optionData[] = [];
data.genders.map((r: any) => {
optiongenders.push({
id: r.name ?? "",
name: r.name ?? "",
});
});
Ops.value.genderOps = optiongenders;
OpsFilter.value.genderOps = optiongenders;
//
let optionprefixs: optionData[] = [];
data.prefixs.map((r: any) => {
optionprefixs.push({
id: r.name ?? "",
name: r.name ?? "",
});
});
Ops.value.prefixOps = optionprefixs;
OpsFilter.value.prefixOps = optionprefixs;
//
let optionrelationships: optionData[] = [];
data.relationships.map((r: any) => {
optionrelationships.push({
id: r.name ?? "",
name: r.name ?? "",
});
});
Ops.value.statusOps = optionrelationships;
OpsFilter.value.statusOps = optionrelationships;
//
let optionreligions: optionData[] = [];
data.religions.map((r: any) => {
optionreligions.push({
id: r.name ?? "",
name: r.name ?? "",
});
});
Ops.value.religionOps = optionreligions;
OpsFilter.value.religionOps = optionreligions;
})
.catch((e: any) => {})
.finally(() => {
hideLoader();
});
} else {
edit.value = false;
}
};
const filterSelector = (val: any, update: Function, refData: string) => {
switch (refData) {
case "prefixOps":
update(() => {
Ops.value.prefixOps = OpsFilter.value.prefixOps.filter(
props.Ops.prefixOps = props.OpsFilter.prefixOps.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "genderOps":
update(() => {
Ops.value.genderOps = OpsFilter.value.genderOps.filter(
props.Ops.genderOps = props.OpsFilter.genderOps.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "bloodOps":
update(() => {
Ops.value.bloodOps = OpsFilter.value.bloodOps.filter(
props.Ops.bloodOps = props.OpsFilter.bloodOps.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "statusOps":
update(() => {
Ops.value.statusOps = OpsFilter.value.statusOps.filter(
props.Ops.statusOps = props.OpsFilter.statusOps.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "religionOps":
update(() => {
Ops.value.religionOps = OpsFilter.value.religionOps.filter(
props.Ops.religionOps = props.OpsFilter.religionOps.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "employeeClassOps":
update(() => {
Ops.value.employeeClassOps = OpsFilter.value.employeeClassOps.filter(
props.Ops.employeeClassOps = props.OpsFilter.employeeClassOps.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "employeeTypeOps":
update(() => {
Ops.value.employeeTypeOps = OpsFilter.value.employeeTypeOps.filter(
props.Ops.employeeTypeOps = props.OpsFilter.employeeTypeOps.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
@ -237,6 +153,7 @@ const filterSelector = (val: any, update: Function, refData: string) => {
const handleDate = async (modelData: Date) => {
informaData.value.dateOfBirth = modelData;
await calRetire(modelData);
onEdit.value = true;
};
const calRetire = async (birth: Date) => {
@ -299,7 +216,7 @@ const editData = async () => {
.finally(async () => {
edit.value = false;
emit("update:statusEdit", false);
await props.fetch();
await props.fetch("Information");
await changeBirth(informaData.value.dateOfBirth ?? new Date());
});
});
@ -318,7 +235,6 @@ const saveData = async () => {
const changeBtn = async () => {
if (edit.value == true) {
if (props.statusEdit === true) {
edit.value = false;
props.notiNoEdit();
} else {
emit("update:statusEdit", true);
@ -334,6 +250,11 @@ const getClass = (val: boolean) => {
"full-width cursor-pointer": !val,
};
};
const onEdit = ref<boolean>(false);
function checkEdit() {
onEdit.value = true;
}
</script>
<template>
<q-card flat bordered class="col-12 q-px-lg q-py-md no-border">
@ -368,10 +289,12 @@ const getClass = (val: boolean) => {
]"
label="เลขประจำตัวประชาชน"
mask="#############"
@update:modelValue="checkEdit"
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
@update:modelValue="checkEdit"
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -408,6 +331,7 @@ const getClass = (val: boolean) => {
v-model="informaData.firstname"
:rules="[(val:string) => !!val || `${'กรุณากรอก ชื่อ'}`]"
:label="`${'ชื่อ'}`"
@update:modelValue="checkEdit"
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
@ -422,6 +346,7 @@ const getClass = (val: boolean) => {
v-model="informaData.lastname"
:rules="[(val:string) => !!val || `${'กรุณากรอก นามสกุล'}`]"
:label="`${'นามสกุล'}`"
@update:modelValue="checkEdit"
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
@ -486,6 +411,7 @@ const getClass = (val: boolean) => {
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
@update:modelValue="checkEdit"
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -511,6 +437,7 @@ const getClass = (val: boolean) => {
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
@update:modelValue="checkEdit"
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -536,6 +463,7 @@ const getClass = (val: boolean) => {
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
@update:modelValue="checkEdit"
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -561,6 +489,7 @@ const getClass = (val: boolean) => {
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-input
@update:modelValue="checkEdit"
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
@ -575,6 +504,7 @@ const getClass = (val: boolean) => {
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-input
@update:modelValue="checkEdit"
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
@ -589,6 +519,7 @@ const getClass = (val: boolean) => {
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
@update:modelValue="checkEdit"
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -614,6 +545,7 @@ const getClass = (val: boolean) => {
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-input
@update:modelValue="checkEdit"
hide-bottom-space
:outlined="edit"
dense

View file

@ -71,7 +71,6 @@ const historyClick = async () => {
};
const ClickCancel = () => {
updateEdit(!props.edit);
props.cancel();
props.changeBtn();
};