190 lines
6.1 KiB
JavaScript
190 lines
6.1 KiB
JavaScript
|
|
function submitApply(data) {
|
|
let obj = handleData(data);
|
|
if(!obj.workList || obj.workList.length === 0){
|
|
return layer.msg('机械化施工必须添加至少一条数据',{icon:7});
|
|
}
|
|
let params = {
|
|
id: dataObj && dataObj.vo ? dataObj.vo.id : null,
|
|
orgId: user.orgId,
|
|
dataJson: JSON.stringify(obj),
|
|
currentDay: checkedDate,
|
|
storeStatus: saveType,
|
|
endTime: dataObj.endTime
|
|
};
|
|
layer.confirm('请仔细检查数据,是否填写完整,数据即将暂存', { title: '操作提示', move: false }, function () {
|
|
uploadData(params);
|
|
});
|
|
}
|
|
|
|
// 保存数据
|
|
function uploadData(params) {
|
|
let loadingMsg = layer.msg('数据保存中,请稍候...', { icon: 16, scrollbar: false, time: 0 });
|
|
$('.save-btn').removeClass("layui-btn-disabled").attr("disabled", true);
|
|
$.ajax({
|
|
headers: {
|
|
"encrypt": sm3(JSON.stringify(params))
|
|
},
|
|
url: dataUrl + 'proteam/pot/cityDailyDutyReport/addData?token=' + token,
|
|
type: 'POST',
|
|
data: params,
|
|
dataType: 'json',
|
|
success: function (result) {
|
|
$('.save-btn').removeClass("layui-btn-disabled").attr("disabled", false);
|
|
layer.close(loadingMsg); // 关闭提示层
|
|
if (result.code === 200) {
|
|
parent.layer.msg(result.msg, { icon: 1 });
|
|
if (saveType === 0) {
|
|
dataObj.vo = result.data;
|
|
} else {
|
|
dataObj.vo.storeStatus = '1'
|
|
removeBtn();
|
|
}
|
|
setCityDailyData(checkedDate, dataObj);
|
|
} else if (result.code === 500) {
|
|
parent.layer.msg(result.msg, { icon: 2 })
|
|
if (result.msg !== '操作失败') {
|
|
/* removeBtn();
|
|
setCityDailyData(checkedDate, dataObj); */
|
|
getDaily(checkedDate);
|
|
}else{
|
|
getDaily(checkedDate);
|
|
}
|
|
} else if (result.code === 401) {
|
|
logout(1)
|
|
}
|
|
},
|
|
error: function (result) {
|
|
layer.close(loadingMsg); // 关闭提示层
|
|
layer.msg('服务异常,请稍后重试', { icon: 16, scrollbar: false, time: 2000 });
|
|
$('.save-btn').removeClass("layui-btn-disabled").attr("disabled", false);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 获取日报-施工单位
|
|
function getSgUnit(){
|
|
sgUnitArr.splice(0,sgUnitArr.length);
|
|
let url = dataUrl + "proteam/pot/cityDailyDutyReport/getDailyUnit";
|
|
ajaxRequest2(url, "POST", {}, false, function (result) {
|
|
if (result.code === 200) {
|
|
sgUnitArr = result.data;
|
|
}
|
|
}, function (xhr) {
|
|
error(xhr)
|
|
}, null, token);
|
|
}
|
|
|
|
// 加载日报数据
|
|
function getDaily(currentDay) {
|
|
removeBtn();
|
|
let loadingMsg = layer.msg("数据加载中,请稍候...", { icon: 16, scrollbar: false, time: 0 });
|
|
$.ajax({
|
|
headers: {
|
|
encrypt: sm3(
|
|
JSON.stringify({
|
|
currentDay: currentDay,
|
|
orgId: user.orgId,
|
|
})
|
|
),
|
|
},
|
|
type: "POST",
|
|
url: dataUrl + "proteam/pot/cityDailyDutyReport/getData?token=" + token,
|
|
data: {
|
|
currentDay: currentDay,
|
|
orgId: user.orgId,
|
|
},
|
|
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 applyBack(){
|
|
layer.confirm('确定要撤回吗?', function () {
|
|
let loadingMsg = layer.msg('数据保存中,请稍等...', { icon: 16, shade: 0.01, time: '0' });
|
|
let url = dataUrl + "proteam/pot/cityDailyDutyReport/updateDailyStatus";
|
|
let params = { id: dataObj && dataObj.vo ? dataObj.vo.id : null,storeStatus:2 };
|
|
ajaxRequest2(url, "POST", params, true, function (result) {
|
|
layer.close(loadingMsg); // 关闭提示层
|
|
if (result.code === 200) {
|
|
parent.layer.msg((result.msg + ',请联系当月值班长审批'), { icon: 1 })
|
|
$('.apply-back-btn').css({'display':'none'});
|
|
setDailyStatus('2');
|
|
} else {
|
|
layer.msg(result.msg, { icon: 2 })
|
|
}
|
|
}, function (xhr) {
|
|
layer.close(loadingMsg); // 关闭提示层
|
|
error(xhr)
|
|
}, null, token);
|
|
})
|
|
}
|
|
|
|
// 下载日报
|
|
function downloadDaily() {
|
|
let suffix = 'doc';
|
|
let downloadType = dataObj.downloadType;
|
|
if(downloadType && downloadType.length > 0){
|
|
suffix = downloadType[0];
|
|
}
|
|
let orgId = user.orgId;
|
|
$('.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/downloadCityDaily?currentDay=" + checkedDate + '&orgId=' + orgId +
|
|
"&orgName=" + orgName +
|
|
"&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,
|
|
orgId: orgId,
|
|
chineseDate: setDate(checkedDate),
|
|
})
|
|
)
|
|
);
|
|
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 = orgName + "_地市公司基建日报_" + setDate(checkedDate) + "." + suffix; // 文件名
|
|
} else {
|
|
layer.msg("服务异常,请稍后重试", {
|
|
icon: 16,
|
|
scrollbar: false,
|
|
time: 2000,
|
|
});
|
|
}
|
|
a.click();
|
|
window.URL.revokeObjectURL(url);
|
|
};
|
|
xhr.send();
|
|
} |