职工福利-收货地址(h5手机端):修复提交保存成功后页面一直处于加载中;
This commit is contained in:
@@ -44,6 +44,7 @@ layout("/mobile/platform.html"){
|
||||
mixins: [mobileMixins, welfareMixins],
|
||||
data() {
|
||||
return {
|
||||
projectId: GetQueryString("projectId"),
|
||||
chosenAddressId: null
|
||||
}
|
||||
},
|
||||
@@ -56,16 +57,27 @@ layout("/mobile/platform.html"){
|
||||
}
|
||||
},
|
||||
onAdd() {
|
||||
pjaxReplace("/mobile/welfare/mine/addressEdit")
|
||||
if (this.projectId) {
|
||||
pjaxReplace("/mobile/welfare/mine/addressEdit?projectId=" + this.projectId)
|
||||
} else {
|
||||
pjaxReplace("/mobile/welfare/mine/addressEdit")
|
||||
}
|
||||
},
|
||||
onEdit(item, index) {
|
||||
pjaxReplace("/mobile/welfare/mine/addressEdit?id=" + item.id)
|
||||
if (this.projectId) {
|
||||
pjaxReplace("/mobile/welfare/mine/addressEdit?id=" + item.id + "&projectId=" + this.projectId)
|
||||
} else {
|
||||
pjaxReplace("/mobile/welfare/mine/addressEdit?id=" + item.id)
|
||||
}
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.startLoading()
|
||||
await this.selectAddressList()
|
||||
this.closeLoading()
|
||||
try {
|
||||
await this.selectAddressList()
|
||||
} finally {
|
||||
this.closeLoading()
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -101,8 +101,12 @@ layout("/mobile/platform.html"){
|
||||
duration: 0
|
||||
})
|
||||
content.userName = content.name
|
||||
const resp = await $.post("/mobile/welfare/mine/doSaveUserAddress", content)
|
||||
loading.close()
|
||||
let resp = {}
|
||||
try {
|
||||
resp = await $.post("/mobile/welfare/mine/doSaveUserAddress", content)
|
||||
} finally {
|
||||
this.closeToastLoading(loading)
|
||||
}
|
||||
if (resp.code === 0) {
|
||||
this.$toast.success(resp.msg)
|
||||
this.$nextTick(() => {
|
||||
@@ -117,14 +121,28 @@ layout("/mobile/platform.html"){
|
||||
overlay: true,
|
||||
duration: 0
|
||||
})
|
||||
const resp = await $.post("/mobile/welfare/mine/deleteAddress", { id: content.id })
|
||||
loading.close()
|
||||
let resp = {}
|
||||
try {
|
||||
resp = await $.post("/mobile/welfare/mine/deleteAddress", { id: content.id })
|
||||
} finally {
|
||||
this.closeToastLoading(loading)
|
||||
}
|
||||
if (resp.code === 0) {
|
||||
this.$toast.success(resp.msg)
|
||||
this.$nextTick(() => {
|
||||
this.back()
|
||||
})
|
||||
}
|
||||
},
|
||||
closeToastLoading(loading) {
|
||||
if (loading && typeof loading.clear === "function") {
|
||||
loading.clear()
|
||||
} else if (loading && typeof loading.close === "function") {
|
||||
loading.close()
|
||||
}
|
||||
if (this.$toast && typeof this.$toast.clear === "function") {
|
||||
this.$toast.clear()
|
||||
}
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
|
||||
@@ -142,24 +142,26 @@ layout("/layouts/platform.html"){
|
||||
function ensureAddressDzOption(options, row) {
|
||||
const provinceTemplate = chengShiList.find((c) => c.label === row.province)
|
||||
const cityTemplate = provinceTemplate?.children?.find((c) => c.label === row.city)
|
||||
if (!provinceTemplate || !cityTemplate) {
|
||||
if (!row.province || !row.city) {
|
||||
return options
|
||||
}
|
||||
const nextOptions = JSON.parse(JSON.stringify(options))
|
||||
let province = nextOptions.find((c) => c.label === row.province)
|
||||
if (!province) {
|
||||
province = {...provinceTemplate, children: []}
|
||||
province = provinceTemplate ? {...provinceTemplate, children: []} : {label: row.province, value: row.province, children: []}
|
||||
nextOptions.push(province)
|
||||
}
|
||||
let city = province.children.find((c) => c.label === row.city)
|
||||
if (!city) {
|
||||
city = {...cityTemplate, children: []}
|
||||
city = cityTemplate ? {...cityTemplate, children: []} : {label: row.city, value: row.city, children: []}
|
||||
province.children.push(city)
|
||||
}
|
||||
if (row.county) {
|
||||
const countyTemplate = cityTemplate.children?.find((c) => c.label === row.county)
|
||||
const countyTemplate = cityTemplate?.children?.find((c) => c.label === row.county)
|
||||
if (countyTemplate && !city.children.find((c) => c.label === row.county)) {
|
||||
city.children.push(countyTemplate)
|
||||
} else if (!countyTemplate && !city.children.find((c) => c.label === row.county)) {
|
||||
city.children.push({label: row.county, value: row.areaCode || row.county})
|
||||
}
|
||||
}
|
||||
return nextOptions
|
||||
@@ -209,16 +211,19 @@ layout("/layouts/platform.html"){
|
||||
)
|
||||
},
|
||||
handleChange(val) {
|
||||
if (val) {
|
||||
if (val && val.length > 0) {
|
||||
let provinceName = ""
|
||||
let cityName = ""
|
||||
let countyName = ""
|
||||
const province = this.dzOptions.find((c) => c.value === val[0])
|
||||
if (!province) return
|
||||
provinceName = province.label
|
||||
const city = province.children.find((p) => p.value === val[1])
|
||||
if (!city) return
|
||||
cityName = city.label
|
||||
if (val.length === 3) {
|
||||
const county = city.children.find((p) => p.value === val[2])
|
||||
if (!county) return
|
||||
countyName = county.label
|
||||
this.$set(this.formData, "areaCode", county.value)
|
||||
} else {
|
||||
@@ -275,17 +280,23 @@ layout("/layouts/platform.html"){
|
||||
},
|
||||
openEdit(row) {
|
||||
this.dzOptions = ensureAddressDzOption(getWelfareReceiveDzOptions(), row)
|
||||
row.addressList = []
|
||||
const addressList = []
|
||||
const province = this.dzOptions.find((c) => c.label === row.province)
|
||||
row.addressList.push(province.value)
|
||||
const city = province.children.find((p) => p.label === row.city)
|
||||
row.addressList.push(city.value)
|
||||
if (row.county) {
|
||||
if (province) {
|
||||
addressList.push(province.value)
|
||||
}
|
||||
const city = province?.children?.find((p) => p.label === row.city)
|
||||
if (city) {
|
||||
addressList.push(city.value)
|
||||
}
|
||||
if (row.county && city) {
|
||||
const county = city.children.find((p) => p.label === row.county)
|
||||
row.addressList.push(county.value)
|
||||
if (county) {
|
||||
addressList.push(county.value)
|
||||
}
|
||||
}
|
||||
|
||||
this.formData = { ...row }
|
||||
this.formData = { ...row, addressList }
|
||||
this.formData.isDefault = this.formData.isDefault ? "1" : "0"
|
||||
this.dialogVisible = true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user