gz_car_ui/js/car_settlement/child/settlement_detail.js

273 lines
11 KiB
JavaScript
Raw Normal View History

2025-01-16 18:47:38 +08:00
let objParam, dataObj;
let form, table, upload, tableIns, layer, element;
let pageNum = 1;
function setParams(params) {
objParam = JSON.parse(params);
$('#titleName').html(objParam.supName + '供应商付款记录');
$('#code').html(objParam.code + setPayStatus());
layui.use(["form", "table", 'upload', 'layer', 'element'], function () {
form = layui.form;
table = layui.table;
upload = layui.upload;
layer = layui.layer;
});
2025-01-17 12:39:11 +08:00
function setPayStatus() {
if (objParam.status === '未付') {
2025-01-16 18:47:38 +08:00
return "<span style='color:#FF9900;margin:0 5px 0 5px;font-size:16px'>●</span>待付款";
2025-01-17 12:39:11 +08:00
} else {
2025-01-16 18:47:38 +08:00
return "<span style='color:#19BE6B;margin:0 5px 0 5px;font-size:16px'>●</span>已付款";
}
}
2025-01-17 12:39:11 +08:00
getSltDetailsInfo();
getPayCarDetails();
2025-01-16 18:47:38 +08:00
}
// 供应商付款记录-详情
function getSltDetailsInfo() {
2025-01-17 12:39:11 +08:00
let encryptedData = { planId: objParam.planId };
2025-01-16 18:47:38 +08:00
let url = dataUrl + 'backstage/carBalance/getSltDetailsInfo?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData));
ajaxRequest(url, "GET", null, true, function () {
}, function (result) {
if (result.code === 200) {
dataObj = result.data;
setTableData(result.data);
}
}, function (xhr, status, error) {
errorFn(xhr, status, error)
}, null);
function setTableData(obj) {
$('#supName').html(objParam.supName);
$('#planCode').html("<a style='color:#409eff;margin:0 5px;cursor: pointer;' onclick='viewPlanDetail(" + JSON.stringify(obj) + ")'>" + obj.code + "</a>");
$('#proName').html(obj.proName);
$('#carNum').html(obj.carNum);
2025-01-21 15:50:15 +08:00
$('#money').html('¥' + obj.money);
2025-01-16 18:47:38 +08:00
$('#dispatchDay').html(obj.dispatchDay);
$('#remark').html(obj.remark);
// 附件文档
setFileTable(obj.fileList);
}
// 附件文档赋值
function setFileTable(fileList) {
$('#file-table 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;">'
}
2025-01-17 12:39:11 +08:00
}
// 用车明细
function getPayCarDetails() {
let encryptedData = { planId: objParam.planId };
let url = dataUrl + 'backstage/carBalance/getPayCarDetails?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData));
ajaxRequest(url, "GET", null, true, function () {
}, function (result) {
if (result.code === 200) {
setData(result.data);
}
}, function (xhr, status, error) {
errorFn(xhr, status, error)
}, null);
function setData(list) {
// 用车明细
let carList = list.filter(item => {
return item.type === '车辆';
})
let dcList = list.filter(item => {
return item.type === '吊车';
})
setDispatchCarTable(carList);
setDispatchCarTable2(dcList);
}
2025-01-16 18:47:38 +08:00
// 派车明细-车辆
function setDispatchCarTable(list) {
$('#dispatch-car-table tr:not(:first)').remove();
if (list.length > 0) {
let html = '';
if (list && list.length > 0) {
$.each(list, function (index, item) {
let imgNum = 0;
imgNum += item.carImage.filter(item => { return item.type !== '6' }).length;
imgNum += item.driverUserImage.filter(item => { return item.type !== '6' }).length;
imgNum += item.fileList.length;
html += "<tr>" +
"<td>" + item.type + "</td>" +
"<td>" + item.name + "</td>" +
"<td>" + item.model + "</td>" +
"<td>" + item.carNum + "</td>" +
"<td>" + (item.ton + '吨') + "</td>" +
"<td>" + item.goodsName + "</td>" +
"<td>" + item.startAddress + "</td>" +
"<td>" + item.endAddress + "</td>" +
"<td>" + item.gls + "</td>" +
"<td>" + item.glsPrice + "</td>" +
"<td> ¥ " + (item.glsMoney ? item.glsMoney : 0) + "</td>" +
"<td style='color:#409eff'>" + imgNum + "<a style='color:#409eff;margin:0 5px;cursor: pointer;' onclick='viewFileDetail(" + JSON.stringify(item) + ",1)'>查看附件>></a></td>" +
"<td><a style='color:#409eff;margin:0 5px;cursor: pointer;' onclick='viewPlanDetail(" + JSON.stringify(item) + ")'>" + item.planCode + "</a></td>" +
"</tr>";
})
} else {
html = '<tr><td colspan="13" style="text-align: center;">暂无数据</td></tr>';
}
$('#dispatch-car-table').removeAttr('style').append(html);
} else {
$('#dispatch-car-table').css('display', 'none');
}
}
// 派车明细-吊车
function setDispatchCarTable2(list) {
$('#dispatch-car-table2 tr:not(:first)').remove();
if (list.length > 0) {
let html = '';
if (list && list.length > 0) {
$.each(list, function (index, item) {
let imgNum = 0;
imgNum += item.driverUserImage.filter(item => { return item.type === '2' || item.type === '3' }).length;
imgNum += item.operaImage.filter(item => { return item.type === '2' || item.type === '3' || item.type === '6' }).length;
imgNum += item.fileList.length;
html += '<tr>' +
'<td>' + item.type + '</td>' +
'<td>' + item.name + '</td>' +
'<td>' + item.model + '</td>' +
'<td>' + item.carNum + '</td>' +
'<td>' + item.useAddress + '</td>' +
'<td>' + item.planDay + '</td>' +
'<td>' + setZlPrice(item) + '</td>' +
2025-01-22 09:52:04 +08:00
'<td> ¥ ' + item.cost + '</td>' +
2025-01-16 18:47:38 +08:00
"<td style='color:#409eff'>" + imgNum + "<a style='color:#409eff;margin:0 5px;cursor: pointer;' onclick='viewFileDetail(" + JSON.stringify(item) + ",2)'>查看附件>></a></td>" +
"<td><a style='color:#409eff;margin:0 5px;cursor: pointer;' onclick='viewPlanDetail(" + JSON.stringify(item) + ")'>" + item.planCode + "</a></td>" +
'</tr>';
})
} else {
html = '<tr><td colspan="10" style="text-align: center;">暂无数据</td></tr>';
}
$('#dispatch-car-table2').removeAttr('style').append(html);
// 设置租赁单价
function setZlPrice(item) {
let html = '';
if (item.dcUnit === '元/月/台') {
html += '<p>' + item.monthPrice + '' + item.dcUnit + '' + '</p>';
} else {
html += '<p>' + item.dayPrice + '' + item.dcUnit + '' + '</p>';
}
if (item.isOutSet === 1) {
html += '<p>' + (item.jcMoney ? item.jcMoney : 0) + '(进出场费)</p>'
}
return html;
}
} else {
$('#dispatch-car-table2').css('display', 'none');
}
}
}
// 预览文件
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 viewFileDetail(obj, type) {
let title = '行驶证/挂靠协议驾驶证/身份证/导航图'
if (type === 1) {
title = '行驶证/挂靠协议驾驶证/身份证/导航图'
} else if (type === 2) {
title = '操作证/身份证/导航图'
}
obj.type = type;
openIframeByParamObj("viewFileDetail", title, '../../car_demand_plan/child/view_file_detail.html', "92%", "95%", obj);
}
// 需求计划详情
function viewPlanDetail(obj) {
obj.id = obj.planId;
2025-01-17 12:39:11 +08:00
obj.code = obj.planCode || obj.code;
2025-01-16 18:47:38 +08:00
let content = '../car_demand_plan/child/apply_plan_detail.html';
if (obj.code.indexOf('spec-') > -1) {
content = '../car_demand_plan/child/emerg_internal_car_detail.html';
}
openIframeByParamObj2("viewPlanDetail", "车辆需求计划", content, "92%", "95%", obj);
}
// 打印
function print() {
$("#main-box").print({
globalStyles: true,
mediaPrint: false,
noPrintSelector: ".no-print",
iframe: true,
append: null,
prepend: null,
manuallyCopyFormValues: true,
deferred: $.Deferred()
});
}
// 关闭页面
function closePage(type) {
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
parent.layer.close(index); // 再执行关闭
}