Commit dfe4d84e by caoyanzhi

fix: 修复会员标签-常驻城市编辑保存时,cityId不对的bug

parent d8685fd5
...@@ -1487,7 +1487,7 @@ export default { ...@@ -1487,7 +1487,7 @@ export default {
*/ */
getcityData() { getcityData() {
const para = { requestProject: 'member-tag' }; const para = { requestProject: 'member-tag' };
this.axios return this.axios
.post(`${this.baseUrl}/api-plug/dict-district-tree`, qs.stringify(para)) .post(`${this.baseUrl}/api-plug/dict-district-tree`, qs.stringify(para))
.then(res => { .then(res => {
if (res.data.errorCode === 0) { if (res.data.errorCode === 0) {
...@@ -1655,6 +1655,27 @@ export default { ...@@ -1655,6 +1655,27 @@ export default {
return item; return item;
}); });
}, },
getCityId(city) {
const [cName, pName] = city.split('-');
const result = { cityId: '', pId: '' };
this.tag010.citySelectOptions.some(province => {
const { provinceName, provinceId, children } = province;
if (pName == provinceName) {
result.pId = provinceId;
if (Array.isArray(children)) {
children.some(city => {
const { cityId, cityName } = city;
if (cName == cityName) {
result.cityId = cityId;
}
return cName == cityName;
})
}
}
return provinceName == province.provinceId;
})
return result;
},
/** /**
* 将tagValue 替代模板数据的v-model * 将tagValue 替代模板数据的v-model
...@@ -1686,10 +1707,12 @@ export default { ...@@ -1686,10 +1707,12 @@ export default {
selectVal = tagParams.selectedVal[1].split(','); selectVal = tagParams.selectedVal[1].split(',');
selectVal.forEach((item, index) => { selectVal.forEach((item, index) => {
const { cityId, pId } = this.getCityId(item);
this.templateData[i].citySelectedOptions.push({ this.templateData[i].citySelectedOptions.push({
selected: selectVal[index], selected: selectVal[index],
cityName: selectVal[index], cityName: selectVal[index],
cityId: item cityId,
pId
}); });
}); });
setTimeout(_ => { setTimeout(_ => {
...@@ -2146,10 +2169,12 @@ export default { ...@@ -2146,10 +2169,12 @@ export default {
} }
}, },
mounted() { mounted() {
this.getcityData().finally(() => {
// 存在id // 存在id
if (this.id) { if (this.id) {
this._getTagType(this.id); this._getTagType(this.id);
} }
});
}, },
filters: { filters: {
aliasTips(name) { aliasTips(name) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment