e80b805f
chenhaodong
初始化
|
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
<template>
<div>
<!-- map -->
<Modal v-model="editPositionModal" :style='modalStyle' :width='modalWidth'>
<Row class="margin-top-50">
<Card class="table-card" style="position:relative; ">
<h4 slot="title">
<Icon type="android-archive"></Icon>
<span v-if="mapParams">
{{title}}
</span>
</h4>
<div slot="extra" style="position:absolute;width:240px; top: -9px;right : 0px;display:flex;">
<Select style="flex : 1;" @on-change="onMapSearch" v-model="mapSearchInput" placeholder="选择区域" clearable>
<Option v-for="(item) in mapSearchCandidates" :value="item.code" :key="item.code">{{ item.name }}</Option>
</Select>
<Select v-if="secondMapSearchCandidates.length" style="flex : 1;" @on-change="onMapSearchSecond" v-model="mapSearchInputSecond" placeholder="选择区域" clearable>
<Option v-for="(item) in secondMapSearchCandidates" :value="item.code" :key="item.code">{{ item.name }}</Option>
</Select>
</div>
<Row>
<mapControl v-if="mapParams" @click="onMapClick" :markers="mapParams.row.trade_regions" ref="mapControl" :height="height" :width="width" />
</Row>
</Card>
</Row>
<div slot="footer">
<Row>
<Col span="2">
<p style=" line-height: 36px; text-align: left;">区域半径(km)</p>
</Col>
<Col span="10">
<Slider v-model="mapRadius" :step="1" :max="25" show-input></Slider>
</Col>
</Col span="10">
<Button type="error" size="large" @click="redrawMap">重新绘制</Button>
<Button type="success" size="large" @click="finishEditMap">完成编辑</Button>
</Col>
</Row>
</div>
</Modal>
<Button type="info" @click="setConditionFilterInfo">MewMapSelector</Button>
</div>
</template>
<script>
import mapControl from '../mew-map';
import areaData from './area-data/data';
export default {
components: {
mapControl
},
props: {
height:{
type:String,
default: '300px'
},
width:{
type:String,
default: '300px'
},
title:{
type:String,
default(){
return '';
}
}
},
computed:{
modalStyle(){
let style ={};
style.height=this.height+'px';
return style;
},
modalWidth(){
let modalWidth=this.width+'%';
return modalWidth;
}
},
data() {
return {
editImageModal: false,
imageViewProduct: {
row: {
image_url: null
}
},
screenHeight: document.documentElement.clientHeight,
mapSearchInput: '',
mapRadius: 5,
mapSearchInputSecond: '',
mapSearchCandidates: Object.keys(areaData['86']).map(function(code) {
return {
code: code,
name: areaData['86'][code]
};
}),
mapParams: undefined,
secondMapSearchCandidates: [],
importModal: false,
editPositionModal: false,
tempExcel: null,
tempExcelResult: '',
uploadExcelURL: '',
filter: {
query: '',
brand: '',
category: ''
},
brands: [],
categorys: [],
templateURL: undefined,
goods: {
total: 1,
limit:
Math.ceil((document.documentElement.clientHeight - 310) / 40) - 2,
start: 0,
list: []
}
};
},
methods: {
onMapSearchSecond() {
this.$refs.mapControl.searchAndMoveToLocation(this.mapSearchInputSecond);
},
finishEditMap() {
this.$emit('choosed-location',
this.mapParams.row.trade_regions
);
},
setConditionFilterInfo() {
var self = this;
self.editPositionModal = true;
self.mapParams = {
row: {
trade_regions: []
}
};
self.$nextTick(function() {
self.$refs.mapControl.updateMakers();
});
},
onMapSearch() {
var self = this;
var keys = Object.keys(areaData[this.mapSearchInput]);
if (keys.length == 1) {
this.secondMapSearchCandidates = [];
this.$refs.mapControl.searchAndMoveToLocation(this.mapSearchInput);
} else {
this.secondMapSearchCandidates = keys.map(function(code) {
return {
code: code,
name: areaData[self.mapSearchInput][code]
};
});
}
},
onMapClick(poi) {
if (this.mapParams.row.trade_regions.length < 3) {
this.mapParams.row.trade_regions.push({
type: 'circle',
radius: this.mapRadius * 1000,
latitude: poi.latitude,
longitude: poi.longitude
});
this.$refs.mapControl.updateMakers();
}
},
redrawMap() {
this.$Modal.confirm({
title: '重新绘制',
content: '请问是否要重新绘制这个经销范围',
onOk: () => {
this.mapParams.row.trade_regions.length = 0;
this.$refs.mapControl.updateMakers();
},
onCancel: () => {}
});
},
itemTitle(item) {
if (typeof item.title === 'object') {
return this.$t(item.title.i18n);
} else {
return item.title;
}
},
beforeUploadProductInfo() {
this.$Loading.start();
return true;
},
uploadProductInfo(result) {
this.tempExcel = result;
this.importModal = true;
this.tempExcelResult = result.result;
this.$Loading.finish();
},
changePage(page) {
this.goods.start = (page - 1) * this.goods.limit;
this.search();
},
doSearch() {
this.goods.start = 0;
this.search();
},
redoSearch() {
this.goods.start = 0;
this.filter.brand = '';
this.filter.category = '';
this.filter.query = '';
this.filter.priceLow = '';
this.filter.priceHigh = '';
this.search();
},
search(newFilter) {
if (newFilter) {
this.filter = newFilter;
}
},
newGoods() {},
catTree() {}
},
mounted() {
this.search();
}
};
</script>
|