[new feature] Area: add is-oversea-code prop (#4163)
This commit is contained in:
+11
-3
@@ -4,6 +4,10 @@ import { pickerProps } from '../picker/shared';
|
||||
|
||||
const [createComponent, bem] = createNamespace('area');
|
||||
|
||||
function isOverseaCode(code) {
|
||||
return code[0] === '9';
|
||||
}
|
||||
|
||||
export default createComponent({
|
||||
props: {
|
||||
...pickerProps,
|
||||
@@ -15,6 +19,10 @@ export default createComponent({
|
||||
columnsNum: {
|
||||
type: [Number, String],
|
||||
default: 3
|
||||
},
|
||||
isOverseaCode: {
|
||||
type: Function,
|
||||
default: isOverseaCode
|
||||
}
|
||||
},
|
||||
|
||||
@@ -81,7 +89,7 @@ export default createComponent({
|
||||
|
||||
if (code) {
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'city') {
|
||||
if (this.isOverseaCode(code) && type === 'city') {
|
||||
code = '9';
|
||||
}
|
||||
|
||||
@@ -97,7 +105,7 @@ export default createComponent({
|
||||
const list = this.getList(type, code.slice(0, compareNum - 2));
|
||||
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'province') {
|
||||
if (this.isOverseaCode(code) && type === 'province') {
|
||||
compareNum = 1;
|
||||
}
|
||||
|
||||
@@ -163,7 +171,7 @@ export default createComponent({
|
||||
const names = values.map(item => item.name);
|
||||
|
||||
area.code = values[values.length - 1].code;
|
||||
if (area.code[0] === '9') {
|
||||
if (this.isOverseaCode(area.code)) {
|
||||
area.country = names[1] || '';
|
||||
area.province = names[2] || '';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user