addGate.vue
15.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
370
371
372
373
374
375
376
377
378
379
<template>
<div>
<el-dialog
:title="$t('button.addSite')"
class="manage-dialog"
:visible.sync="addDialogVisible"
:close-on-click-modal="false"
@open="dialogOpenAdd(addForm)"
@close="addDialogClose()">
<el-form :model="addForm" status-icon :rules="rules" ref="addForm">
<el-form-item :label="$t('dialog.name')" prop="name">
<el-input v-model="addForm.name"></el-input>
<i class="error-tip">*</i>
</el-form-item>
<el-form-item :label="$t('table.type')" prop="type">
<el-select class="manage-sel" v-model="addForm.type" :placeholder="$t('pholder.type')">
<el-tooltip class="item" popper-class="tooltipClass" effect="light" placement="top-start" offset="-200">
<div slot="content">
传统客流智能机或者CBOX统计基础客流量。
</div>
<el-option :label="$t('dictionary.tradCount')" :value="1"></el-option>
</el-tooltip>
<el-tooltip class="item" popper-class="tooltipClass" effect="light" placement="top-start" offset="-200">
<div slot="content">
通过人脸抓拍识别统计<span class="red-font">客流量</span>及<span class="red-font">人脸属性</span>分析。
</div>
<el-option :label="$t('dictionary.faceFlow')" :value="3"></el-option>
</el-tooltip>
<el-tooltip class="item" popper-class="tooltipClass" effect="light" placement="top-start" offset="-200">
<div slot="content">
通过人脸抓拍识别仅分析人脸属性。<span class="red-font">无客流量</span>。
</div>
<el-option :label="$t('dictionary.faceCapture')" :value="5"></el-option>
</el-tooltip>
<el-tooltip class="item" popper-class="tooltipClass" effect="light" placement="top-start" offset="-200">
<div slot="content">
通过店外设备统计门前路过的客流量。
</div>
<el-option :label="$t('dictionary.inStoreRate')" :value="2"></el-option>
</el-tooltip>
<el-tooltip class="item" popper-class="tooltipClass" effect="light" placement="top-start" offset="-200">
<div slot="content">
通过鱼眼相机采集人员位置信息,并做热力呈现。
</div>
<el-option :label="$t('dictionary.heatmap')" :value="4"></el-option>
</el-tooltip>
<!-- <el-option label="出入口" value="1"></el-option>
<el-option label="柜台" value="2"></el-option> -->
<!-- <el-option label="收银台" value="3"></el-option> -->
</el-select>
<i class="error-tip">*</i>
</el-form-item>
<el-form-item :label="$t('table.state')" prop="status">
<el-select class="manage-sel" v-model="addForm.status" :placeholder="$t('pholder.state')">
<el-option :label="$t('table.stateA')" :value="1"></el-option>
<el-option :label="$t('table.stateB')" :value="2"></el-option>
</el-select>
<i class="error-tip">*</i>
</el-form-item>
<el-form-item :label="$t('table.square')" prop="mallId">
<el-select class="manage-sel" v-model="addForm.mallId" filterable :placeholder="$t('pholder.select')" :no-data-text="$t('pholder.nodata')" @change="changeAddMall">
<el-option v-for="item in mallList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
<i class="error-tip">*</i>
</el-form-item>
<el-form-item :label="$t('table.InstallationFloor')" prop="floorId">
<el-select class="manage-sel" v-model="addForm.floorId" filterable :placeholder="$t('pholder.select')" :no-data-text="$t('pholder.nodata')" @change="getFloorImg">
<el-option v-for="item in floorList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('dialog.coordinate')">
<el-col :span="7">
<el-form-item prop="x" class="spe-form-item">
<el-input v-model="addForm.x" :placeholder="$t('pholder.x')" class="gate-xy-inp"></el-input>
</el-form-item>
</el-col>
<el-col class="line" :span="2" style="text-align: center;">-</el-col>
<el-col :span="7">
<el-form-item prop="y" class="spe-form-item">
<el-input v-model="addForm.y" :placeholder="$t('pholder.y')" class="gate-xy-inp"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-button class="bdmap-btn" icon="el-icon-location" @click="getXY()" :disabled="XyActive">{{$t('button.getXY')}}</el-button>
</el-col>
<i class="error-tip">*</i>
</el-form-item>
<el-form-item :label="$t('table.externalNum')" prop="externalId">
<el-input v-model="addForm.externalId"></el-input>
</el-form-item>
<!-- <el-form-item label="安装坐标(X)" prop="x">
<el-input v-model.number="addForm.x"></el-input>
<i class="error-tip">*</i>
</el-form-item>
<el-form-item label="安装坐标(Y)" prop="y">
<el-input v-model.number="addForm.y"></el-input>
<i class="error-tip">*</i>
</el-form-item> -->
<!-- <el-form-item label="所属集团" prop="accountId">
<el-select class="manage-sel" v-model="addForm.accountId" filterable :placeholder="$t('pholder.select')" @change="changeAddAccount" :no-data-text="$t('pholder.nodata')">
<el-option v-for="item in accountList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</el-form-item> -->
<el-form-item :label="$t('table.SquareEntrance')" prop="isMallGate">
<el-select class="manage-sel" v-model="addForm.isMallGate" :placeholder="$t('pholder.select')">
<el-option label="否" :value="0"></el-option>
<el-option label="是" :value="1"></el-option>
</el-select>
<i class="error-tip">*</i>
</el-form-item>
<el-form-item :label="$t('table.faceCamera')" prop="isHasFace">
<el-select class="manage-sel" v-model="addForm.isHasFace" :placeholder="$t('pholder.select')">
<el-option label="否" :value="0"></el-option>
<el-option label="是" :value="1"></el-option>
</el-select>
<i class="error-tip">*</i>
</el-form-item>
<el-form-item :label="$t('table.describe')">
<el-input type="textarea" v-model="addForm.intro"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="addDialogVisible = false" class="dialog-btn">{{$t('dialog.cancel')}}</el-button>
<el-button type="primary" @click="addSubmit('addForm')" class="dialog-btn dialog-confirm-btn" :disabled="btnDisabled">{{$t('dialog.confirm')}}</el-button>
</div>
</el-dialog>
<!-- 楼层平面图 -->
<floor-pos-dialog ref="posModel" @posXY="getPosXY"></floor-pos-dialog>
</div>
</template>
<script>
import floorPos from './addFloorpos'
import defaultImg from '@/assets/img/manage/defaultFloor.svg'
export default {
data() {
var checkX = (rule, value, callback) => {
if (!value && value != 0) {
return callback(new Error('X坐标不能为空'));
}
var valReg = /^[0-9]+([.]{1}[0-9]+){0,1}$/;
if (!valReg.test(value)) {
callback(new Error('请输入正确的格式'));
} else {
callback();
}
};
var checkY = (rule, value, callback) => {
if (!value && value != 0) {
return callback(new Error('Y坐标不能为空'));
}
var valReg = /^[0-9]+([.]{1}[0-9]+){0,1}$/;
if (!valReg.test(value)) {
callback(new Error('请输入正确的格式'));
} else {
callback();
}
};
return {
addDialogVisible: false,
addForm: {
name: '',
externalId: '',
type: null,
status: null,
mallId: null,
floorId: null,
x: null,
y: null,
isMallGate: null,
isHasFace: null,
intro: ''
},
mallList: [],
floorList: [],
XyActive: true,
floorPlanUrl: window._vionConfig.imagesUrl + "/images/",
floorImg: '',
btnDisabled: false,
rules: {
name: [
{ required: true, message: '请输入监控点名称', trigger: 'blur' },
// { min: 2, max: 10, message: '长度在 2 到 10 个字符', trigger: 'blur' }
],
type: [
{ required: true, message: '请选择类型', trigger: 'change' },
],
status: [
{ required: true, message: '请选择状态', trigger: 'change' },
],
x: [
// { required: true, message: '请输入x坐标', trigger: 'change' },
{ validator: checkX, trigger: 'change' }
],
y: [
// { required: true, message: '请输入y坐标', trigger: 'change' },
{ validator: checkY, trigger: 'change' }
],
mallId: [
{ required: true, message: '请选择门店', trigger: 'change' },
],
// accountId: [
// { required: true, message: '请选择集团', trigger: 'blur' }
// ],
// floorId: [
// { required: true, message: '请选择楼层', trigger: 'blur' }
// ],
isMallGate: [
{ required: true, message: '请选择是否为入口', trigger: 'change' },
],
isHasFace: [
{ required: true, message: '请选择是否为人脸', trigger: 'change' },
]
},
curMallId: null,
}
},
components: {
'floor-pos-dialog': floorPos
},
methods: {
dialogInit(mall_id) {
this.curMallId = mall_id;
this.addDialogVisible = true;
},
dialogOpenAdd(formDatas) {
formDatas['accountId'] = this.$cookie.get('accountId');
this.getMallList(formDatas.accountId);
},
getMallList(accountId) {
this.addForm.mallId = '';
this.addForm.floorId = '';
this.floorList = [];
this.mallList = [];
this.$api.base.mall({
accountId: accountId,
// status: 1,
status_arr: '1,3'
// _t: Date.parse(new Date()) / 1000
},null,true)
.then((data) => {
let result = data.data;
result.data.forEach(item => {
if(item.id == this.curMallId) {
this.addForm.mallId = item.id;
}
})
this.mallList = result.data;
if (this.mallList.length > 0) {
if(!this.curMallId) {
this.addForm.mallId = this.mallList[0].id;
}
this.getFloorList(this.addForm.mallId)
}
})
.catch((error) => { })
},
changeAddMall(val) {
this.getFloorList(val)
},
getFloorList(mallId) {
this.addForm.floorId = '';
this.floorList = [];
this.$api.base.floor({
mallId: mallId,
status: 1,
// _t: Date.parse(new Date()) / 1000
})
.then((data) => {
var result = data.data;
if (result.data.length > 0) {
this.floorList = result.data;
this.addForm.floorId = this.floorList[0].id;
}
this.floorList = result.data;
})
.catch((error) => { })
},
//获取新增楼层照片
getFloorImg() {
if (this.addForm.floorId) {
this.XyActive = false;
} else {
this.XyActive = true;
}
this.$api.base.floor({
id: this.addForm.floorId,
// _t: Date.parse(new Date()) / 1000
})
.then(res => {
if (res.data.data[0].floorPlan) {
this.floorImg = this.floorPlanUrl + res.data.data[0].floorPlan;
} else {
this.floorImg = defaultImg
this.$message({
showClose: true,
message: this.$t('message.NoFloorImg'),
type: 'warning'
})
}
})
.catch(err => {
this.$throw(err)
})
},
getXY() {
this.$refs.posModel.dialogInit(this.floorImg);
},
getPosXY(XY) {
this.addForm.x = XY.x;
this.addForm.y = XY.y;
},
addSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.btnDisabled = true;
setTimeout(() => {
this.btnDisabled = false;
}, 2000)
this.addForm.accountId = this.$cookie.get('accountId');
this.addForm.createUser = this.$cookie.get('userId');
this.addForm.modifyUser = this.$cookie.get('userId');
this.$api.management.addGate(this.addForm)
.then((data) => {
this.addDialogVisible = false;
this.$parent.getTableData();
})
.catch((error) => { })
} else {
return false;
}
});
// this.$refs.addUpload.submit();
},
addDialogClose() {
this.$refs.addForm.resetFields();
this.XyActive = true;
},
}
}
</script>
<style scoped>
.bdmap-btn {
margin-left: 17px;
padding: 0 8px;
height: 28px;
border-radius: 2px;
font-size: 13px;
}
@media only screen and (max-width: 1680px) {
.bdmap-btn {
padding: 0 10px;
height: 30px;
}
}
@media only screen and (max-width: 1440px) {
.bdmap-btn {
padding: 0 10px;
height: 20px;
}
}
@media only screen and (max-width: 1366px) {
.bdmap-btn {
padding: 0 9px;
height: 20px;
}
}
@media only screen and (max-width: 1280px) {
.bdmap-btn {
padding: 0 9px;
height: 20px;
}
}
</style>