zhangjiaqing
8 天以前 1cef3adee31c6934c0da4b4f0b8a6f5ac03b364f
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
/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            monitorMachineManageInfo: {
                machines: [],
                total: 0,
                records: 1,
                moreCondition: false,
                machineName: '',
                machineTypes: [],
                conditions: {
                    machineCode: '',
                    machineTypeCd: '9998',
                    machineName: '',
                    machineIp: '',
                    machineMac: '',
                    communityId: vc.getCurrentCommunity().communityId,
                    domain: 'MONITOR'
                },
                listColumns: []
            }
        },
        _initMethod: function () {
            //vc.component._listMachines(DEFAULT_PAGE, DEFAULT_ROWS);
            vc.getDict('machine', "machine_type_cd", function (_data) {
                vc.component.monitorMachineManageInfo.machineTypes = _data;
            });
            $that._getColumns(function () {
                vc.component._listMachines(DEFAULT_PAGE, DEFAULT_ROWS);
            });
        },
        _initEvent: function () {
            vc.on('monitorMachineManage', 'listMachine', function (_param) {
                vc.component._listMachines(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                vc.component._listMachines(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listMachines: function (_page, _rows) {
                vc.component.monitorMachineManageInfo.conditions.page = _page;
                vc.component.monitorMachineManageInfo.conditions.row = _rows;
                let param = {
                    params: vc.component.monitorMachineManageInfo.conditions
                };
                param.params.machineName = param.params.machineName.trim();
                param.params.machineCode = param.params.machineCode.trim();
                //发送get请求
                vc.http.apiGet('/machine.listMachines',
                    param,
                    function (json, res) {
                        let _monitorMachineManageInfo = JSON.parse(json);
                        vc.component.monitorMachineManageInfo.total = _monitorMachineManageInfo.total;
                        vc.component.monitorMachineManageInfo.records = _monitorMachineManageInfo.records;
                        vc.component.monitorMachineManageInfo.machines = _monitorMachineManageInfo.machines;
                        $that.dealMachineAttr(vc.component.monitorMachineManageInfo.machines);
                        vc.emit('pagination', 'init', {
                            total: vc.component.monitorMachineManageInfo.records,
                            dataCount: vc.component.monitorMachineManageInfo.total,
                            currentPage: _page
                        });
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddMachineModal: function () {
                vc.emit('addMonitorMachine', 'openAddMachineModal', {});
            },
            _openEditMachineModel: function (_machine) {
                vc.emit('editMonitorMachine', 'openEditMachineModal', _machine);
            },
            _openDeleteMachineModel: function (_machine) {
                vc.emit('deleteMachine', 'openDeleteMachineModal', _machine);
            },
            //查询
            _queryMachineMethod: function () {
                vc.component._listMachines(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetMachineMethod: function () {
                vc.component.monitorMachineManageInfo.conditions.machineName = "";
                vc.component.monitorMachineManageInfo.conditions.machineCode = "";
                vc.component._listMachines(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if (vc.component.monitorMachineManageInfo.moreCondition) {
                    vc.component.monitorMachineManageInfo.moreCondition = false;
                } else {
                    vc.component.monitorMachineManageInfo.moreCondition = true;
                }
            },
            _openMachineDetailModel: function (_machine) {
            },
            dealMachineAttr: function (machines) {
                machines.forEach(item => {
                    $that._getColumnsValue(item);
                });
            },
            _getColumnsValue: function (_machine) {
                _machine.listValues = [];
                if (!_machine.hasOwnProperty('machineAttrs') || _machine.machineAttrs.length < 1) {
                    $that.monitorMachineManageInfo.listColumns.forEach(_value => {
                        _machine.listValues.push('');
                    })
                    return;
                }
                let _machineAttrs = _machine.machineAttrs;
                $that.monitorMachineManageInfo.listColumns.forEach(_value => {
                    let _tmpValue = '';
                    _machineAttrs.forEach(_attrItem => {
                        if (_value == _attrItem.specName) {
                            _tmpValue = _attrItem.valueName;
                        }
                    })
                    _machine.listValues.push(_tmpValue);
                })
            },
            _getColumns: function (_call) {
                console.log('_getColumns');
                $that.monitorMachineManageInfo.listColumns = [];
                vc.getAttrSpec('machine_attr', function (data) {
                    $that.monitorMachineManageInfo.listColumns = [];
                    data.forEach(item => {
                        if (item.listShow == 'Y') {
                            $that.monitorMachineManageInfo.listColumns.push(item.specName);
                        }
                    });
                    _call();
                }, 'MONITOR');
            },
            _openViewVideoModel: function (_machine) {
                vc.emit('viewCameraVideo', 'openCameraVideoModal', _machine);
            }
        }
    });
})(window.vc);