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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
(function (vc) {
 
    vc.extends({
        data: {
            ownerExitRoomInfo: {
                name: '',
                link: '',
                ownerId: '',
                idCard: '',
                rooms: [],
                selectRooms: [],
                batchFees: [],
                fees: [],
                quan: false
            }
        },
        watch: { // 监视双向绑定的数据数组
            'ownerExitRoomInfo.selectRooms': {
                handler() { // 数据数组有变化将触发此函数
                    if ($that.ownerExitRoomInfo.rooms.length == $that.ownerExitRoomInfo.selectRooms.length) {
                        $that.ownerExitRoomInfo.quan = true;
                    } else {
                        $that.ownerExitRoomInfo.quan = false;
                    }
                    $that._dealFees();
                },
                deep: true // 深度监视
            }
        },
        _initMethod: function () {
 
        },
        _initEvent: function () {
 
            vc.on('ownerExitRoom', 'chooseOwner', function (param) {
                vc.copyObject(param, $that.ownerExitRoomInfo);
                $that.listRoom();
            })
 
            vc.on('ownerExitRoom', 'notifyFeeConfig', function (fee) {
                $that.ownerExitRoomInfo.fees.push(fee);
            })
        },
        methods: {
            ownerExitRoomValidate() {
                return vc.validate.validate({
                    ownerExitRoomInfo: $that.ownerExitRoomInfo
                }, {
                    'ownerExitRoomInfo.ownerId': [{
                        limit: "required",
                        param: "",
                        errInfo: "业主不能为空"
                    }
                    ],
                });
            },
            saveOwnerExitRoomInfo: function () {
                if (!$that.ownerExitRoomValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }
                let _selectRoom = $that.ownerExitRoomInfo.selectRooms;
                if(!_selectRoom || _selectRoom.length <1){
                    vc.toast('未选择房屋');
                    return ;
                }
 
                let _fees = $that.ownerExitRoomInfo.fees;
                let _feeFlag = false;
                _fees.forEach(_feeItem =>{
                    if(_feeItem.state == '2008001'){
                        _feeFlag = true;
                    }
                });
                if(_feeFlag){
                    vc.toast('房屋还存在费用,请先在业务受理处理费用');
                    return ;
                }
 
                $that.ownerExitRoomInfo.communityId = vc.getCurrentCommunity().communityId;
                vc.http.apiPost(
                    '/owner.ownerExitRoom',
                    JSON.stringify($that.ownerExitRoomInfo), {
                    emulateJSON: true
                },
                    function (json, res) {
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            vc.toast('提交成功');
                            $that._goBack();
                            return;
                        }
                        vc.toast(_json.msg);
 
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
 
                        vc.toast(errInfo);
 
                    });
            },
            clearAddHandoverInfo: function () {
                $that.ownerExitRoomInfo = {
                    name: '',
                    link: '',
                    remark: '',
                    ownerId: '',
                    idCard: '',
                    rooms: [],
                    fees: [],
                    quan: false
                };
            },
            _goBack: function () {
                vc.goBack();
            },
            _selectOwner: function () {
                vc.emit('searchOwner', 'openSearchOwnerModel', {});
            },
            listRoom: function () {
                var param = {
                    params: {
                        page: 1,
                        row: 100,
                        ownerId: $that.ownerExitRoomInfo.ownerId,
                        communityId: vc.getCurrentCommunity().communityId
                    }
                };
                //发送get请求
                vc.http.apiGet('/room.queryRoomsByOwner',
                    param,
                    function (json, res) {
                        let listRoomData = JSON.parse(json);
                        $that.ownerExitRoomInfo.rooms = listRoomData.rooms;
                        listRoomData.rooms.forEach(_room =>{
                            $that.ownerExitRoomInfo.selectRooms.push(_room.roomId);
                        })
                        $that._loadBatchFees();
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _createFeeOrder: function () {
                vc.emit('selectFeeConfig', 'openSelectFeeConfigModal', {
                    call: 'ownerExitRoom'
                })
            },
            _openDelFeeModel: function (_room) {
                let _tmpFees = [];
                $that.ownerExitRoomInfo.fees.forEach(item => {
                    if (item.configId != _room.configId) {
                        _tmpFees.push(item);
                    }
                });
                $that.ownerExitRoomInfo.fees = _tmpFees;
            },
            _loadBatchFees: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 500,
                        communityId: vc.getCurrentCommunity().communityId,
                        ownerId: $that.ownerExitRoomInfo.ownerId,
                        payerObjType: '3333',
                        state: '2008001'
                    }
                };
                //发送get请求
                vc.http.apiGet('/fee.listFee',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        let _fees = _json.fees;
                        if (!_fees || _fees.length < 1) {
                            return;
                        }
                        $that.ownerExitRoomInfo.batchFees = _fees;
                        $that._dealFees();
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            _dealFees: function () {
                let _selectRooms = $that.ownerExitRoomInfo.selectRooms;
                let _batchFees = $that.ownerExitRoomInfo.batchFees;
                $that.ownerExitRoomInfo.fees = [];
                _selectRooms.forEach(item => {
                    _batchFees.forEach(itemFee => {
                        if (item == itemFee.payerObjId) {
                            $that.ownerExitRoomInfo.fees.push(itemFee);
                        }
                    })
                })
            },
            checkAll: function (e) {
                let checkObj = document.querySelectorAll('.checkItem'); // 获取所有checkbox项
                if (e.target.checked) { // 判定全选checkbox的勾选状态
                    for (var i = 0; i < checkObj.length; i++) {
                        if (!checkObj[i].checked) { // 将未勾选的checkbox选项push到绑定数组中
                            $that.ownerExitRoomInfo.selectRooms.push(checkObj[i].value);
                        }
                    }
                } else { // 如果是去掉全选则清空checkbox选项绑定数组
                    $that.ownerExitRoomInfo.selectRooms = [];
                }
                $that._dealFees()
            }
        }
    });
 
})(window.vc);