feat(AddressEdit): add area-placeholder prop (#6023)

This commit is contained in:
Lindy 2020-04-10 15:44:09 +08:00 committed by GitHub
parent da4a94c9e0
commit e9f3936989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View File

@ -67,6 +67,7 @@ export default {
|------|------|------|------| |------|------|------|------|
| area-list | Area List | *object* | - | | area-list | Area List | *object* | - |
| area-columns-placeholder `v2.2.5` | placeholder of area columns | *string[]* | `[]` | | area-columns-placeholder `v2.2.5` | placeholder of area columns | *string[]* | `[]` |
| area-placeholder | placeholder of area input field | *string* | `Area` |
| address-info | Address Info | *AddressInfo* | `{}` | | address-info | Address Info | *AddressInfo* | `{}` |
| search-result | Address search result | *SearchResult[]* | `[]` | | search-result | Address search result | *SearchResult[]* | `[]` |
| show-postal | Whether to show postal field | *boolean* | `false` | | show-postal | Whether to show postal field | *boolean* | `false` |

View File

@ -67,6 +67,7 @@ export default {
|------|------|------|------| |------|------|------|------|
| area-list | 地区列表 | *object* | - | | area-list | 地区列表 | *object* | - |
| area-columns-placeholder `v2.2.5` | 地区选择列占位提示文字 | *string[]* | `[]` | | area-columns-placeholder `v2.2.5` | 地区选择列占位提示文字 | *string[]* | `[]` |
| area-placeholder | 地区输入框占位提示文字 | *string* | `选择省 / 市 / 区` |
| address-info | 收货人信息初始值 | *AddressInfo* | `{}` | | address-info | 收货人信息初始值 | *AddressInfo* | `{}` |
| search-result | 详细地址搜索结果 | *SearchResult[]* | `[]` | | search-result | 详细地址搜索结果 | *SearchResult[]* | `[]` |
| show-postal | 是否显示邮政编码 | *boolean* | `false` | | show-postal | 是否显示邮政编码 | *boolean* | `false` |

View File

@ -44,6 +44,7 @@ export default createComponent({
showSearchResult: Boolean, showSearchResult: Boolean,
saveButtonText: String, saveButtonText: String,
deleteButtonText: String, deleteButtonText: String,
areaPlaceholder: String,
showArea: { showArea: {
type: Boolean, type: Boolean,
default: true, default: true,
@ -106,7 +107,7 @@ export default createComponent({
if (province && province === city) { if (province && province === city) {
arr.splice(1, 1); arr.splice(1, 1);
} }
return arr.filter((text) => text).join('/'); return arr.filter(text => text).join('/');
} }
return ''; return '';
}, },
@ -144,9 +145,9 @@ export default createComponent({
}, },
onAreaConfirm(values) { onAreaConfirm(values) {
values = values.filter((value) => !!value); values = values.filter(value => !!value);
if (values.some((value) => !value.code)) { if (values.some(value => !value.code)) {
Toast(t('areaEmpty')); Toast(t('areaEmpty'));
return; return;
} }
@ -182,7 +183,7 @@ export default createComponent({
items.push('postalCode'); items.push('postalCode');
} }
const isValid = items.every((item) => { const isValid = items.every(item => {
const msg = this.getErrorMessage(item); const msg = this.getErrorMessage(item);
if (msg) { if (msg) {
this.errorInfo[item] = msg; this.errorInfo[item] = msg;
@ -260,7 +261,7 @@ export default createComponent({
render() { render() {
const { data, errorInfo, searchResult, disableArea } = this; const { data, errorInfo, searchResult, disableArea } = this;
const onFocus = (name) => () => this.onFocus(name); const onFocus = name => () => this.onFocus(name);
// hide bottom field when use search && detail get focused // hide bottom field when use search && detail get focused
const hideBottomFields = const hideBottomFields =
@ -291,7 +292,7 @@ export default createComponent({
readonly readonly
clickable={!disableArea} clickable={!disableArea}
label={t('area')} label={t('area')}
placeholder={t('areaPlaceholder')} placeholder={this.areaPlaceholder || t('areaPlaceholder')}
errorMessage={errorInfo.areaCode} errorMessage={errorInfo.areaCode}
rightIcon={!disableArea ? 'arrow' : null} rightIcon={!disableArea ? 'arrow' : null}
value={this.areaText} value={this.areaText}
@ -313,7 +314,7 @@ export default createComponent({
onFocus={onFocus('addressDetail')} onFocus={onFocus('addressDetail')}
onBlur={this.onDetailBlur} onBlur={this.onDetailBlur}
onInput={this.onChangeDetail} onInput={this.onChangeDetail}
onSelect-search={(event) => { onSelect-search={event => {
this.$emit('select-search', event); this.$emit('select-search', event);
}} }}
/> />
@ -337,7 +338,7 @@ export default createComponent({
vModel={data.isDefault} vModel={data.isDefault}
vShow={!hideBottomFields} vShow={!hideBottomFields}
title={t('defaultAddress')} title={t('defaultAddress')}
onChange={(event) => { onChange={event => {
this.$emit('change-default', event); this.$emit('change-default', event);
}} }}
/> />