diff --git a/src/views/system/tenant/component/editTenant.vue b/src/views/system/tenant/component/editTenant.vue index fea30d4..e877f5b 100644 --- a/src/views/system/tenant/component/editTenant.vue +++ b/src/views/system/tenant/component/editTenant.vue @@ -212,30 +212,23 @@ const passwordStrengthClass = computed(() => { const openDialog = (row?: any) => { resetForm(); if (row) { - // 处理城市回显:如果是字符串且以00结尾,去掉00并转为数组(这里简化处理,实际可能需要根据code反查路径) - // 假设 row.city 是 "110100",element-china-area-data 的 provinceAndCityData 对应的是 "110000", "110100" - // 注意:provinceAndCityData 的二级(市)code 通常不带后缀 00,或者需要具体看数据源 - // 这里假设后端存的是 "110100",前端组件需要 ["110000", "110100"] 形式的路径数组 - // 由于没有反查函数,这里如果 row.city 是字符串,我们暂时将其直接放入数组,或者需要调用专门的工具函数 - // 简单处理:如果 row.city 是字符串,尝试回显 + // 处理城市回显:根据 cityCode 转换为级联选择器需要的数组格式 + // cityCode 是6位代码如 "220100",级联选择器需要 ["22", "2201"] 格式 let cityArray: string[] = []; - if (row.cityMergerName && typeof row.cityMergerName === 'string') { - const storedCode = row.cityMergerName; + const storedCode = row.cityCode; + if (storedCode && typeof storedCode === 'string') { // 判断是否为直辖市代码 (11xxxx, 12xxxx, 31xxxx, 50xxxx) if (/^(11|12|31|50)/.test(storedCode)) { - // 直辖市,回显为 [2位代码] (如 '11') + // 直辖市,回显为省级代码(2位) cityArray = [storedCode.substring(0, 2)]; } else { - // 普通省市,回显为 [2位省代码, 4位市代码] (如 '13', '1301') - // 假设 storedCode 是 6 位,如 130100 + // 普通省市,回显为 [省代码(2位), 市代码(4位)] if (storedCode.length >= 4) { const provinceCode = storedCode.substring(0, 2); const cityCode = storedCode.substring(0, 4); cityArray = [provinceCode, cityCode]; } } - } else if (Array.isArray(row.cityMergerName)) { - cityArray = row.cityMergerName; } state.ruleForm = {