whychdw
2019-12-09 064c6d5b84fd6ddbbe4c20c41d139f7371460985
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
<template>
    <div class="flex-layout">
        <div class="flex-header">
            <Row>
                <i-col span="12" class="white">维护区</i-col>
                <i-col span="12" class="white">机房名称</i-col>
                <i-col span="12">
                    <Select 
                    v-model="linkage.StationName1.value" 
                    style="width: 80%"
                    @on-change="searchStationName"
                    filterable
                    clearable>
                        <Option value="-1">全部(共{{linkage.StationName1.data.length}})</Option>
                        <Option v-for="item in linkage.StationName1.data" :value="item.StationName1" :key="item.StationName1">{{ item.StationName1 }}</Option>
                    </Select>
                </i-col>
                <i-col span="12">
                    <Select 
                    v-model="linkage.StationName.value" 
                    style="width: 80%"
                    @on-change="handleStationNameChange"
                    filterable
                    clearable>
                        <Option value="-1">全部(共{{linkage.StationName.data.length}})</Option>
                        <Option v-for="item in linkage.StationName.data" :value="item.StationName" :key="item.StationName">{{ item.StationName }}</Option>
                    </Select>
                </i-col>
            </Row>
            <br>
        </div>
        <div class="tbl-tools">
            <div class="tbl-tools-inner">
                <Row>
                    <i-col span="12">
                        <Button type="primary" @click="searchBatt" icon="md-search" size="small">查询</Button>
                        <Button type="primary" @click="newHome.show=true" icon="md-home" size="small">新建机房</Button>
                        <Button type="primary" @click="showNewBattModal" icon="md-battery-charging" size="small">新建电池组</Button>
                        <Button type="primary" @click="showEditBattModal" icon="md-brush" size="small">编辑</Button>
                        <Button type="error" @click="delBattConfirm" icon="ios-trash" size="small">删除</Button>
                    </i-col>
                </Row>
                <!-- <Button type="success" icon="md-refresh" size="small">刷新</Button> -->
            </div>
        </div>
        <div class="flex-body" ref="main">
            <Table 
            highlight-row
            :height="tbl.height"
            :loading="tbl.loading"
            border 
            :columns="tbl.columns" 
            :data="tbl.data"
            size="small"
            @on-row-click="handleTblClick">
                <!-- <template slot-scope="{ row, index }" slot="action">
                    <Button type="primary" size="small" style="margin-right: 5px">编辑</Button>
                    <Button type="error" size="small">删除</Button>
                </template> -->
            </Table>
        </div>
        <div class="flex-footer">
            <div class="flex-footer-inner">
                <Page 
                size="small" 
                :total="page.pageAll" 
                :page-size="page.pageSize"
                @on-change="handlePageChange"
                @on-page-size-change="handlePageSizeChange"
                show-sizer/>
            </div>
        </div>
        <Modal
        v-model="newHome.show"
        :width="960"
        title="新建机房"
        footer-hide
        :mask-closable="false">
            <new-home v-if="newHome.show" @ensure="newHomeEnsure"></new-home>
        </Modal>
        <Modal
        v-model="newBatt.show"
        :width="960"
        title="新建电池组"
        footer-hide
        :mask-closable="false">
            <new-batt v-if="newBatt.show" :info="tbl.active"  @ensure="newBattEnsure"></new-batt>
        </Modal>
        <Modal
        v-model="editBatt.show"
        :width="960"
        title="修改电池组"
        footer-hide
        :mask-closable="false">
            <edit-batt v-if="editBatt.show" :info="tbl.active"  @ensure="eidtBattEnsure"></edit-batt>
        </Modal>
    </div>
