| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import _extends from "@babel/runtime/helpers/esm/extends";
- import { use, isAndroid } from '../utils';
- import Cell from '../cell';
- import Field from '../field';
- var _use = use('address-edit-detail'),
- sfc = _use[0],
- bem = _use[1],
- t = _use[2];
- var android = isAndroid();
- export default sfc({
- props: {
- value: String,
- error: Boolean,
- focused: Boolean,
- detailRows: Number,
- searchResult: Array,
- showSearchResult: Boolean
- },
- methods: {
- onSelect: function onSelect(express) {
- this.$emit('select-search', express);
- this.$emit('input', ((express.address || '') + " " + (express.name || '')).trim());
- },
- onFinish: function onFinish() {
- this.$refs.field.blur();
- },
- renderFinish: function renderFinish() {
- var h = this.$createElement;
- var show = this.value && this.focused && android;
- if (show) {
- return h("div", {
- "class": bem('finish'),
- "on": {
- "click": this.onFinish
- }
- }, [t('complete')]);
- }
- },
- renderSearchResult: function renderSearchResult() {
- var _this = this;
- var h = this.$createElement;
- var searchResult = this.searchResult;
- var show = this.focused && searchResult && this.showSearchResult;
- if (show) {
- return searchResult.map(function (express) {
- return h(Cell, {
- "key": express.name + express.address,
- "attrs": {
- "title": express.name,
- "label": express.address,
- "icon": "location-o",
- "clickable": true
- },
- "on": {
- "click": function click() {
- _this.onSelect(express);
- }
- }
- });
- });
- }
- }
- },
- render: function render(h) {
- return h(Cell, {
- "class": bem()
- }, [h(Field, {
- "attrs": {
- "autosize": true,
- "rows": this.detailRows,
- "clearable": !android,
- "type": "textarea",
- "maxlength": "200",
- "value": this.value,
- "error": this.error,
- "label": t('label'),
- "placeholder": t('placeholder')
- },
- "ref": "field",
- "scopedSlots": {
- icon: this.renderFinish
- },
- "on": _extends({}, this.$listeners)
- }), this.renderSearchResult()]);
- }
- });
|