276 lines
8.7 KiB
JavaScript
276 lines
8.7 KiB
JavaScript
let objParam;
|
|
let form, table, tableIns, layer, element;
|
|
let pageNum = 1;
|
|
|
|
function setParams(params) {
|
|
objParam = JSON.parse(params);
|
|
console.error(objParam);
|
|
$('#proName').html(objParam.proName);
|
|
$('#bmname').html(objParam.companyName);
|
|
layui.use(["form", "table", 'layer', 'element'], function () {
|
|
form = layui.form;
|
|
table = layui.table;
|
|
element = layui.element;
|
|
layer = layui.layer;
|
|
getProStatisticsDetails();
|
|
initTable();
|
|
});
|
|
}
|
|
|
|
// 数据概览
|
|
function getProStatisticsDetails() {
|
|
let params = {
|
|
encryptedData: JSON.stringify({
|
|
'proId': objParam.proId
|
|
})
|
|
};
|
|
let url = dataUrl + 'backstage/dispatchCar/getProStatisticsDetails';
|
|
ajaxRequest(url, "POST", params, true, function () {
|
|
}, function (result) {
|
|
if (result.code === 200) {
|
|
setNum(result.data);
|
|
}
|
|
}, function (xhr, status, error) {
|
|
errorFn(xhr, status, error)
|
|
}, null);
|
|
|
|
// 数据概览赋值
|
|
function setNum(obj) {
|
|
$('.layui-progress').remove();
|
|
$('#planNum').html(obj.planNum);
|
|
$('#dispatchNum').html(obj.dispatchNum);
|
|
$('#noDispatchNum').html(obj.noDispatchNum);
|
|
$('.layui-progress').remove();
|
|
$("#progress").after(`
|
|
<div class="layui-progress" lay-showpercent="true" lay-filter="demo-filter-progress">
|
|
<div class="layui-progress-bar layui-bg-blue" lay-percent="${objParam.process}%"></div>
|
|
</div>
|
|
`);
|
|
element.render();
|
|
}
|
|
|
|
}
|
|
|
|
// 查询/重置
|
|
function queryTable(type) {
|
|
if (type === 1) {
|
|
let code = $('#code').val();
|
|
let flag = checkValue(code);
|
|
if (flag) {
|
|
$('#code').val('');
|
|
return layer.msg('需求计划编号查询包含特殊字符,请重新输入', { icon: 2 });
|
|
}
|
|
reloadTable(1);
|
|
} else if (type === 2) {
|
|
$('#code').val('');
|
|
$('#status').val('');
|
|
layui.form.render();
|
|
reloadTable(1);
|
|
}
|
|
}
|
|
|
|
// 刷新页面数据
|
|
function reloadData() {
|
|
reloadTable(pageNum);
|
|
}
|
|
|
|
// 重载表格
|
|
function reloadTable(pageNum) {
|
|
table.reload("currentTableId", {
|
|
page: {
|
|
curr: pageNum ? pageNum : 1,
|
|
},
|
|
where: {
|
|
encryptedData: JSON.stringify({
|
|
'code': $('#code').val(),
|
|
'status': $('#status').val(),
|
|
'proId': objParam.proId
|
|
}),
|
|
},
|
|
},
|
|
);
|
|
}
|
|
|
|
// 初始化表格
|
|
function initTable() {
|
|
tableIns = table.render({
|
|
elem: "#currentTableId",
|
|
id: 'currentTableId',
|
|
headers: {
|
|
authorization: sessionStorage.getItem("gz-token"),
|
|
},
|
|
height: "full-250",
|
|
url: dataUrl + "backstage/dispatchCar/getNeedPlanList",
|
|
where: {
|
|
encryptedData: JSON.stringify({
|
|
'code': $('#code').val(),
|
|
'status': $('#status').val(),
|
|
'proId': objParam.proId
|
|
}),
|
|
},
|
|
request: {
|
|
pageName: 'pageNum',
|
|
limitName: 'pageSize'
|
|
},
|
|
parseData: function (res) { // res 即为原始返回的数据
|
|
if (res.code === 401) {
|
|
closeWindowOpen();
|
|
}
|
|
return {
|
|
"code": 0, // 解析接口状态
|
|
"msg": '获取成功', // 解析提示文本
|
|
"count": res.total, // 解析数据长度
|
|
"data": res.list // 解析数据列表
|
|
};
|
|
},
|
|
cols: [
|
|
[
|
|
{
|
|
width: '5.9%',
|
|
title: "序号",
|
|
align: "center",
|
|
templet: function (d) {
|
|
return d.LAY_NUM;
|
|
},
|
|
},
|
|
{
|
|
field: "typeName",
|
|
width: '10%',
|
|
title: "计划类型",
|
|
unresize: true,
|
|
align: "center",
|
|
sort:true,
|
|
},
|
|
{
|
|
field: "code",
|
|
width: '12%',
|
|
title: "需求计划编号",
|
|
unresize: true,
|
|
align: "center",
|
|
sort:true,
|
|
templet: function (d) {
|
|
return "<a style='color:#409eff;' onclick='viewPlanDetail(" + JSON.stringify(d) + ")'>" + d.code + "</a>";
|
|
},
|
|
},
|
|
{
|
|
field: "userName",
|
|
width: '10%',
|
|
title: "申请人",
|
|
unresize: true,
|
|
align: "center",
|
|
sort:true,
|
|
},
|
|
{
|
|
field: "appLyTime",
|
|
title: "申请时间",
|
|
width: '10%',
|
|
unresize: true,
|
|
align: "center",
|
|
sort:true,
|
|
},
|
|
{
|
|
field: "remark",
|
|
title: "备注",
|
|
width: '12%',
|
|
unresize: true,
|
|
align: "center",
|
|
sort:true,
|
|
templet: function (d) {
|
|
if (d.remark) {
|
|
if (d.remark.length > 60) {
|
|
return '<span title="' + d.remark + '">' + d.remark.substring(0, 60) + '...</span>'
|
|
} else {
|
|
return '<span title="' + d.remark + '">' + d.remark + '</span>'
|
|
}
|
|
} else {
|
|
return '';
|
|
}
|
|
},
|
|
},
|
|
{
|
|
field: "statusName",
|
|
title: "派车状态",
|
|
width: '10%',
|
|
unresize: true,
|
|
align: "center",
|
|
sort:true,
|
|
templet: function (d) {
|
|
if (d.statusName === '待派车' || d.statusName === '待审核') {
|
|
return '<span style="color:#ff9900;font-weight:bold;"> ● </span>' + d.statusName + '';
|
|
} else if (d.statusName === '已派车') {
|
|
return '<span style="color:#19be6b;font-weight:bold;"> ● </span>' + d.statusName + '';
|
|
} else {
|
|
return '';
|
|
}
|
|
},
|
|
},
|
|
{
|
|
field: "dispatchNum",
|
|
width: '10%',
|
|
title: "派车数量",
|
|
unresize: true,
|
|
align: "center",
|
|
sort:true,
|
|
templet: function (d) {
|
|
return "<span style='color:#19be6b'>" + d.dispatchNum + "</span>";
|
|
},
|
|
},
|
|
{
|
|
field: "supName",
|
|
title: "采购金额",
|
|
width: '10%',
|
|
align: "center",
|
|
unresize: true,
|
|
sort:true,
|
|
},
|
|
{
|
|
title: "操作",
|
|
width: '10%',
|
|
align: "center",
|
|
unresize: true,
|
|
templet: function (d) {
|
|
let html = "";
|
|
html += "<a onclick='dispatchCarDetail(" + JSON.stringify(d) + ",1)'>详情</a>";
|
|
return html;
|
|
},
|
|
},
|
|
],
|
|
],
|
|
limits: [10, 15, 20, 25, 50, 100],
|
|
limit: 10,
|
|
page: true,
|
|
done: function (res, curr, count) {
|
|
pageNum = tableIns.config.page.curr;
|
|
table.resize("currentTableId");
|
|
},
|
|
});
|
|
}
|
|
|
|
|
|
// 导出
|
|
function exportExcel() {
|
|
let params = {
|
|
'planCode': $('#planCode').val(),
|
|
'status': $('#status').val(),
|
|
'proId': objParam.proId
|
|
}
|
|
let url = dataUrl + "backstage/purchase/exportDetails";
|
|
exportExcelUtil(url, '需求计划详情', JSON.stringify(params));
|
|
}
|
|
|
|
// 详情
|
|
function dispatchCarDetail(obj, type) {
|
|
let flag = isExistData(type, obj);
|
|
if (!flag && type === 1) {
|
|
return layer.msg('暂无派车批次数据', { icon: 7 });
|
|
} else if (!flag && type === 2) {
|
|
return layer.msg('暂无待审核批次数据', { icon: 7 });
|
|
}
|
|
let title = '详情';
|
|
if (type === 2) {
|
|
title = '审核';
|
|
}
|
|
obj.type = type;
|
|
openIframeByParamObj2("dispatchCarDetail", title, "../car_demand_plan/child/dispatch_car_detail.html", "92%", "95%", obj, 2);
|
|
}
|