ah_jjzhgd_webscreen/js/pages/newDataAnalysis/projectManagement.js

173 lines
5.8 KiB
JavaScript
Raw Normal View History

2025-07-23 19:27:27 +08:00
let table, layer, form;
layui.use(["layer", "table", "form"], function () {
layer = layui.layer;
table = layui.table;
form = layui.form;
// 响应成功后的拦截器
$.ajaxSetup({
beforeSend: function (xhr, options) {
var originalSuccess = options.success;
options.success = function (data, textStatus, jqXhr) {
data = modifyResponseData(data);
// success(data,textStatus, jqXhr);
originalSuccess.apply(this, arguments);
};
},
});
initTable(1, parent.$("#bidPro").val());
});
/* 切换数据 */
function changeData(that, type) {
const bidCode = parent.$("#bidPro").val();
$(".ul-box li").each(function () {
if ($(this).hasClass("check")) {
$(this).removeClass("check").addClass("nocheck");
}
});
var tableElem = $("#demo2").parents(".layui-table-view");
tableElem.remove();
$(that).removeClass("nocheck").addClass("check");
if (type === 1 || type === 2 || type === 3 || type === 6 || type === 12) {
initTable(type, bidCode);
$("#right-table-box").removeAttr("style");
$("#no-data-box").css({ display: "none" });
$("#right-box").css({ display: "none" });
}
}
function initTable(type, bidCode) {
const url = commonUrl + "screen/largeScreen/tb_project_new/list";
2025-07-23 19:27:27 +08:00
table.render({
elem: "#demo2",
url: url,
skin: "line",
page: true,
height: "full-100",
headers: {
decrypt: "decrypt",
Authorization: token,
},
where: {
bidCode: bidCode,
type: type,
},
response: {
statusName: "code", // 规定数据状态的字段名称默认code
statusCode: 200, // 规定成功的状态码默认0
countName: "count", // 规定数据总数的字段名称默认count
dataName: "rows", // 规定数据列表的字段名称默认data
},
2025-07-23 19:27:27 +08:00
cols: [setCols(type)],
initComplete: function () {
// 在表格渲染完成后,重新渲染序号列
var that = this.elem.next();
var tool = that
.children(".layui-table-box")
.children(".layui-table-fixed")
.children(".layui-table-body")
.children(".layui-table");
tool.find("tr").each(function (index, item) {
$(this)
.find('td[data-field="LAY_TABLE_INDEX"]')
.text(index + 1);
});
},
done: function (res, curr, count, origin) {
2025-07-24 10:42:33 +08:00
$(".layui-table-body table.layui-table tbody tr #exportBtn").on(
"click",
function () {
// 获取当前行的数据
var index = $(this).index();
var rowData = res.rows[index]; // 获取对应行的数据
console.log(rowData, "rowData导出");
const url =
commonUrl +
"screen/largeScreen/tb_project_new/export?proName=" +
rowData.taskName +
"&token=" +
sessionStorage.getItem("zhgd_token");
// window.location.href = url;
window.open(url, "_blank");
// $.ajax({
// url: url,
// type: "get",
// headers: {
// authorization: sessionStorage.getItem("zhgd_token"),
// },
// success: function (data) {
// console.log(data, "导出的数据结果");
// },
// });
2025-07-24 10:42:33 +08:00
}
);
2025-07-23 19:27:27 +08:00
},
});
function setCols(type) {
if (type === 1) {
return [
{ type: "numbers", title: "序号", width: "10%" }, // 添加序号列
{
field: "taskName",
2025-07-23 19:27:27 +08:00
title: "工程名称",
align: "center",
},
{
field: "projectNumber",
title: "任务名称",
align: "center",
},
{
field: "planStartTime",
title: "计划开始时间",
align: "center",
},
{
field: "planEndTime",
title: "实际开始时间",
align: "center",
},
{
field: "diffDay",
title: "偏差天数",
align: "center",
},
{
field: "planCost",
title: "成本预算",
2025-07-23 19:27:27 +08:00
align: "center",
},
{
field: "actualCost",
title: "实际成本",
2025-07-23 19:27:27 +08:00
align: "center",
},
{
field: "riskLevel",
title: "风险等级",
2025-07-23 19:27:27 +08:00
align: "center",
},
{
field: "suggestion",
title: "建议策略",
2025-07-23 19:27:27 +08:00
align: "center",
},
{
title: "操作",
2025-07-23 19:27:27 +08:00
align: "center",
templet: (d) => {
let text = "";
text +=
'<a id="exportBtn" style="color: #007bff;cursor: pointer;font-size: 16px">分析报告</a>';
return text;
},
2025-07-23 19:27:27 +08:00
},
];
}
}
}