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
(function (vc) {
    vc.extends({
        data: {
            editItemReleaseViewInfo: {
                irId: '',
                typeId: '',
                applyCompany: '',
                applyPerson: '',
                idCard: '',
                applyTel: '',
                passTime: '',
                resNames: [],
                state: '',
                carNum: '',
                remark: '',
                itemReleaseTypes: []
            }
        },
        _initMethod: function () {
            $that.editItemReleaseViewInfo.irId = vc.getParam('irId');
            $that._listItemReleaseTypes();
            $that._listItemReleases();
            $that._loadItemReleaseRes();
            vc.initDateTime('editPassTime', function (_value) {
                $that.editItemReleaseViewInfo.passTime = _value;
            });
        },
        _initEvent: function () {
        },
        methods: {
            editItemReleaseViewValidate() {
                return vc.validate.validate({
                    editItemReleaseViewInfo: vc.component.editItemReleaseViewInfo
                }, {
                    'editItemReleaseViewInfo.typeId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "放行类型不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "30",
                            errInfo: "放行类型不能超过30"
                        },
                    ],
                    'editItemReleaseViewInfo.applyCompany': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "申请单位不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "64",
                            errInfo: "申请单位不能超过64"
                        },
                    ],
                    'editItemReleaseViewInfo.applyPerson': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "申请人不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "64",
                            errInfo: "申请人不能超过64"
                        },
                    ],
                    'editItemReleaseViewInfo.idCard': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "身份证不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "18",
                            errInfo: "身份证不能超过18"
                        },
                    ],
                    'editItemReleaseViewInfo.applyTel': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "手机号不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "11",
                            errInfo: "手机号不能超过11"
                        },
                    ],
                    'editItemReleaseViewInfo.passTime': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "通行时间不能为空"
                        },
                        {
                            limit: "datetime",
                            param: "",
                            errInfo: "通行时间格式错误"
                        },
                    ],
                    'editItemReleaseViewInfo.carNum': [
                        {
                            limit: "maxLength",
                            param: "12",
                            errInfo: "车牌号不能超过12"
                        },
                    ],
                    'editItemReleaseViewInfo.remark': [
                        {
                            limit: "maxLength",
                            param: "512",
                            errInfo: "备注不能超过512"
                        },
                    ]
                });
            },
            _updateItemReleaseInfo: function () {
                if (!vc.component.editItemReleaseViewValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }
                vc.component.editItemReleaseViewInfo.communityId = vc.getCurrentCommunity().communityId;
                vc.http.apiPost(
                    '/itemRelease.updateItemRelease',
                    JSON.stringify(vc.component.editItemReleaseViewInfo),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            vc.goBack();
                            vc.toast("修改成功");
                            return;
                        } else {
                            vc.toast(_json.msg);
                        }
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                        vc.toast(errInfo);
                    });
            },
            _listItemReleaseTypes: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 100,
                        communityId: vc.getCurrentCommunity().communityId
                    }
                };
                //发送get请求
                vc.http.apiGet('/itemRelease.listItemReleaseType',
                    param,
                    function (json, res) {
                        let _itemReleaseTypeManageInfo = JSON.parse(json);
                        vc.component.editItemReleaseViewInfo.itemReleaseTypes = _itemReleaseTypeManageInfo.data;
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _addResName: function () {
                $that.editItemReleaseViewInfo.resNames.push({
                    resName: '',
                    amount: ''
                })
            },
            // 移除选中item
            _removeResName: function (resName) {
                $that.editItemReleaseViewInfo.resNames.forEach((item, index) => {
                    if (item.resName == resName) {
                        $that.editItemReleaseViewInfo.resNames.splice(index, 1);
                    }
                })
            },
            _listItemReleases: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 1,
                        communityId: vc.getCurrentCommunity().communityId,
                        irId: $that.editItemReleaseViewInfo.irId
                    }
                };
                //发送get请求
                vc.http.apiGet('/itemRelease.listItemRelease',
                    param,
                    function (json, res) {
                        let _itemReleaseManageInfo = JSON.parse(json);
                        vc.copyObject(_itemReleaseManageInfo.data[0], $that.editItemReleaseViewInfo);
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _loadItemReleaseRes: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 500,
                        communityId: vc.getCurrentCommunity().communityId,
                        irId: vc.component.editItemReleaseViewInfo.irId,
                    }
                };
                //发送get请求
                vc.http.apiGet('/itemRelease.listItemReleaseRes',
                    param,
                    function (json) {
                        let _unitInfo = JSON.parse(json);
                        vc.component.editItemReleaseViewInfo.resNames = _unitInfo.data;
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
        }
    });
})(window.vc);