mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-10-14 12:42:10 +08:00
build: compile 0.5.22
This commit is contained in:
parent
a5436e3328
commit
38fe9befb9
61
dist/area/index.js
vendored
61
dist/area/index.js
vendored
@ -1,5 +1,6 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { pickerProps } from '../picker/shared';
|
||||
const COLUMNSPLACEHOLDERCODE = '000000';
|
||||
VantComponent({
|
||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||
props: Object.assign({}, pickerProps, { value: String, areaList: {
|
||||
@ -8,10 +9,22 @@ VantComponent({
|
||||
}, columnsNum: {
|
||||
type: [String, Number],
|
||||
value: 3
|
||||
}, columnsPlaceholder: {
|
||||
type: Array,
|
||||
observer(val) {
|
||||
this.setData({
|
||||
typeToColumnsPlaceholder: {
|
||||
province: val[0] || '',
|
||||
city: val[1] || '',
|
||||
county: val[2] || '',
|
||||
}
|
||||
});
|
||||
}
|
||||
} }),
|
||||
data: {
|
||||
columns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||
displayColumns: [{ values: [] }, { values: [] }, { values: [] }]
|
||||
displayColumns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||
typeToColumnsPlaceholder: {}
|
||||
},
|
||||
watch: {
|
||||
value(value) {
|
||||
@ -41,20 +54,40 @@ VantComponent({
|
||||
this.emit('cancel', event.detail);
|
||||
},
|
||||
onConfirm(event) {
|
||||
this.emit('confirm', event.detail);
|
||||
const { index } = event.detail;
|
||||
let { value } = event.detail;
|
||||
value = this.parseOutputValues(value);
|
||||
this.emit('confirm', { value, index });
|
||||
},
|
||||
emit(type, detail) {
|
||||
detail.values = detail.value;
|
||||
delete detail.value;
|
||||
this.$emit(type, detail);
|
||||
},
|
||||
// parse output columns data
|
||||
parseOutputValues(values) {
|
||||
const { columnsPlaceholder } = this.data;
|
||||
return values.map((value, index) => {
|
||||
// save undefined value
|
||||
if (!value)
|
||||
return value;
|
||||
value = JSON.parse(JSON.stringify(value));
|
||||
if (!value.code || value.name === columnsPlaceholder[index]) {
|
||||
value.code = '';
|
||||
value.name = '';
|
||||
}
|
||||
return value;
|
||||
});
|
||||
},
|
||||
onChange(event) {
|
||||
const { index, picker, value } = event.detail;
|
||||
this.code = value[index].code;
|
||||
let getValues = picker.getValues();
|
||||
getValues = this.parseOutputValues(getValues);
|
||||
this.setValues().then(() => {
|
||||
this.$emit('change', {
|
||||
picker,
|
||||
values: picker.getValues(),
|
||||
values: getValues,
|
||||
index
|
||||
});
|
||||
});
|
||||
@ -64,6 +97,7 @@ VantComponent({
|
||||
return (areaList && areaList[`${type}_list`]) || {};
|
||||
},
|
||||
getList(type, code) {
|
||||
const { typeToColumnsPlaceholder } = this.data;
|
||||
let result = [];
|
||||
if (type !== 'province' && !code) {
|
||||
return result;
|
||||
@ -80,6 +114,14 @@ VantComponent({
|
||||
}
|
||||
result = result.filter(item => item.code.indexOf(code) === 0);
|
||||
}
|
||||
if (typeToColumnsPlaceholder[type] && result.length) {
|
||||
// set columns placeholder
|
||||
const codeFill = type === 'province' ? '' : type === 'city' ? COLUMNSPLACEHOLDERCODE.slice(2, 4) : COLUMNSPLACEHOLDERCODE.slice(4, 6);
|
||||
result.unshift({
|
||||
code: `${code}${codeFill}`,
|
||||
name: typeToColumnsPlaceholder[type]
|
||||
});
|
||||
}
|
||||
return result;
|
||||
},
|
||||
getIndex(type, code) {
|
||||
@ -99,7 +141,18 @@ VantComponent({
|
||||
},
|
||||
setValues() {
|
||||
const county = this.getConfig('county');
|
||||
let code = this.code || Object.keys(county)[0] || '';
|
||||
let { code } = this;
|
||||
if (!code) {
|
||||
if (this.data.columnsPlaceholder.length) {
|
||||
code = COLUMNSPLACEHOLDERCODE;
|
||||
}
|
||||
else if (Object.keys(county)[0]) {
|
||||
code = Object.keys(county)[0];
|
||||
}
|
||||
else {
|
||||
code = '';
|
||||
}
|
||||
}
|
||||
const province = this.getList('province');
|
||||
const city = this.getList('city', code.slice(0, 2));
|
||||
const picker = this.getPicker();
|
||||
|
@ -13,6 +13,7 @@ var __assign = (this && this.__assign) || function () {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var shared_1 = require("../picker/shared");
|
||||
var COLUMNSPLACEHOLDERCODE = '000000';
|
||||
component_1.VantComponent({
|
||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||
props: __assign({}, shared_1.pickerProps, { value: String, areaList: {
|
||||
@ -21,10 +22,22 @@ component_1.VantComponent({
|
||||
}, columnsNum: {
|
||||
type: [String, Number],
|
||||
value: 3
|
||||
}, columnsPlaceholder: {
|
||||
type: Array,
|
||||
observer: function (val) {
|
||||
this.setData({
|
||||
typeToColumnsPlaceholder: {
|
||||
province: val[0] || '',
|
||||
city: val[1] || '',
|
||||
county: val[2] || '',
|
||||
}
|
||||
});
|
||||
}
|
||||
} }),
|
||||
data: {
|
||||
columns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||
displayColumns: [{ values: [] }, { values: [] }, { values: [] }]
|
||||
displayColumns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||
typeToColumnsPlaceholder: {}
|
||||
},
|
||||
watch: {
|
||||
value: function (value) {
|
||||
@ -55,21 +68,41 @@ component_1.VantComponent({
|
||||
this.emit('cancel', event.detail);
|
||||
},
|
||||
onConfirm: function (event) {
|
||||
this.emit('confirm', event.detail);
|
||||
var index = event.detail.index;
|
||||
var value = event.detail.value;
|
||||
value = this.parseOutputValues(value);
|
||||
this.emit('confirm', { value: value, index: index });
|
||||
},
|
||||
emit: function (type, detail) {
|
||||
detail.values = detail.value;
|
||||
delete detail.value;
|
||||
this.$emit(type, detail);
|
||||
},
|
||||
// parse output columns data
|
||||
parseOutputValues: function (values) {
|
||||
var columnsPlaceholder = this.data.columnsPlaceholder;
|
||||
return values.map(function (value, index) {
|
||||
// save undefined value
|
||||
if (!value)
|
||||
return value;
|
||||
value = JSON.parse(JSON.stringify(value));
|
||||
if (!value.code || value.name === columnsPlaceholder[index]) {
|
||||
value.code = '';
|
||||
value.name = '';
|
||||
}
|
||||
return value;
|
||||
});
|
||||
},
|
||||
onChange: function (event) {
|
||||
var _this = this;
|
||||
var _a = event.detail, index = _a.index, picker = _a.picker, value = _a.value;
|
||||
this.code = value[index].code;
|
||||
var getValues = picker.getValues();
|
||||
getValues = this.parseOutputValues(getValues);
|
||||
this.setValues().then(function () {
|
||||
_this.$emit('change', {
|
||||
picker: picker,
|
||||
values: picker.getValues(),
|
||||
values: getValues,
|
||||
index: index
|
||||
});
|
||||
});
|
||||
@ -79,6 +112,7 @@ component_1.VantComponent({
|
||||
return (areaList && areaList[type + "_list"]) || {};
|
||||
},
|
||||
getList: function (type, code) {
|
||||
var typeToColumnsPlaceholder = this.data.typeToColumnsPlaceholder;
|
||||
var result = [];
|
||||
if (type !== 'province' && !code) {
|
||||
return result;
|
||||
@ -95,6 +129,14 @@ component_1.VantComponent({
|
||||
}
|
||||
result = result.filter(function (item) { return item.code.indexOf(code) === 0; });
|
||||
}
|
||||
if (typeToColumnsPlaceholder[type] && result.length) {
|
||||
// set columns placeholder
|
||||
var codeFill = type === 'province' ? '' : type === 'city' ? COLUMNSPLACEHOLDERCODE.slice(2, 4) : COLUMNSPLACEHOLDERCODE.slice(4, 6);
|
||||
result.unshift({
|
||||
code: "" + code + codeFill,
|
||||
name: typeToColumnsPlaceholder[type]
|
||||
});
|
||||
}
|
||||
return result;
|
||||
},
|
||||
getIndex: function (type, code) {
|
||||
@ -115,7 +157,18 @@ component_1.VantComponent({
|
||||
setValues: function () {
|
||||
var _this = this;
|
||||
var county = this.getConfig('county');
|
||||
var code = this.code || Object.keys(county)[0] || '';
|
||||
var code = this.code;
|
||||
if (!code) {
|
||||
if (this.data.columnsPlaceholder.length) {
|
||||
code = COLUMNSPLACEHOLDERCODE;
|
||||
}
|
||||
else if (Object.keys(county)[0]) {
|
||||
code = Object.keys(county)[0];
|
||||
}
|
||||
else {
|
||||
code = '';
|
||||
}
|
||||
}
|
||||
var province = this.getList('province');
|
||||
var city = this.getList('city', code.slice(0, 2));
|
||||
var picker = this.getPicker();
|
||||
|
Loading…
x
Reference in New Issue
Block a user