369 lines
14 KiB
JavaScript
369 lines
14 KiB
JavaScript
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;
|
||
});
|
||
|
||
function setPayStatus() {
|
||
if (objParam.status === '未付') {
|
||
return "<span style='color:#FF9900;margin:0 5px 0 5px;font-size:16px'>●</span>待付款";
|
||
} else {
|
||
return "<span style='color:#19BE6B;margin:0 5px 0 5px;font-size:16px'>●</span>已付款";
|
||
}
|
||
}
|
||
|
||
getSltDetailsInfo();
|
||
getPayCarDetails();
|
||
}
|
||
|
||
//admission fee
|
||
|
||
// 供应商付款记录-详情
|
||
function getSltDetailsInfo() {
|
||
let encryptedData = {planId: objParam.planId};
|
||
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);
|
||
$('#money').html('¥' + obj.money);
|
||
$('#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;">'
|
||
}
|
||
|
||
|
||
}
|
||
|
||
// 用车明细
|
||
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);
|
||
}
|
||
|
||
// 派车明细-车辆
|
||
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>' + item.days + '</td>' +
|
||
'<td>' + item.fee + '元</td>' +
|
||
'<td>' + setZlPrice(item) + '</td>' +
|
||
'<td> ¥ ' + item.cost + '</td>' +
|
||
"<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>" +
|
||
"<td><a style='color:#409eff;margin:0 5px;cursor: pointer;' onclick='enter(" + JSON.stringify(item) + ")'>录入</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;
|
||
obj.code = obj.planCode || obj.code;
|
||
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 enter(obj) {
|
||
var html = `
|
||
<form class="layui-form" lay-filter="feeForm" style="padding: 20px;">
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">实际天数</label>
|
||
<div class="layui-input-block">
|
||
<input type="number" name="days" lay-verify="required|number|min[1]"
|
||
placeholder="请输入使用天数" autocomplete="off"
|
||
class="layui-input" min="1">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">入场费(元)</label>
|
||
<div class="layui-input-block">
|
||
<input type="number" name="fee" lay-verify="required|number|min[0]"
|
||
placeholder="请输入入场费用" autocomplete="off"
|
||
class="layui-input" min="0" step="0.01">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="layui-form-item">
|
||
<div class="layui-input-block">
|
||
<button class="layui-btn layui-bg-blue no-print" lay-submit lay-filter="submitForm">确认</button>
|
||
<button type="reset" class="layui-btn layui-btn-primary" id="resetForm">重置</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
`;
|
||
layer.open({
|
||
type: 1,
|
||
title: '录入信息',
|
||
content: html,
|
||
area: ['500px', '300px'],
|
||
shade: 0.3,
|
||
btn: [], // 不显示默认按钮
|
||
success: function (layero) {
|
||
// 渲染表单
|
||
form.render();
|
||
|
||
// 表单提交事件
|
||
form.on('submit(submitForm)', function (data) {
|
||
obj.days = data.field.days;
|
||
obj.fee = data.field.fee;
|
||
let params = {
|
||
encryptedData: JSON.stringify(obj)
|
||
}
|
||
let url = dataUrl + 'backstage/carBalance/updatePayCar';
|
||
ajaxRequest(url, "POST", params, true, function () {
|
||
}, function (result) {
|
||
if (result.code === 200) {
|
||
getPayCarDetails()
|
||
}
|
||
}, function (xhr, status, error) {
|
||
errorFn(xhr, status, error)
|
||
}, null);
|
||
|
||
|
||
// 显示成功提示
|
||
layer.msg('录入成功!', {icon: 1});
|
||
|
||
// 关闭弹窗
|
||
layer.closeAll('page');
|
||
|
||
return false; // 阻止表单跳转
|
||
});
|
||
|
||
// 重置按钮事件
|
||
layero.find('#resetForm').on('click', function () {
|
||
form.val('feeForm', {
|
||
'days': '',
|
||
'fee': ''
|
||
});
|
||
return false; // 阻止默认重置行为
|
||
});
|
||
}
|
||
});
|
||
}
|
||
|
||
// 打印
|
||
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); // 再执行关闭
|
||
} |