mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-10-14 20:52: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 { VantComponent } from '../common/component';
|
||||||
import { pickerProps } from '../picker/shared';
|
import { pickerProps } from '../picker/shared';
|
||||||
|
const COLUMNSPLACEHOLDERCODE = '000000';
|
||||||
VantComponent({
|
VantComponent({
|
||||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||||
props: Object.assign({}, pickerProps, { value: String, areaList: {
|
props: Object.assign({}, pickerProps, { value: String, areaList: {
|
||||||
@ -8,10 +9,22 @@ VantComponent({
|
|||||||
}, columnsNum: {
|
}, columnsNum: {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
value: 3
|
value: 3
|
||||||
|
}, columnsPlaceholder: {
|
||||||
|
type: Array,
|
||||||
|
observer(val) {
|
||||||
|
this.setData({
|
||||||
|
typeToColumnsPlaceholder: {
|
||||||
|
province: val[0] || '',
|
||||||
|
city: val[1] || '',
|
||||||
|
county: val[2] || '',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} }),
|
} }),
|
||||||
data: {
|
data: {
|
||||||
columns: [{ values: [] }, { values: [] }, { values: [] }],
|
columns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||||
displayColumns: [{ values: [] }, { values: [] }, { values: [] }]
|
displayColumns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||||
|
typeToColumnsPlaceholder: {}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value(value) {
|
value(value) {
|
||||||
@ -41,20 +54,40 @@ VantComponent({
|
|||||||
this.emit('cancel', event.detail);
|
this.emit('cancel', event.detail);
|
||||||
},
|
},
|
||||||
onConfirm(event) {
|
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) {
|
emit(type, detail) {
|
||||||
detail.values = detail.value;
|
detail.values = detail.value;
|
||||||
delete detail.value;
|
delete detail.value;
|
||||||
this.$emit(type, detail);
|
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) {
|
onChange(event) {
|
||||||
const { index, picker, value } = event.detail;
|
const { index, picker, value } = event.detail;
|
||||||
this.code = value[index].code;
|
this.code = value[index].code;
|
||||||
|
let getValues = picker.getValues();
|
||||||
|
getValues = this.parseOutputValues(getValues);
|
||||||
this.setValues().then(() => {
|
this.setValues().then(() => {
|
||||||
this.$emit('change', {
|
this.$emit('change', {
|
||||||
picker,
|
picker,
|
||||||
values: picker.getValues(),
|
values: getValues,
|
||||||
index
|
index
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -64,6 +97,7 @@ VantComponent({
|
|||||||
return (areaList && areaList[`${type}_list`]) || {};
|
return (areaList && areaList[`${type}_list`]) || {};
|
||||||
},
|
},
|
||||||
getList(type, code) {
|
getList(type, code) {
|
||||||
|
const { typeToColumnsPlaceholder } = this.data;
|
||||||
let result = [];
|
let result = [];
|
||||||
if (type !== 'province' && !code) {
|
if (type !== 'province' && !code) {
|
||||||
return result;
|
return result;
|
||||||
@ -80,6 +114,14 @@ VantComponent({
|
|||||||
}
|
}
|
||||||
result = result.filter(item => item.code.indexOf(code) === 0);
|
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;
|
return result;
|
||||||
},
|
},
|
||||||
getIndex(type, code) {
|
getIndex(type, code) {
|
||||||
@ -99,7 +141,18 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
setValues() {
|
setValues() {
|
||||||
const county = this.getConfig('county');
|
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 province = this.getList('province');
|
||||||
const city = this.getList('city', code.slice(0, 2));
|
const city = this.getList('city', code.slice(0, 2));
|
||||||
const picker = this.getPicker();
|
const picker = this.getPicker();
|
||||||
|
@ -13,6 +13,7 @@ var __assign = (this && this.__assign) || function () {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
var component_1 = require("../common/component");
|
var component_1 = require("../common/component");
|
||||||
var shared_1 = require("../picker/shared");
|
var shared_1 = require("../picker/shared");
|
||||||
|
var COLUMNSPLACEHOLDERCODE = '000000';
|
||||||
component_1.VantComponent({
|
component_1.VantComponent({
|
||||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||||
props: __assign({}, shared_1.pickerProps, { value: String, areaList: {
|
props: __assign({}, shared_1.pickerProps, { value: String, areaList: {
|
||||||
@ -21,10 +22,22 @@ component_1.VantComponent({
|
|||||||
}, columnsNum: {
|
}, columnsNum: {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
value: 3
|
value: 3
|
||||||
|
}, columnsPlaceholder: {
|
||||||
|
type: Array,
|
||||||
|
observer: function (val) {
|
||||||
|
this.setData({
|
||||||
|
typeToColumnsPlaceholder: {
|
||||||
|
province: val[0] || '',
|
||||||
|
city: val[1] || '',
|
||||||
|
county: val[2] || '',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} }),
|
} }),
|
||||||
data: {
|
data: {
|
||||||
columns: [{ values: [] }, { values: [] }, { values: [] }],
|
columns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||||
displayColumns: [{ values: [] }, { values: [] }, { values: [] }]
|
displayColumns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||||
|
typeToColumnsPlaceholder: {}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value: function (value) {
|
value: function (value) {
|
||||||
@ -55,21 +68,41 @@ component_1.VantComponent({
|
|||||||
this.emit('cancel', event.detail);
|
this.emit('cancel', event.detail);
|
||||||
},
|
},
|
||||||
onConfirm: function (event) {
|
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) {
|
emit: function (type, detail) {
|
||||||
detail.values = detail.value;
|
detail.values = detail.value;
|
||||||
delete detail.value;
|
delete detail.value;
|
||||||
this.$emit(type, detail);
|
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) {
|
onChange: function (event) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var _a = event.detail, index = _a.index, picker = _a.picker, value = _a.value;
|
var _a = event.detail, index = _a.index, picker = _a.picker, value = _a.value;
|
||||||
this.code = value[index].code;
|
this.code = value[index].code;
|
||||||
|
var getValues = picker.getValues();
|
||||||
|
getValues = this.parseOutputValues(getValues);
|
||||||
this.setValues().then(function () {
|
this.setValues().then(function () {
|
||||||
_this.$emit('change', {
|
_this.$emit('change', {
|
||||||
picker: picker,
|
picker: picker,
|
||||||
values: picker.getValues(),
|
values: getValues,
|
||||||
index: index
|
index: index
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -79,6 +112,7 @@ component_1.VantComponent({
|
|||||||
return (areaList && areaList[type + "_list"]) || {};
|
return (areaList && areaList[type + "_list"]) || {};
|
||||||
},
|
},
|
||||||
getList: function (type, code) {
|
getList: function (type, code) {
|
||||||
|
var typeToColumnsPlaceholder = this.data.typeToColumnsPlaceholder;
|
||||||
var result = [];
|
var result = [];
|
||||||
if (type !== 'province' && !code) {
|
if (type !== 'province' && !code) {
|
||||||
return result;
|
return result;
|
||||||
@ -95,6 +129,14 @@ component_1.VantComponent({
|
|||||||
}
|
}
|
||||||
result = result.filter(function (item) { return item.code.indexOf(code) === 0; });
|
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;
|
return result;
|
||||||
},
|
},
|
||||||
getIndex: function (type, code) {
|
getIndex: function (type, code) {
|
||||||
@ -115,7 +157,18 @@ component_1.VantComponent({
|
|||||||
setValues: function () {
|
setValues: function () {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var county = this.getConfig('county');
|
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 province = this.getList('province');
|
||||||
var city = this.getList('city', code.slice(0, 2));
|
var city = this.getList('city', code.slice(0, 2));
|
||||||
var picker = this.getPicker();
|
var picker = this.getPicker();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user