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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            feeReceiptManageInfo: {
                rooms: [],
                feeReceipts: [],
                total: 0,
                records: 1,
                moreCondition: false,
                feeReceiptId: '',
                printUrl: '/print.html#/pages/property/printLXFee',
                conditions: {
                    objType: '',
                    storeName: '',
                    objId: '',
                    month: '',
                    qstartTime: '',
                    qendTime: '',
                    type: '',
                    roomId: '',
                    communityId: vc.getCurrentCommunity().communityId,
                    receiptId: ''
                }
            }
        },
        _initMethod: function () {
            //切换 至费用页面
            vc.on('feeReceipt', 'switch', function (_param) {
                if (_param.ownerId == '') {
                    return;
                }
                console.log(_param);
                vc.component.feeReceiptManageInfo.conditions.roomId = _param.roomName;
                vc.component._listFeeReceipts(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.component._initDate();
            vc.component._listFeeReceipts(DEFAULT_PAGE, DEFAULT_ROWS);
            $that._listFeePrintPages();
            // vc.initDateMonth('startTime', function (_startTime) {
            //     $that.feeReceiptManageInfo.conditions.month = _startTime;
            // });
            // vc.initDateDay('startTime', function (_startTime) {
            //     $that.feeReceiptManageInfo.conditions.startTime = _startTime;
            // });
            // vc.initDateDay('endTime', function (_endTime) {
            //     $that.feeReceiptManageInfo.conditions.endTime = _endTime;
            // });
            // vc.initDateMonth('startTime', function (_startTime) {
            //     $that.reportFeeSummaryInfo.conditions.startTime = _startTime;
            // });
        },
        _initEvent: function () {
            vc.on('feeReceiptManage', 'listFeeReceipt', function (_param) {
                vc.component._listFeeReceipts(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                vc.component._listFeeReceipts(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _initDate: function () {
                $(".startTime").datetimepicker({
                    language: 'zh-CN',
                    fontAwesome: 'fa',
                    format: 'yyyy-mm-dd',
                    startView: 2,
                    minView: 2,
                    initTime: true,
                    initialDate: new Date(),
                    autoClose: 1,
                    todayBtn: true
                });
                $(".endTime").datetimepicker({
                    language: 'zh-CN',
                    fontAwesome: 'fa',
                    format: 'yyyy-mm-dd',
                    startView: 2,
                    minView: 2,
                    initTime: true,
                    initialDate: new Date(),
                    autoClose: 1,
                    todayBtn: true
                });
                $('.startTime').datetimepicker()
                    .on('changeDate', function (ev) {
                        var value = $(".startTime").val();
                        vc.component.feeReceiptManageInfo.conditions.qstartTime = value;
                        let start = Date.parse(new Date(vc.component.feeReceiptManageInfo.conditions.qstartTime))
                        let end = Date.parse(new Date(vc.component.feeReceiptManageInfo.conditions.qendTime))
                        if (end != 0 && start - end >= 0) {
                            vc.toast("开始时间必须小于结束时间")
                            vc.component.feeReceiptManageInfo.conditions.qstartTime = '';
                        }
                    });
                $('.endTime').datetimepicker()
                    .on('changeDate', function (ev) {
                        var value = $(".endTime").val();
                        vc.component.feeReceiptManageInfo.conditions.qendTime = value;
                        let start = Date.parse(new Date(vc.component.feeReceiptManageInfo.conditions.qstartTime))
                        let end = Date.parse(new Date(vc.component.feeReceiptManageInfo.conditions.qendTime))
                        if (start - end >= 0) {
                            vc.toast("结束时间必须大于开始时间")
                            vc.component.feeReceiptManageInfo.conditions.qendTime = '';
                        }
                    });
                //防止多次点击时间插件失去焦点
                document.getElementsByClassName('form-control startTime')[0].addEventListener('click', myfunc)
 
                function myfunc(e) {
                    e.currentTarget.blur();
                }
 
                document.getElementsByClassName("form-control endTime")[0].addEventListener('click', myfunc)
 
                function myfunc(e) {
                    e.currentTarget.blur();
                }
            },
            _listFeeReceipts: function (_page, _rows) {
                vc.component._initDate();
                vc.component.feeReceiptManageInfo.conditions.page = _page;
                vc.component.feeReceiptManageInfo.conditions.row = _rows;
                var param = {
                    params: vc.component.feeReceiptManageInfo.conditions
                };
                param.params.receiptId = param.params.receiptId.trim();
                param.params.roomId = param.params.roomId.trim();
                // console.log(param);
                //发送get请求
                vc.http.apiGet('/feeReceipt/queryFeeReceipt',
                    param,
                    function (json, res) {
                        var _feeReceiptManageInfo = JSON.parse(json);
                        vc.component.feeReceiptManageInfo.total = _feeReceiptManageInfo.total;
                        vc.component.feeReceiptManageInfo.records = _feeReceiptManageInfo.records;
                        vc.component.feeReceiptManageInfo.feeReceipts = _feeReceiptManageInfo.data;
                        var storeName = "";
                        for (var i = 0; i < vc.component.feeReceiptManageInfo.feeReceipts.length; i++) {
                            storeName = vc.component.feeReceiptManageInfo.feeReceipts[i].storeName;
                        }
                        vc.component.feeReceiptManageInfo.conditions.storeName = storeName;
                        vc.emit('pagination', 'init', {
                            total: vc.component.feeReceiptManageInfo.records,
                            dataCount: vc.component.feeReceiptManageInfo.total,
                            currentPage: _page
                        });
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _queryFeeReceiptMethod: function () {
                vc.component._listFeeReceipts(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetFeeReceiptMethod: function () {
                vc.component.feeReceiptManageInfo.conditions.objType = "";
                vc.component.feeReceiptManageInfo.conditions.roomId = "";
                vc.component.feeReceiptManageInfo.conditions.receiptId = "";
                vc.component.feeReceiptManageInfo.conditions.qstartTime = "";
                vc.component.feeReceiptManageInfo.conditions.qendTime = "";
                vc.component._listFeeReceipts(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _printFeeReceipt: function (_receipt) {
                window.open($that.feeReceiptManageInfo.printUrl + "?receiptId=" + _receipt.receiptId);
            },
            _printFeeSmallReceipt: function (_receipt) {
                window.open('/smallPrint.html#/pages/property/printSmallPayFee?receiptIds=' + _receipt.receiptId);
            },
            _printFeeReceipts: function (_conditions) {
                // console.log(_conditions)
                if (_conditions.roomId == null || _conditions.roomId == "") {
                    vc.toast("请填写收费对象", 1000);
                    return;
                }
                if (_conditions.type == null || _conditions.type == "") {
                    vc.toast("请选择打印类型", 1000);
                    return;
                }
                // if(_conditions.month==null|| _conditions.month ==""){
                //     vc.toast("请选择费用月份",1000);
                //     return;
                // }
                if (_conditions.qstartTime == null || _conditions.qstartTime == "") {
                    vc.toast("请选择开始时间", 1000);
                    return;
                }
                if (_conditions.qendTime == null || _conditions.qendTime == "") {
                    vc.toast("请选择结束时间", 1000);
                    return;
                }
                // window.open("/print.html#/pages/property/printLXFees?roomName=" + _conditions.roomId+
                // "&type="+_conditions.type+"&month="+_conditions.month);
                window.open("/print.html#/pages/property/printLXFees?roomName=" + _conditions.roomId +
                    "&type=" + _conditions.type + "&qstartTime=" + _conditions.qstartTime + "&qendTime=" + _conditions.qendTime);
            },
            _moreCondition: function () {
                if (vc.component.feeReceiptManageInfo.moreCondition) {
                    vc.component.feeReceiptManageInfo.moreCondition = false;
                } else {
                    vc.component.feeReceiptManageInfo.moreCondition = true;
                }
            },
            _listFeePrintPages: function (_page, _rows) {
                var param = {
                    params: {
                        page: 1,
                        row: 1,
                        state: 'T',
                        communityId: vc.getCurrentCommunity().communityId
                    }
                };
                //发送get请求
                vc.http.apiGet('/feePrintPage.listFeePrintPage',
                    param,
                    function (json, res) {
                        var _feePrintPageManageInfo = JSON.parse(json);
                        let feePrintPages = _feePrintPageManageInfo.data;
                        if (feePrintPages && feePrintPages.length > 0) {
                            $that.feeReceiptManageInfo.printUrl = feePrintPages[0].url;
                        }
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
        }
    });
})(window.vc);