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(`清重新进入本页面! 返回主页 `);
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("下班操作成功! 点击这里返回控制主页 ");
};
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();
});