CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
// @Bind @dtTiming.onDataChange
!function(self, arg) {
    var porp = arg.property;
    if (porp == "timType") {
        if (arg.newValue == "day") {
            arg.entity.set("week", null);
            arg.entity.set("appointTime", null);
            view.get("^week").set("readOnly", true);
            view.get("^day").set("readOnly", false);
            view.get("^hour").set("readOnly", true);
        }
        if (arg.newValue == "week") {
            arg.entity.set("appointTime", null);
            view.get("^week").set("readOnly", false);
            view.get("^day").set("readOnly", false);
            view.get("^hour").set("readOnly", true);
        }
        if (arg.newValue == "hour") {
            arg.entity.set("week", null);
            arg.entity.set("hour", null);
            arg.entity.set("minute", null);
            view.get("^week").set("readOnly", true);
            view.get("^day").set("readOnly", true);
            view.get("^hour").set("readOnly", false);
        }
    }
};
 
// @Bind view.onReady
!function(self, arg) {
    /**
     * 配置规则渲染说明
     * 
     * @param {Object}
     *            arg
     * @param {Object}
     *            self
     */
    view.get("#dataSetTiming").flushAsync();
    weekRenderCell = function(arg, self) {
        var data = arg.data;
        var week = data.get("week");
        var result = "";
        if (data.get("timType") == "day") {
            result = "每天:" + data.get("hour") + "点" + data.get("minute")
                    + "分 执行";
        }
        if (data.get("timType") == "week") {
            if (week == "MON")
                result = "每周一:" + data.get("hour") + "点" + data.get("minute")
                        + "分 执行";
            if (week == "TUE")
                result = "每周二:" + data.get("hour") + "点" + data.get("minute")
                        + "分 执行";
            if (week == "WED")
                result = "每周三:" + data.get("hour") + "点" + data.get("minute")
                        + "分 执行";
            if (week == "THU")
                result = "每周四:" + data.get("hour") + "点" + data.get("minute")
                        + "分 执行";
            if (week == "FRI")
                result = "每周五:" + data.get("hour") + "点" + data.get("minute")
                        + "分 执行";
            if (week == "SAT")
                result = "每周六:" + data.get("hour") + "点" + data.get("minute")
                        + "分 执行";
            if (week == "SUN")
                result = "每周日:" + data.get("hour") + "点" + data.get("minute")
                        + "分 执行";
        }
        if (data.get("timType") == "hour") {
            if (data.get("appointTime")) {
                result = "指定时间:"
                        + data.get("appointTime").formatDate("Y年m月d日 H点i分s秒")
                        + " 执行。";
            } else {
                result = "指定时间:执行。";
            }
        }
        arg.dom.innerHTML = result;
    };
};
 
// @Bind #dgItemsGrain.onDataRowClick
!function(self, arg) {
    var timId = view.get("#dataSetTiming").getData("#").get("id");
    view.get("#dsTimingDevice").set("parameter", {
        timId : timId
    }).flushAsync();
};
 
// @Bind #dialogTim.onHide
!function(self, arg) {
    var data = view.get("#dataSetTiming.data:#");
    if (data)
        data.cancel();
};
 
// @Bind #dialogTD.onShow
!function(self, arg) {
    var tim = view.get("#dataSetTiming.data:#");
    //view.get("#timDepotId").set("value", tim.get("depotId"));
    self.set("caption","调整设备-"+tim.getText("name"));
    var deviceTypeTag = "2";
    view.get("#dsDevice").set("parameter", {
        tag : deviceTypeTag
    }).flushAsync();
};
//@Bind #dialogTD2.onShow
!function(self, arg) {
    var tim = view.get("#dataSetTiming.data:#");
    //view.get("#timDepotId").set("value", tim.get("depotId"));
    self.set("caption","调整设备-"+tim.getText("name"));
    var deviceTypeTag = "1";
    view.get("#dsDevice2").set("parameter", {
        tag :deviceTypeTag
    }).flushAsync();
};
// @Bind #addJob.onClick
!function(self, arg) {
    var type = "lamp";
    var ds = view.get("#dataSetTiming");
    var af = view.get("#dialogTim");
    ds.insert({
        type : type,
        disabledTag : "N"
    });
    af.show();
};
 
// @Bind #updJob.onClick
!function(self, arg) {
    var cur = view.get("#dataSetTiming.data:#");
    if (cur)
        view.get("#dialogTim").show();
};
 
// @Bind #delJob.onClick
!function(self, arg) {
    var data = view.get("#dataSetTiming.data:#");
    if (data) {
        var job = data.get("job");
        if (job) {
            if (job.get("state") !== "stop" && job.get("state") !== "ready") {
                $alert("要删除的Job必须为停止或待命状态,否则不能删除");
                return;
            }
        }
        $confirm("真的要删除当前JOB?", function() {
            view.get("#ajaxActionDelJob").set("parameter", data.get("id"))
                    .execute(function() {
                        data.remove();
                    });
        });
    } else {
        $alert("没有数据可以删除!");
    }
};
 
