var inspectList;
/**
* 弹出提示框
*/
function toast(msg) {
api.toast({
msg: msg,
duration: 3000,
locaiton: 'top'
});
}
/**
* 获取巡检安排,并显示在屏幕上
* @param {*} callback
*/
function getInspectArrangement(callback) {
var id = api.pageParam.id;
var messageId = api.pageParam.messageId;
var args = {
msgId: messageId
};
var url = '/ems/rest/xj/task';
$api.get(url, args, function(data, err) {
if (err) {
toast("网络请求失败");
} else {
if (data.code == 200) {
if (data.body && data.body.length > 0) {
for (var i = 0; i < data.body.length; i++) {
var item = data.body[i];
var xjCount = item.xjCount?item.xjCount: 0;
var inspectItem = '';
inspectItem += '
';
inspectItem += '
';
inspectItem += '' + ($api.getStorage('cus') ? $api.guestPrName : item.prName) + '';
inspectItem += '' + item.xjDate + '';
inspectItem += '
';
inspectItem += '
';
inspectItem += '
巡检次数:' + xjCount+ '次
';
for (var j = 0; j < item.xjPeoples.length; j++) {
var person = item.xjPeoples[j];
inspectItem += '
' + (j + 1) + '.巡检组长:' + person.xjPeople + '
';
}
inspectItem += '
';
inspectItem += '
';
inspectList.append(inspectItem);
}
}
} else if (data.code == 404) {
var msg = "消息不存在";
toast(msg);
api.sendEvent({
name: 'removeMessage',
extra: {
messageId: messageId
}
});
window.setTimeout(function() {
api.closeWin();
}, 2000);
} else {
toast("服务器响应错误" + (data.code ? (",错误码:" + data.code) : ""));
}
}
if (callback) {
callback();
}
});
}
apiready = function() {
// 适配安卓状态栏
CommonModel.fitInStatusBar();
inspectList = $("#inspectList");
//用户点击了返回按钮
$(".back").on("touchend", function() {
api.closeWin();
});
getInspectArrangement();
}