gz_gqj_web/js/demandPlan/child/excess_inventory_source.js

165 lines
5.0 KiB
JavaScript

let objParam;
let form, table, element, tableIns, layer;
let pageNum = 1;
function setParams(obj) {
objParam = JSON.parse(obj);
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) {
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);
$('#wfhNum').html(obj.wfhNum);
$('#kuNum').html(obj.kuNum);
$('#clNum').html(obj.clNum);
$('#proNum').html(obj.proNum);
}
}
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: '5.8%',
title: "序号",
align: "center",
templet: function (d) {
return d.LAY_NUM;
},
},
{
field: "code",
width: '12%',
title: "需求计划编号",
unresize: true,
align: "center",
templet: function (d) {
let html = "";
html += "<a onclick='demand_plan(" + JSON.stringify(d) + ")'>"+d.code+"</a>";
return html;
},
},
{
field: "proName",
width: '15%',
title: "工程名称",
unresize: true,
align: "center",
},
{
field: "projectPart",
width: '13%',
title: "项目部分",
unresize: true,
align: "center",
},
{
field: "projectContent",
width: '15%',
title: "工程内容 ",
unresize: true,
align: "center",
},
{
field: "proName",
width: '15%',
title: "需用日期",
unresize: true,
align: "center",
},
{
field: "remark",
width: '15%',
title: "计划说明 ",
unresize: true,
align: "center",
},
{
field: "needNum",
width: '9%',
title: "需用量 ",
unresize: true,
align: "center",
templet: function (d) {
return setNumColor(d.needNum, 1);
},
}
]
],
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", "机具需求计划", "../../../page/demandPlan/child/apply_plan_detail.html", "92%", "95%", obj);
}