xianniu-ui 0.8.26 → 0.8.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/xianniu-ui.common.js +53 -34
- package/lib/xianniu-ui.umd.js +53 -34
- package/lib/xianniu-ui.umd.min.js +2 -2
- package/package.json +1 -1
- package/packages/city/main.vue +21 -7
package/package.json
CHANGED
package/packages/city/main.vue
CHANGED
|
@@ -188,12 +188,9 @@ export default {
|
|
|
188
188
|
return recursive(data);
|
|
189
189
|
},
|
|
190
190
|
// 获取选中
|
|
191
|
-
handleChange(
|
|
191
|
+
handleChange(code) {
|
|
192
192
|
// 返回数组形式 code和label
|
|
193
|
-
const cityName = this.
|
|
194
|
-
const city = this.handleTreeLabel(cityCode, this.cityList, 2);
|
|
195
|
-
const cityCodeLast = cityCode[cityCode.length - 1];
|
|
196
|
-
const cityNameLast = cityName[cityName.length - 1];
|
|
193
|
+
const { city, cityCode, cityName, cityCodeLast, cityNameLast } = this.getRes(code);
|
|
197
194
|
let value = "";
|
|
198
195
|
if (this.valueKey) {
|
|
199
196
|
value = city[city.length - 1];
|
|
@@ -209,6 +206,20 @@ export default {
|
|
|
209
206
|
cityNameLast,
|
|
210
207
|
});
|
|
211
208
|
},
|
|
209
|
+
// 获取结果
|
|
210
|
+
getRes(cityCode) {
|
|
211
|
+
const cityName = this.handleTreeLabel(cityCode, this.cityList);
|
|
212
|
+
const city = this.handleTreeLabel(cityCode, this.cityList, 2);
|
|
213
|
+
const cityCodeLast = cityCode[cityCode.length - 1];
|
|
214
|
+
const cityNameLast = cityName[cityName.length - 1];
|
|
215
|
+
return {
|
|
216
|
+
city,
|
|
217
|
+
cityCode,
|
|
218
|
+
cityName,
|
|
219
|
+
cityCodeLast,
|
|
220
|
+
cityNameLast,
|
|
221
|
+
};
|
|
222
|
+
},
|
|
212
223
|
/**
|
|
213
224
|
* 根据城市code 获取对应的城市
|
|
214
225
|
* @param {Array} val 选中的城市code
|
|
@@ -253,7 +264,9 @@ export default {
|
|
|
253
264
|
const [cityName, ...rest] = nameList;
|
|
254
265
|
const item =
|
|
255
266
|
data &&
|
|
256
|
-
data.find(
|
|
267
|
+
data.find(
|
|
268
|
+
(i) => i.cityName === cityName || cityName.indexOf(i.cityName) > -1
|
|
269
|
+
);
|
|
257
270
|
if (item) {
|
|
258
271
|
return [item.cityCode, ...this.getCity(item.subCitys, rest)];
|
|
259
272
|
} else {
|
|
@@ -270,7 +283,8 @@ export default {
|
|
|
270
283
|
return ZXCITY.includes(item) && idx === 0 ? [item, ...arr] : arr;
|
|
271
284
|
})[0];
|
|
272
285
|
const arr = this.getCity(this.cityList, newarr);
|
|
273
|
-
|
|
286
|
+
const res = this.getRes(arr);
|
|
287
|
+
return { ...res };
|
|
274
288
|
},
|
|
275
289
|
},
|
|
276
290
|
};
|