Commit 5c7a3d88 by 张立顺

fix bug

1 parent 1146ee0d
......@@ -298,6 +298,7 @@ export default {
} catch {
return;
}
this.syncEditDataRegionFromProvinceCityRef();
const params = this.buildSubmitVerificationPayload(
merchantBrandList
);
......
......@@ -32,6 +32,21 @@ function parentMerchantSupportsAccountType(parentRow, typeDictValue) {
return allowed.includes(tv);
}
/** 省市区树节点上的行政区划码(高德 adcode;部分网关仅返回 code / citycode) */
function districtTreeNodeCode(node) {
if (!node || typeof node !== "object") return "";
const raw =
node.adcode != null && node.adcode !== ""
? node.adcode
: node.code != null && node.code !== ""
? node.code
: node.citycode != null && node.citycode !== ""
? node.citycode
: "";
if (raw === "" || raw == null) return "";
return String(raw).trim();
}
/** 解析商户名校验接口返回值(boolean / data.exists / data 等) */
export function normalizeMerchantNameDuplicateResponse(res) {
if (res == null) return false;
......@@ -479,13 +494,13 @@ export default {
const v = value == null ? "" : String(value);
if (
!/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,20}$/.test(
v,
v
)
) {
callback(
new Error(
"登录密码须为6-20位,仅字母与数字且须同时包含字母与数字",
),
"登录密码须为6-20位,仅字母与数字且须同时包含字母与数字"
)
);
return false;
}
......@@ -652,9 +667,14 @@ export default {
this.$refs.provinceForm.resetAddressForm();
}
this.$nextTick(() => {
this.$refs.editFormRef?.$refs[
this.editChildRef
]?.clearValidate();
const editForm = this.$refs.editFormRef;
if (
editForm &&
typeof editForm.resetPasswordToggle === "function"
) {
editForm.resetPasswordToggle();
}
editForm?.$refs[this.editChildRef]?.clearValidate();
});
},
getOptionsList(formName, hasAll = true, refreshSigle) {
......@@ -935,6 +955,90 @@ export default {
this.$refs.provinceForm.init(provinceData);
}
},
/**
* 提交前将 ProvinceCity 内部 provinceForm 中的编码补进 editData。
* 地图短路径校验通过时 editData 可能缺 provinceCode;组件内可能已有 adcode。
* 仅补空字段,避免覆盖用户已生效的数据。
*/
syncEditDataRegionFromProvinceCityRef() {
const root = this.$refs.provinceForm;
const pf = root && root.provinceForm;
const norm = (x) =>
x != null && String(x).trim() !== "" ? String(x).trim() : "";
const fill = (key, val) => {
const v = norm(val);
if (v && !norm(this.editData[key])) {
this.editData[key] = v;
}
};
if (pf) {
fill("provinceCode", pf.provinceCode);
fill("cityCode", pf.cityCode);
fill("districtCode", pf.townCode);
fill("provinceName", pf.provinceName);
fill("cityName", pf.cityName);
fill("districtName", pf.townName);
}
if (!root) return;
// 有省名无省码:行政树节点可能只有 code 无 adcode,或地图逆地理仅写入名称
const pname = norm(this.editData.provinceName);
const allData = root.AllData;
if (
pname &&
!norm(this.editData.provinceCode) &&
Array.isArray(allData) &&
allData.length
) {
const prov = allData.find(
(item) =>
item &&
item.name &&
(item.name === pname ||
item.name.indexOf(pname) !== -1 ||
pname.indexOf(item.name) !== -1)
);
const pc = prov ? districtTreeNodeCode(prov) : "";
if (pc) this.editData.provinceCode = pc;
}
const cname = norm(this.editData.cityName);
const cityList = root.cityList;
if (
cname &&
!norm(this.editData.cityCode) &&
Array.isArray(cityList) &&
cityList.length
) {
const city = cityList.find(
(item) =>
item &&
item.name &&
(item.name === cname ||
item.name.indexOf(cname) !== -1 ||
cname.indexOf(item.name) !== -1)
);
const cc = city ? districtTreeNodeCode(city) : "";
if (cc) this.editData.cityCode = cc;
}
const dname = norm(this.editData.districtName);
const townList = root.townList;
if (
dname &&
!norm(this.editData.districtCode) &&
Array.isArray(townList) &&
townList.length
) {
const town = townList.find(
(item) =>
item &&
item.name &&
(item.name === dname ||
item.name.indexOf(dname) !== -1 ||
dname.indexOf(item.name) !== -1)
);
const dc = town ? districtTreeNodeCode(town) : "";
if (dc) this.editData.districtCode = dc;
}
},
selectProvince(val) {
this.$set(this.editData, "detailAddress", "");
this.editData.cityName = "";
......@@ -947,12 +1051,8 @@ export default {
this.editData.longitude = "";
if (val && typeof val === "object" && val.name) {
this.editData.provinceName = val.name;
const pc =
val.adcode != null && val.adcode !== ""
? val.adcode
: val.code;
this.editData.provinceCode =
pc != null && pc !== "" ? String(pc) : "";
const pc = districtTreeNodeCode(val);
this.editData.provinceCode = pc;
} else {
this.editData.provinceName = "";
this.editData.provinceCode = "";
......@@ -961,12 +1061,8 @@ export default {
selectCity(val) {
if (val && typeof val === "object" && val.name) {
this.editData.cityName = val.name;
const cc =
val.adcode != null && val.adcode !== ""
? val.adcode
: val.code;
this.editData.cityCode =
cc != null && cc !== "" ? String(cc) : "";
const cc = districtTreeNodeCode(val);
this.editData.cityCode = cc;
} else {
this.editData.cityName = "";
this.editData.cityCode = "";
......@@ -982,12 +1078,8 @@ export default {
selectTown(val) {
if (val && typeof val === "object" && val.name) {
this.editData.districtName = val.name;
const dc =
val.adcode != null && val.adcode !== ""
? val.adcode
: val.code;
this.editData.districtCode =
dc != null && dc !== "" ? String(dc) : "";
const dc = districtTreeNodeCode(val);
this.editData.districtCode = dc;
} else {
this.editData.districtName = "";
this.editData.districtCode = "";
......
......@@ -163,6 +163,19 @@ export default {
}
},
methods: {
/** 行政区划节点上的编码(高德常用 adcode;部分网关数据为 code / citycode) */
districtNodeCode(node) {
if (!node || typeof node !== 'object') return ''
const raw =
node.adcode != null && node.adcode !== ''
? node.adcode
: node.code != null && node.code !== ''
? node.code
: node.citycode != null && node.citycode !== ''
? node.citycode
: ''
return raw !== '' && raw != null ? String(raw).trim() : ''
},
/*
* @params:传入的为一个key-value的对象
1、keywords --查询关键字,只支持单个关键词语搜索关键词支持:行政区名称、citycode、adcode
......@@ -243,17 +256,17 @@ export default {
if (item.name.indexOf(province) != -1) {
this.provinceForm.provinceName = item.name
this.cityList = item.districts
this.provinceForm.provinceCode = item.adcode
this.provinceForm.provinceCode = this.districtNodeCode(item)
if (city) {
this.cityList.map(itm => {
if (itm.name.indexOf(city) != -1) {
this.provinceForm.cityCode = itm.adcode
this.provinceForm.cityCode = this.districtNodeCode(itm)
this.provinceForm.cityName = itm.name
this.townList = itm.districts
if (townName) {
this.townList.map(itmx => {
if (itmx.name.indexOf(townName) != -1) {
this.provinceForm.townCode = itmx.adcode
this.provinceForm.townCode = this.districtNodeCode(itmx)
this.provinceForm.townName = itmx.name
}
})
......@@ -270,9 +283,14 @@ export default {
this.provinceForm.fullAddress = ''
this.provinceForm.cityName = ''
this.provinceForm.townName = ''
this.provinceForm.cityCode = ''
this.provinceForm.townCode = ''
if (val) {
this.cityList = val.districts
const raw = this.districtNodeCode(val)
this.provinceForm.provinceCode = raw
} else {
this.provinceForm.provinceCode = ''
val = ''
}
// 选择省
......@@ -283,9 +301,13 @@ export default {
this.provinceForm.cityName = val ? val.name : ''
this.provinceForm.fullAddress = ''
this.provinceForm.townName = ''
this.provinceForm.townCode = ''
if (val) {
this.townList = val.districts
const raw = this.districtNodeCode(val)
this.provinceForm.cityCode = raw
} else {
this.provinceForm.cityCode = ''
val = ''
}
// 选择市
......@@ -295,6 +317,12 @@ export default {
selectTown(val) {
this.provinceForm.townName = val ? val.name : ''
this.provinceForm.fullAddress = ''
if (val) {
const raw = this.districtNodeCode(val)
this.provinceForm.townCode = raw
} else {
this.provinceForm.townCode = ''
}
// 选择区
this.$emit('selectTown', val)
},
......@@ -319,7 +347,9 @@ export default {
const adStr =
mapData.adcode != null && mapData.adcode !== ''
? String(mapData.adcode)
: ''
: mapData.code != null && mapData.code !== ''
? String(mapData.code)
: ''
const setCodesFromAdcode = () => {
if (adStr.length >= 3) {
this.provinceForm.provinceCode = String(
......@@ -366,10 +396,7 @@ export default {
this.provinceForm.provinceName = foundP.name
this.cityList = foundP.districts || []
this.provinceForm.provinceCode =
foundP.adcode != null && foundP.adcode !== ''
? String(foundP.adcode)
: ''
this.provinceForm.provinceCode = this.districtNodeCode(foundP)
let foundC = null
for (let j = 0; j < this.cityList.length; j++) {
......@@ -394,9 +421,7 @@ export default {
this.provinceForm.cityName = foundC.name
this.provinceForm.cityCode =
foundC.adcode != null && foundC.adcode !== ''
? String(foundC.adcode)
: adStr
this.districtNodeCode(foundC) || adStr
this.townList = foundC.districts || []
if (this.subdistrict !== 3) {
......@@ -415,10 +440,7 @@ export default {
}
if (foundT) {
this.provinceForm.townName = foundT.name
this.provinceForm.townCode =
foundT.adcode != null && foundT.adcode !== ''
? String(foundT.adcode)
: ''
this.provinceForm.townCode = this.districtNodeCode(foundT)
} else {
this.provinceForm.townName = townName
const tc =
......@@ -457,7 +479,9 @@ export default {
? String(md.town_code)
: md.adcode != null && md.adcode !== ''
? String(md.adcode)
: ''
: md.code != null && md.code !== ''
? String(md.code)
: ''
if (tcMerged) {
this.provinceForm.townCode = tcMerged
}
......@@ -500,6 +524,7 @@ export default {
}
.map-input {
width: 350px !important;
// margin-top: 10px;
::v-deep .el-input__inner {
......
......@@ -264,7 +264,7 @@ export default {
}],
PlatformLevelList: [
{
merchantId: "-1",
merchantId: -1,
showMerchantName: "嘀加智慧云",
merchantName: "嘀加智慧云",
userType: 1,
......
......@@ -263,7 +263,7 @@ export default {
merchantLevelList: [],
PlatformLevelList: [
{
merchantId: "-1",
merchantId: -1,
showMerchantName: "嘀加智慧云",
merchantName: "嘀加智慧云",
// userType: res.userType
......@@ -442,10 +442,9 @@ export default {
}
},
"financialObj.realityShopMerchantId": {
handler(val) {
// this.financialObj.realityShopMerchantId
handler(newVal, oldVal) {
const obj = this.baseData.merchantLevelList.find(
(item) => item.merchantId == val
(item) => item.merchantId == newVal
)
if (obj) {
const shop = {
......@@ -455,13 +454,13 @@ export default {
}
this.financialObj = Object.assign(this.financialObj, shop)
}
this._maybeInvalidateDivisionTabsForLedgerFieldChange(newVal, oldVal)
}
},
"financialObj.realityPlatformMerchantId": {
handler(val) {
// this.financialObj.realityShopMerchantId
handler(newVal, oldVal) {
const obj = this.baseData.PlatformLevelList.find(
(item) => item.merchantId == val
(item) => item.merchantId == newVal
)
if (obj) {
const Platform = {
......@@ -471,6 +470,7 @@ export default {
}
this.financialObj = Object.assign(this.financialObj, Platform)
}
this._maybeInvalidateDivisionTabsForLedgerFieldChange(newVal, oldVal)
}
},
"financialObj.multiPlatformMerchantFlag": {
......@@ -493,12 +493,6 @@ export default {
},
immediate: true
},
"financialObj.realityShopMerchantId"(newVal, oldVal) {
this._maybeInvalidateDivisionTabsForLedgerFieldChange(newVal, oldVal)
},
"financialObj.realityPlatformMerchantId"(newVal, oldVal) {
this._maybeInvalidateDivisionTabsForLedgerFieldChange(newVal, oldVal)
},
"financialObj.djzhySubMerchantId"(newVal, oldVal) {
this._maybeInvalidateDivisionTabsForLedgerFieldChange(newVal, oldVal)
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!