1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
| import _extends from "@babel/runtime/helpers/esm/extends";
| // Utils
| import { createNamespace } from '../utils';
| import { isAndroid } from '../utils/validate/system'; // Components
|
| import Cell from '../cell';
| import Field from '../field';
|
| var _createNamespace = createNamespace('address-edit-detail'),
| createComponent = _createNamespace[0],
| bem = _createNamespace[1],
| t = _createNamespace[2];
|
| var android = isAndroid();
| export 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, {
| "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, {
| "class": bem()
| }, [h(Field, {
| "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": _extends({}, this.$listeners)
| }), this.genSearchResult()]);
| }
| });
|
|