// @Bind #startJob.onClick
!function(self, arg) {
    var data = view.get("#dataSetTiming.data:#");
    var job = data.get("job");
    if (job) {
        var state = job.get("state");
        if (state == "running") {
            $alert("当前Job正处于启动中状态,不能再次执行启动动作");
            return;
        }
        if (state == "run") {
            $alert("当前Job正处于启动状态,不能再次执行启动动作");
            return;
        }
        $confirm("确定要启动当前定时任务么?", function() {
            var action = view.id("ajaxActionRunJob");
            action.set("parameter", {
                jobDefinitionId : data.get("id")
            });
            action.execute(function() {
                job.set("state", "running");
                data.setState(dorado.Entity.STATE_NONE);
            });
        });
    } else {
        $alert("当前配置没有JOB信息……");
    }
 
};
 
// @Bind #stopJob.onClick
!function(self, arg) {
    var data = view.get("#dataSetTiming.data:#");
    var job = data.get("job");
    if (job) {
        var state = job.get("state");
        if (state == "stopping") {
            $alert("当前Job正处于停止中状态,不能再次执行停止动作");
            return;
        }
        if (state == "stop") {
            $alert("当前Job正处于停止状态,不能再次执行停止动作");
            return;
        }
        $confirm("真的要停止当前任务?", function() {
            var action = view.id("ajaxActionStopJob");
            action.set("parameter", {
                jobDefinitionId : job.get("id")
            });
            action.execute(function() {
                job.set("state", "stopping");
                data.setState(dorado.Entity.STATE_NONE);
            });
        });
    } else {
        $alert("当前数据没有JOB信息");
    }
 
};
 
// @Bind #addSetting.onClick
!function(self, arg, dialogTD) {
    var cur = view.get("#dataSetTiming.data:#");
    if (cur) {
        dialogTD.show();
    } else {
        $notify("请先新增定时配置信息!");
    }
};
//@Bind #addSetting2.onClick
!function(self, arg, dialogTD2) {
    var cur = view.get("#dataSetTiming.data:#");
    if (cur) {
        dialogTD2.show();
    } else {
        $notify("请先新增定时配置信息!");
    }
};
 
// @Bind #delSetting.onClick
!function(self, arg) {
    var cur = view.get("#dgItems").get("selection");
    if (cur) {
        $confirm("确定要删除当前选择数据么?", function() {
            view.get("#ajaxActionDelSetings").set("parameter", cur).execute(
                    function() {
                        view.get("#dataSetTiming").flushAsync();
                    });
        });
    } else {
        $notify("请选择需要删除的数据!");
    }
};
 
// @Bind #confirmTim.onClick
!function(self, arg) {
    var cur = view.get("#dataSetTiming.data:#");
    if (cur.validate() == "ok") {
        view.get("#uaSaveTim").execute(function() {
            self.get("parent").hide();
            view.get("#dataSetTiming").flushAsync();
        });
    } else {
        $alert("数据校验失败,请核查!");
    }
};
 
// @Bind #cancelTim.onClick
!function(self, arg) {
    self.get("parent").hide();
};
 
// @Bind #confirmTD.onClick
!function(self, arg) {
    var selection = view.get("#dsDevice.data");
    var timId = view.id("dataSetTiming").getData("#").get("id");
    view.id("ajaxActionAddSetings").set("parameter", {
        "list" : selection,
        "timId" : timId
    }).execute(function() {
        view.id("dialogTD").close();
        view.get("#dataSetTiming").flushAsync();
    });
};
 
// @Bind #cancelTD.onClick
!function(self, arg) {
    self.get("parent").hide();
};
 
// @Bind #refresh.onClick
!function(self, arg) {
    var depotId = view.get("#timDepotId").get("value");
    var deviceTypeTag = "2";
    view.get("#dsDevice").set("parameter", {
        depotId : depotId,
        tag:deviceTypeTag
    }).flushAsync();
};
 
 
//@Bind #confirmTD2.onClick
!function(self, arg) {
    var selection = view.get("#dsDevice2.data");
    var timId = view.id("dataSetTiming").getData("#").get("id");
    view.id("ajaxActionAddSetings").set("parameter", {
        "list" : selection,
        "timId" : timId
    }).execute(function() {
        view.id("dialogTD2").close();
        view.get("#dataSetTiming").flushAsync();
    });
};
 
// @Bind #cancelTD2.onClick
!function(self, arg) {
    self.get("parent").hide();
};
 
// @Bind #refresh2.onClick
!function(self, arg) {
    var depotId = view.get("#timDepotId2").get("value");
    var deviceTypeTag = "1";
    view.get("#dsDevice2").set("parameter", {
        depotId : depotId,
        tag:deviceTypeTag
    }).flushAsync();
};