fei.wang
2025-04-30 722da005a5ec126bedf752ac6bd5c5c7f6172155
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
<template>
    <view class="template-job tn-safe-area-inset-bottom tn-skeleton">
        <!-- 顶部自定义导航 -->
        <tn-nav-bar :isBack="false" fixed style="position: absolute;z-index: 999999999;">
            <!--         <text v-if="isAchor==false" class="title_linespan" style="color: #00aaff;text-decoration: underline;"
                @click="goAchor">绘制</text>
            <text v-else class="title_linespan" @click="goAchor">绘制</text>
            <text class="title_linespan" style="margin-left: 10px;" @click="goTag">管理</text> -->
            <text v-if="isAchor==false" class="title_linespan" style="color: #00aaff;text-decoration: underline;"
                @click="goAchor">绘制</text>
            <text v-else class="title_linespan" @click="goAchor">绘制</text>
 
            <text class="title_linespan" style="margin-left: 10px;" @click="goTag">管理</text>
        </tn-nav-bar>
 
        <view v-show="lock==false" class="page-wrap u-skeleton" :style="{'margin-top':vuex_custom_bar_height+16+'px'}">
            <view class="item-wrap">
                <!-- <view class="container" > -->
 
                <tn-form>
                    <!-- <tn-form-item label="序号:">
                    <tn-input v-model="form.objectid" inputAlign="right" disabled></tn-input>
                </tn-form-item> -->
                    <tn-form-item label="围栏形状:" :labelWidth="labelWidth">
                        <tn-input v-model="form.shape" type="select" @click="show = true" inputAlign="right" />
                        <tn-action-sheet :list="shapeList" v-model="show" @click="shapeCallback"></tn-action-sheet>
                    </tn-form-item>
 
                    <tn-form-item label="围栏类型:" :labelWidth="labelWidth">
                        <tn-input v-model="form.type" type="select" @click="show1 = true" inputAlign="right" />
                        <tn-action-sheet :list="typeList" v-model="show1" @click="typeCallback"></tn-action-sheet>
                    </tn-form-item>
                    <tn-form-item label="关联部门:" :labelWidth="labelWidth">
                        <tn-input v-model="form.bumen" type="select" @click="show2 = true" inputAlign="right"
                            placeholder="请选择关联部门" />
                        <tn-action-sheet :list="bumenList" v-model="show2" @click="bymenCallback"></tn-action-sheet>
                    </tn-form-item>
                    <tn-form-item label="选择设备:" :labelWidth="labelWidth">
                        <tn-input v-model="form.tagId" inputAlign="right" placeholder="请输入设备编号"></tn-input>
                    </tn-form-item>
                    <tn-form-item v-show="isshape==true" label="圆心坐标:" :labelWidth="labelWidth">
                        <tn-input :disabled="disable" v-model="form.zuobiao" inputAlign="right"
                            @input="cleanconext"></tn-input>
                        <tn-button v-show="tips==true" backgroundColor="#55aaff" fontColor="#ffffff" size="small"
                            @click="acquisitionxy">采集坐标</tn-button>
                    </tn-form-item>
                    <tn-form-item v-show="isshape==true" label="围栏半径:" :labelWidth="labelWidth">
                        <tn-input v-model="form.banjing" inputAlign="right" placeholder="请输入围栏半径"></tn-input>
                    </tn-form-item>
                    <!--         <tn-form-item v-show="isshape==false" label="坐标数量:" :labelWidth="labelWidth">
                        <tn-input disabled inputAlign="right"></tn-input>
                        <tn-number-box v-model="zuobiaonum" :min="0" :max="10" @change="onchange"></tn-number-box>
                    </tn-form-item> -->
                    <tn-form-item v-for="(item, index) in list" :key="index" v-show="isshape==false" label="坐标点"
                        :labelWidth="labelWidth">
                        <tn-input v-show="list[index]==index" :disabled="disable" inputAlign="right"
                            @input="cleanconext"></tn-input>
                        <tn-input v-show="list[index]!=index" :disabled="disable" v-model="list[index]"
                            inputAlign="right" @input="cleanconext"></tn-input>
                        <tn-button v-show="list[index]==index" backgroundColor="#55aaff" fontColor="#ffffff"
                            size="small" @click="acquisitionxy(index)">采集坐标</tn-button>
                    </tn-form-item>
                    <!--     <tn-form-item  v-show="isshape==false" label="坐标点2:" :labelWidth="labelWidth">
                    <tn-input :disabled="disable" v-model="form.zuobiao" inputAlign="right" @input="cleanconext"></tn-input>
                      <tn-button v-show="tips==true" backgroundColor="#55aaff" fontColor="#ffffff" size="small" @click="acquisitionxy">采集坐标</tn-button>
                </tn-form-item>
                <tn-form-item  v-show="isshape==false" label="坐标点3:" :labelWidth="labelWidth">
                    <tn-input :disabled="disable" v-model="form.zuobiao" inputAlign="right" @input="cleanconext"></tn-input>
                      <tn-button v-show="tips==true" backgroundColor="#55aaff" fontColor="#ffffff" size="small" @click="acquisitionxy">采集坐标</tn-button>
                </tn-form-item>
                <tn-form-item  v-show="isshape==false" label="坐标点4:" :labelWidth="labelWidth">
                    <tn-input :disabled="disable" v-model="form.zuobiao" inputAlign="right" @input="cleanconext"></tn-input>
                      <tn-button v-show="tips==true" backgroundColor="#55aaff" fontColor="#ffffff" size="small" @click="acquisitionxy">采集坐标</tn-button>
                </tn-form-item>
                <tn-form-item  v-show="isshape==false" label="坐标点5:" :labelWidth="labelWidth">
                    <tn-input :disabled="disable" v-model="form.zuobiao" inputAlign="right" @input="cleanconext"></tn-input>
                      <tn-button v-show="tips==true" backgroundColor="#55aaff" fontColor="#ffffff" size="small" @click="acquisitionxy">采集坐标</tn-button>
                </tn-form-item> -->
 
                    <tn-form-item label="围栏高度:" :labelWidth="labelWidth">
                        <!-- {{form.disable}} -->
                        <tn-input v-model="form.baoliu1" inputAlign="right" placeholder="请输入围栏高度"></tn-input>
                        <text>CM</text>
                    </tn-form-item>
                    <tn-form-item label="围栏名称:" :labelWidth="labelWidth">
                        <tn-input v-model="form.name" inputAlign="right" placeholder="请输入围栏名称"></tn-input>
                    </tn-form-item>
                </tn-form>
 
                <!-- </view> -->
 
            </view>
            <button style="margin-top: 20px;" type="primary" @click="drawfence">绘制围栏</button>
        </view>
 
        <tn-skeleton :show="showSkeleton"></tn-skeleton>
        <successCom ref="refSuccess"></successCom>
        <!-- <u-empty text="暂未开放" mode="list" style="width: 90%; top: 30%;left: 5%; position: absolute; "></u-empty> -->
        <!-- u-search class="searchbg" shape="true" bg-color="rgba(255, 255, 255, 0.5)" placeholder="请输入名称" :show-action="false" 
        :style="{top: topheight+'px',position: 'absolute',width: '50%',left: '25%'}"></u-search> -->
        <!-- <drawCom  v-show="lock==true" @goAchor="goAchor"></drawCom> -->
    </view>
