123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- getUserId();
- var FlowRealTime = new (function () {
- this.pgName = "flowDashBoard";
- this.page = new SinglePage(this.pgName);
- this.scheduleId = utils_get_param("scheduleId");
- this.flowId = utils_get_param("flowId");
- if(scheduleId == null || flowId == null)
- {
- send_alert(`清重新进入本页面!<a href='denglu.html'> 返回主页 </a>`);
- return;
- }
- this.flowPlace = " % flowPlace %";
- this.flowName = " % flowPlace %";
- this.scheduleLoadDataService = new DataObjectService("fcWorkScheduleLoad", ONDEMAND /*AUTO & FAST*/, "?scheduleId=" + scheduleId);
- this.oaStaffService = new DataObjectService("fcWorkScheduleLoad", ONDEMAND, "");
- this.sectorService = new DataObjectService("fcWorkScheduleLoad", ONDEMAND, "");
- this.flowService = new DataObjectService("fcFlow", ONDEMAND, "");
- this.MeduimData = new (function () {
- this.initializeUsers = function(list){
- list.forEach(function (val, it, arr) {
- var isExist = false;
- userIDs.forEach(function (vals) {
- if (vals == val.userId) {
- isExist = true;
- }
- });
- if (!isExist) userIDs.push(val.userId);
- });
- };
- })();
- this.initPage = function() {
- // todo...
- };
- this.Action = new (function (parent) {
- this.parent = parent;
- this.doStopSchedule = function () {
- get_data("fcWorkSchedule/stopSchedule?userId=" + userId + "&scheduleId=" + scheduleId, this.parent.UI.showStopSuccess, this.parent);
- };
- this.confirmStopSchedule = function () {
- var out = confirm("真的要下班吗?");
- if (out == true) {
- this.doStopSchedule();
- } else {
- }
- };
- })(this);
- this.UI = new (function (parent) {
- this.p = parent;
- this.showClearPanel = function () {
- $("#clearModal").modal('show');
- };
- this.showStopSuccess = function (obj, sta, scope) {
- send_alert("下班操作成功! <a href='denglu.html'> 点击这里返回控制主页 </a>");
- };
- this.bind = function () {
- $(".confirm-clear-data").click(function(){
- FlowRealTime.ClearDataControl.clearDataOfDeviceId($('#handInput').val());
- });
- $(".open-clear-panel").click(function () {
- FlowRealTime.UI.showClearPanel();
- })
- $(".close-schedule").click(function () {
- FlowRealTime.Action.confirmStopSchedule();
- })
- }
- })(this);
- this.ClearDataControl = new (function (parent) {
- this.p = parent;
- this.finished = true;
- this.executed = false;
- this.directCount = -1;
- this.clearDataOfDeviceId = function (handId) {
- this.executed = false;
- this.directCount = -1;
- this.finished = true;
- var hand = handId;
- hand = hand.trim();
- var possible = "0123456789,-*";
- for(let i = 0; i < hand.length ; i++){
- if(possible.indexOf(hand.charAt(i)) === -1){
- send_alert("您的输入有误,请重新输入 : " +handId);
- return;
- }
- }
- get_data("endpoint/clearBoard?flowId=" + flowId + "&handheldId=" + hd, this.clearSuccess);
- };
- this.clearSuccess = function (obj, sta) {
- console.warn("------- 手持设备清空 ----------");
- console.warn(obj);
- send_alert("发送清空请求成功, 正在等待采集端进行处理...");
- this.finished = false;
- setTimeout(this.resultVerifyTimeout, 8000, this);
- setTimeout(this.getVerify, 300, this);
- }
- this.getVerify = function (obj) {
- if (obj.finished) return;
- get_data("endpoint/heartbeat?flowId=" + flowId, obj.onVerifyResult);
- setTimeout(obj.getVerify, 100, obj);
- };
- this.onVerifyResult = function (obj, sta) {
- var parsed = {};
- if (typeof(obj) === "string") {
- parsed = JSON.parse(obj);
- } else {
- parsed = obj;
- }
- if (typeof(parsed) === "object") {
- if (parsed.ret === "10000") {
- //ok
- if (parsed.model == null || parsed.model === undefined) {
- executed = true;
- finished = true;
- } else if (typeof(obj.model) === "object") {
- // 没有拿到,继续
- if (obj.model.list != null && obj.model.list.length > 0) {
- var direct = obj.model.list[0];
- if (direct.eventType + "" !== "500") {
- // OK
- executed = true;
- finished = true;
- } else if (direct.arg2 + "" !== "" + $("#handInput").val()) {
- // OK
- executed = true;
- finished = true;
- } else {
- directCount = direct.counter;
- }
- }
- }
- }
- }
- }
- this.resultVerifyTimeout = function (obj) {
- finished = true;
- if (executed) {
- // 执行成功
- } else {
- if (directCount >= 0) {
- get_data("endpoint/ack?counter=" + directCount, function () {
- console.log("撤销操作成功");
- console.log(this);
- });
- directCount = -1;
- send_alert("请求已经超时!请注意,采集端可能没有执行成功。即将撤销您的请求。");
- } else {
- send_alert("请求已经超时!请注意,采集端可能没有执行成功。");
- }
- }
- }
- })(this);
- })();
- $(document).ready(function(){
- FlowRealTime.initPage();
- FlowRealTime.UI.bind();
- });
|