mrzcc
2020-02-18 8aab6e0c7b825a2758d3441bc41515863afc31cf
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
(function (vc, vm) {
 
    vc.extends({
        data: {
            editInspectionPlanInfo: {
                inspectionPlanId: '',
                inspectionPlanName: '',
                inspectionRouteId: '',
                inspectionPlanPeriod: '',
                staffId: '',
                staffName: '',
                startTime: '',
                endTime: '',
                signType: '',
                signTypes:[],
                inspectionPlanPeriods: [],
                states: [],
                isDefault:'',
                state: '',
                remark: '',
                companyId:'',
                companyName:'',
                departmentId:'',
                departmentName:'',
                createUserId:'',
                createUserName:''
            }
        },
        _initMethod: function () {
            vc.getDict('inspection_plan',"sign_type",function(_data){
                vc.component.editInspectionPlanInfo.signTypes = _data;
            });
            vc.getDict('inspection_plan',"inspection_plan_period",function(_data){
                vc.component.editInspectionPlanInfo.inspectionPlanPeriods = _data;
            });
            vc.getDict('inspection_plan',"state",function(_data){
                vc.component.editInspectionPlanInfo.states = _data;
            });
 
        },
        _initEvent: function () {
            vc.component._initEditInspectionPlanDateInfo();
            vc.on('editInspectionPlan', 'openEditInspectionPlanModal', function (_params) {
                vc.component.refreshEditInspectionPlanInfo();
                $('#editInspectionPlanModel').modal('show');
                vc.copyObject(_params, vc.component.editInspectionPlanInfo);
                vc.component.editInspectionPlanInfo.communityId = vc.getCurrentCommunity().communityId;
                //公司select2
                vc.emit('editInspectionPlan', 'orgSelect2', 'setOrg', {
                    orgId: vc.component.editInspectionPlanInfo.companyId,
                    orgName: vc.component.editInspectionPlanInfo.companyName,
                });
 
                //部门select2
                vc.emit('editInspectionPlan', 'departmentSelect2', 'setDepartment', {
                    orgId: vc.component.editInspectionPlanInfo.departmentId,
                    orgName: vc.component.editInspectionPlanInfo.departmentName,
                });
 
                //员工select2
                vc.emit('editInspectionPlan', 'staffSelect2', 'setStaff', {
                    staffId: vc.component.editInspectionPlanInfo.staffId,
                    staffName: vc.component.editInspectionPlanInfo.staffName,
                });
 
 
 
            });
        },
        methods: {
            editInspectionPlanValidate: function () {
                return vc.validate.validate({
                    editInspectionPlanInfo: vc.component.editInspectionPlanInfo
                }, {
                    'editInspectionPlanInfo.inspectionPlanName': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "计划名称不能为空"
                        },
                        {
                            limit: "maxin",
                            param: "1,100",
                            errInfo: "巡检计划名称不能超过100位"
                        },
                    ],
                    'editInspectionPlanInfo.inspectionRouteId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "巡检路线不能为空"
                        },
                        {
                            limit: "maxin",
                            param: "1,30",
                            errInfo: "巡检路线不能超过30位"
                        },
                    ],
                    'editInspectionPlanInfo.inspectionPlanPeriod': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "执行周期不能为空"
                        },
                        {
                            limit: "maxin",
                            param: "1,12",
                            errInfo: "执行周期格式错误"
                        },
                    ],
                    'editInspectionPlanInfo.staffId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "执行人员不能为空"
                        },
                        {
                            limit: "maxin",
                            param: "1,30",
                            errInfo: "执行人员不能超过30位"
                        },
                    ],
                    'editInspectionPlanInfo.startTime': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "开始时间不能为空"
                        },
                        {
                            limit: "dateTime",
                            param: "",
                            errInfo: "计计划开始时间不是有效的时间格式"
                        },
                    ],
                    'editInspectionPlanInfo.endTime': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "结束时间不能为空"
                        },
                        {
                            limit: "dateTime",
                            param: "",
                            errInfo: "计划结束时间不是有效的时间格式"
                        },
                    ],
                    'editInspectionPlanInfo.signType': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "签到方式不能为空"
                        },
                        {
                            limit: "num",
                            param: "",
                            errInfo: "签到方式格式错误"
                        },
                    ],
                    'editInspectionPlanInfo.state': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "状态不能为空"
                        },
                        {
                            limit: "num",
                            param: "",
                            errInfo: "签到方式格式错误"
                        },
                    ],
                    'editInspectionPlanInfo.remark': [
                        {
                            limit: "maxLength",
                            param: "200",
                            errInfo: "备注信息不能超过200位"
                        },
                    ],
                    'editInspectionPlanInfo.inspectionPlanId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "巡检计划名称不能为空"
                        }]
 
                });
            },
            editInspectionPlan: function () {
                if (!vc.component.editInspectionPlanValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }
 
                vc.http.post(
                    'editInspectionPlan',
                    'update',
                    JSON.stringify(vc.component.editInspectionPlanInfo),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        if (res.status == 200) {
                            //关闭model
                            $('#editInspectionPlanModel').modal('hide');
                            vc.emit('inspectionPlanManage', 'listInspectionPlan', {});
                            return;
                        }
                        vc.message(json);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
 
                        vc.message(errInfo);
                    });
            },
            refreshEditInspectionPlanInfo: function () {
                var signTypes = vc.component.editInspectionPlanInfo.signTypes;
                var states = vc.component.editInspectionPlanInfo.states;
                var inspectionPlanPeriods = vc.component.editInspectionPlanInfo.inspectionPlanPeriods;
                vc.component.editInspectionPlanInfo = {
                    inspectionPlanId: '',
                    inspectionPlanName: '',
                    inspectionRouteId: '',
                    inspectionPlanPeriod: '',
                    staffId: '',
                    staffName: '',
                    startTime: '',
                    endTime: '',
                    signType: '',
                    state: '',
                    remark: '',
                    companyId:'',
                    companyName:'',
                    departmentId:'',
                    departmentName:'',
                    createUserId:'',
                    createUserName:''
                };
                vc.component.editInspectionPlanInfo.signTypes = signTypes;
                vc.component.editInspectionPlanInfo.states = states;
                vc.component.editInspectionPlanInfo.inspectionPlanPeriods = inspectionPlanPeriods;
            },
            _initEditInspectionPlanDateInfo:function(){
                $('.editInspectionPlanStartTime').datetimepicker({
                    language: 'zh-CN',
                    format: 'yyyy-mm-dd hh:ii:ss',
                    initTime: true,
                    initialDate: new Date(),
                    autoClose: 1,
                    todayBtn: true
 
                });
                $('.editInspectionPlanStartTime').datetimepicker()
                    .on('changeDate', function (ev) {
                        var value = $(".editInspectionPlanStartTime").val();
                        vc.component.editInspectionPlanInfo.startTime = value;
                    });
                $('.editInspectionPlanEndTime').datetimepicker({
                    language: 'zh-CN',
                    format: 'yyyy-mm-dd hh:ii:ss',
                    initTime: true,
                    initialDate: new Date(),
                    autoClose: 1,
                    todayBtn: true
                });
                $('.editInspectionPlanEndTime').datetimepicker()
                    .on('changeDate', function (ev) {
                        var value = $(".editInspectionPlanEndTime").val();
                        vc.component.editInspectionPlanInfo.endTime = value;
                    });
            }
        }
    });
 
})(window.vc, window.vc.component);