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
/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            reportCommunitySpaceInfo: {
                communitySpaces: [],
                venues: [],
                persons: [],
                total: 0,
                records: 1,
                moreCondition: false,
                spaceId: '',
                appointmentTime: vc.getDateYYYYMMDD(),
                conditions: {
                    spaceId: '',
                    name: '',
                    state: '',
                    venueId: '',
                    communityId: vc.getCurrentCommunity().communityId
                }
            }
        },
        _initMethod: function () {
            vc.initDate('queryDate', function (_value) {
                $that.reportCommunitySpaceInfo.appointmentTime = _value;
            });
            $that._listCommunityVenues();
        },
        _initEvent: function () {
            vc.on('communitySpaceManage', 'listCommunityVenue', function (_param) {
                vc.component._listCommunityVenues(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('communitySpaceManage', 'listCommunitySpacePerson', function (_param) {
                vc.component._listCommunitySpacePerson(DEFAULT_PAGE, DEFAULT_ROWS);
            });
        },
        methods: {
            _listCommunitySpaces: function (_page, _rows) {
                vc.component.reportCommunitySpaceInfo.conditions.page = _page;
                vc.component.reportCommunitySpaceInfo.conditions.row = _rows;
                var param = {
                    params: vc.component.reportCommunitySpaceInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/communitySpace.listCommunitySpace',
                    param,
                    function (json, res) {
                        let _reportCommunitySpaceInfo = JSON.parse(json);
                        vc.component.reportCommunitySpaceInfo.total = _reportCommunitySpaceInfo.total;
                        vc.component.reportCommunitySpaceInfo.records = _reportCommunitySpaceInfo.records;
                        vc.component.reportCommunitySpaceInfo.communitySpaces = _reportCommunitySpaceInfo.data;
                        vc.emit('pagination', 'init', {
                            total: vc.component.reportCommunitySpaceInfo.records,
                            dataCount: vc.component.reportCommunitySpaceInfo.total,
                            currentPage: _page
                        });
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                        vc.component.reportCommunitySpaceInfo.communitySpaces = [];
                        vc.component.reportCommunitySpaceInfo.total = 0;
                        vc.component.reportCommunitySpaceInfo.records = 0;
                    }
                );
            },
            _listCommunitySpacePerson: function () {
                var param = {
                    params: {
                        page: 1,
                        row: 50,
                        venueId: $that.reportCommunitySpaceInfo.conditions.venueId,
                        appointmentTime: $that.reportCommunitySpaceInfo.appointmentTime,
                        communityId: vc.getCurrentCommunity().communityId,
                        state: 'S'
                    }
                };
                //发送get请求
                vc.http.apiGet('/communitySpace.listCommunitySpacePerson',
                    param,
                    function (json, res) {
                        let _reportCommunitySpaceInfo = JSON.parse(json);
                        vc.component.reportCommunitySpaceInfo.persons = _reportCommunitySpaceInfo.data;
                        $that._listCommunitySpaces(DEFAULT_PAGE, DEFAULT_ROWS);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _listCommunityVenues: function (_page, _rows) {
                let param = {
                    params: {
                        page: 1,
                        row: 100,
                        communityId: vc.getCurrentCommunity().communityId
                    }
                };
                //发送get请求
                vc.http.apiGet('/communityVenue.listCommunityVenue',
                    param,
                    function (json, res) {
                        let _communityVenue = JSON.parse(json);
                        vc.component.reportCommunitySpaceInfo.venues = _communityVenue.data;
                        if (_communityVenue.data && _communityVenue.data.length > 0) {
                            $that.swatchVenue(_communityVenue.data[0]);
                        }
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                        vc.component.reportCommunitySpaceInfo.venues = [];
                        vc.component.reportCommunitySpaceInfo.communitySpaces = [];
                        vc.component.reportCommunitySpaceInfo.persons = [];
                    }
                );
            },
            _openAddCommunitySpaceModal: function () {
                if (!$that.reportCommunitySpaceInfo.conditions.venueId) {
                    vc.toast('未选择场馆');
                    return;
                }
                vc.emit('addCommunitySpace', 'openAddCommunitySpaceModal', {
                    venueId: $that.reportCommunitySpaceInfo.conditions.venueId
                });
            },
            _getSpaceHoursTime: function (_hours, _space) {
                let _times = _space.openTimes;
                let _person = '';
                _times.forEach(item => {
                    if (item.hours == _hours && item.isOpen == 'N') {
                        _person = '不可预约';
                    }
                });
                if (_person) {
                    return _person;
                }
                let _persons = $that.reportCommunitySpaceInfo.persons;
                _persons.forEach(item => {
                    if (item.spaceId == _space.spaceId) {
                        item.times.forEach(itemTime => {
                            if (itemTime.hours == _hours) {
                                _person = item.personName + ">" + item.personTel;
                            }
                        })
                    }
                })
                if (_person) {
                    return _person;
                }
                return "可预约";
            },
            swatchVenue: function (_venue) {
                $that.reportCommunitySpaceInfo.conditions.venueId = _venue.venueId;
                $that._listCommunitySpacePerson();
            },
            _moreCondition: function () {
                if (vc.component.reportCommunitySpaceInfo.moreCondition) {
                    vc.component.reportCommunitySpaceInfo.moreCondition = false;
                } else {
                    vc.component.reportCommunitySpaceInfo.moreCondition = true;
                }
            },
            _openAddCommunitySpacePersonModal: function (_spaceId, _hours) {
                vc.emit('addCommunitySpacePerson', 'openAddCommunitySpacePersonModal', {
                    spaceId: _spaceId,
                    hours: _hours,
                    appointmentTime: $that.reportCommunitySpaceInfo.appointmentTime,
                    openTime: _hours
                });
            },
            _changeDateQuery: function () {
                $that._listCommunityVenues();
            }
        }
    });
})(window.vc);