gz_machines_ui/js/accessory/child/pro_part_detail.js

140 lines
3.8 KiB
JavaScript

let form, table;
let tableIns;
let pageNum = 1; // 定义分页
function setParams(params) {
objParam = JSON.parse(params);
layui.use(["form", "table", 'upload', 'layer'], function () {
form = layui.form;
table = layui.table;
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('');
// $('#proStatus').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(),
'id': objParam.id
}),
},
},
);
}
// 初始化表格
function initTable() {
tableIns = table.render({
elem: "#currentTableId",
id: 'currentTableId',
headers: {
authorization: sessionStorage.getItem("gz-token"),
},
height: "full-170",
url: dataUrl + "backstage/statistic/getListDetails",
where: {
encryptedData: JSON.stringify({
'keyWord': $('#keyWord').val(),
'id': objParam.id
}),
},
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: '20%',
title: "序号",
align: "center",
templet: function (d) {
return d.LAY_NUM;
},
},
{
width: '30%',
title: "配件领用设备",
unresize: true,
align: "center",
templet: function (d) {
return objParam.module;
},
},
{
field: "proName",
width: '30%',
title: "领用工程",
unresize: true,
align: "center",
},
{
title: "领用配件详情",
width: '20%',
align: "center",
unresize: true,
templet: function (d) {
let html = "";
d.module=objParam.module;
html += "<a onclick='partDetail(" + 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;
table.resize("currentTableId");
},
});
}
// 配件退料详情
function partDetail(obj) {
openIframeByParamObj("part_detail", "配件详情", "./part_detail.html", "92%", "95%", obj);
}