Refactor location selection methods in various components to use async data fetching. Update ChangeIl and ChangeIlce functions to clear dependent fields and handle empty selections, ensuring accurate form data management. Enhance error handling in data retrieval with skipErrorForStatuses option for improved user experience.

This commit is contained in:
burakovec
2026-03-31 10:03:24 +03:00
parent 2615e9b3ee
commit 2bbeea8c6f
5 changed files with 43 additions and 26 deletions

View File

@ -383,13 +383,23 @@
return uyeBilgileriStore.mahalleList.length === 0
})
const ChangeIl = (e: Event, v: string | number, d: Record<string, any>) => {
const ChangeIl = async (e: Event, v: string | number, d: Record<string, any>) => {
uyeBilgileriStore.formData.ilceId = ''
uyeBilgileriStore.ilceList = d.ilceler
}
const ChangeIlce = (e: Event, v: string | number, d: Record<string, any>) => {
uyeBilgileriStore.formData.mahalleId = ''
uyeBilgileriStore.mahalleList = d.mahalleler
uyeBilgileriStore.mahalleList = []
if (Object.keys(d).length === 0) {
uyeBilgileriStore.ilceList = []
return
}
uyeBilgileriStore.ilceList = await dataStore.GetIlcelerByIlId(v)
}
const ChangeIlce = async (e: Event, v: string | number, d: Record<string, any>) => {
uyeBilgileriStore.formData.mahalleId = ''
if (Object.keys(d).length === 0) {
uyeBilgileriStore.mahalleList = []
return
}
uyeBilgileriStore.mahalleList = await dataStore.GetMahallelerByIlceId(v)
}
const PasswordCheck = (e: KeyboardEvent) => {
if (

View File

@ -38,10 +38,13 @@
const GetData = async () => {
loaded.value = false
let dt = await dataStore.dataGet(
'IrtibatBilgi/GetIrtibatBilgiCekilis/' + piyangoStore.selectedLottery
'IrtibatBilgi/GetIrtibatBilgiCekilis/' + piyangoStore.selectedLottery,
{
skipErrorForStatuses: [404]
}
)
if (dt !== 'errorfalse') {
if (dt !== 'errorfalse' && !dt?._error) {
Object.assign(piyangoContactStore.contactData, dt)
}
setTimeout(()=>{

View File

@ -443,9 +443,14 @@
return piyangoStore.lotteryData.ilId === null || ilceList.value.length === 0
})
const ChangeIl = (e: Event, v: string | number, d: Record<string, any>) => {
const ChangeIl = async (e: Event, v: string | number, d: Record<string, any>) => {
piyangoStore.lotteryData.ilceId = ''
ilceList.value = d.ilceler
if (Object.keys(d).length === 0) {
ilceList.value = []
formChanged.value = true
return
}
ilceList.value = await dataStore.GetIlcelerByIlId(v)
formChanged.value = true
}
const OnKeyup = () => {
@ -474,11 +479,8 @@
piyangoStore.lotteryData.ilceId !== null &&
piyangoStore.lotteryData.ilceId !== ''
) {
let ilO = globalDataStore.ilList.filter((v: Record<string, any>) => {
return v.id === piyangoStore.lotteryData.ilId
})
if (ilO.length !== 0)
ilceList.value.splice(0, ilceList.value.length, ...(ilO[0]['ilceler'] as IIl[]))
const ilceler = await dataStore.GetIlcelerByIlId(piyangoStore.lotteryData.ilId)
ilceList.value.splice(0, ilceList.value.length, ...(ilceler as IIl[]))
}
if (piyangoStore.lotteryData.amacpiyangoId === 2) {

View File

@ -87,11 +87,14 @@
const GetData = async () => {
loaded.value = false
let dt = await dataStore.dataGet(
'IrtibatBilgi/GetIrtibatBilgiCekilis/' + piyangoStore.selectedLottery
'IrtibatBilgi/GetIrtibatBilgiCekilis/' + piyangoStore.selectedLottery,
{
skipErrorForStatuses: [404]
}
)
piyangoContactStore.ResetFormData()
if (dt !== 'errorfalse') {
if (dt !== 'errorfalse' && !dt?._error) {
Object.assign(piyangoContactStore.contactData, dt)
Object.assign(piyangoContactStore.safeContactData, dt)
} else {

View File

@ -255,7 +255,7 @@
label="İlçe"
:listData="ilceList"
listText="ad"
listVal="id"
listVal="ad"
modelKey="ilce"
v-model="piyangoKatilimciStore.piyangoKatilimciUserFormData.ilce"
:invalidText="piyangoKatilimciValidationStore.userFormInvalidTexts.ilce"
@ -391,13 +391,14 @@
piyangoKatilimciValidationStore.userFormChanged = true
}
const ChangeIl = (e: Event, v: string | number, d: Record<string, any>) => {
const ChangeIl = async (e: Event, v: string | number, d: Record<string, any>) => {
piyangoKatilimciStore.piyangoKatilimciUserFormData.ilce = ''
if (Object.keys(d).length === 0) {
ilceList.value = []
return
}
ilceList.value.splice(0, ilceList.value.length, ...d.ilceler)
const ilceler = await dataStore.GetIlcelerByIlId(d.id)
ilceList.value.splice(0, ilceList.value.length, ...ilceler)
piyangoKatilimciValidationStore.userFormChanged = true
}
const ilceDisabled = computed<boolean>(() => {
@ -417,13 +418,11 @@
piyangoKatilimciStore.piyangoKatilimciUserFormData.ilce !== null &&
piyangoKatilimciStore.piyangoKatilimciUserFormData.ilce !== ''
) {
let ilO: Record<string, any>[] = globalDataStore.ilList.filter(
(v: Record<string, any>) => {
return v.ad === piyangoKatilimciStore.piyangoKatilimciUserFormData.il
}
)
if (ilO.length !== 0)
ilceList.value.splice(0, ilceList.value.length, ...ilO[0]['ilceler'])
const selectedIl = dataStore.GetIlByName(piyangoKatilimciStore.piyangoKatilimciUserFormData.il)
if (selectedIl !== undefined) {
const ilceler = await dataStore.GetIlcelerByIlId(selectedIl.id)
ilceList.value.splice(0, ilceList.value.length, ...ilceler)
}
}
})
</script>