mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-08-30 04:39:46 +08:00
feat: migrate AddressEdit component
This commit is contained in:
parent
092c5356e6
commit
1349301f01
@ -80,4 +80,5 @@ module.exports = [
|
|||||||
'goods-action',
|
'goods-action',
|
||||||
'goods-action-icon',
|
'goods-action-icon',
|
||||||
'goods-action-button',
|
'goods-action-button',
|
||||||
|
'address-edit',
|
||||||
];
|
];
|
||||||
|
@ -20,6 +20,8 @@ export default createComponent({
|
|||||||
showSearchResult: Boolean,
|
showSearchResult: Boolean,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
emits: ['blur', 'focus', 'input', 'select-search'],
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
shouldShowSearchResult() {
|
shouldShowSearchResult() {
|
||||||
return this.focused && this.searchResult && this.showSearchResult;
|
return this.focused && this.searchResult && this.showSearchResult;
|
||||||
@ -39,6 +41,14 @@ export default createComponent({
|
|||||||
this.$refs.field.blur();
|
this.$refs.field.blur();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onFocus(event) {
|
||||||
|
this.$emit('focus', event);
|
||||||
|
},
|
||||||
|
|
||||||
|
onBlur(event) {
|
||||||
|
this.$emit('blur', event);
|
||||||
|
},
|
||||||
|
|
||||||
genFinish() {
|
genFinish() {
|
||||||
const show = this.value && this.focused && android;
|
const show = this.value && this.focused && android;
|
||||||
if (show) {
|
if (show) {
|
||||||
@ -55,16 +65,7 @@ export default createComponent({
|
|||||||
if (shouldShowSearchResult) {
|
if (shouldShowSearchResult) {
|
||||||
return searchResult.map((express) => (
|
return searchResult.map((express) => (
|
||||||
<Cell
|
<Cell
|
||||||
key={express.name + express.address}
|
v-slots={{
|
||||||
clickable
|
|
||||||
border={false}
|
|
||||||
icon="location-o"
|
|
||||||
label={express.address}
|
|
||||||
class={bem('search-item')}
|
|
||||||
onClick={() => {
|
|
||||||
this.onSelect(express);
|
|
||||||
}}
|
|
||||||
scopedSlots={{
|
|
||||||
title: () => {
|
title: () => {
|
||||||
if (express.name) {
|
if (express.name) {
|
||||||
const text = express.name.replace(
|
const text = express.name.replace(
|
||||||
@ -76,6 +77,15 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
key={express.name + express.address}
|
||||||
|
clickable
|
||||||
|
border={false}
|
||||||
|
icon="location-o"
|
||||||
|
label={express.address}
|
||||||
|
class={bem('search-item')}
|
||||||
|
onClick={() => {
|
||||||
|
this.onSelect(express);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -86,19 +96,25 @@ export default createComponent({
|
|||||||
return (
|
return (
|
||||||
<Cell class={bem()}>
|
<Cell class={bem()}>
|
||||||
<Field
|
<Field
|
||||||
|
v-slots={{ icon: this.genFinish }}
|
||||||
autosize
|
autosize
|
||||||
ref="field"
|
ref="field"
|
||||||
rows={this.detailRows}
|
rows={this.detailRows}
|
||||||
clearable={!android}
|
clearable={!android}
|
||||||
type="textarea"
|
type="textarea"
|
||||||
value={this.value}
|
|
||||||
errorMessage={this.errorMessage}
|
|
||||||
border={!this.shouldShowSearchResult}
|
|
||||||
label={t('label')}
|
label={t('label')}
|
||||||
|
border={!this.shouldShowSearchResult}
|
||||||
maxlength={this.detailMaxlength}
|
maxlength={this.detailMaxlength}
|
||||||
|
modelValue={this.value}
|
||||||
placeholder={t('placeholder')}
|
placeholder={t('placeholder')}
|
||||||
scopedSlots={{ icon: this.genFinish }}
|
errorMessage={this.errorMessage}
|
||||||
{...{ on: this.$listeners }}
|
onBlur={this.onBlur}
|
||||||
|
onFocus={this.onFocus}
|
||||||
|
{...{
|
||||||
|
'onUpdate:modelValue': (val) => {
|
||||||
|
this.$emit('input', val);
|
||||||
|
},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{this.genSearchResult()}
|
{this.genSearchResult()}
|
||||||
</Cell>
|
</Cell>
|
||||||
|
@ -282,11 +282,11 @@ export default createComponent({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Cell
|
<Cell
|
||||||
|
v-slots={slots}
|
||||||
vShow={!this.hideBottomFields}
|
vShow={!this.hideBottomFields}
|
||||||
center
|
center
|
||||||
title={t('defaultAddress')}
|
title={t('defaultAddress')}
|
||||||
class={bem('default')}
|
class={bem('default')}
|
||||||
scopedSlots={slots}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -328,7 +328,7 @@ export default createComponent({
|
|||||||
placeholder={this.areaPlaceholder || t('areaPlaceholder')}
|
placeholder={this.areaPlaceholder || t('areaPlaceholder')}
|
||||||
errorMessage={errorInfo.areaCode}
|
errorMessage={errorInfo.areaCode}
|
||||||
rightIcon={!disableArea ? 'arrow' : null}
|
rightIcon={!disableArea ? 'arrow' : null}
|
||||||
value={this.areaText}
|
modelValue={this.areaText}
|
||||||
onFocus={onFocus('areaCode')}
|
onFocus={onFocus('areaCode')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.$emit('click-area');
|
this.$emit('click-area');
|
||||||
@ -337,15 +337,15 @@ export default createComponent({
|
|||||||
/>
|
/>
|
||||||
<Detail
|
<Detail
|
||||||
vShow={this.showDetail}
|
vShow={this.showDetail}
|
||||||
focused={this.detailFocused}
|
|
||||||
value={data.addressDetail}
|
value={data.addressDetail}
|
||||||
|
focused={this.detailFocused}
|
||||||
errorMessage={errorInfo.addressDetail}
|
errorMessage={errorInfo.addressDetail}
|
||||||
detailRows={this.detailRows}
|
detailRows={this.detailRows}
|
||||||
detailMaxlength={this.detailMaxlength}
|
detailMaxlength={this.detailMaxlength}
|
||||||
searchResult={this.searchResult}
|
searchResult={this.searchResult}
|
||||||
showSearchResult={this.showSearchResult}
|
showSearchResult={this.showSearchResult}
|
||||||
onFocus={onFocus('addressDetail')}
|
|
||||||
onBlur={this.onDetailBlur}
|
onBlur={this.onDetailBlur}
|
||||||
|
onFocus={onFocus('addressDetail')}
|
||||||
onInput={this.onChangeDetail}
|
onInput={this.onChangeDetail}
|
||||||
onSelect-search={(event) => {
|
onSelect-search={(event) => {
|
||||||
this.$emit('select-search', event);
|
this.$emit('select-search', event);
|
||||||
@ -363,7 +363,7 @@ export default createComponent({
|
|||||||
onFocus={onFocus('postalCode')}
|
onFocus={onFocus('postalCode')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{this.slots()}
|
{this.$slots.default?.()}
|
||||||
</div>
|
</div>
|
||||||
{this.genSetDefaultCell(h)}
|
{this.genSetDefaultCell(h)}
|
||||||
<div vShow={!hideBottomFields} class={bem('buttons')}>
|
<div vShow={!hideBottomFields} class={bem('buttons')}>
|
||||||
@ -386,11 +386,16 @@ export default createComponent({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Popup
|
<Popup
|
||||||
vModel={this.showAreaPopup}
|
show={this.showAreaPopup}
|
||||||
round
|
round
|
||||||
position="bottom"
|
position="bottom"
|
||||||
lazyRender={false}
|
lazyRender={false}
|
||||||
getContainer="body"
|
getContainer="body"
|
||||||
|
{...{
|
||||||
|
'onUpdate:modelValue': (value) => {
|
||||||
|
this.showAreaPopup = value;
|
||||||
|
},
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Area
|
<Area
|
||||||
ref="area"
|
ref="area"
|
||||||
|
@ -323,10 +323,10 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
title: '业务组件',
|
title: '业务组件',
|
||||||
items: [
|
items: [
|
||||||
// {
|
{
|
||||||
// path: 'address-edit',
|
path: 'address-edit',
|
||||||
// title: 'AddressEdit 地址编辑',
|
title: 'AddressEdit 地址编辑',
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
path: 'address-list',
|
path: 'address-list',
|
||||||
title: 'AddressList 地址列表',
|
title: 'AddressList 地址列表',
|
||||||
@ -657,10 +657,10 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
title: 'Business Components',
|
title: 'Business Components',
|
||||||
items: [
|
items: [
|
||||||
// {
|
{
|
||||||
// path: 'address-edit',
|
path: 'address-edit',
|
||||||
// title: 'AddressEdit',
|
title: 'AddressEdit',
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
path: 'address-list',
|
path: 'address-list',
|
||||||
title: 'AddressList',
|
title: 'AddressList',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user