You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
3.6 KiB
130 lines
3.6 KiB
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
exports.__esModule = true;
|
|
exports.default = void 0;
|
|
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
|
|
var _utils = require("../utils");
|
|
|
|
var _system = require("../utils/validate/system");
|
|
|
|
var _cell = _interopRequireDefault(require("../cell"));
|
|
|
|
var _field = _interopRequireDefault(require("../field"));
|
|
|
|
// Utils
|
|
// Components
|
|
var _createNamespace = (0, _utils.createNamespace)('address-edit-detail'),
|
|
createComponent = _createNamespace[0],
|
|
bem = _createNamespace[1],
|
|
t = _createNamespace[2];
|
|
|
|
var android = (0, _system.isAndroid)();
|
|
|
|
var _default = createComponent({
|
|
props: {
|
|
value: String,
|
|
errorMessage: String,
|
|
focused: Boolean,
|
|
detailRows: [Number, String],
|
|
searchResult: Array,
|
|
detailMaxlength: [Number, String],
|
|
showSearchResult: Boolean
|
|
},
|
|
computed: {
|
|
shouldShowSearchResult: function shouldShowSearchResult() {
|
|
return this.focused && this.searchResult && this.showSearchResult;
|
|
}
|
|
},
|
|
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();
|
|
},
|
|
genFinish: function genFinish() {
|
|
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')]);
|
|
}
|
|
},
|
|
genSearchResult: function genSearchResult() {
|
|
var _this = this;
|
|
|
|
var h = this.$createElement;
|
|
var value = this.value,
|
|
shouldShowSearchResult = this.shouldShowSearchResult,
|
|
searchResult = this.searchResult;
|
|
|
|
if (shouldShowSearchResult) {
|
|
return searchResult.map(function (express) {
|
|
return h(_cell.default, {
|
|
"key": express.name + express.address,
|
|
"attrs": {
|
|
"clickable": true,
|
|
"border": false,
|
|
"icon": "location-o",
|
|
"label": express.address
|
|
},
|
|
"class": bem('search-item'),
|
|
"on": {
|
|
"click": function click() {
|
|
_this.onSelect(express);
|
|
}
|
|
},
|
|
"scopedSlots": {
|
|
title: function title() {
|
|
if (express.name) {
|
|
var text = express.name.replace(value, "<span class=" + bem('keyword') + ">" + value + "</span>");
|
|
return h("div", {
|
|
"domProps": {
|
|
"innerHTML": text
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
},
|
|
render: function render() {
|
|
var h = arguments[0];
|
|
return h(_cell.default, {
|
|
"class": bem()
|
|
}, [h(_field.default, {
|
|
"attrs": {
|
|
"autosize": true,
|
|
"rows": this.detailRows,
|
|
"clearable": !android,
|
|
"type": "textarea",
|
|
"value": this.value,
|
|
"errorMessage": this.errorMessage,
|
|
"border": !this.shouldShowSearchResult,
|
|
"label": t('label'),
|
|
"maxlength": this.detailMaxlength,
|
|
"placeholder": t('placeholder')
|
|
},
|
|
"ref": "field",
|
|
"scopedSlots": {
|
|
icon: this.genFinish
|
|
},
|
|
"on": (0, _extends2.default)({}, this.$listeners)
|
|
}), this.genSearchResult()]);
|
|
}
|
|
});
|
|
|
|
exports.default = _default; |