gz_gqj_web/js/demandPlan/child/excess_inventory_source.js

154 lines
4.7 KiB
JavaScript
Raw Normal View History

2024-11-11 10:54:13 +08:00
let objParam;
let form, table, element, tableIns, layer;
let pageNum = 1;
function setParams(obj) {
objParam = JSON.parse(obj);
console.log(objParam);
layui.use(["form", "table", 'element', 'layer'], function () {
form = layui.form;
table = layui.table;
element = layui.element;
layer = layui.layer;
getDataInfoDetails();
initTable();
});
}
// 基本数据
function getDataInfoDetails() {
let encryptedData = {
'moduleId': objParam.moduleId,
};
let url = dataUrl + 'backstage/planOut/getDataInfoDetails?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData));
ajaxRequest(url, "GET", null, true, function () {
}, function (result) {
console.log(result);
if (result.code === 200) {
setData(result.data);
}
}, function (xhr, status, error) {
errorFn(xhr, status, error)
}, null);
function setData(obj) {
$('#type').html(obj.type);
$('#name').html(obj.name);
$('#unit').html(obj.unit);
$('#module').html(obj.module);
}
}
function initTable() {
tableIns = table.render({
elem: "#currentTableId",
id: 'currentTableId',
headers: {
authorization: sessionStorage.getItem("gz-token"),
},
height: "full-180",
url: dataUrl + "backstage/planOut/getDataPlanByPage",
where: {
encryptedData: JSON.stringify({
'moduleId': objParam.moduleId
}),
},
request: {
pageName: 'pageNum',
limitName: 'pageSize'
},
parseData: function (res) { // res 即为原始返回的数据
return {
"code": 0, // 解析接口状态
"msg": '获取成功', // 解析提示文本
"count": res.total, // 解析数据长度
"data": res.list // 解析数据列表
};
},
cols: [
[
{
width: '9.8%',
title: "序号",
align: "center",
templet: function (d) {
return d.LAY_NUM;
},
},
{
field: "proName",
width: '30%',
title: "工程名称 ",
unresize: true,
align: "center",
},
{
field: "code",
width: '30%',
title: "需求计划编号",
unresize: true,
align: "center",
templet: function (d) {
let html = "";
html += "<a onclick='demand_plan(" + JSON.stringify(d) + ")'>"+d.code+"</a>";
return html;
},
},
{
field: "needNum",
width: '10%',
title: "需用量 ",
unresize: true,
templet: function (d) {
return setNumColor(d.needNum, 1);
},
},
{
field: "needNum",
title: "已发货量",
width: '10%',
unresize: true,
align: "center",
templet: function (d) {
return setNumColor(d.needNum, 2);
},
},
{
field: "needNum",
title: "待发货量",
width: '10%',
unresize: true,
align: "center",
templet: function (d) {
return setNumColor(d.needNum, 3);
},
}
]
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
done: function (res, curr, count) {
pageNum = tableIns.config.page.curr;
element.render();
table.resize("currentTableId");
},
});
}
// 数量颜色 1.需要量 2.已发货量 3.待发货量
function setNumColor(value, type) {
let color = "#409Eff";
if (type === 1) {
color = "#409Eff";
} else if (type === 2) {
color = "#19be6b";
} else if (type === 3) {
color = "#f56c6c";
}
return '<span style="color:' + color + '">' + value + "</span>";
}
// 需求计划编号
function demand_plan(obj){
openIframeByParamObj2("demand_plan", "机具需求计划", "./excess_inventory_source.html", "92%", "95%", obj);
}