</template>
<script>
    import successCom from '@/components/success.vue'
    import drawCom from '@/pages/index/draw.vue'
    import {
        minLogin
    } from '@/js/minLogin.js'
    import {
        findbumen,
        submitper,
        findFence,
        acquisition
    } from '@/config/api.js';
    import {
        pagesEquipment
    } from '@/js/pages/equipment.js'
    export default {
        mixins: [minLogin, pagesEquipment],
        components: {
            drawCom,
            successCom
        },
        data() {
            return {
                labelWidth: 100,
                tips: true,
                zuobiaonum: 0,
                isshape: false,
                disable: true,
                isAchor: false,
                warnindex: 0,
                warlist: {},
                lock: false,
                keyword: '',
                pageNo: 1,
                pageSize: 10,
                imgStyle: {
                    width: '100px',
                    height: '1000px',
                    borderRadius: '50%'
                },
                form: {
                    bumen: '',
                    name: '',
                    baoliu1: '',
                    tagId: '',
                    zuobiao: '',
                    shape: '多边形',
                    banjing: '',
                    type: '进入告警',
                    list: [],
                    disable: false,
                    company: this.company,
                },
                showSkeleton: true,
                options: [{
                    text: '删除',
                    style: {
                        backgroundColor: '#F93737',
                    }
                }, ],
                boxKey: 0,
                scrollHeight: 500,
                topheight: 0,
                paddingTop: 60,
                emitDate: 'indexHome',
                show: false,
                show1: false,
                show2: false,
                time: '',
                list: [],
                total: 0,
                bumenList: [],
                shapeList: [
                    // {
                    //     text: '圆形'
                    // },
                    {
                        text: '多边形'
                    }
                ],
 
                typeList: [{
                        text: '进入告警'
                    },
                    {
                        text: '出去告警'
                    },
                    {
                        text: '超员告警'
                    }
                ],
                options1: [{
                    text: '删除',
                    style: {
                        backgroundColor: '#F93737'
                    }
                }]
            }
        },
        props: {
            // formfence: {
            //     type: Object,
            //     default: () => {
            //         return []
            //     }
            // },
 
        },
        computed: {
 
            countList() {
                let num = 0;
                for (let i in this.list) {
                    num += this.list[i].fQty;
                }
                return num;
            }
        },
        mounted() {
            this.findbumenall()
            // if (this.formfence.zuobiao!='') {
            //     this.tips=false
            // }
            // this.form=this.formfence
            this.topheight = this.vuex_custom_bar_height + 15
            setTimeout(() => {
                this.showSkeleton = false
            }, 1000)
 
            // this.$refs.refSuccess.showBox({
            //     type:'error',//success/error/warning,
            //     txt:'操作失败,请重试!'
            // })
 
            this.scrollHeight = this.screenHeight - 282;
 
            setTimeout(() => {
                this.paddingTop = this.vuex_padding_top
                this.paddingTop += 5
            }, 400)
 
        },
        onLoad() {
 
        },
        methods: {
            findbumenall() {
                if (this.vuex_is_login) {
                    const params = {
                        company: this.company,
                        juese:uni.getStorageSync('juese'),
                    }
                    findbumen(params).then((res) => {
                        if (res.code == 0) {
                            for (var i = 0; i < res.data.length; i++) {
                                var json = {}
                                json.text = res.data[i].departmentName
                                // .textres.data[i]
                                this.bumenList.push(json)
                            }
 
                            // this.form.lonlat=res.data.lat+";"+res.data.lon
                            // this.tips=false
                            // this.disable=false
                        } else {
                            this.$refs.refSuccess.showBox({
                                type: 'error',
                                txt: res.msg
                            });
                        }
                    })
                }
            },
            onchange(e) {
                var list = []
                if (this.list.length < e.value) {
                    for (var i = this.list.length; i < e.value; i++) {
 
                        list.push(i)
                        this.list.push(i)
                        // e[i]
                    }
                } else {
                    this.list.splice(e.value, this.list.length - e.value)
                }
            },
            drawfence() {
                if (this.form.tagId == '') {
                    this.$refs.refSuccess.showBox({
                        type: 'error',
                        txt: '请输入设备编号'
                    });
                    return false;
                } else if (this.form.baoliu1 == '') {
                    this.$refs.refSuccess.showBox({
                        type: 'error',
                        txt: '请输入围栏高度'
                    });
                    return false;
                } else if (this.form.name == '') {
                    this.$refs.refSuccess.showBox({
                        type: 'error',
                        txt: '请输入围栏名称'
                    });
                    return false;
                } else if (this.form.bumen == '') {
                    this.$refs.refSuccess.showBox({
                        type: 'error',
                        txt: '请选择部门'
                    });
                    return false;
                } else {
                    this.$emit('goindex');
                    // uni.reLaunch({
                    //     url: '/pages/index/index'
                    // });
                }
            },
            submitForm() {
                this.form.list = this.list
                if (this.form.tagId == '') {
                    this.$refs.refSuccess.showBox({
                        type: 'error',
                        txt: '请输入设备编号采集坐标'
                    });
                    return false;
                } else if (this.form.baoliu1 == '') {
                    this.$refs.refSuccess.showBox({
                        type: 'error',
                        txt: '请输入围栏高度采集坐标'
                    });
                    return false;
                } else if (this.form.name == '') {
                    this.$refs.refSuccess.showBox({
                        type: 'error',
                        txt: '请输入围栏名称采集坐标'
                    });
                    return false;
                } else if (this.form.shape == '圆形') {
                    if (this.form.zuobiao == '') {
                        this.$refs.refSuccess.showBox({
                            type: 'error',
                            txt: '请采集坐标'
                        });
                        return false;
                    }
                    if (this.form.banjing == '') {
                        this.$refs.refSuccess.showBox({
                            type: 'error',
                            txt: '请输入围栏半径'
                        });
                        return false;
                    }
                } else if (this.form.shape == '多边形') {
                    if (this.form.list.length < 0) {
                        this.$refs.refSuccess.showBox({
                            type: 'error',
                            txt: '请采集坐标'
                        });
                        return false;
                    }
                }
                this.form.company = this.company
                if (this.vuex_is_login) {
                    submitper(this.form).then((res) => {
                        if (res.code == 0) {
                            this.$refs.refSuccess.showBox({
                                type: 'success',
                                txt: "保存成功"
                            });
                            //保存成功跳转围栏列表,清空this.form
                            this.tips = true
                            this.isAchor = false
                            setTimeout(() => {
                                this.$emit('manualRefresh');
                                this.list = []
                                this.isshape = false
                                this.form.bumen = ''
                                this.form.name = ''
                                this.form.baoliu1 = ''
                                this.form.tagId = ''
                                this.form.zuobiao = ''
                                this.form.shape = '多边形'
                                this.form.banjing = ''
                                this.form.type = '进入报警'
                                this.form.list = []
                                this.form.disable = false
                            }, 2000);
                        } else {
                            this.$refs.refSuccess.showBox({
                                type: 'error',
                                txt: res.data
                            });
                        }
                    })
                }
 
            },
            cleanconext() {
                if (this.form.zuobiao == '') {
                    this.tips = true
                    this.disable = true
                }
            },
            acquisitionxy(index) {
                if (this.form.tagId == '') {
                    this.$refs.refSuccess.showBox({
                        type: 'error',
                        txt: '请输入设备编号采集坐标'
                    });
 
                } else {
                    const params = {
                        baoliu3: this.form.tagId,
                        company: this.company,
                    }
                    if (this.vuex_is_login) {
                        acquisition(params).then((res) => {
                            if (res.code == 0) {
                                this.form.zuobiao += res.data.lat + ":" + res.data.lon + ";"
                                // this.zuobiao1=res.data.lat+";"+res.data.lon
                                // this.list.
                                this.list.splice(index, 1, res.data.lat + ";" + res.data.lon);
                                this.tips = false
                                this.disable = false
                            } else {
                                this.$refs.refSuccess.showBox({
                                    type: 'error',
                                    txt: res.msg
                                });
                            }
                        })
                    }
                }
 
            },
            shapeCallback(index) {
                this.form.shape = this.shapeList[index].text;
                if (this.shapeList[index].text == '圆形') {
                    this.isshape = true
                } else {
                    this.isshape = false
                }
            },
 
            bymenCallback(index) {
                this.form.bumen = this.bumenList[index].text;
 
            },
            typeCallback(index) {
                this.form.type = this.typeList[index].text;
            },
            goTag() {
                this.isAchor = false
                // uni.reLaunch({
                //     url: '/pages/index/equipmentCom'
                // });
                this.$emit('goAchor');
            },
            goAchor() {
                // this.isAchor = false
                this.lock = false
            },
 
            // 模拟请求加载数据
            handleLoad(data, callback) {
                const params = {
                    current: data.page,
                    size: data.size,
                }
                if (this.vuex_is_login) {
                    findFence(params).then((res) => {
                        if (res.code == 0) {
                            let list = [];
                            setTimeout(() => {
                                let list = [];
                                for (var i = 0; i < res.data.records.length; i++) {
                                    list.push(res.data.records[i]);
                                }
                                this.list = [...this.list, ...list];
                                callback({
                                    list: this.list,
                                    total: res.data.total
                                });
                            }, 1500);
                        }
                    })
                } else {
                    callback({
                        list: [],
                        total: 0
                    });
                }
            },
            handleSearch(data, callback) {
                const params = {
                    current: 1,
                    size: 10,
                    objectid: this.keyword,
                }
                if (this.vuex_is_login) {
                    findFence(params).then((res) => {
                        this.list = []
                        if (res.code == 0) {
                            let list = [];
                            setTimeout(() => {
                                let list = [];
                                for (var i = 0; i < res.data.records.length; i++) {
                                    list.push(res.data.records[i]);
                                }
                                this.list = [...this.list, ...list];
                                callback({
                                    list: this.list,
                                    total: res.data.total
                                });
                            }, 1500);
                        }
                    })
                }
 
            },
            // 模拟请求数据刷新
            handleRefresh(data, callback) {
                const params = {
                    current: data.page,
                    size: data.size,
                }
                if (this.vuex_is_login) {
                    findFence(data).then((res) => {
                        if (res.code == 0) {
                            let list = [];
                            setTimeout(() => {
                                let list = [];
                                for (var i = 0; i < res.data.records.length; i++) {
                                    list.push(res.data.records[i]);
                                }
                                this.list = []
                                this.list = [...this.list, ...list];
                                callback({
                                    list: this.list,
                                    total: res.data.total
                                });
                            }, 1500);
                        }
                    })
                }
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    /* 鼠标未悬浮时效果设置 */
    .title_linespan {
        font-size: 17px;
        font-weight: bold;
        // font-weight: 100px;
        color: #000000
    }
 
    /* 鼠标悬浮后的设置 */
    .title_linespan:hover {
        font-size: 17px;
        font-weight: bold;
        color: #00aaff;
        text-decoration: underline;
    }
 
    .modal-btn {
        position: absolute;
 
        left: 80%;
        // margin-top: -40px;
        // display: flex;
        // align-items: center;
        // justify-content: center;
        // box-sizing: border-box;
        // width: 120rpx;
        // height: 40rpx;
        // background: rgba(103, 149, 255, 0.2);
    }
 
    .page-wrap {
        height: 100%;
        width: 100%;
        // padding-top: 45px;
        padding-left: 30rpx;
        padding-right: 30rpx;
 
        .test-view {
            height: 300rpx;
        }
 
        .navbar-content {
            width: 100%;
            display: flex;
            padding: 30rpx;
            align-items: center;
            justify-content: space-between;
        }
 
        .u-icon {
            margin-left: 30rpx;
        }
 
        .item-wrap {
            background-color: #ffffff;
            // display: flex;
            margin-top: 30rpx;
            padding: 30rpx;
            align-items: center;
            border-radius: 16rpx;
            box-shadow: 0rpx 8rpx 16rpx rgba(0, 0, 0, 0.11);
 
            .avatar {
                width: 150rpx;
                height: 150rpx;
                margin-right: 30rpx;
                border-radius: 16rpx;
                background-color: #c0c0c0;
            }
 
            .item {
                width: 100rpx;
                height: 30rpx;
                margin-bottom: 10rpx;
                border-radius: 16rpx;
                background-color: #c8c7cc;
            }
 
        }
    }
 
    .container {
        width: 100%;
        position: 'absolute';
        z-index: 9999999;
        padding: 20px;
    }
 
    .card {
        background-color: #fff;
        padding: 15px;
        margin-bottom: 20px;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
 
    .title {
        font-size: 18px;
        font-weight: bold;
    }
 
    .tags {
        margin-top: 10px;
    }
 
    .tag {
        display: inline-block;
        padding: 2px 5px;
        border-radius: 3px;
        margin-right: 5px;
        font-size: 12px;
    }
 
    .sos {
        background-color: #f8bbd0;
        color: #fff;
    }
 
    .time {
        margin-top: 10px;
        font-size: 14px;
        color: #666;
    }
 
    .form-item {
        margin-top: 15px;
    }
 
    .picker {
        margin-top: 5px;
    }
 
    .submit-button {
        margin-top: 20px;
        background-color: #007aff;
        color: #fff;
        padding: 10px;
        border-radius: 5px;
    }
</style>