// Utils import { createNamespace } from '../utils'; import { isAndroid } from '../utils/validate/system'; // Components import Cell from '../cell'; import Field from '../field'; const [createComponent, bem, t] = createNamespace('address-edit-detail'); const android = isAndroid(); export default createComponent({ props: { value: String, errorMessage: String, focused: Boolean, detailRows: [Number, String], searchResult: Array, detailMaxlength: [Number, String], showSearchResult: Boolean, }, computed: { shouldShowSearchResult() { return this.focused && this.searchResult && this.showSearchResult; }, }, methods: { onSelect(express) { this.$emit('select-search', express); this.$emit( 'input', `${express.address || ''} ${express.name || ''}`.trim() ); }, onFinish() { this.$refs.field.blur(); }, genFinish() { const show = this.value && this.focused && android; if (show) { return (
{t('complete')}
); } }, genSearchResult() { const { value, shouldShowSearchResult, searchResult } = this; if (shouldShowSearchResult) { return searchResult.map((express) => ( { this.onSelect(express); }} scopedSlots={{ title: () => { if (express.name) { const text = express.name.replace( value, `${value}` ); return
; } }, }} /> )); } }, }, render() { return ( {this.genSearchResult()} ); }, });