232 lines
5.9 KiB
JavaScript
232 lines
5.9 KiB
JavaScript
let form, table, element;
|
|
let tableIns;
|
|
let pageNum = 1; // 定义分页
|
|
layui.use(["form", "table"], function () {
|
|
form = layui.form;
|
|
table = layui.table;
|
|
element = layui.element;
|
|
// 动态插入进度条元素
|
|
$("#num-progress").after(`
|
|
<div class="layui-progress layui-bg-red" lay-filter="demo-filter-progress" style="margin-top:10%;">
|
|
<div class="layui-progress-bar " lay-percent="30%"></div>
|
|
</div>
|
|
`);
|
|
$("#num-progress2").after(`
|
|
<div class="layui-progress" lay-filter="demo-filter-progress" style="margin-top:2%;">
|
|
<div class="layui-progress-bar layui-bg-red" lay-percent="30%"></div>
|
|
</div>
|
|
`);
|
|
$("#num-progress3").after(`
|
|
<div class="layui-progress" lay-filter="demo-filter-progress" style="margin-top:2%;">
|
|
<div class="layui-progress-bar" lay-percent="30%"></div>
|
|
</div>
|
|
`);
|
|
element.render();
|
|
initTable();
|
|
});
|
|
|
|
// 查询/重置
|
|
function queryTable(type){
|
|
if(type === 1){
|
|
reloadTable(1);
|
|
}else if(type === 2){
|
|
$('#proName').val('');
|
|
$('#status').val('0');
|
|
layui.form.render();
|
|
reloadTable(1);
|
|
}
|
|
}
|
|
|
|
// 刷新页面数据
|
|
function reloadData() {
|
|
reloadData(pageNum);
|
|
}
|
|
|
|
// 重载表格
|
|
function reloadTable(pageNum) {
|
|
table.reload("currentTableId",{
|
|
page: {
|
|
curr: pageNum ? pageNum : 1,
|
|
},
|
|
where: {
|
|
encryptedData: JSON.stringify({
|
|
'proName':$('#proName').val(),
|
|
'status':$('#status').val()
|
|
}),
|
|
},
|
|
},
|
|
);
|
|
}
|
|
|
|
// 初始化表格
|
|
function initTable() {
|
|
tableIns = table.render({
|
|
elem: "#currentTableId",
|
|
id:'currentTableId',
|
|
headers: {
|
|
authorization: sessionStorage.getItem("gz-token"),
|
|
},
|
|
height: "full-350",
|
|
url: dataUrl + "backstage/planOut/getProPlanPage",
|
|
where: {
|
|
encryptedData: JSON.stringify({
|
|
'proName':$('#proName').val(),
|
|
'status':$('#status').val()
|
|
}),
|
|
},
|
|
request: {
|
|
pageName: 'pageNum',
|
|
limitName: 'pageSize'
|
|
},
|
|
parseData: function(res){ // res 即为原始返回的数据
|
|
return {
|
|
"code": 0, // 解析接口状态
|
|
"msg": '获取成功', // 解析提示文本
|
|
"count": res.total, // 解析数据长度
|
|
"data": res.list // 解析数据列表
|
|
};
|
|
},
|
|
cols: [
|
|
[
|
|
{
|
|
width: 120,
|
|
title: "序号",
|
|
align: "center",
|
|
templet: function (d) {
|
|
return d.LAY_NUM;
|
|
},
|
|
},
|
|
{
|
|
field: "proName",
|
|
width: 300,
|
|
title: "工程名称",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "planNum",
|
|
width: 180,
|
|
title: "需求计划数量",
|
|
unresize: true,
|
|
align: "center",
|
|
templet: function (d) {
|
|
return setNumColor(d.planNum);
|
|
},
|
|
},
|
|
{
|
|
field: "recordNum",
|
|
width: 180,
|
|
title: "出库单数量 ",
|
|
unresize: true,
|
|
align: "center",
|
|
templet: function (d) {
|
|
return setNumColor(d.recordNum);
|
|
},
|
|
},
|
|
{
|
|
field: "status",
|
|
title: "发货状态",
|
|
width: 200,
|
|
unresize: true,
|
|
align: "center",
|
|
templet: function (d) {
|
|
return setStatusColor(d.status);
|
|
},
|
|
},
|
|
{
|
|
field: "lastDay",
|
|
width: 200,
|
|
title: "最后发货时间",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "progress",
|
|
width: 300,
|
|
title: "进度",
|
|
unresize: true,
|
|
align: "center",
|
|
templet: schedule,
|
|
},
|
|
{
|
|
title: "操作",
|
|
minwidth: 180,
|
|
align: "center",
|
|
unresize: true,
|
|
templet: function (d) {
|
|
let html = "";
|
|
html += "<a onclick=\"viewData('" + d.proId + "')\">详情</a>";
|
|
html += "<div class='splitLine'>|</div><a onclick='sendGoods("+JSON.stringify(d)+")'>发货</a>";
|
|
return html;
|
|
},
|
|
},
|
|
],
|
|
],
|
|
limits: [10, 15, 20, 25, 50, 100],
|
|
limit: 10,
|
|
page: true,
|
|
done: function (res, curr, count) {
|
|
pageNum = tableIns.config.page.curr;
|
|
element.render();
|
|
},
|
|
});
|
|
}
|
|
|
|
// 数量颜色
|
|
function setNumColor(value) {
|
|
return '<span style="color:#409Eff;font-weight:bold;">' + value + "</span>";
|
|
}
|
|
|
|
// 发货状态颜色
|
|
function setStatusColor(value) {
|
|
let color = "#409Eff";
|
|
if (value === "未发货") {
|
|
color = "#f56c6c";
|
|
} else if (value === "部分发货") {
|
|
color = "#ff9900";
|
|
}else if (value === "全部发货") {
|
|
color = "#19be6b";
|
|
}
|
|
return '<span style="color:' + color + '">' + value + "</span>";
|
|
}
|
|
|
|
// 设置进度值
|
|
function schedule(d) {
|
|
d.filter == undefined ? (d.filter = d.LAY_NUM) : d.filter;
|
|
d.progress == undefined ? (d.progress = 100) : d.progress;
|
|
var color = "layui-bg-orange";
|
|
if (d.progress < 100) {
|
|
color = "layui-bg-orange";
|
|
} else if (d.progress === 100) {
|
|
color = "layui-bg-primary";
|
|
} else if (d.progress > 100) {
|
|
color = "layui-bg-blue";
|
|
}
|
|
//设置页面进度条
|
|
return (
|
|
'<div class="layui-progress layui-progress-big" lay-showpercent="true" id="' +d.filter +'" lay-filter="progress' +d.filter +'">' +
|
|
'<div class="layui-progress-bar ' +color +'" lay-percent="' +d.progress +'%">' +
|
|
"</div></div>"
|
|
);
|
|
}
|
|
|
|
// 导出
|
|
function exportExcel() {
|
|
let encryptedData = JSON.stringify({
|
|
'proName':$('#proName').val(),
|
|
'status':$('#status').val()
|
|
});
|
|
let url = dataUrl + "backstage/planOut/exportExcel?encryptedData=" + encryptedData;
|
|
exportExcelUtil(url,'机具公司发货数据');
|
|
}
|
|
|
|
// 发货
|
|
function sendGoods(obj) {
|
|
openIframeByParamObj("sendGoods","发货","./child/send_goods_form.html","92%","95%",obj);
|
|
}
|
|
|
|
// type 1.总需求量 2.待发货量 3.已发货量
|
|
function openViewData(type) {
|
|
openIframeByParam("viewData","数据概览","./child/view_data_list.html","92%","95%",type);
|
|
}
|