อัพเดท api ที่อยู่

This commit is contained in:
AnandaTon 2023-03-22 10:56:02 +07:00
parent a02e4fe4ec
commit 31529815d2
3 changed files with 92 additions and 85 deletions

View file

@ -4,6 +4,9 @@ const prefix = `${env.API_URI}/prefix/`
const religion = `${env.API_URI}/religion/`
const relationship = `${env.API_URI}/relationship/`
const educationLevel = `${env.API_URI}/education-level/`
const province = `${env.API_URI}/province/`;
const district = `${env.API_URI}/district/`;
const subDistrict = `${env.API_URI}/sub-district/`;
export default {
countDashbordSubHistory: (type: number) => `${dashbord}${type}`,
@ -11,5 +14,8 @@ export default {
prefix,
religion,
relationship,
educationLevel
educationLevel,
province,
listDistrict: (id: string) => `${district}${id}`,
listSubDistrict: (id: string) => `${subDistrict}${id}`,
}

View file

@ -100,7 +100,7 @@
lazy-rules
readonly
borderless
v-model="addressData.code"
v-model="codep"
:style="!edit ? '' : 'padding:0 12px;'"
:label="`${'รหัสไปรษณีย์'}`"
/>
@ -212,7 +212,7 @@
lazy-rules
readonly
borderless
v-model="addressData.codeC"
v-model="codec"
:style="!edit ? '' : 'padding:0 12px;'"
:label="`${'รหัสไปรษณีย์'}`"
/>
@ -273,9 +273,9 @@ const props = defineProps({
const emit = defineEmits(['update:statusEdit'])
onMounted(() => {
// fetchProvince()
// fetchDistrict(addressData.value.provinceId, '1')
// fetchDistrict(addressData.value.provinceIdC, '2')
fetchProvince()
fetchDistrict(addressData.value.provinceId, '1')
fetchDistrict(addressData.value.provinceIdC, '2')
})
const saveData = async () => {
@ -349,72 +349,72 @@ const selectSubDistrict = (e: string, name: string) => {
}
const fetchProvince = async () => {
// // loader.value = true;
// await http
// .get(config.API.province)
// .then((res) => {
// const data = res.data.result
// let option: DataOption[] = []
// // console.log(data);
// data.map((r: any) => {
// option.push({ id: r.id.toString(), name: r.name.toString() })
// })
// provinceOptions.value = option
// })
// .catch((e: any) => {})
// .finally(() => {
// // loader.value = false;
// })
// loader.value = true;
await http
.get(config.API.province)
.then((res) => {
const data = res.data.result
let option: DataOption[] = []
// console.log(data);
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() })
})
provinceOptions.value = option
})
.catch((e: any) => {})
.finally(() => {
// loader.value = false;
})
}
const fetchDistrict = async (id: string, position: string) => {
// // loader.value = true;
// await http
// .get(config.API.listDistrict(id))
// .then((res) => {
// const data = res.data.result
// let option: DataOption[] = []
// // console.log(data);
// data.map((r: any) => {
// option.push({ id: r.id.toString(), name: r.name.toString() })
// })
// if (position == '1') {
// districtOptions.value = option
// } else {
// districtCOptions.value = option
// }
// })
// .catch((e: any) => {})
// .finally(() => {
// // loader.value = false;
// })
// loader.value = true;
await http
.get(config.API.listDistrict(id))
.then((res) => {
const data = res.data.result
let option: DataOption[] = []
// console.log(data);
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() })
})
if (position == '1') {
districtOptions.value = option
} else {
districtCOptions.value = option
}
})
.catch((e: any) => {})
.finally(() => {
// loader.value = false;
})
}
const fetchSubDistrict = async (id: string, position: string) => {
// // loader.value = true;
// await http
// .get(config.API.listSubDistrict(id))
// .then((res) => {
// const data = res.data.result
// let option: zipCodeOption[] = []
// // console.log(res);
// data.map((r: any) => {
// option.push({
// id: r.id.toString(),
// name: r.name.toString(),
// zipCode: r.zipCode.toString()
// })
// })
// if (position == '1') {
// subdistrictOptions.value = option
// } else {
// subdistrictCOptions.value = option
// }
// })
// .catch((e: any) => {})
// .finally(() => {
// // loader.value = false;
// })
// loader.value = true;
await http
.get(config.API.listSubDistrict(id))
.then((res) => {
const data = res.data.result
let option: zipCodeOption[] = []
// console.log(res);
data.map((r: any) => {
option.push({
id: r.id.toString(),
name: r.name.toString(),
zipCode: r.zipCode.toString()
})
})
if (position == '1') {
subdistrictOptions.value = option
} else {
subdistrictCOptions.value = option
}
})
.catch((e: any) => {})
.finally(() => {
// loader.value = false;
})
}
const consenClose = () => {

View file

@ -202,7 +202,7 @@
:outlined="edit"
dense
lazy-rules
v-model="informaData.provinceId"
v-model="province"
emit-value
map-options
option-label="name"
@ -350,8 +350,8 @@ const mixin = useCounterMixin()
const store = useExamDataStore()
const { date2Thai, calAge } = mixin
const prefix = ref<string>()
const province = ref<string>()
const relationship = ref<string>()
const prefixOptions = ref<DataOption[]>([])
const relationshipOptions = ref<DataOption[]>([])
@ -405,14 +405,15 @@ const props = defineProps({
const emit = defineEmits(['update:statusEdit'])
onMounted(async () => {
// fetchProvince()
await fetchData()
await fetchprefix()
await fetchrelationship()
await fetchProvince()
})
const fetchData = () => {
prefix.value = 'e4e6a4f8-39c6-467f-bd84-7650d105fc4c'
relationship.value = '02fbc0e3-1da0-45b5-90da-783d344b5896'
province.value = '02fbc0e3-1da0-45b5-90da-783d344b5896'
}
const saveData = async () => {
@ -443,22 +444,22 @@ const changeBtn = async () => {
}
const fetchProvince = async () => {
// // loader.value = true;
// await http
// .get(config.API.province)
// .then((res) => {
// const data = res.data.result
// let option: DataOption[] = []
// // console.log(data);
// data.map((r: any) => {
// option.push({ id: r.id.toString(), name: r.name.toString() })
// })
// provinceOptions.value = option
// })
// .catch((e: any) => {})
// .finally(() => {
// // loader.value = false;
// })
// loader.value = true;
await http
.get(config.API.province)
.then((res) => {
const data = res.data.result
let option: DataOption[] = []
// console.log(data);
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() })
})
provinceOptions.value = option
})
.catch((e: any) => {})
.finally(() => {
// loader.value = false;
})
}
const fetchprefix = async () => {
// loader.value = true;