</template>
<script>
import NewHome from '../../components/NewHome'
import NewBatt from '../../components/NewBatt'
import EditBatt from '../../components/EidtBatt'
import {ajax} from '../../libs/common'
export default {
    components: {
        NewHome,    // 新建机房
        NewBatt,    // 新建电池组
        EditBatt,   // 修改电池组信息
    },
    data () {
        return {
            tbl: {
                height: 300,
                loading: true,
                columns: [
                    {
                        title: '机房编号',
                        key: 'StationId',
                        align: "center",
                        width: 120,
                    },
                    {
                        title: '省',
                        key: 'StationName1',
                        align: "center",
                        width: 100
                    },
                    {
                        title: '市',
                        key: 'StationName2',
                        align: "center",
                        width: 100
                    },
                    {
                        title: '区县',
                        key: 'StationName5',
                        align: "center",
                        width: 100
                    },
                    {
                        title: '机房名称',
                        key: 'StationName3',
                        align: "center",
                        width: 360
                    },
                    {
                        title: '设备名称',
                        key: 'StationName4',
                        align: "center",
                        width: 160
                    },
                    {
                        title: '机房ip',
                        key: 'StationIp',
                        align: "center",
                        width: 160
                    },
                    {
                        title: 'FBS设备ID(重要)',
                        key: 'FBSDeviceId',
                        align: "center",
                        width: 160
                    },
                    {
                        title: 'FBS设备IP(重要)',
                        key: 'FbsDeviceIp',
                        align: "center",
                        width: 160
                    },
                    {
                        title: '子网掩码',
                        key: 'FbsDeviceIp_YM',
                        align: "center",
                        width: 160
                    },
                    {
                        title: '网关',
                        key: 'FbsDeviceIp_WG',
                        align: "center",
                        width: 160
                    },
                    {
                        title: 'FBS设备名称',
                        key: 'FBSDeviceName',
                        align: "center",
                        width: 160
                    },
                    {
                        title: 'FBS设备索引',
                        key: 'GroupIndexInFBSDevice',
                        align: "center",
                        width: 160
                    },
                    {
                        title: '电池组ID',
                        key: 'BattGroupId',
                        align: "center",
                        width: 160,
                    },
                    {
                        title: '机房内电池组组数',
                        key: 'BattGroupNum',
                        align: "center",
                        width: 160,
                    },
                    {
                        title: '电池组名称',
                        key: 'BattGroupName',
                        align: "center",
                        width: 160,
                    },
                    {
                        title: '浮充电压阀值',
                        key: 'FloatVolLevel',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'OfflineVolLevel',
                        title: '离线电压阀值',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'BattFloatCurrent',
                        title: '浮充阀值',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'MonCount',
                        title: '单体数量',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'MonCapStd',
                        title: '标称容量',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'MonVolStd',
                        title: '标称单体电压',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'MonResStd',
                        title: '标称单体内阻',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'MonSerStd',
                        title: '标称单体电导',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'MonVolLowToAvg',
                        title: '单体电压次低偏移量',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'Load_curr',
                        title: '负载电流',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'DisCurrMax',
                        title: '最大核容电流',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'station_phone',
                        title: '基站手机号码',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'BattProducer',
                        title: '电池品牌',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'BattModel',
                        title: '电池型号',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'BattProductDate',
                        title: '电池生产日期',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'BattInUseDate',
                        title: '投入使用日期',
                        align: "center",
                        width: 160,
                    },
                    {
                        key: 'Vol_grade',
                        title: '电压等级(kV)',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'Manufacturers',
                        title: '生产厂家',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'Assetequipment',
                        title: '是否资产级设备',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'Deviceclasspath',
                        title: '设备分类全路径',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'Deviceoperationdepartment',
                        title: '设备运维部门',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'PropertyRightUnit',
                        title: '产权单位',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'PropertyAttribute',
                        title: '产权属性',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'FactoryNumber',
                        title: '出厂编号',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'OperationTeam',
                        title: '运维(保管)班组',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'DeviceIdentityCode',
                        title: '设备身份编码',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'ProjectType',
                        title: '项目类型',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'BatteryApplicationType',
                        title: '蓄电池应用类型',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'SingleRatedVoltage',
                        title: '单电压额定电压',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'RemoteMonitor',
                        title: '是否实现远程监控',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'BatttIndependentPlaced',
                        title: '是否独立蓄电池室放置',
                        align: 'center',
                        width: 160
                    },
                    {
                        key: 'JunChargeVoltageValue',
                        title: '均充电压设定值',
                        align: 'center',
                        width: 160
                    }
                ],
                data: [],
                active: -1
            },
            page: {
                pageCurr:1,
                pageSize:20,
                pageAll:0,
            },
            linkage: {
                StationName1: {
                    value: '-1',
                    data: []
                },
                StationName: {
                    value: '-1',
                    data: []
                },
            },
            newHome: {
                show: false
            },
            newBatt: {
                show: false
            },
            editBatt: {
                show: false
            }
        }
    },
    methods: {
        searchStationName1() {  // 查询维护区
            var self = this;
            // 请求后台
            ajax({
                url: 'BattInfAction_serchByStation',
                data: null,
                success: function(res) {
                    var rs = JSON.parse(res.result);
                    var data = [];
                    if(rs.code == 1) {
                        data = rs.data;
                    }
                    // 设置StationName1.data的值
                    self.linkage.StationName1.data = data;
                },
                complete: function() {
                    self.searchStationName();
                }
            });
        },
        searchStationName() {   // 查询机房名称
            var self = this;
            // StationName1.value == undefined 不执行查询
            if(this.linkage.StationName1.value == undefined) {
                return;
            }
            // 构造查询条件
            var StationName1 = this.linkage.StationName1.value == -1?"":this.linkage.StationName1.value;
            // 请求后台
            ajax({
                url: 'BattInfAction_serchByStationName',
                data: 'bif.StationName1='+StationName1,
                success: function(res) {
                    var rs = JSON.parse(res.result);
                    var data = [];
                    if(rs.code == 1) {
                        data = rs.data;
                    }
                    // 初始化StationName.value的值
                    self.linkage.StationName.value = '-1';
                    // 设置StationName.data的值
                    self.linkage.StationName.data = data;
                },
                complete: function() {
                    // 初始化分页信息
                    self.page.pageCurr = 1;
                    // 查询电池信息
                    self.searchBatt();
                }
            });
        },
        handleStationNameChange: function() {
            // 初始化分页信息
            this.page.pageCurr = 1;
            // 查询电池信息
            this.searchBatt();
        },
        searchBatt: function() {
            var self = this;
            // StationName1.value == undefined不执行查询
            if(this.linkage.StationName1.value == undefined) {
                return;
            }
            // StationName.value == undefined不执行查询
            if(this.linkage.StationName.value == undefined) {
                return;
            }
            // 开启等待框
            this.tbl.loading = true;
            // 设置维护区和机房名称
            var StationName1 = this.linkage.StationName1.value==-1?"":this.linkage.StationName1.value;
            var StationName = this.linkage.StationName.value==-1?"":this.linkage.StationName.value;
            // 构造查询对象
            var searchParams = {
                binf:{
                    StationName: StationName,
                    StationName1: StationName1,
                },
                page: this.page,    
            };
            // 初始化active
            this.tbl.active = -1;
            // 请求后台
            ajax({
                url: 'BattInfAction!searchInform',
                data: 'json='+JSON.stringify(searchParams),
                success: function(res) {
                    var rs = JSON.parse(res.result);
                    var data = [];
                    var pageAll = 0;
                    if(rs.code == 1) {
                        data = rs.data;
                        pageAll = data[data.length-1].num;
                    }
                    self.page.pageAll = pageAll;
                    self.tbl.data = data;
                },
                complete: function() {
                    // 关闭等待框
                    self.tbl.loading = false;
                }
            });
        },
        handleTblClick: function(data, index) {
            // 设置被点击行的数据
            this.tbl.active = data;
        },
        handlePageChange: function(curr) {
            this.page.pageCurr = curr;
            // 查询电池信息
            this.searchBatt();
        },
        handlePageSizeChange: function(size) {
            // 初始化pageCurr
            this.page.pageCurr = 1;
            // 设置pageSize
            this.page.pageSize = size;
            // 查询电池信息
            this.searchBatt();
        },
        showNewBattModal: function() {
            if(this.tbl.active != -1) {
                this.newBatt.show = true;
            }else {
                this.$Message.warning("请先选择机房!")
            }
        },
        showEditBattModal: function() {
            if(this.tbl.active != -1) {
                this.editBatt.show = true;
            }else {
                this.$Message.warning("请先选择电池组!")
            }
        },
        newHomeEnsure: function(valid) {
            if(valid) {
                this.newHome.show = false;
                this.searchStationName1();
            }
        },
        newBattEnsure: function(valid) {
            if(valid) {
                this.newBatt.show = false;
                this.searchBatt();
            }
        },
        eidtBattEnsure: function(valid) {
            if(valid) {
                this.editBatt.show = false;
                this.searchBatt();
            }
        },
        delBattConfirm: function() {
            var self = this;
            if(this.tbl.active != -1) {
                this.$Modal.confirm({
                    title: '系统提示',
                    content: '删除<span style="color: red">'+this.tbl.active.StationName+'-'+this.tbl.active.BattGroupName+'</span>',
                    loading: true,
                    onOk:()=>{
                        this.delBatt();
                    }
                });
            }else {
                this.$Message.warning("请先选择电池组!")
            }
        },
        delBatt: function() {
            var self = this;
            var home = Object.assign({}, this.tbl.active);
            console.log(home);
            // 构造查询条件
            var searchParams = [home];
            // 请求后台添加
            ajax({
                url: 'BattInfAction!delete',
                data: 'json='+JSON.stringify(searchParams),
                success: function(res) {
                    var rs = JSON.parse(res.result);
                    if(rs.code == 1) {
                        self.$Message.success('删除成功!');
                    }else {
                        self.$Message.error('删除失败!');
                    }
                },
                error: function() {
                    self.$Message.error('删除失败!');
                },
                complete: function() {
                    // 关闭按钮的等待框
                    self.$Modal.remove();
                    self.searchStationName1();
                }
            });
            
        },
        setHt: function() {
            var main = this.$refs.main;
            var ht = main.offsetHeight;
            this.tbl.height = ht-5;
        },
    },
    mounted() {
        var self = this;
 
        // 设置高度
        this.setHt();
 
        // 延时执行
        setTimeout(function() {
            // 查询维护区
            self.searchStationName1();
        }, 300);
    }
}
</script>
<style scoped>
.flex-footer-inner {
    padding: 4px 0;
    text-align: center;
}
.ivu-col.white {
    color: #FFFFFF;
}
.tbl-tools-inner {
    padding: 4px 4px;
}
.tbl-tools-inner .ivu-btn {
    margin-left: 8px;
}
</style>