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
/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            communitySpaceManageInfo: {
                communitySpaces: [],
                venues: [],
                total: 0,
                records: 1,
                moreCondition: false,
                spaceId: '',
                conditions: {
                    spaceId: '',
                    name: '',
                    state: '',
                    venueId: '',
                    communityId: vc.getCurrentCommunity().communityId
                }
            }
        },
        _initMethod: function () {
            $that._listCommunityVenues();
            vc.component._listCommunitySpaces(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('communitySpaceManage', 'listCommunityVenue', function (_param) {
                vc.component._listCommunityVenues(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('communitySpaceManage', 'listCommunitySpace', function (_param) {
                vc.component._listCommunitySpaces(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                vc.component._listCommunitySpaces(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listCommunitySpaces: function (_page, _rows) {
                vc.component.communitySpaceManageInfo.conditions.page = _page;
                vc.component.communitySpaceManageInfo.conditions.row = _rows;
                var param = {
                    params: vc.component.communitySpaceManageInfo.conditions
                };
                param.params.spaceId = param.params.spaceId.trim();
                param.params.name = param.params.name.trim();
                //发送get请求
                vc.http.apiGet('/communitySpace.listCommunitySpace',
                    param,
                    function (json, res) {
                        let _communitySpaceManageInfo = JSON.parse(json);
                        vc.component.communitySpaceManageInfo.total = _communitySpaceManageInfo.total;
                        vc.component.communitySpaceManageInfo.records = _communitySpaceManageInfo.records;
                        vc.component.communitySpaceManageInfo.communitySpaces = _communitySpaceManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: vc.component.communitySpaceManageInfo.records,
                            dataCount: vc.component.communitySpaceManageInfo.total,
                            currentPage: _page
                        });
                    },
                    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);
                        $that.communitySpaceManageInfo.venues = _communityVenue.data;
                        if (_communityVenue.data && _communityVenue.data.length > 0) {
                            $that.swatchVenue(_communityVenue.data[0]);
                        }
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddCommunitySpaceModal: function () {
                if (!$that.communitySpaceManageInfo.conditions.venueId) {
                    vc.toast('未选择场馆');
                    return;
                }
                vc.emit('addCommunitySpace', 'openAddCommunitySpaceModal', {
                    venueId: $that.communitySpaceManageInfo.conditions.venueId
                });
            },
            _openEditCommunitySpaceModel: function (_communitySpace) {
                vc.emit('editCommunitySpace', 'openEditCommunitySpaceModal', _communitySpace);
            },
            _openEditOpenTime: function (_communitySpace) {
                vc.emit('editCommunitySpaceOpenTime', 'openEditCommunitySpaceModal', _communitySpace);
            },
            _openDeleteCommunitySpaceModel: function (_communitySpace) {
                vc.emit('deleteCommunitySpace', 'openDeleteCommunitySpaceModal', _communitySpace);
            },
            //查询
            _queryCommunitySpaceMethod: function () {
                vc.component._listCommunitySpaces(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetCommunitySpaceMethod: function () {
                vc.component.communitySpaceManageInfo.conditions.spaceId = "";
                vc.component.communitySpaceManageInfo.conditions.name = "";
                vc.component.communitySpaceManageInfo.conditions.state = "";
                vc.component._listCommunitySpaces(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _openAddCommunityVenueModal: function () {
                vc.emit('addCommunityVenue', 'openAddCommunityVenueModal', {});
            },
            _openEditCommunityVenueModel: function (_communityVenue) {
                if (!$that.communitySpaceManageInfo.conditions.venueId) {
                    vc.toast('未选择场馆');
                    return;
                }
                vc.emit('editCommunityVenue', 'openEditCommunityVenueModal', {
                    venueId: $that.communitySpaceManageInfo.conditions.venueId
                });
            },
            _openDeleteCommunityVenueModel: function (_communityVenue) {
                if (!$that.communitySpaceManageInfo.conditions.venueId) {
                    vc.toast('未选择场馆');
                    return;
                }
                vc.emit('deleteCommunityVenue', 'openDeleteCommunityVenueModal', {
                    venueId: $that.communitySpaceManageInfo.conditions.venueId
                });
            },
            swatchVenue: function (_venue) {
                $that.communitySpaceManageInfo.conditions.venueId = _venue.venueId;
                $that._listCommunitySpaces(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if (vc.component.communitySpaceManageInfo.moreCondition) {
                    vc.component.communitySpaceManageInfo.moreCondition = false;
                } else {
                    vc.component.communitySpaceManageInfo.moreCondition = true;
                }
            }
        }
    });
})(window.vc);