gz_machines_ui/js/accessory/child/part_detail.js

170 lines
4.8 KiB
JavaScript

let form, table, laydate;
let tableIns;
let pageNum = 1; // 定义分页
function setParams(params) {
objParam = JSON.parse(params);
layui.use(["form", "table", 'upload', 'layer', 'laydate'], function () {
form = layui.form;
table = layui.table;
laydate = layui.laydate;
laydate.render({
elem: '#ID-laydate-rangeLinked',
range: ['#startDay', '#endDay'],
rangeLinked: true
});
initTable();
});
}
// 查询/重置
function queryTable(type) {
if (type === 1) {
let keyWord = $('#keyWord').val();
let flag = checkValue(keyWord);
if (flag) {
$('#keyWord').val('');
return layer.msg('关键字查询包含特殊字符,请重新输入', { icon: 2 });
}
reloadTable(1);
} else if (type === 2) {
$('#keyWord').val('');
$('#startDay').val('');
$('#endDay').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({
'keyWord': $('#keyWord').val(),
'deviceId': objParam.deviceId,
'proId': objParam.proId,
'startDay': $('#startDay').val(),
'endDay': $('#endDay').val()
}),
},
},
);
}
// 初始化表格
function initTable() {
tableIns = table.render({
elem: "#currentTableId",
id: 'currentTableId',
headers: {
authorization: sessionStorage.getItem("gz-token"),
},
height: "full-170",
url: dataUrl + "backstage/statistic/getPartList",
where: {
encryptedData: JSON.stringify({
'keyWord': $('#keyWord').val(),
'deviceId': objParam.deviceId,
'proId': objParam.proId,
'startDay': $('#startDay').val(),
'endDay': $('#endDay').val()
}),
},
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%',
title: "序号",
align: "center",
templet: function (d) {
return d.LAY_NUM;
},
},
{
width: '15%',
title: "配件领用设备",
unresize: true,
align: "center",
templet: function (d) {
return objParam.module;
},
},
{
field: "proName",
width: '15%',
title: "领用工程",
unresize: true,
align: "center",
},
{
field: "code",
width: '14%',
title: "领料单编号",
unresize: true,
align: "center",
},
{
field: "partName",
width: '15%',
title: "配件名称",
unresize: true,
align: "center",
},
{
field: "partModel",
width: '12%',
title: "配件规格",
unresize: true,
align: "center",
},
{
field: "applyNum",
width: '8%',
title: "领用数量",
unresize: true,
align: "center",
},
{
field: "createTime",
width: '15%',
title: "申请时间",
unresize: true,
align: "center",
},
],
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
done: function (res, curr, count) {
pageNum = tableIns.config.page.curr;
table.resize("currentTableId");
},
});
}