124 lines
3.7 KiB
JavaScript
124 lines
3.7 KiB
JavaScript
// 加载日报数据
|
|
function getDaily(currentDay, orgIds) {
|
|
let loadingMsg = layer.msg("数据加载中,请稍候...", { icon: 16, scrollbar: false, time: 0 });
|
|
$.ajax({
|
|
headers: {
|
|
encrypt: sm3(
|
|
JSON.stringify({
|
|
currentDay: currentDay,
|
|
orgIds: orgIds ? orgIds : []
|
|
})
|
|
),
|
|
},
|
|
type: "POST",
|
|
url: dataUrl + "proteam/pot/cityDailyDutyReport/getSummaryData?token=" + token,
|
|
data: {
|
|
currentDay: currentDay,
|
|
orgIds: orgIds ? orgIds : []
|
|
},
|
|
async: false,
|
|
dataType: "json",
|
|
success: function (result) {
|
|
layer.close(loadingMsg);
|
|
if (result.code === 500) {
|
|
setCityDailyData(currentDay, null);
|
|
return layer.alert(data.msg, { icon: 2, });
|
|
} else if (result.code === 401) {
|
|
logout(1);
|
|
} else if (result.code === 200) {
|
|
if (result.data) {
|
|
setCityDailyData(currentDay, result.data);
|
|
} else {
|
|
setCityDailyData(currentDay, null);
|
|
}
|
|
}
|
|
},
|
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
layer.close(loadingMsg); // 关闭提示层
|
|
layer.msg("数据加载发生异常,请稍后重试", { icon: 16, scrollbar: false, time: 2000 });
|
|
setCityDailyData(currentDay, null);
|
|
},
|
|
});
|
|
}
|
|
|
|
// 下载日报
|
|
function downloadDaily() {
|
|
let suffix = 'doc';
|
|
let downloadType = dataObj.downloadType;
|
|
if(downloadType && downloadType.length > 0){
|
|
suffix = downloadType[0];
|
|
}
|
|
let orgId = '';
|
|
let buildCode = formSelects.value('buildCode', 'val');
|
|
if (buildCode && buildCode.length > 0) {
|
|
orgId = buildCode.toString();
|
|
}
|
|
$('.download-btn').addClass("layui-btn-disabled").attr("disabled", true);
|
|
let loadingMsg = layer.msg("日报下载中,请稍候...", { icon: 16, scrollbar: false, time: 0, });
|
|
let url = dataUrl + "proteam/pot/cityDailyDutyReport/downloadSummaryCityDaily?currentDay=" + checkedDate + "&orgId=" + orgId + "&chineseDate=" + setDate(checkedDate) + "&token=" + token;
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.open("get", url, true);
|
|
xhr.responseType = "blob"; // 转换流
|
|
xhr.setRequestHeader(
|
|
"encrypt", sm3(
|
|
JSON.stringify({
|
|
currentDay: checkedDate,
|
|
chineseDate: setDate(checkedDate),
|
|
orgId:orgId
|
|
})
|
|
)
|
|
);
|
|
xhr.setRequestHeader("encryption","encryption");
|
|
xhr.onload = function () {
|
|
layer.close(loadingMsg);
|
|
$('.download-btn').removeClass("layui-btn-disabled").attr("disabled", false);
|
|
if (this.status === 200) {
|
|
let blob = this.response;
|
|
var a = document.createElement("a");
|
|
var url = window.URL.createObjectURL(blob);
|
|
a.href = url;
|
|
a.download = "地市公司基建日报" + setDate(checkedDate) + "." + suffix; // 文件名
|
|
} else {
|
|
layer.msg("服务异常,请稍后重试", {
|
|
icon: 16,
|
|
scrollbar: false,
|
|
time: 2000,
|
|
});
|
|
}
|
|
a.click();
|
|
window.URL.revokeObjectURL(url);
|
|
};
|
|
xhr.send();
|
|
}
|
|
|
|
// 获取地市日报申请退回数量
|
|
function getApplyBackDataNum(){
|
|
let url = dataUrl + "proteam/pot/cityDailyDutyReport/getApplyBackDataNum";
|
|
ajaxRequest2(url, "POST", {}, false, function (result) {
|
|
if (result.code === 200) {
|
|
$('.layui-badge').html(result.data);
|
|
}
|
|
}, function (xhr) {
|
|
error(xhr)
|
|
}, null, token);
|
|
}
|
|
|
|
// 获取建管单位
|
|
function getOrgList() {
|
|
let orgList = getOrgSelect();
|
|
let keys = [];
|
|
$.each(orgList, function (index, item) {
|
|
if(item.code !== '12Z0'){
|
|
let temp = {
|
|
"name": item.name,
|
|
"value": item.code,
|
|
"titleName": item.name
|
|
};
|
|
keys.push(temp);
|
|
}
|
|
})
|
|
formSelects.data('buildCode', 'local', {
|
|
arr: keys
|
|
});
|
|
layui.form.render();
|
|
} |