commonOptionContent.vue
14.3 KB
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<template>
<div class="mall-option-content">
<!-- 对象个数 -->
<slot name="object-number"></slot>
<!-- 商场 -->
<div class="condition-item" v-show="cascadeVisible.mall">
<span class="condition-item-text">{{$t('asisTab.mallT')}}</span>
<div class="condition-item-option">
<el-select
v-model="mallVal"
filterable
:multiple="mallIsMultiple"
collapse-tags
:placeholder="$t('pholder.shopSelect')"
class="mall-sel-box"
@change="mallChangeHandle">
<div :class="isMallSelectAll ? 'sel-all-box selected' : 'sel-all-box'" @click="selAllHandle('mall')" v-show="mallIsMultiple">
<span class="custom-checkbox__input">
<span class="custom-checkbox__inner"></span>
</span>
<span style="padding-left: 5px;">{{$t('allPages.all')}}</span>
</div>
<el-option v-for="item in mallData" :key="item.id" :label="item.name" :value="item.id">
<span class="custom-checkbox__input" v-show="mallIsMultiple">
<span class="custom-checkbox__inner"></span>
</span>
<span :style="mallLabel">{{ item.name }}</span>
</el-option>
</el-select>
</div>
</div>
<!-- 监控点 -->
<div class="condition-item" v-show="cascadeVisible.gate">
<span class="condition-item-text">{{$t('asisTab.inOutT')}}</span>
<div class="condition-item-option">
<el-select
v-model="gateVal"
filterable
:multiple="gateIsMultiple"
collapse-tags
:placeholder="$t('pholder.gateType')"
class="mall-sel-box"
@change="gateChangeHandle">
<div :class="isGateSelectAll ? 'sel-all-box selected' : 'sel-all-box'" @click="selAllHandle('gate')" v-show="gateIsMultiple">
<span class="custom-checkbox__input">
<span class="custom-checkbox__inner"></span>
</span>
<span style="padding-left: 5px;">{{$t('allPages.all')}}</span>
</div>
<el-option v-for="item in gateData" :key="item.id" :label="item.name" :value="item.id">
<span class="custom-checkbox__input" v-show="gateIsMultiple">
<span class="custom-checkbox__inner"></span>
</span>
<span :style="gateLabel">{{ item.name }}</span>
</el-option>
</el-select>
</div>
</div>
<!-- 日期 -->
<div class="condition-item" v-show="cascadeVisible.date">
<span class="condition-item-text spe-item-text">{{$t('asisTab.date')}}</span>
<div class="condition-item-option">
<div class="time-wrapper">
<el-select v-model="reportVal" :placeholder="$t('pholder.select')" @change="DateHandle(reportVal)">
<el-option
v-for="item in analyasisTime"
:key="item.value"
:label="i18nFormatter(item.label)"
:value="item.value">
</el-option>
</el-select>
</div>
</div>
</div>
<div class="condition-item" v-show="cascadeVisible.date">
<div class="condition-item-option">
<el-date-picker class="date-input analysis-date-input" v-show="reportTime.isDay" v-model="dayTime" value-format="yyyy-MM-dd" align="right" type="date" size="mini" :placeholder="$t('pholder.date')" :picker-options="pickerOptions1">
</el-date-picker>
<el-date-picker class="date-input analysis-date-input date-week-box" v-show="reportTime.isWeek" v-model="weekTime" align="right" type="week" :format="datePickerFormatter('week')" size="mini" :placeholder="$t('pholder.week')" :picker-options="weekPickerOpt">
</el-date-picker>
<el-date-picker class="date-input analysis-date-input date-month-box" v-show="reportTime.isMonth" v-model="monthTime" align="right" type="month" :format="datePickerFormatter('month')" size="mini" :placeholder="$t('pholder.month')" :picker-options="pickerOptions1">
</el-date-picker>
<el-date-picker class="date-input analysis-date-input" v-show="reportTime.isYear" v-model="yearTime" align="right" type="year" :format="datePickerFormatter('year')" size="mini" :placeholder="$t('pholder.year')" :picker-options="pickerOptions1">
</el-date-picker>
<el-date-picker
class="date-input analysis-date-input times-box"
v-model="customTime"
value-format="yyyy-MM-dd"
align="right"
type="daterange"
size="mini"
:picker-options="pickerOptions1"
range-separator="-"
v-show="reportTime.isCustom"
:start-placeholder="$t('table.startTime')"
:end-placeholder="$t('table.endTime')">
</el-date-picker>
</div>
</div>
<!-- 指标 -->
<slot name="kpi"></slot>
<!-- 按钮 -->
<div class="condition-item btn-group">
<el-button type="primary" class="primary-btn analysis-collapse-btn" size="samll" @click="confirmCondition">{{$t('button.confirm')}}</el-button>
<!-- <el-button class="reset-btn analysis-collapse-btn" size="samll" @click="resetRefresh">{{$t('button.reset')}}</el-button> -->
</div>
</div>
</template>
<script>
export default {
name: 'commonOptionContent',
props: {
activeTab: {
type: Object,
required: true,
default: {}
}
},
data() {
return {
///////////////////////////////////////////////////// 商场 门店
mallData: [{
accountId: 2,
area: 100,
cityId: 2,
createTime: "2018-10-24 19:49:36",
createUser: 2,
externalId: "11010910476",
group: {name: "华东区"},
groupId: 5,
id: 2,
intro: "",
latitude: 40.066593,
longitude: 116.31105,
mallNo: "",
manager: "vion",
modifyTime: "2019-01-15 10:30:35",
modifyUser: 2,
name: "文安智能-北京",
openDate: "2018-10-01 00:00:00",
provinceId: 110000,
status: 1,
unid: "e15b9a8e-d782-11e8-b19d-7cd30ac4c9a6"
}],
multiMallVal: [],
radioMallVal: null,
mallIsMultiple: false,
isMallSelectAll: false,
///////////////////////////////////////////////////// 楼层
///////////////////////////////////////////////////// 店铺
///////////////////////////////////////////////////// 出入口
gateData: [{
account: {name: "文安智能"},
accountId: 2,
createTime: "2018-10-24 19:52:23",
createUser: 3,
externalId: "abcd",
floor: {name: "1F"},
floorId: 2,
id: 2,
isHasFace: 1,
isMallGate: 1,
mall: {name: "文安智能-北京"},
mallId: 2,
modifyTime: "2019-03-06 20:17:06",
modifyUser: 3,
name: "模拟门店A",
status: 1,
type: 3,
unid: "44fb714a-d783-11e8-9d18-7cd30ac4c9a6",
user: {realName: "vion"},
x: 0,
y: 0
}],
multiGateVal: [],
radioGateVal: null,
gateIsMultiple: false,
isGateSelectAll: false,
///////////////////////////////////////////////////// 日期
analyasisTime: [{
label: 'day',
value: 'day',
is_active: 'time-btn'
}, {
label: 'week',
value: 'week',
is_active: 'time-btn'
}, {
label: 'month',
value: 'month',
is_active: 'time-btn'
}, {
label: 'year',
value: 'year',
is_active: 'time-btn'
}, {
label: 'custom',
value: 'custom',
is_active: 'time-btn'
}],
reportVal: 'day',
reportTime: {
isDay: false,
isWeek: false,
isMonth: false,
isYear: false,
isCustom: false
},
pickerOptions1: {
disabledDate(time) {
return time.getTime() > Date.now();
}
},
weekPickerOpt: {
firstDayOfWeek: 1
},
dayTime: '',
weekTime: '',
monthTime: '',
yearTime: '',
customTime: '',
///////////////////////////////////////////////////// 条件选项
cascadeVisible: {
mall: false,
floor: false,
zone: false,
gate: false,
date: false
},
///////////////////////////////////////////////////// 分析条件结果
conditions: {}
}
},
computed: {
mallVal() {
if(this.mallIsMultiple) {
return this.multiMallVal;
} else {
return this.radioMallVal;
}
},
gateVal() {
if(this.gateIsMultiple) {
return this.multiGateVal;
} else {
return this.radioGateVal;
}
},
mallLabel() {
if(this.mallIsMultiple) {
return 'padding-left: 5px';
} else {
return '';
}
},
gateLabel() {
if(this.gateIsMultiple) {
return 'padding-left: 5px';
} else {
return '';
}
},
},
watch: {
activeTab: {
handler: 'createSelector',
immediate: true
}
},
created() {
this.DateHandle('day');
this.initTime();
},
methods: {
i18nFormatter(label){
let langeLabel = 'asisTab.' + label;
return this.$t(langeLabel)
},
initTime() {
this.dayTime = this.dayTime ? this.dayTime : dateUnit.dateFormat(new Date(), 'yyyy-MM-dd');
this.customTime = [this.dayReduce(new Date(), 30), dateUnit.dateFormat(new Date(), 'yyyy-MM-dd')];
this.weekTime = this.weekTime ? this.weekTime : new Date();
this.monthTime = this.monthTime ? this.monthTime : new Date();
this.yearTime = this.yearTime ? this.yearTime : new Date();
},
createSelector(activeTabItem) {
this.visibleHandler(false)
this.visibleHandler(true, activeTabItem.value)
if(activeTabItem.value === 'mall') {
this.mallIsMultiple = true;
this.multiMallVal = [this.mallData[0].id];
this.gateIsMultiple = false;
this.radioGateVal = this.gateData[0].id;
activeTabItem.cascade.forEach(item => {
this.visibleHandler(true, item.cascadeOption)
})
} else if(activeTabItem.value === 'gate') {
this.mallIsMultiple = false;
this.radioMallVal = this.mallData[0].id;
this.gateIsMultiple = true;
this.multiGateVal = [this.gateData[0].id];
activeTabItem.cascade.forEach(item => {
this.visibleHandler(true, item.cascadeOption)
})
} else {
this.mallIsMultiple = false;
this.radioMallVal = this.mallData[0].id;
this.gateIsMultiple = false;
this.radioGateVal = this.gateData[0].id;
activeTabItem.cascade.forEach(item => {
this.visibleHandler(true, item.cascadeOption)
})
}
},
mallChangeHandle() {},
gateChangeHandle() {},
selAllHandle(selectorType) {
//
},
DateHandle(value) {
for(let k in this.reportTime) {
this.reportTime[k] = false;
}
switch (value) {
case 'day':
this.reportTime.isDay = true;
break;
case 'week':
this.reportTime.isWeek = true;
break;
case 'month':
this.reportTime.isMonth = true;
break;
case 'year':
this.reportTime.isYear = true;
break;
case 'custom':
this.reportTime.isCustom = true;
break;
default:
break;
}
},
visibleHandler(isVisible, value) {
if(isVisible) {
this.cascadeVisible[value] = true;
} else {
Object.keys(this.cascadeVisible).forEach(key => {
this.cascadeVisible[key] = false;
})
}
},
confirmCondition() {},
resetRefresh() {}
}
}
</script>
<style scoped>
.mall-option-content {
padding: 15px 0 13px 50px;
background: #fff;
/* box-shadow: 0 1px 4px 0 rgba(0, 0, 0, .1); */
-webkit-box-sizing: border-box;
box-sizing: border-box;
overflow: hidden;
}
</style>