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
(function(vc) {
    //员工权限
    vc.extends({
        data: {
            unitInfo: {
                units: [],
                _currentFloorId: '',
                moreCondition: false,
                conditions: {
                    floorId: '',
                    floorName: '',
                    unitNum: '',
                    layerCount: '',
                    lift: '',
                }
            }
        },
        _initMethod: function() {
            var _paramFloorId = vc.getParam("floorId");
            var _paramFloorName = vc.getParam("floorName");
            console.log('_paramFloorId', _paramFloorId);
            if (vc.notNull(_paramFloorId)) {
                vc.component.unitInfo.conditions.floorId = _paramFloorId;
                vc.component.unitInfo.conditions.floorName = _paramFloorName;
                vc.component._loadUnits({ 'floorId': _paramFloorId });
            }
 
        },
        _initEvent: function() {
            vc.on('unit', 'chooseFloor', function(_param) {
                vc.component.unitInfo.conditions.floorId = _param.floorId;
                vc.component.unitInfo.conditions.floorName = _param.floorName;
            });
 
            vc.on('unit', 'loadUnit', function(_param) {
                vc.component.unitInfo.conditions.floorId = _param.floorId;
                vc.component._loadUnits(_param);
            });
            vc.on('unit', 'loadData', function(_param) {
                vc.component._loadUnits(_param);
            });
        },
        methods: {
            _loadUnits: function(_param) {
                vc.component.unitInfo._currentFloorId = _param.floorId;
                if (!vc.notNull(_param.floorId)) {
                    return;
                }
                vc.component.unitInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
                var param = {
                    params: vc.component.unitInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/unit.queryUnits',
                    param,
                    function(json) {
                        var _unitInfo = JSON.parse(json);
                        vc.component.unitInfo.units = _unitInfo;
                    },
                    function() {
                        console.log('请求失败处理');
                    });
            },
            _openDeleteUnitModel: function(_unit) {
                _unit.floorId = vc.component.unitInfo._currentFloorId;
                vc.emit('deleteUnit', 'openUnitModel', _unit);
            },
            _openEditUnitModel: function(_unit) {
                _unit.floorId = vc.component.unitInfo._currentFloorId;
                vc.emit('editUnit', 'openUnitModel', _unit);
            },
            _openChooseFloorMethod: function() {
                vc.emit('searchFloor', 'openSearchFloorModel', {});
            },
            openAddUnitModel: function() {
                if (!vc.isNotEmpty($that.unitInfo.conditions.floorId)) {
                    vc.toast('请先选择楼栋');
                    return;
                }
                vc.emit('addUnit', 'addUnitModel', {
                    floorId: vc.component.unitInfo.conditions.floorId
                });
            },
            _queryUnitMethod: function() {
                vc.component._loadUnits({ 'floorId': vc.component.unitInfo.conditions.floorId });
            },
            _moreCondition: function() {
                if (vc.component.unitInfo.moreCondition) {
                    vc.component.unitInfo.moreCondition = false;
                } else {
                    vc.component.unitInfo.moreCondition = true;
                }
            }
        }
    });
 
})(window.vc);