gz_safety_ui/js/aq_settlement/child/settlement_detail.js

350 lines
11 KiB
JavaScript

let objParam;
let form, table, upload, tableIns, layer;
let pageNum = 1;
function setParams(params) {
objParam = JSON.parse(params);
console.error(objParam);
$('#code').html(objParam.planCode);
$('#titleName').html(objParam.supName + '供应商付款记录');
layui.use(["form", "table", 'upload', 'layer'], function () {
form = layui.form;
table = layui.table;
upload = layui.upload;
layer = layui.layer;
getPlanApplyPayDetails();
initTable();
});
}
// 详情
function getPlanApplyPayDetails() {
let params = {
encryptedData: JSON.stringify({
'contractId': objParam.contractId,
'supId': objParam.supId,
'outId': objParam.outId,
'planId': objParam.planId,
})
};
let url = dataUrl + 'backstage/supApply/getPlanApplyPayDetails';
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) {
if (obj.planCode) {
$('#planCode').html("<a style='color:#2F82FB;cursor: pointer;' onclick='openPlanDetail(" + JSON.stringify(objParam) + ")'>" + obj.planCode + "</a>");
} else {
$('#planCode').html("");
}
$('#supName').html(obj.supName);
$('#proName').html(objParam.proName);
$('#cgNum').html(obj.cgNum);
$('#money').html(" ¥ "+(obj.money ? obj.money : 0));
$('#outTime').html(obj.outTime);
setFileTable(obj.fileList);
}
}
// 附件文档赋值
function setFileTable(fileList) {
$('#file-table tbody tr:not(:first)').remove();
let html = '';
if (fileList && fileList.length > 0) {
$.each(fileList, function (index, item) {
html += '<tr>' +
'<td>' + handleFileType(item.fileName) + item.fileName + '</td>' +
'<td>' + item.type + '</td>' +
'<td><img src="../../../images/user_head_icon.png" width="20px" height="20px">' + item.createName + '</td>' +
'<td>' + item.createTime + '</td>' +
'<td><a style="margin:0 5px;color:#409EFF;cursor: pointer;" onclick=\'viewFile(' + JSON.stringify(item) + ')\'>预览</a>' +
'<a style="margin:0 5px;color:#409EFF;cursor: pointer;" onclick=\'downLoadFile(' + JSON.stringify(item) + ')\'>下载</a>' +
'</td>' +
'</tr>';
})
} else {
html = '<tr><td colspan="5" style="text-align: center;">暂无数据</td></tr>';
}
$('#file-table tbody').after(html);
}
// 处理文件类型
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 queryTable(type) {
if (type === 1) {
let name = $('#name').val();
let flag = checkValue(name);
if (flag) {
$('#name').val('');
return layer.msg('名称查询包含特殊字符,请重新输入', { icon: 2 });
}
let model = $('#model').val();
let flag2 = checkValue(model);
if (flag2) {
$('#model').val('');
return layer.msg('规格查询包含特殊字符,请重新输入', { icon: 2 });
}
reloadTable(1);
} else if (type === 2) {
$('#name').val('');
$('#model').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({
'name': $('#name').val(),
'model': $('#model').val(),
'contractId': objParam.contractId,
'supId': objParam.supId,
'outId': objParam.outId,
'planId': objParam.planId,
}),
},
},
);
}
// 初始化表格
function initTable() {
tableIns = table.render({
elem: "#currentTableId",
id: 'currentTableId',
headers: {
authorization: sessionStorage.getItem("gz-token"),
},
height: "full",
url: dataUrl + "backstage/supApply/getPlanApplyPayDetailsList",
where: {
encryptedData: JSON.stringify({
'partType': $('#partType').val(),
'partName': $('#partName').val(),
'contractId': objParam.contractId,
'supId': objParam.supId,
'outId': objParam.outId,
'planId': objParam.planId,
}),
},
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: '6.9%',
title: "序号",
align: "center",
templet: function (d) {
return d.LAY_NUM;
},
},
{
field: "name",
width: '10%',
title: "名称",
unresize: true,
align: "center",
sort:true,
},
{
field: "model",
width: '8%',
title: "规格",
unresize: true,
align: "center",
sort:true,
},
{
field: "unit",
title: "单位",
width: '7%',
unresize: true,
align: "center",
sort:true,
},
{
field: "price",
title: "单价(元)",
width: '10%',
unresize: true,
align: "center",
sort:true,
},
{
field: "cgNum",
width: '8%',
title: "入库量",
unresize: true,
align: "center",
sort:true,
},
{
field: "ccDay",
title: "出厂日期",
width: '10%',
align: "center",
unresize: true,
sort:true,
},
{
field: "jyDay",
title: "检验日期",
width: '10%',
align: "center",
unresize: true,
sort:true,
},
{
field: "remark",
title: "备注",
width: '10%',
align: "center",
unresize: true,
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: "planCode",
title: "需求计划编号",
width: '10%',
align: "center",
unresize: true,
sort:true,
templet: function (d) {
if (!d.planCode) {
return ""; // 返回空字符串
}
let html = "";
html += "<a onclick='openPlanDetail(" + JSON.stringify(d) + ")'>" + d.planCode + "</a>";
return html;
},
},
{
field: "proName",
title: "工程名称",
width: '10%',
align: "center",
unresize: true,
sort: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 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 + "sys/file/download?fileId=" + obj.id;
downLoadFileUtil(url, obj.fileName, null);
}
// 打印
function print() {
$("#main-box").print({
globalStyles: true,
mediaPrint: false,
noPrintSelector: ".no-print",
iframe: true,
append: null,
prepend: null,
manuallyCopyFormValues: true,
deferred: $.Deferred()
});
}
// 需求计划详情
function openPlanDetail(obj) {
obj.id = obj.planId;
obj.code = obj.planCode;
openIframeByParamObj2("planDetail2", "安全工器具需求计划", "../aq_demand_plan/child/apply_plan_detail.html", "92%", "95%", obj);
}