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
(function (vc) {
    vc.extends({
        data: {
            auditParkingSpaceApplyInfo: {
                psId: '',
                psName: '',
                applyId: '',
                carNum: '',
                carBrand: '',
                carType: '',
                carColor: '',
                startTime: '',
                endTime: '',
                applyPersonName: '',
                applyPersonLink: '',
                applyPersonId: '',
                state: '',
                remark: '',
                remark2: '',
                communityId:'',
            }
        },
        _initMethod: function () {
            $that.auditParkingSpaceApplyInfo.applyId = vc.getParam('applyId');
            $that.auditParkingSpaceApplyInfo.communityId = vc.getCurrentCommunity().communityId;
            $that._listParkingSpaceApply();
            $('.editStartTime').datetimepicker({
                language: 'zh-CN',
                fontAwesome: 'fa',
                format: 'yyyy-mm-dd hh:ii:ss',
                initTime: true,
                initialDate: new Date(),
                autoClose: 1,
                todayBtn: true
            });
            $('.editStartTime').datetimepicker()
                .on('changeDate', function (ev) {
                    var value = $(".editStartTime").val();
                    $that.auditParkingSpaceApplyInfo.startTime = value;
                });
            $('.editEndTime').datetimepicker({
                language: 'zh-CN',
                fontAwesome: 'fa',
                format: 'yyyy-mm-dd hh:ii:ss',
                initTime: true,
                initialDate: new Date(),
                autoClose: 1,
                todayBtn: true
            });
            $('.editEndTime').datetimepicker()
                .on('changeDate', function (ev) {
                    var value = $(".editEndTime").val();
                    $that.auditParkingSpaceApplyInfo.endTime = value;
                });
        },
        _initEvent: function () {
            vc.on('auditParkingSpaceApply', 'chooseParkingSpace', function (_parkingArea) {
                $that.auditParkingSpaceApplyInfo.psId = _parkingArea.psId;
                $that.auditParkingSpaceApplyInfo.psName = _parkingArea.num;
            });
        },
        methods: {
            auditParkingSpaceApplyValidate() {
                return vc.validate.validate({
                    auditParkingSpaceApplyInfo: $that.auditParkingSpaceApplyInfo
                }, {
                    'auditParkingSpaceApplyInfo.psId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "车位不能为空"
                        }
                    ],
                });
            },
            _listParkingSpaceApply: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 1,
                        applyId: $that.auditParkingSpaceApplyInfo.applyId
                    }
                };
                //发送get请求
                vc.http.apiGet('/parkingSpaceApply.listParkingSpaceApply',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        let _apply = _json.data[0];
                        vc.copyObject(_apply, $that.auditParkingSpaceApplyInfo);
                        $that.auditParkingSpaceApplyInfo.state = '';
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _doAuditParkingSpaceApply: function () {
                if (!$that.auditParkingSpaceApplyInfo.state) {
                    vc.toast("请选择审核结果");
                    return;
                }
                if ($that.auditParkingSpaceApplyInfo.state == '2002' && !$that.auditParkingSpaceApplyValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }
                if ($that.auditParkingSpaceApplyInfo.state == '4004' && !$that.auditParkingSpaceApplyInfo.remark2) {
                    vc.toast("审核结果不通过时,必须填写意见");
                    return;
                }
                $that.auditParkingSpaceApplyInfo.remark = $that.auditParkingSpaceApplyInfo.remark + "审核意见:" + $that.auditParkingSpaceApplyInfo.remark2;
                vc.http.apiPost(
                    '/parkingSpaceApply.auditParkingSpaceApply',
                    JSON.stringify($that.auditParkingSpaceApplyInfo), {
                        emulateJSON: true
                    },
                    function (json, res) {
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            vc.toast('保存成功');
                            $that.clearAddParkingSpaceApplyInfo();
                            $that._goBack();
                            return;
                        } else {
                            vc.toast(_json.msg);
                        }
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                        vc.message(errInfo);
                    });
            },
            clearAddParkingSpaceApplyInfo: function () {
                $that.auditParkingSpaceApplyInfo = {
                    psId: '',
                    psName: '',
                    carNum: '',
                    carBrand: '',
                    carType: '',
                    carColor: '',
                    startTime: '',
                    endTime: '',
                    applyPersonName: '',
                    applyPersonLink: '',
                    applyPersonId: '',
                    state: '',
                    remark: '',
                    communityId:'',
                };
            },
            _goBack: function () {
                vc.goBack();
            },
            _openChooseParkingArea: function () {
                vc.emit('chooseParkingArea', 'openChooseParkingAreaModel', {});
            },
            _openChooseParkingSpace: function () {
                vc.emit('searchParkingSpace', 'openSearchParkingSpaceModel', {});
            },
        }
    });
})(window.vc);