xianniu-ui 0.8.47 → 0.8.48
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 +109 -63
- package/lib/xianniu-ui.umd.js +109 -63
- package/lib/xianniu-ui.umd.min.js +7 -7
- package/package.json +1 -1
- package/packages/city/main.vue +79 -32
package/package.json
CHANGED
package/packages/city/main.vue
CHANGED
|
@@ -33,7 +33,7 @@ export default {
|
|
|
33
33
|
* 省级 -> 省
|
|
34
34
|
*/
|
|
35
35
|
value: {
|
|
36
|
-
type: [String, Number, Object],
|
|
36
|
+
type: [String, Number, Object, Array],
|
|
37
37
|
default: "",
|
|
38
38
|
},
|
|
39
39
|
valueKey: {
|
|
@@ -67,10 +67,10 @@ export default {
|
|
|
67
67
|
/**
|
|
68
68
|
* 是否全国
|
|
69
69
|
*/
|
|
70
|
-
isAll:{
|
|
71
|
-
type:Boolean,
|
|
72
|
-
default:false
|
|
73
|
-
}
|
|
70
|
+
isAll: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: false,
|
|
73
|
+
},
|
|
74
74
|
},
|
|
75
75
|
data() {
|
|
76
76
|
return {
|
|
@@ -88,17 +88,41 @@ export default {
|
|
|
88
88
|
};
|
|
89
89
|
},
|
|
90
90
|
computed: {
|
|
91
|
+
// cityValue: {
|
|
92
|
+
// set: function (n) {
|
|
93
|
+
// this.val = n;
|
|
94
|
+
// },
|
|
95
|
+
// get: function () {
|
|
96
|
+
// const { value, valueKey } = this;
|
|
97
|
+
// const _value = valueKey ? value[valueKey] : value;
|
|
98
|
+
// const res = this.findParent(_value, this.flattenResult).map(
|
|
99
|
+
// (item) => item.cityCode
|
|
100
|
+
// );
|
|
101
|
+
// return res;
|
|
102
|
+
// },
|
|
103
|
+
// },
|
|
91
104
|
cityValue: {
|
|
92
105
|
set: function (n) {
|
|
93
106
|
this.val = n;
|
|
94
107
|
},
|
|
95
108
|
get: function () {
|
|
96
109
|
const { value, valueKey } = this;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
if (Array.isArray(value)) {
|
|
111
|
+
return value.map((v) => {
|
|
112
|
+
const _value = valueKey ? v[valueKey] : v;
|
|
113
|
+
const res = this.findParent(_value, this.flattenResult).map(
|
|
114
|
+
(item) => item.cityCode
|
|
115
|
+
);
|
|
116
|
+
return res;
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
const _value = valueKey ? value[valueKey] : value;
|
|
120
|
+
const res = this.findParent(_value, this.flattenResult).map(
|
|
121
|
+
(item) => item.cityCode
|
|
122
|
+
);
|
|
123
|
+
console.log('123',res);
|
|
124
|
+
return res;
|
|
125
|
+
}
|
|
102
126
|
},
|
|
103
127
|
},
|
|
104
128
|
},
|
|
@@ -168,11 +192,11 @@ export default {
|
|
|
168
192
|
// 接口获取城市联动数据
|
|
169
193
|
fnGetCitys() {
|
|
170
194
|
const cityArr = citys;
|
|
171
|
-
if(this.isAll){
|
|
195
|
+
if (this.isAll) {
|
|
172
196
|
cityArr.unshift({
|
|
173
|
-
cityName:
|
|
174
|
-
cityCode:
|
|
175
|
-
})
|
|
197
|
+
cityName: "全国",
|
|
198
|
+
cityCode: "000000",
|
|
199
|
+
});
|
|
176
200
|
}
|
|
177
201
|
const _citys = this.$utils.deepClone(cityArr);
|
|
178
202
|
this.cityList = this.toTreeDataLevel(_citys);
|
|
@@ -202,23 +226,47 @@ export default {
|
|
|
202
226
|
return recursive(data);
|
|
203
227
|
},
|
|
204
228
|
// 获取选中
|
|
229
|
+
// handleChange(code) {
|
|
230
|
+
// // 返回数组形式 code和label
|
|
231
|
+
// const { city, cityCode, cityName, cityCodeLast, cityNameLast } = this.getRes(code);
|
|
232
|
+
// let value = "";
|
|
233
|
+
// if (this.valueKey) {
|
|
234
|
+
// value = city[city.length - 1];
|
|
235
|
+
// } else {
|
|
236
|
+
// value = cityCodeLast;
|
|
237
|
+
// }
|
|
238
|
+
// this.$emit("on-change", value);
|
|
239
|
+
// this.$emit("on-city", {
|
|
240
|
+
// city,
|
|
241
|
+
// cityCode,
|
|
242
|
+
// cityName,
|
|
243
|
+
// cityCodeLast,
|
|
244
|
+
// cityNameLast,
|
|
245
|
+
// });
|
|
246
|
+
// },
|
|
205
247
|
handleChange(code) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
248
|
+
const changeResults = Array.isArray(code)
|
|
249
|
+
? code.map((c) => this.getRes(c))
|
|
250
|
+
: this.getRes(code);
|
|
251
|
+
|
|
252
|
+
const value = changeResults.map(({ cityCodeLast }) =>
|
|
253
|
+
this.valueKey ? code : cityCodeLast
|
|
254
|
+
);
|
|
255
|
+
|
|
214
256
|
this.$emit("on-change", value);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
cityCode,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
257
|
+
|
|
258
|
+
const cityResults = changeResults.map((res) => {
|
|
259
|
+
const { city, cityCode, cityName, cityCodeLast, cityNameLast } = res;
|
|
260
|
+
return {
|
|
261
|
+
city,
|
|
262
|
+
cityCode,
|
|
263
|
+
cityName,
|
|
264
|
+
cityCodeLast,
|
|
265
|
+
cityNameLast,
|
|
266
|
+
};
|
|
221
267
|
});
|
|
268
|
+
|
|
269
|
+
this.$emit("on-city", cityResults);
|
|
222
270
|
},
|
|
223
271
|
// 获取结果
|
|
224
272
|
getRes(cityCode) {
|
|
@@ -291,14 +339,13 @@ export default {
|
|
|
291
339
|
if (!val) return;
|
|
292
340
|
val = val.replace(/[^\u4e00-\u9fa5]/g, "");
|
|
293
341
|
const cityArr = val.match(this.$reg.getCity) || [];
|
|
294
|
-
console.log("🚀 ~ str2Code ~ this.$reg.getCity:", this.$reg.getCity)
|
|
295
|
-
console.log("🚀 ~ str2Code ~ cityArr:", cityArr)
|
|
296
342
|
const newarr =
|
|
297
343
|
cityArr.length &&
|
|
298
344
|
cityArr.map((item, idx, arr) => {
|
|
299
|
-
return ZXCITY.includes(item) && idx === 0 && arr.length == 2
|
|
345
|
+
return ZXCITY.includes(item) && idx === 0 && arr.length == 2
|
|
346
|
+
? [item, ...arr]
|
|
347
|
+
: arr;
|
|
300
348
|
})[0];
|
|
301
|
-
console.log(newarr)
|
|
302
349
|
const arr = this.getCity(this.cityList, newarr);
|
|
303
350
|
const res = this.getRes(arr);
|
|
304
351
|
return { ...res };
|