144 lines
4.7 KiB
JavaScript
144 lines
4.7 KiB
JavaScript
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";
|
||
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
|
||
},
|
||
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) {
|
||
// console.log(res);
|
||
},
|
||
});
|
||
|
||
function setCols(type) {
|
||
if (type === 1) {
|
||
return [
|
||
{ type: "numbers", title: "序号", width: "10%" }, // 添加序号列
|
||
{
|
||
field: "taskName",
|
||
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: "成本预算",
|
||
align: "center",
|
||
},
|
||
{
|
||
field: "actualCost",
|
||
title: "实际成本",
|
||
align: "center",
|
||
},
|
||
{
|
||
field: "riskLevel",
|
||
title: "风险等级",
|
||
align: "center",
|
||
},
|
||
{
|
||
field: "suggestion",
|
||
title: "建议策略",
|
||
align: "center",
|
||
},
|
||
{
|
||
title: "操作",
|
||
align: "center",
|
||
templet: (d) => {
|
||
let text = "";
|
||
text +=
|
||
'<a id="exportBtn" style="color: #007bff;cursor: pointer;font-size: 16px">导出</a>';
|
||
return text;
|
||
},
|
||
},
|
||
];
|
||
}
|
||
}
|
||
}
|