อัพเดท 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

@ -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 = () => {