mrzcc
2020-03-06 ecdac8a738f254db2b2ea28cbe3248f7a6a7eb2b
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
(function (vc, vm) {
 
    vc.extends({
        data: {
            editMachineTranslateInfo: {
                machineTranslateId: '',
                machineCode: '',
                machineId: '',
                typeCd: '',
                objName: '',
                objId: '',
                state: '',
 
            }
        },
        _initMethod: function () {
 
        },
        _initEvent: function () {
            vc.on('editMachineTranslate', 'openEditMachineTranslateModal', function (_params) {
                vc.component.refreshEditMachineTranslateInfo();
                $('#editMachineTranslateModel').modal('show');
                vc.copyObject(_params, vc.component.editMachineTranslateInfo);
                vc.component.editMachineTranslateInfo.communityId = vc.getCurrentCommunity().communityId;
            });
        },
        methods: {
            editMachineTranslateValidate: function () {
                return vc.validate.validate({
                    editMachineTranslateInfo: vc.component.editMachineTranslateInfo
                }, {
                    'editMachineTranslateInfo.machineCode': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "设备编码不能为空"
                        },
                        {
                            limit: "maxin",
                            param: "1,30",
                            errInfo: "设备编码不能超过30位"
                        },
                    ],
                    'editMachineTranslateInfo.machineId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "设备ID不能为空"
                        }],
                    'editMachineTranslateInfo.typeCd':
                        [
                            {
                                limit: "required",
                                param: "",
                                errInfo: "对象类型不能为空"
                            },
                            {
                                limit: "num",
                                param: "",
                                errInfo: "对象类型格式错误"
                            },
                        ],
                    'editMachineTranslateInfo.objName':
                        [
                            {
                                limit: "required",
                                param: "",
                                errInfo: "对象名称不能为空"
                            }],
                    'editMachineTranslateInfo.objId':
                        [
                            {
                                limit: "required",
                                param: "",
                                errInfo: "对象Id不能为空"
                            },
                            {
                                limit: "num",
                                param: "",
                                errInfo: "对象Id必须为数字"
                            },
                        ],
                    'editMachineTranslateInfo.state':
                        [
                            {
                                limit: "required",
                                param: "",
                                errInfo: "状态不能为空"
                            },
                            {
                                limit: "num",
                                param: "",
                                errInfo: "状态格式错误"
                            },
                        ],
                    'editMachineTranslateInfo.machineTranslateId':
                        [
                            {
                                limit: "required",
                                param: "",
                                errInfo: "同步ID不能为空"
                            }]
 
                })
                    ;
            },
            editMachineTranslate: function () {
                if (!vc.component.editMachineTranslateValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }
 
                vc.http.post(
                    'editMachineTranslate',
                    'update',
                    JSON.stringify(vc.component.editMachineTranslateInfo),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        if (res.status == 200) {
                            //关闭model
                            $('#editMachineTranslateModel').modal('hide');
                            vc.emit('machineTranslateManage', 'listMachineTranslate', {});
                            return;
                        }
                        vc.message(json);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
 
                        vc.message(errInfo);
                    });
            },
            refreshEditMachineTranslateInfo: function () {
                vc.component.editMachineTranslateInfo = {
                    machineTranslateId: '',
                    machineCode: '',
                    machineId: '',
                    typeCd: '',
                    objName: '',
                    objId: '',
                    state: '',
 
                }
            }
        }
    });
 
})(window.vc, window.vc.component);