361 lines
11 KiB
JavaScript
361 lines
11 KiB
JavaScript
let objParam;
|
|
let form, table, upload, tableIns, layer;
|
|
let pageNum = 1;
|
|
|
|
function setParams(params) {
|
|
objParam = JSON.parse(params);
|
|
$('#proStatus').html(setProStatus(objParam.proStatus));
|
|
$('#titleName').html(objParam.proName + '配件记录');
|
|
layui.use(["form", "table", 'upload', 'layer'], function () {
|
|
form = layui.form;
|
|
table = layui.table;
|
|
upload = layui.upload;
|
|
layer = layui.layer;
|
|
getInputDetails();
|
|
initTable();
|
|
initFileTable();
|
|
});
|
|
}
|
|
|
|
// 获取配件到货入库详情
|
|
function getInputDetails() {
|
|
let params = {
|
|
encryptedData: JSON.stringify({
|
|
'proId': objParam.proId
|
|
})
|
|
};
|
|
let url = dataUrl + 'backstage/statistic/getProDetails';
|
|
ajaxRequest(url, "POST", params, true, function () {
|
|
}, function (result) {
|
|
console.error(result);
|
|
if (result.code === 200) {
|
|
setTableData(result.data);
|
|
} else {
|
|
}
|
|
}, function (xhr, status, error) {
|
|
errorFn(xhr, status, error)
|
|
}, null);
|
|
// 基本数据表格赋值
|
|
function setTableData(obj) {
|
|
$('#lyNum').html(obj.lyNum);
|
|
$('#lyMoney').html(obj.lyMoney);
|
|
}
|
|
}
|
|
|
|
// 处理文件类型
|
|
function handleFileType(value) {
|
|
value = value.toLowerCase();
|
|
let src = '';
|
|
if (value.indexOf('docx') > -1 || value.indexOf('doc') > -1) {
|
|
src = '../../../images/docx.png'
|
|
} else if (value.indexOf('xls') > -1 || value.indexOf('xlsx') > -1) {
|
|
src = '../../../images/xlsx.png'
|
|
} else if (value.indexOf('pdf') > -1) {
|
|
src = '../../../images/pdf.png'
|
|
} else if (value.indexOf('png') > -1 || value.indexOf('jpg') > -1 || value.indexOf('jpeg') > -1) {
|
|
src = '../../../images/img_icon.png'
|
|
}
|
|
return '<img width="20px" height="20px" src = "' + src + '" style="margin:0 5px;">'
|
|
}
|
|
|
|
|
|
function initFileTable() {
|
|
tableIns = table.render({
|
|
elem: "#currentTableIdByFile",
|
|
id: 'currentTableIdByFile',
|
|
headers: {
|
|
authorization: sessionStorage.getItem("gz-token"),
|
|
},
|
|
height: "full",
|
|
url: dataUrl + "backstage/statistic/getProDetailsFilePage",
|
|
where: {
|
|
encryptedData: JSON.stringify({
|
|
'proId': objParam.proId
|
|
}),
|
|
},
|
|
request: {
|
|
pageName: 'pageNum',
|
|
limitName: 'pageSize'
|
|
},
|
|
parseData: function (res) { // res 即为原始返回的数据
|
|
return {
|
|
"code": 0, // 解析接口状态
|
|
"msg": '获取成功', // 解析提示文本
|
|
"count": res.total, // 解析数据长度
|
|
"data": res.list // 解析数据列表
|
|
};
|
|
},
|
|
cols: [
|
|
[
|
|
{
|
|
width: '9.9%',
|
|
title: "序号",
|
|
align: "center",
|
|
templet: function (d) {
|
|
return d.LAY_NUM;
|
|
},
|
|
},
|
|
{
|
|
field: "fileName",
|
|
width: '30%',
|
|
title: "文件名",
|
|
unresize: true,
|
|
align: "center",
|
|
templet: function (d) {
|
|
return handleFileType(d.fileName) + d.fileName;
|
|
},
|
|
},
|
|
{
|
|
field: "type",
|
|
width: '10%',
|
|
title: "文件类型",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "createName",
|
|
title: "上传人员",
|
|
width: '10%',
|
|
unresize: true,
|
|
align: "center",
|
|
templet: function (d) {
|
|
return '<img src="../../../images/user_head_icon.png" width="20px" height="20px">' + d.createName;
|
|
},
|
|
},
|
|
{
|
|
field: "createTime",
|
|
title: "上传时间",
|
|
width: '20%',
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "inputNum",
|
|
title: "操作",
|
|
width: '20%',
|
|
unresize: true,
|
|
align: "center",
|
|
templet: function (d) {
|
|
let html = "";
|
|
html += "<a style='margin:0 5px;color:#409EFF;cursor: pointer;' onclick='viewFile(" + JSON.stringify(d) + ")'>预览</a>";
|
|
html += "<a style='margin:0 5px;color:#409EFF;cursor: pointer;' onclick='downLoadFile(" + 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 queryTable(type) {
|
|
if (type === 1) {
|
|
reloadTable(1);
|
|
} else if (type === 2) {
|
|
$('#partType').val('');
|
|
$('#partName').val('');
|
|
$('#partModel').val('');
|
|
layui.form.render();
|
|
reloadTable(1);
|
|
}
|
|
}
|
|
|
|
// 刷新页面数据
|
|
function reloadData() {
|
|
reloadData(pageNum);
|
|
}
|
|
|
|
// 重载表格
|
|
function reloadTable(pageNum) {
|
|
table.reload("currentTableId", {
|
|
page: {
|
|
curr: pageNum ? pageNum : 1,
|
|
},
|
|
where: {
|
|
encryptedData: JSON.stringify({
|
|
'partType': $('#partType').val(),
|
|
'partName': $('#partName').val(),
|
|
'partModel': $('#partModel').val(),
|
|
'proId': objParam.proId
|
|
}),
|
|
},
|
|
},
|
|
);
|
|
}
|
|
|
|
// 初始化表格
|
|
function initTable() {
|
|
tableIns = table.render({
|
|
elem: "#currentTableId",
|
|
id: 'currentTableId',
|
|
headers: {
|
|
authorization: sessionStorage.getItem("gz-token"),
|
|
},
|
|
height: "full",
|
|
url: dataUrl + "backstage/statistic/getProDetailsPage",
|
|
where: {
|
|
encryptedData: JSON.stringify({
|
|
'partType': $('#partType').val(),
|
|
'partName': $('#partName').val(),
|
|
'partModel': $('#partModel').val(),
|
|
'proId': objParam.proId
|
|
}),
|
|
},
|
|
request: {
|
|
pageName: 'pageNum',
|
|
limitName: 'pageSize'
|
|
},
|
|
parseData: function (res) { // res 即为原始返回的数据
|
|
return {
|
|
"code": 0, // 解析接口状态
|
|
"msg": '获取成功', // 解析提示文本
|
|
"count": res.total, // 解析数据长度
|
|
"data": res.list // 解析数据列表
|
|
};
|
|
},
|
|
cols: [
|
|
[
|
|
{
|
|
width: '9.9%',
|
|
title: "序号",
|
|
align: "center",
|
|
templet: function (d) {
|
|
return d.LAY_NUM;
|
|
},
|
|
},
|
|
{
|
|
field: "partType",
|
|
width: '15%',
|
|
title: "配件类型",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "partName",
|
|
width: '15%',
|
|
title: "配件名称",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "partModel",
|
|
title: "规格型号",
|
|
width: '15%',
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "partUnit",
|
|
title: "单位",
|
|
width: '10%',
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
|
|
{
|
|
field: "applyNum",
|
|
width: '10%',
|
|
title: "领用量",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "money",
|
|
width: '10%',
|
|
title: "金额(元)",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "remark",
|
|
title: "备注",
|
|
width: '15%',
|
|
align: "center",
|
|
unresize: true,
|
|
},
|
|
],
|
|
],
|
|
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 = {
|
|
'partType': $('#partType').val(),
|
|
'partName': $('#partName').val(),
|
|
'partModel': $('#partModel').val(),
|
|
'proId': objParam.proId,
|
|
}
|
|
let url = dataUrl + "backstage/statistic/exportProDetailsPage";
|
|
exportExcelUtil(url, '配件明细', JSON.stringify(params));
|
|
}
|
|
|
|
|
|
// 预览文件
|
|
function viewFile(obj) {
|
|
let fileName = obj.fileName.toLowerCase();
|
|
if (fileName.indexOf('png')> -1 || fileName.indexOf('jpg')> -1 || fileName.indexOf('jpeg')> -1 ) {
|
|
layer.photos({
|
|
shade: 0.5,
|
|
photos: {
|
|
"title": "图片预览",
|
|
"start": 0,
|
|
"data": [
|
|
{
|
|
"alt": "layer",
|
|
"pid": 1,
|
|
"src": fileUrl + obj.fileUrl + '?token=' + sessionStorage.getItem("gz-token"),
|
|
}
|
|
]
|
|
}
|
|
});
|
|
} else {
|
|
// 调用公司的预览文件的服务
|
|
commonViewFile(obj.fileUrl);
|
|
}
|
|
}
|
|
|
|
// 下载文件
|
|
function downLoadFile(obj) {
|
|
let url = dataUrl + "backstage/export/download?fileId=" + obj.id;
|
|
downLoadFileUtil(url, obj.fileName, null);
|
|
}
|
|
|
|
// 打印
|
|
function print() {
|
|
Print('#body', {
|
|
onStart: function () {
|
|
console.log('onStart', new Date())
|
|
},
|
|
onEnd: function () {
|
|
console.log('onEnd', new Date())
|
|
}
|
|
})
|
|
}
|
|
|
|
// 工程状态
|
|
function setProStatus(status) {
|
|
if (status === '1') {
|
|
return "<span style='color:#19BE6B;margin:0 5px 0 5px;font-size:16px'>●</span>在建";
|
|
} else if (status === '2') {
|
|
return "<span style='color:#999;margin:0 5px 0 5px;font-size:16px;'>●</span>完工";
|
|
} else {
|
|
return '/';
|
|
}
|
|
} |