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
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
/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROW = 10;
    vc.extends({
        data: {
            shopsUnits: [],
            shopsInfo: {
                shopss: [],
                total: 0,
                records: 1,
                floorId: '',
                unitId: '',
                state: '',
                roomNum: '',
                moreCondition: false,
                conditions: {
                    floorId: '',
                    floorName: '',
                    unitId: '',
                    roomNum: '',
                    roomId: '',
                    state: '',
                    section: '',
                    roomType: '2020602',
                    roomName: ''
                },
                listColumns: []
            }
        },
        _initMethod: function () {
            vc.component.shopsInfo.conditions.floorId = vc.getParam("floorId");
            vc.component.shopsInfo.conditions.floorName = vc.getParam("floorName");
            vc.component.listShops(DEFAULT_PAGE, DEFAULT_ROW);
        },
        _initEvent: function () {
            vc.on('shops', 'chooseFloor', function (_param) {
                vc.component.shopsInfo.conditions.floorId = _param.floorId;
                vc.component.shopsInfo.conditions.floorName = _param.floorName;
                vc.component.loadUnits(_param.floorId);
            });
            vc.on('shops', 'listShops', function (_param) {
                vc.component.listShops(DEFAULT_PAGE, DEFAULT_ROW);
            });
            vc.on('shops', 'loadData', function (_param) {
                vc.component.listShops(DEFAULT_PAGE, DEFAULT_ROW);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                vc.component.listShops(_currentPage, DEFAULT_ROW);
            });
        },
        methods: {
            listShops: function (_page, _row) {
                vc.component.shopsInfo.conditions.page = _page;
                vc.component.shopsInfo.conditions.row = _row;
                vc.component.shopsInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
                var param = {
                    params: JSON.parse(JSON.stringify(vc.component.shopsInfo.conditions))
                };
                param.params.roomId = param.params.roomId.trim();
                param.params.roomNum = param.params.roomNum.trim();
                let _allNum = $that.shopsInfo.conditions.roomName;
                if (_allNum.split('-').length == 2) {
                    let _allNums = _allNum.split('-')
                    param.params.floorNum = _allNums[0].trim();
                    param.params.unitNum = '0';
                    param.params.roomNum = _allNums[1].trim();
                    param.params.roomId = '';
                }
                //发送get请求
                vc.http.apiGet('/room.queryRooms',
                    param,
                    function (json, res) {
                        var listShopsData = JSON.parse(json);
                        vc.component.shopsInfo.total = listShopsData.total;
                        vc.component.shopsInfo.records = listShopsData.records;
                        vc.component.shopsInfo.shopss = listShopsData.rooms;
                        $that.dealShopsAttr(listShopsData.shopss);
                        vc.emit('pagination', 'init', {
                            total: vc.component.shopsInfo.records,
                            dataCount: vc.component.shopsInfo.total,
                            currentPage: _page
                        });
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddShops: function () {
                vc.emit('addShops', 'addShopsModel', {});
            },
            _openHireShopsModel: function (_shops) {
                _shops.shopsState = '2006';
                vc.emit('bindOwnerShops', 'bindOwnerShopsModel', _shops);
            },
            _openSellShopsModel: function (_shops) {
                _shops.shopsState = '2007';
                vc.emit('bindOwnerShops', 'bindOwnerShopsModel', _shops);
            },
            _openEditShopsModel: function (_shops) {
                //_shops.floorId = vc.component.shopsInfo.conditions.floorId;
                vc.emit('editShops', 'openEditShopsModal', _shops);
            },
            _openDelShopsModel: function (_shops) {
                //_shops.floorId = vc.component.shopsInfo.conditions.floorId;
                vc.emit('deleteRoom', 'openRoomModel', _shops);
            },
            _openDeleteShopsOwnerModel: function (_shops) {
                vc.jumpToPage('/#/pages/property/deleteOwnerRoom?ownerId=' + _shops.ownerId + "&roomType=" + _shops.roomType);
            },
            //查询
            _queryShopsMethod: function () {
                vc.component.listShops(DEFAULT_PAGE, DEFAULT_ROW);
            },
            //重置
            _resetShopsMethod: function () {
                vc.component.shopsInfo.conditions.roomNum = "";
                vc.component.shopsInfo.conditions.state = "";
                vc.component.shopsInfo.conditions.roomId = "";
                vc.component.listShops(DEFAULT_PAGE, DEFAULT_ROW);
            },
            showState: function (_state) {
                if (_state == '2001') {
                    return "已入住";
                } else if (_state == '2002') {
                    return "未入住";
                } else if (_state == '2003') {
                    return "已交定金";
                } else if (_state == '2004') {
                    return "已出租";
                } else {
                    return "未知";
                }
            },
            _moreCondition: function () {
                if (vc.component.shopsInfo.moreCondition) {
                    vc.component.shopsInfo.moreCondition = false;
                } else {
                    vc.component.shopsInfo.moreCondition = true;
                }
            },
            dealShopsAttr: function (shopss) {
                if (shopss && shopss.length > 0) {
                    $that._getColumns(shopss, function () {
                        shopss.forEach(item => {
                            $that._getColumnsValue(item);
                        });
                    });
                }
            },
            _getColumnsValue: function (_shops) {
                _shops.listValues = [];
                if (!_shops.hasOwnProperty('shopsAttrDto') || _shops.shopsAttrDto.length < 1) {
                    $that.shopsInfo.listColumns.forEach(_value => {
                        _shops.listValues.push('');
                    })
                    return;
                }
                let _shopsAttrDtos = _shops.shopsAttrDto;
                $that.shopsInfo.listColumns.forEach(_value => {
                    let _tmpValue = '';
                    if (_shopsAttrDtos && _shopsAttrDtos.length > 0) {
                        _shopsAttrDtos.forEach(_attrItem => {
                            if (_value == _attrItem.specName) {
                                _tmpValue = _attrItem.valueName;
                            }
                        })
                    }
                    _shops.listValues.push(_tmpValue);
                })
            },
            _getColumns: function (_shopss, _call) {
                $that.shopsInfo.listColumns = [];
                vc.getAttrSpec('building_shops_attr', function (data) {
                    $that.shopsInfo.listColumns = [];
                    data.forEach(item => {
                        if (item.listShow == 'Y') {
                            $that.shopsInfo.listColumns.push(item.specName);
                        }
                    });
                    _call();
                });
            }
        }
    });
})(window.vc);