付款单申请审核
This commit is contained in:
parent
97eb522fb8
commit
c8028b979f
|
|
@ -201,12 +201,12 @@ function carDetail(list) {
|
|||
function setZlPrice(item) {
|
||||
let html = '';
|
||||
if (item.dcUnit === '元/月/台') {
|
||||
html += '<p>' + item.monthPrice + '(' + item.dcUnit + ')' + '</p>';
|
||||
html += '<span>' + item.monthPrice + '(' + item.dcUnit + ')' + '</span>';
|
||||
} else {
|
||||
html += '<p>' + item.dayPrice + '(' + item.dcUnit + ')' + '</p>';
|
||||
html += '<span>' + item.dayPrice + '(' + item.dcUnit + ')' + '</span>';
|
||||
}
|
||||
if (item.isOutSet === 1) {
|
||||
html += '<p>' + (item.jcMoney ? item.jcMoney : 0) + '(进出场费)</p>'
|
||||
html += '<span>' + (item.jcMoney ? item.jcMoney : 0) + '(进出场费)</span>'
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
|
@ -520,11 +520,11 @@ function setOperRecordInfo(list, obj) {
|
|||
// 2. 部门映射表(替代多 if-else,清晰直观)
|
||||
const deptMap = {
|
||||
'0': '分包商',
|
||||
'1': '项目部',
|
||||
'2': '防线部门',
|
||||
'3': '分公司',
|
||||
'4': '经营部',
|
||||
'5': '总公司'
|
||||
'1': '现场项目部',
|
||||
'2': '智联装备云控公司放线队',
|
||||
'3': '项目部所属分公司',
|
||||
'4': '智联装备云控经营部',
|
||||
'5': '智联装备云控公司总经理'
|
||||
};
|
||||
const dept = deptMap[auditType] || '未知部门'; // 默认值容错
|
||||
|
||||
|
|
@ -532,6 +532,7 @@ function setOperRecordInfo(list, obj) {
|
|||
const operRules = [
|
||||
// 规则:[条件函数, 操作文案],按优先级排序(先匹配先执行)
|
||||
[() => index === 0 && auditType == '0', '发起申请'],
|
||||
[() => auditType === '0' && auditStatus == '0', `发起申请,时间:${times} 原因备注:${remark}`],
|
||||
|
||||
[() => auditType === '1' && auditStatus == '1', `审核确认通过,时间:${times} 原因备注:${remark}`], // 原逻辑:无 index 限制
|
||||
[() => auditType === '1' && auditStatus == '2', `驳回-给发起人${creator},共间隔:${times} 原因备注:${remark}`],
|
||||
|
|
@ -568,7 +569,7 @@ function setOperRecordInfo(list, obj) {
|
|||
'</div>' +
|
||||
'<div class="user-oper layout">' +
|
||||
'<div style="width: 100%">' +
|
||||
'<span>' + (item.auditReason ? item.auditReason : item.auditUser) + '</span><span>' + dept + '</span>' +
|
||||
'<span>' + dept+ '</span>-<span>' + item.auditUser + '</span>' +
|
||||
'</div>' +
|
||||
'<div style="width: 100%">' +
|
||||
'<span>' + operData + '</span>' +
|
||||
|
|
|
|||
|
|
@ -121,20 +121,11 @@ function initTable() {
|
|||
{
|
||||
field: "planNum",
|
||||
width: '10%',
|
||||
title: "车辆数量",
|
||||
title: "计划数量",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort:true,
|
||||
},
|
||||
{
|
||||
field: "ygMoney",
|
||||
width: '14%',
|
||||
title: "预估金额(元) ",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort:true,
|
||||
|
||||
},
|
||||
{
|
||||
field: "money",
|
||||
width: '14%',
|
||||
|
|
@ -199,13 +190,13 @@ function initTable() {
|
|||
let html = "";
|
||||
let status = d.status;
|
||||
if(status == -1){
|
||||
html += "<a onclick='checkSubmit(" + JSON.stringify(d) + ")'>提交</a><div class='splitLine'>|</div>"
|
||||
html += "<a onclick='checkSubmit(" + JSON.stringify(d) + ")'>提交</a>"
|
||||
}
|
||||
if(status == -1 || status == 2){
|
||||
html += "<a onclick='checkUpdate(" + JSON.stringify(d) + ")'>修改</a><div class='splitLine'>|</div>"
|
||||
html += "<div class='splitLine'>|</div><a onclick='checkUpdate(" + JSON.stringify(d) + ")'>修改</a>"
|
||||
html += "<div class='splitLine'>|</div><a onclick='checkDelete(" + JSON.stringify(d) + ")'>删除</a>";
|
||||
}
|
||||
html += "<a onclick='planAuditDetail(" + JSON.stringify(d) + ")'>详情</a>";
|
||||
html += "<div class='splitLine'>|</div><a onclick='planAuditDetail(" + JSON.stringify(d) + ")'>详情</a>";
|
||||
if ( status == 1 ) {
|
||||
html += "<div class='splitLine'>|</div><a onclick='checkDetail(" + JSON.stringify(d) + ")'>审核</a>";
|
||||
}
|
||||
|
|
@ -246,18 +237,18 @@ function getCheckStatus(auditType,status) {
|
|||
}
|
||||
let name = '分包商';
|
||||
if(auditType == 1){
|
||||
name = "项目部"
|
||||
name = "现场项目部"
|
||||
}else if(auditType == 2){
|
||||
name = "防线部门"
|
||||
name = "智联装备云控公司放线队"
|
||||
}else if(auditType == 3){
|
||||
name = "分公司"
|
||||
name = "项目部所属分公司"
|
||||
}else if(auditType == 4){
|
||||
name = "经营部"
|
||||
name = "智联装备云控经营部"
|
||||
}else if(auditType == 5){
|
||||
name = "总公司"
|
||||
name = "智联装备云控公司总经理"
|
||||
}
|
||||
if (status == 1) {
|
||||
return "<span style='color:#FF9900;margin:0 5px 0 5px;font-size:16px'>●</span>"+ name+"待审核";
|
||||
return "<span style='color:#FF9900;margin:0 5px 0 5px;font-size:16px'>●</span>待"+ name+"审核";
|
||||
} else if (status == 2) {
|
||||
return "<span style='color:#19BE6B;margin:0 5px 0 5px;font-size:16px;'>●</span>审核驳回";
|
||||
} else if (status == -1) {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
let idParam, objParam, fileList = new Array(), imgListUp = new Array();
|
||||
let form, laydate, layer, upload, table, util;
|
||||
let pageNum = 1, tableIns; // 定义分页
|
||||
let jjDataArr = []; // 清单数据
|
||||
let delIdArr = []; // 存储要删除的文件ID(关键:新增初始化)
|
||||
let planId = ''; // 计划ID
|
||||
let allDataList = [];
|
||||
// 全局变量
|
||||
let idParam, objParam;
|
||||
let fileList = []; // 附件列表
|
||||
let delIdArr = []; // 删除旧附件ID
|
||||
let jjDataArr = []; // 计划明细
|
||||
let allDataList = []; // 派车明细
|
||||
let planId = ''; // 当前选择计划ID
|
||||
|
||||
let form, laydate, layer, upload, table, util;
|
||||
let pageNum = 1, tableIns;
|
||||
|
||||
// ------------------- 初始化参数 -------------------
|
||||
function setParams(obj) {
|
||||
objParam = JSON.parse(obj);
|
||||
// 初始化删除文件ID数组(避免残留)
|
||||
delIdArr = [];
|
||||
layui.use(['form','layer','laydate','upload','table'], function(){
|
||||
form = layui.form;
|
||||
|
|
@ -17,45 +20,37 @@ function setParams(obj) {
|
|||
upload = layui.upload;
|
||||
table = layui.table;
|
||||
util = layui.util;
|
||||
laydate.render({
|
||||
elem: '#fkTime'
|
||||
});
|
||||
|
||||
laydate.render({elem:'#fkTime'});
|
||||
form.verify();
|
||||
form.on('submit(formData)', function (data) {
|
||||
submitApply(data);
|
||||
});
|
||||
form.on('submit(formData)', function(data){ submitApply(data); });
|
||||
form.render();
|
||||
|
||||
// 初始化上传
|
||||
let uploadObj = upload.render({
|
||||
elem: '#test2',
|
||||
multiple: true,
|
||||
dataType: "json",
|
||||
exts: 'jpg|png|jpeg|doc|docx|pdf|xlsx|xls',
|
||||
acceptMime: 'image/jpg,image/png,image/jpeg,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
number: 5, //最大上传数量
|
||||
size: 1024 * 10, //最大文件大小,单位k
|
||||
auto: false, //是否自动上传 ,默认为true
|
||||
bindAction: '#hideUpload', //绑定的按钮
|
||||
number: 5,
|
||||
size: 10240,
|
||||
auto: false,
|
||||
bindAction: '#hideUpload',
|
||||
choose: function(obj){
|
||||
let length = $('.file-iteme').length;
|
||||
if (length >= 5) {
|
||||
return layer.msg('最多上传5个附件证明', {icon: 7});
|
||||
}
|
||||
let existCount = fileList.length;
|
||||
if(existCount >=5){ return layer.msg('最多上传5个附件证明',{icon:7}); }
|
||||
uploadObj.config.elem.next()[0].value = '';
|
||||
let num = 0;
|
||||
obj.preview(function(index, file, result){
|
||||
num++;
|
||||
if (num <= (5 - length)) {
|
||||
$('#uploader-list').append(
|
||||
'<div id="" class="file-iteme">' +
|
||||
'<div class="handle"><p>x</p></div>' +
|
||||
handleFileType(index, file, result) +
|
||||
'</div>'
|
||||
);
|
||||
let map = new Map();//将选择的图片索引和图片写成对象存入集合
|
||||
map.index = index;
|
||||
map.file = file;
|
||||
fileList.push(map);
|
||||
}
|
||||
if(fileList.length >=5) return;
|
||||
const uid = 'new_' + Date.now() + '_' + Math.random();
|
||||
fileList.push({uid,name:file.name,file,isExist:false,fileId:null});
|
||||
$('#uploader-list').append(`
|
||||
<div class="file-iteme" data-uid="${uid}">
|
||||
<div class="handle">x</div>
|
||||
${handleFileType(index,file,result)}
|
||||
</div>
|
||||
`);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -64,350 +59,247 @@ function setParams(obj) {
|
|||
});
|
||||
}
|
||||
|
||||
// 获取数据详情
|
||||
// ------------------- 获取数据详情 -------------------
|
||||
function getBalanceDataDetails(){
|
||||
let encryptedData = {id: objParam.id};
|
||||
let url = dataUrl+'backstage/carBalance/getBalanceDataDetails?encryptedData='+encodeURIComponent(JSON.stringify(encryptedData));
|
||||
ajaxRequest(url, "GET", null, true, function () {
|
||||
}, function (result) {
|
||||
ajaxRequest(url,"GET",null,true,null,function(result){
|
||||
if(result.code===200){
|
||||
let dataObj = result.data;
|
||||
|
||||
// 基本信息回显
|
||||
let dataObj = result.data;
|
||||
$('#supId').val(dataObj.supId);
|
||||
$('#supName').val(dataObj.supName);
|
||||
$('#fkTime').val(util.toDateString(dataObj.fkTime,'yyyy-MM-dd'));
|
||||
$('#money').val(dataObj.money);
|
||||
$('#remark').val(dataObj.remark);
|
||||
$('#planListNum').val(dataObj.planList.length)
|
||||
$('#planListNum').val(dataObj.planList.length);
|
||||
|
||||
// ========== 保留:附件回显+加入 ==========
|
||||
let cent = '';
|
||||
// 清空原有fileList和delIdArr(避免重复)
|
||||
// 附件回显
|
||||
fileList = [];
|
||||
delIdArr = []; // 重置删除文件ID数组
|
||||
if (dataObj.fileList.length > 0) {
|
||||
for (let i = 0; i < dataObj.fileList.length; i++) {
|
||||
let l = dataObj.fileList[i];
|
||||
let path = fileUrl + l.fileUrl + '?token=' + sessionStorage.getItem("gz-token");
|
||||
let file = { name: l.fileName, id: l.id, type: l.type };
|
||||
cent += '<div id="" class="file-iteme" data-file-id="' + l.id + '">' +
|
||||
'<div class="handle"><p>x</p></div>' +
|
||||
handleFileType(i, file, path, l.type) +
|
||||
'</div>';
|
||||
// 回显附件加入fileList(标记为已存在的文件)
|
||||
fileList.push({
|
||||
index: i,
|
||||
file: file,
|
||||
isExist: true, // 标记为回显的旧文件
|
||||
fileId: l.id // 存储文件ID,用于删除
|
||||
delIdArr = [];
|
||||
$('#uploader-list').html('');
|
||||
if(dataObj.fileList && dataObj.fileList.length>0){
|
||||
dataObj.fileList.forEach((f,i)=>{
|
||||
const uid = 'old_'+f.id;
|
||||
const path = fileUrl+f.fileUrl+'?token='+sessionStorage.getItem("gz-token");
|
||||
fileList.push({uid,name:f.fileName,isExist:true,fileId:f.id,file:null});
|
||||
$('#uploader-list').append(`
|
||||
<div class="file-iteme" data-uid="${uid}" data-file-id="${f.id}">
|
||||
<div class="handle">x</div>
|
||||
${handleFileType(i,{name:f.fileName,ext:f.type},path)}
|
||||
</div>
|
||||
`);
|
||||
});
|
||||
}
|
||||
}
|
||||
console.log("aa==",fileList)
|
||||
$('#uploader-list').append(cent);
|
||||
|
||||
// 计划明细回显
|
||||
planDetail(dataObj.planList)
|
||||
// 用车明细回显
|
||||
carDetail(dataObj.detailsList)
|
||||
planDetail(dataObj.planList);
|
||||
|
||||
// ========== 保留:初始化allDataList和jjDataArr ==========
|
||||
// 用车明细回显
|
||||
carDetail(dataObj.detailsList);
|
||||
|
||||
// 初始化全局数据
|
||||
allDataList = dataObj.detailsList || [];
|
||||
jjDataArr = dataObj.planList || [];
|
||||
}
|
||||
}, function (xhr, status, error) {
|
||||
errorFn(xhr, status, error)
|
||||
}, null);
|
||||
},function(xhr,status,error){ errorFn(xhr,status,error); },null);
|
||||
}
|
||||
|
||||
// ------------------- 计划明细 -------------------
|
||||
function planDetail(list){
|
||||
$('#plan-detail-table tr:not(:first)').remove();
|
||||
if(list.length>0){
|
||||
let html = '';
|
||||
$.each(list, function (index, item) {
|
||||
html += '<tr>' +
|
||||
'<td>' + (index + 1) + '</td>' +
|
||||
'<td>' + item.proName + '</td>' +
|
||||
'<td>' + item.code + '</td>' +
|
||||
'<td>' + item.supName + '</td>' +
|
||||
'<td>' + item.carNum + '</td>' +
|
||||
'<td>' + item.money + '</td>' +
|
||||
'<td>' + item.ygMoney + '</td>' +
|
||||
'<td>' +
|
||||
'<div class="handle">' +
|
||||
'<a style="color:#f56c6c;cursor: pointer;" onclick="delPlanDetail(' + index + ')">删除</a>' +
|
||||
'</div>' +
|
||||
'</td>' +
|
||||
'</tr>';
|
||||
list.forEach((item,index)=>{
|
||||
html+=`<tr>
|
||||
<td>${index+1}</td>
|
||||
<td>${item.proName}</td>
|
||||
<td>${item.code}</td>
|
||||
<td>${item.supName}</td>
|
||||
<td>${item.carNum}</td>
|
||||
<td>${item.money}</td>
|
||||
<td>${item.ygMoney}</td>
|
||||
<td><div class="handle"><a style="color:#f56c6c;cursor:pointer;" onclick="delPlanDetail(${index})">删除</a></div></td>
|
||||
</tr>`;
|
||||
});
|
||||
$('#plan-detail-table').append(html);
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 保留:delPlanDetail删除关联用车明细+同步数据 ==========
|
||||
// ------------------- 删除计划明细 -------------------
|
||||
function delPlanDetail(index){
|
||||
let planList = $('#plan-detail-table tr:not(:first)');
|
||||
if (planList.length <= 1) {
|
||||
return layer.msg('计划明细至少保留1条数据,无法删除!', {icon: 7});
|
||||
}
|
||||
if(planList.length<=1){ return layer.msg('计划明细至少保留1条数据,无法删除!',{icon:7}); }
|
||||
|
||||
let currentTr = planList.eq(index);
|
||||
let delCode = currentTr.find('td:eq(2)').text().trim();
|
||||
if (!delCode) {
|
||||
return layer.msg('未获取到需求计划编号,无法删除!', {icon: 2});
|
||||
}
|
||||
if(!delCode) return layer.msg('未获取到需求计划编号,无法删除!',{icon:2});
|
||||
|
||||
layer.confirm('确定删除该计划明细及对应的用车明细数据吗?',{icon:3,title:'提示'},function(layIndex){
|
||||
currentTr.remove();
|
||||
$('#plan-detail-table tr:not(:first)').each(function(i) {
|
||||
$(this).find('td:eq(0)').text(i + 1);
|
||||
});
|
||||
//删除用车明细中code匹配的数据
|
||||
$('#plan-detail-table tr:not(:first)').each(function(i){ $(this).find('td:eq(0)').text(i+1); });
|
||||
deleteCarDetailByCode(delCode);
|
||||
// 同步更新jjDataArr和allDataList
|
||||
jjDataArr = jjDataArr.filter(item=>item.code!==delCode);
|
||||
allDataList = allDataList.filter(item=>item.planCode!==delCode);
|
||||
layer.close(layIndex);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// ========== 保留:deleteCarDetailByCode精准删除用车明细 ==========
|
||||
// ------------------- 删除用车明细 -------------------
|
||||
function deleteCarDetailByCode(delCode){
|
||||
// 1. 删除普通车辆表格中对应code的数据
|
||||
$('#dispatch-car-table tr:not(:first)').each(function() {
|
||||
['#dispatch-car-table','#dispatch-car-table2'].forEach(tableId=>{
|
||||
$(`${tableId} tr:not(:first)`).each(function(){
|
||||
let $tr=$(this);
|
||||
// 优先获取a标签文本,避免索引错误
|
||||
let carCode = $tr.find('td:last a').text().trim() || '';
|
||||
if (!carCode) {
|
||||
carCode = $tr.find('td:last').text().replace(/<.*?>/g, '').trim();
|
||||
}
|
||||
if (carCode === delCode) {
|
||||
$tr.remove();
|
||||
}
|
||||
let code = $tr.find('td:last a').text().trim() || $tr.find('td:last').text().replace(/<.*?>/g,'').trim();
|
||||
if(code===delCode) $tr.remove();
|
||||
});
|
||||
|
||||
// 2. 删除吊车表格中对应code的数据
|
||||
$('#dispatch-car-table2 tr:not(:first)').each(function() {
|
||||
let $tr = $(this);
|
||||
// 优先获取a标签文本,避免索引错误
|
||||
let dcCode = $tr.find('td:last a').text().trim() || '';
|
||||
if (!dcCode) {
|
||||
dcCode = $tr.find('td:last').text().replace(/<.*?>/g, '').trim();
|
||||
}
|
||||
if (dcCode === delCode) {
|
||||
$tr.remove();
|
||||
}
|
||||
if($(`${tableId} tr:not(:first)`).length===0){ $(`${tableId}`).css('display','none'); }
|
||||
});
|
||||
|
||||
// 3. 处理删除后无数据的情况
|
||||
if ($('#dispatch-car-table tr:not(:first)').length === 0) {
|
||||
$('#dispatch-car-table').css('display', 'none');
|
||||
}
|
||||
if ($('#dispatch-car-table2 tr:not(:first)').length === 0) {
|
||||
$('#dispatch-car-table2').css('display', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------- 用车明细 -------------------
|
||||
function carDetail(list){
|
||||
// 派车明细
|
||||
let carList = list.filter(item => {
|
||||
return item.type === '车辆';
|
||||
})
|
||||
let dcList = list.filter(item => {
|
||||
return item.type === '吊车';
|
||||
})
|
||||
const carList = list.filter(item=>item.type==='车辆');
|
||||
const dcList = list.filter(item=>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;
|
||||
|
||||
const actualGls = formatToTwoDecimals(item.exeGls) || 0.00; // 实际公里数初始=预估公里数
|
||||
|
||||
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><input type='number' class='form-control actual-gls' value='" + actualGls +
|
||||
"' style='width: 100%; padding: 2px; border: 1px solid #ddd;' data-id='" + item.id + "'></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>';
|
||||
}
|
||||
list.forEach(item=>{
|
||||
const imgNum = (item.carImage.filter(i=>i.type!=='6').length)+(item.driverUserImage.filter(i=>i.type!=='6').length)+item.fileList.length;
|
||||
const actualGls = formatToTwoDecimals(item.exeGls||0);
|
||||
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><input type='number' class='form-control actual-gls' value='${actualGls}' style='width:100%;padding:2px;border:1px solid #ddd;' data-id='${item.id}'></td>
|
||||
<td>${item.glsPrice}</td>
|
||||
<td>¥ ${item.glsMoney||0}</td>
|
||||
<td style='color:#409eff'>${imgNum}<a style='color:#409eff;margin:0 5px;cursor:pointer;' onclick='viewFileDetail(${safeStringify(item)},1)'>查看附件>></a></td>
|
||||
<td><a style='color:#409eff;margin:0 5px;cursor:pointer;' onclick='viewPlanDetail(${safeStringify(item)})'>${item.planCode}</a></td>
|
||||
</tr>`;
|
||||
});
|
||||
$('#dispatch-car-table').removeAttr('style').append(html);
|
||||
} else {
|
||||
$('#dispatch-car-table').css('display', 'none');
|
||||
}
|
||||
}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;
|
||||
|
||||
list.forEach(item=>{
|
||||
const imgNum = item.driverUserImage.filter(i=>['2','3'].includes(i.type)).length + item.operaImage.filter(i=>['2','3','6'].includes(i.type)).length + item.fileList.length;
|
||||
const actualPlanDay = item.exeDay||0;
|
||||
const actualDcMoney = formatToTwoDecimals(item.money);
|
||||
|
||||
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><input type='number' class='form-control actual-dc-planDay' value='" + actualPlanDay +
|
||||
"' style='width: 100%; padding: 2px; border: 1px solid #ddd;' data-id='" + item.id + "'></td>" +
|
||||
'<td>' + setZlPrice(item) + '</td>' +
|
||||
'<td> ¥ ' + item.dcMoney + '</td>' +
|
||||
|
||||
"<td><input type='number' class='form-control actual-dc-money' value='" + actualDcMoney +
|
||||
"' style='width: 100%; padding: 2px; border: 1px solid #ddd;' data-id='" + item.id + "'></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>" +
|
||||
'</tr>';
|
||||
})
|
||||
} else {
|
||||
html = '<tr><td colspan="10" style="text-align: center;">暂无数据</td></tr>';
|
||||
}
|
||||
const actualDcMoney = formatToTwoDecimals(item.money||0);
|
||||
html+=`<tr>
|
||||
<td>${item.type}</td>
|
||||
<td>${item.name}</td>
|
||||
<td>${item.model}</td>
|
||||
<td>${item.carNum}</td>
|
||||
<td>${item.useAddress}</td>
|
||||
<td><input type='number' class='form-control actual-dc-planDay' value='${actualPlanDay}' style='width:100%;padding:2px;border:1px solid #ddd;' data-id='${item.id}'></td>
|
||||
<td>${item.dcUnit==='元/月/台'?item.monthPrice+'('+item.dcUnit+')':item.dayPrice+'('+item.dcUnit+')'}${item.isOutSet===1?'<br/>'+(item.jcMoney||0)+'(进出场费)':''}</td>
|
||||
<td>¥ ${item.dcMoney}</td>
|
||||
<td><input type='number' class='form-control actual-dc-money' value='${actualDcMoney}' style='width:100%;padding:2px;border:1px solid #ddd;' data-id='${item.id}'></td>
|
||||
<td style='color:#409eff'>${imgNum}<a style='color:#409eff;margin:0 5px;cursor:pointer;' onclick='viewFileDetail(${safeStringify(item)},2)'>查看附件>></a></td>
|
||||
<td><a style='color:#409eff;margin:0 5px;cursor:pointer;' onclick='viewPlanDetail(${safeStringify(item)})'>${item.planCode}</a></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');
|
||||
}
|
||||
}else{ $('#dispatch-car-table2').css('display','none'); }
|
||||
}
|
||||
}
|
||||
|
||||
// 设置文件类型
|
||||
// ------------------- 安全序列化 -------------------
|
||||
function safeStringify(obj){
|
||||
const cache = new Set();
|
||||
return JSON.stringify(obj,(key,value)=>{
|
||||
if(typeof value==='object' && value!==null){
|
||||
if(cache.has(value)) return;
|
||||
cache.add(value);
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------- 文件类型显示 -------------------
|
||||
function handleFileType(index,file,result){
|
||||
let html='', img='';
|
||||
if (file.ext) {
|
||||
file.ext = file.ext.toLowerCase();
|
||||
}
|
||||
if (file.name) {
|
||||
file.name = file.name.toLowerCase();
|
||||
}
|
||||
if (file.ext === 'doc' || file.ext === 'docx') {
|
||||
img = '../../../images/docx.png';
|
||||
} else if (file.ext === 'xls' || file.ext === 'xlsx') {
|
||||
img = '../../../images/xlsx.png';
|
||||
} else if (file.ext === 'pdf') {
|
||||
img = '../../../images/pdf.png';
|
||||
} else {
|
||||
return '<img class="img" style="width: 130px;height: 120px;" data-index=' + index + ' data-name=' + file.name + ' src=' + result + '>';
|
||||
}
|
||||
html += '<div class="layout upload-file" data-index=' + index + '>' +
|
||||
'<img src="' + img + '">' +
|
||||
'<p style="text-align: center;font-size:12px;">' + file.name + '</p>' +
|
||||
'</div>';
|
||||
if(file.ext) file.ext=file.ext.toLowerCase();
|
||||
if(file.name) file.name=file.name.toLowerCase();
|
||||
if(file.ext==='doc'||file.ext==='docx'){ img='../../../images/docx.png'; }
|
||||
else if(file.ext==='xls'||file.ext==='xlsx'){ img='../../../images/xlsx.png'; }
|
||||
else if(file.ext==='pdf'){ img='../../../images/pdf.png'; }
|
||||
else{ return `<img class="img" style="width:130px;height:120px;" data-index=${index} data-name=${file.name} src=${result}>`; }
|
||||
html=`<div class="layout upload-file" data-index=${index}>
|
||||
<img src="${img}">
|
||||
<p style="text-align:center;font-size:12px;">${file.name}</p>
|
||||
</div>`;
|
||||
return html;
|
||||
}
|
||||
|
||||
// ========== 保留+优化:附件删除逻辑(兼容回显/新增,收集delIdArr) ==========
|
||||
$(document).on("click", ".file-iteme .handle", function (event) {
|
||||
event.stopPropagation();
|
||||
let $this = $(this);
|
||||
let $parent = $this.parent();
|
||||
let fileId = $parent.attr('data-file-id'); // 回显文件的ID
|
||||
let index = $this.next().attr('data-index'); // 新增文件的索引
|
||||
|
||||
// 1. 收集要删除的文件ID(用于后端删除)
|
||||
if (fileId) {
|
||||
delIdArr.push(fileId); // 存储要删除的旧文件ID
|
||||
}
|
||||
|
||||
// 2. 过滤fileList数组
|
||||
let newFileList = [];
|
||||
$.each(fileList, function (inx, ele) {
|
||||
// 排除要删除的文件(新增文件按index,回显文件按fileId)
|
||||
if ((index && index != ele.index) || (fileId && ele.fileId != fileId)) {
|
||||
newFileList.push(ele);
|
||||
}
|
||||
// ------------------- 删除附件 -------------------
|
||||
$(document).on("click",".file-iteme .handle",function(e){
|
||||
e.stopPropagation();
|
||||
const $item=$(this).closest('.file-iteme');
|
||||
const uid = $item.attr('data-uid');
|
||||
const fileId = $item.attr('data-file-id');
|
||||
if(fileId && !delIdArr.includes(fileId)) delIdArr.push(fileId);
|
||||
fileList = fileList.filter(f=>f.uid!==uid);
|
||||
$item.remove();
|
||||
});
|
||||
|
||||
// 3. 更新fileList
|
||||
fileList = newFileList;
|
||||
// 4. 删除DOM
|
||||
$parent.remove();
|
||||
// ------------------- 获取编辑后的实际值 -------------------
|
||||
function getEditedActualValues(){
|
||||
let actualValues={carActualList:[],craneActualList:[]};
|
||||
$('#dispatch-car-table .actual-gls').each(function(){
|
||||
const id=$(this).data('id');
|
||||
const val=formatToTwoDecimals($(this).val());
|
||||
actualValues.carActualList.push({outDetailId:id,exeGls:val,inMoney:0});
|
||||
});
|
||||
|
||||
function saveData2() {
|
||||
$('#formSubmit').trigger('click')
|
||||
$('#dispatch-car-table2 tr:not(:first)').each(function(){
|
||||
const id=$(this).find('.actual-dc-money').data('id');
|
||||
if(!id) return;
|
||||
const day=$(this).find('.actual-dc-planDay').val()||0;
|
||||
const money=formatToTwoDecimals($(this).find('.actual-dc-money').val());
|
||||
actualValues.craneActualList.push({outDetailId:id,exeDay:day,inMoney:money});
|
||||
});
|
||||
return actualValues;
|
||||
}
|
||||
|
||||
// ========== 保留+核心修改:submitApply(delFileId逗号分隔) ==========
|
||||
// ------------------- 格式化两位小数 -------------------
|
||||
function formatToTwoDecimals(num){ return isNaN(Number(num))? '0.00': Number(num).toFixed(2); }
|
||||
|
||||
// ------------------- 正则校验输入框 -------------------
|
||||
$(document).on('input','.actual-gls,.actual-money,.actual-dc-money',function(){
|
||||
this.value=this.value.replace(/[^0-9.]/g,'').replace(/\.{2,}/g,'.').replace(/^0+(?=\d)/,'');
|
||||
if(this.value.indexOf('.')!==-1){ const parts=this.value.split('.'); this.value=parts[0]+'.'+parts[1].substring(0,2);}
|
||||
const numValue=Number(this.value||0); if(numValue>100000000) this.value=(100000000).toFixed(2);
|
||||
});
|
||||
$(document).on('blur','.actual-gls,.actual-money,.actual-dc-money',function(){ this.value=formatToTwoDecimals(this.value); });
|
||||
|
||||
// ------------------- 提交 -------------------
|
||||
function submitApply(data){
|
||||
// 校验附件证明是否上传(保留:兼容回显附件)
|
||||
console.log('fileList:', fileList)
|
||||
let totalFileCount = fileList.length;
|
||||
if (totalFileCount === 0) {
|
||||
return layer.msg('请上传付款单', {icon: 7});
|
||||
}
|
||||
if (jjDataArr.length === 0) {
|
||||
return layer.msg('请选择需求计划', {icon: 7});
|
||||
}
|
||||
if (allDataList.length === 0) {
|
||||
return layer.msg('用车明细数据为空,无法提交', {icon: 7});
|
||||
}
|
||||
if(fileList.length===0) return layer.msg('请上传付款单',{icon:7});
|
||||
if(jjDataArr.length===0) return layer.msg('请选择需求计划',{icon:7});
|
||||
if(allDataList.length===0) return layer.msg('用车明细数据为空,无法提交',{icon:7});
|
||||
|
||||
data.field.supId=objParam.supId;
|
||||
data.field.id = objParam.id; // 修改操作必须传主键ID
|
||||
// ========== 核心修改:delFileId用逗号分隔 ==========
|
||||
data.field.delFileId = delIdArr.join(','); // 数组转逗号分隔字符串
|
||||
console.log('delFileId(逗号分隔):', data.field.delFileId); // 调试用
|
||||
data.field.id=objParam.id;
|
||||
data.field.delFileId=delIdArr.join(',');
|
||||
|
||||
let planList=[],detailsList=[];
|
||||
$.each(jjDataArr, function (index, item) {
|
||||
let obj = {
|
||||
jjDataArr.forEach(item=>{
|
||||
planList.push({
|
||||
id:item.id||'',
|
||||
planId:item.planId||item.id,
|
||||
supId:item.supId,
|
||||
|
|
@ -415,16 +307,14 @@ function submitApply(data) {
|
|||
type:item.type||'1',
|
||||
proId:item.proId||'',
|
||||
carNum:item.carNum||item.needNum||0
|
||||
};
|
||||
planList.push(obj);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
const actualValues = getEditedActualValues();
|
||||
|
||||
$.each(allDataList, function (index, item) {
|
||||
const carActual = actualValues.carActualList.find(v => v.outDetailId == item.id); // 普通车辆
|
||||
const craneActual = actualValues.craneActualList.find(v => v.outDetailId == item.id); // 吊车
|
||||
let obj = {
|
||||
allDataList.forEach(item=>{
|
||||
const carActual = actualValues.carActualList.find(v=>v.outDetailId==item.id);
|
||||
const craneActual = actualValues.craneActualList.find(v=>v.outDetailId==item.id);
|
||||
detailsList.push({
|
||||
id:item.id||'',
|
||||
planId:item.planId||'',
|
||||
type:item.type||'车辆',
|
||||
|
|
@ -438,328 +328,40 @@ function submitApply(data) {
|
|||
outDetailId:item.outDetailId||'',
|
||||
modelId:item.modelId||'',
|
||||
ton:item.ton||0
|
||||
};
|
||||
detailsList.push(obj);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
data.field.planList=planList;
|
||||
data.field.detailsList=detailsList;
|
||||
|
||||
let formData = new FormData();
|
||||
//遍历最终文件集合(仅上传新增文件)
|
||||
for (let i = 0; i < fileList.length; i++) {
|
||||
let fileItem = fileList[i];
|
||||
if (!fileItem.isExist && fileItem.file) {
|
||||
formData.append("file[]", fileItem.file)
|
||||
}
|
||||
}
|
||||
fileList.forEach(item=>{ if(!item.isExist && item.file) formData.append("file[]",item.file); });
|
||||
formData.append('params',JSON.stringify(data.field));
|
||||
console.log("提交参数:", data.field); // 调试用
|
||||
|
||||
let loadingMsg = layer.msg('正在提交保存,请稍等...',{icon:16,shade:0.01,time:'0'});
|
||||
let url = dataUrl+'backstage/carBalance/updateBalanceData';
|
||||
ajaxRequestByUploadFile(url, formData, function(){
|
||||
$('.save').addClass("layui-btn-disabled").attr("disabled", true);
|
||||
$('.cancel').addClass("layui-btn-disabled").attr("disabled", true);
|
||||
$('.save,.cancel').addClass("layui-btn-disabled").attr("disabled",true);
|
||||
}, function(result){
|
||||
layer.close(loadingMsg);
|
||||
$('.save').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
$('.cancel').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
if (result.code === 200) {
|
||||
parent.layer.msg(result.msg, {icon: 1});
|
||||
closePage(1);
|
||||
} else {
|
||||
layer.msg(result.msg, {icon: 2});
|
||||
}
|
||||
$('.save,.cancel').removeClass("layui-btn-disabled").attr("disabled",false);
|
||||
if(result.code===200){ parent.layer.msg(result.msg,{icon:1}); closePage(1);}
|
||||
else layer.msg(result.msg,{icon:2});
|
||||
}, function(xhr,status,error){
|
||||
layer.close(loadingMsg); // 关闭提示层
|
||||
layer.close(loadingMsg);
|
||||
layer.msg('服务异常,请稍后重试',{icon:16,scrollbar:false,time:2000});
|
||||
$('.save').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
$('.cancel').removeClass("layui-btn-disabled").attr("disabled", false);
|
||||
errorFn(xhr, status, error)
|
||||
$('.save,.cancel').removeClass("layui-btn-disabled").attr("disabled",false);
|
||||
errorFn(xhr,status,error);
|
||||
}, null);
|
||||
}
|
||||
|
||||
// 选择需求计划单据
|
||||
function chooseFitType() {
|
||||
let params = {
|
||||
contractId: objParam.contractId,
|
||||
supId: objParam.supId,
|
||||
planId: planId,
|
||||
jjDataArr: JSON.stringify(jjDataArr)
|
||||
};
|
||||
openIframeByParamObj("choose_plan_code_list", '选择需要付款的需求计划编号', "./choose_plan_code_list.html", '92%', '95%', params);
|
||||
function saveData2() {
|
||||
$('#formSubmit').trigger('click')
|
||||
}
|
||||
|
||||
// 需求计划单据赋值
|
||||
function addFitDatas(data, planIdArr) {
|
||||
jjDataArr = JSON.parse(data);
|
||||
console.error(jjDataArr);
|
||||
|
||||
let money = 0;
|
||||
$.each(jjDataArr, function (index, item) {
|
||||
const dataNum = item.money ? item.money : 0;
|
||||
const num = Number(dataNum);
|
||||
const cents = Math.round(num * 1000);
|
||||
money += cents;
|
||||
})
|
||||
$('#money').val(money / 1000);
|
||||
if (!planId) {
|
||||
$('#chooseValue').val('选择数据(已选择 ' + planIdArr.length + ' 条)');
|
||||
$('#no_data_title').css({'display': 'none'});
|
||||
$('#search-info').removeAttr('style');
|
||||
$('#table-box').removeAttr('style');
|
||||
planId = planIdArr.join('@');
|
||||
getPayCarDetails();
|
||||
} else {
|
||||
$('#chooseValue').val('选择数据(已选择 ' + planIdArr.length + ' 条)');
|
||||
planId = planIdArr.join('@');
|
||||
getPayCarDetails();
|
||||
}
|
||||
}
|
||||
|
||||
// 派车录入详情明细-派车资料等明细
|
||||
function getPayCarDetails(id) {
|
||||
let encryptedData = {planId: planId};
|
||||
let url = dataUrl + 'backstage/carBalance/getPayCarDetails?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(list) {
|
||||
allDataList.splice(0, allDataList.length);
|
||||
allDataList = 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;
|
||||
|
||||
const actualGls = formatToTwoDecimals(item.gls) || 0.00; // 实际公里数初始=预估公里数
|
||||
// const actualMoney = formatToTwoDecimals(0); // 实际金额初始=预估金额
|
||||
|
||||
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><input type='number' class='form-control actual-gls' value='" + actualGls +
|
||||
"' style='width: 100%; padding: 2px; border: 1px solid #ddd;' data-id='" + item.id + "'></td>" +
|
||||
|
||||
"<td>" + item.glsPrice + "</td>" +
|
||||
"<td> ¥ " + (item.glsMoney ? item.glsMoney : 0) + "</td>" +
|
||||
|
||||
// "<td><input type='number' class='form-control actual-money' value='" + actualMoney +
|
||||
// "' style='width: 100%; padding: 2px; border: 1px solid #ddd;' data-id='" + item.id + "'></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;
|
||||
|
||||
const actualPlanDay = item.planDay || 0;
|
||||
const actualDcMoney = formatToTwoDecimals(0);
|
||||
|
||||
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><input type='number' class='form-control actual-dc-planDay' value='" + actualPlanDay +
|
||||
"' style='width: 100%; padding: 2px; border: 1px solid #ddd;' data-id='" + item.id + "'></td>" +
|
||||
'<td>' + setZlPrice(item) + '</td>' +
|
||||
'<td> ¥ ' + item.dcMoney + '</td>' +
|
||||
|
||||
"<td><input type='number' class='form-control actual-dc-money' value='" + actualDcMoney +
|
||||
"' style='width: 100%; padding: 2px; border: 1px solid #ddd;' data-id='" + item.id + "'></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>" +
|
||||
'</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 viewPlanDetail(obj) {
|
||||
obj.id = obj.planId;
|
||||
obj.code = obj.planCode;
|
||||
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 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 getEditedActualValues() {
|
||||
// 存储最终收集的实际值
|
||||
let actualValues = {
|
||||
carActualList: [], // 普通车辆实际值(实际公里数、实际金额)
|
||||
craneActualList: [] // 吊车实际值(实际金额)
|
||||
};
|
||||
|
||||
// 1. 收集普通车辆的实际公里数、实际金额
|
||||
$('#dispatch-car-table tr:not(:first)').each(function () {
|
||||
const $tr = $(this);
|
||||
const itemId = $tr.find('.actual-gls').data('id'); // 获取数据ID
|
||||
if (!itemId) return; // 无ID则跳过
|
||||
|
||||
// 修复列索引:实际公里数输入框在td:eq(9),预估公里数在td:eq(8)
|
||||
const actualGls = $tr.find('.actual-gls').val().trim() || $tr.find('td:eq(8)').text().trim() || '0.00';
|
||||
// const actualMoney = $tr.find('.actual-money').val()?.trim() || '0.00';
|
||||
|
||||
actualValues.carActualList.push({
|
||||
outDetailId: itemId,
|
||||
exeGls: formatToTwoDecimals(actualGls),
|
||||
inMoney: 0
|
||||
});
|
||||
});
|
||||
|
||||
// 2. 收集吊车的实际金额
|
||||
$('#dispatch-car-table2 tr:not(:first)').each(function () {
|
||||
const $tr = $(this);
|
||||
const itemId = $tr.find('.actual-dc-money').data('id'); // 获取数据ID
|
||||
if (!itemId) return; // 无ID则跳过
|
||||
|
||||
const actualPlanDay = $tr.find('.actual-dc-planDay').val().trim() || $tr.find('td:eq(5)').text().trim() || '0';
|
||||
const actualDcMoney = $tr.find('.actual-dc-money').val().trim() || '0.00';
|
||||
|
||||
actualValues.craneActualList.push({
|
||||
outDetailId: itemId,
|
||||
inMoney: formatToTwoDecimals(actualDcMoney),
|
||||
exeDay: actualPlanDay
|
||||
});
|
||||
});
|
||||
return actualValues;
|
||||
}
|
||||
|
||||
// 全局工具函数:格式化数字为两位小数(处理空值、非数字)
|
||||
function formatToTwoDecimals(num) {
|
||||
if (num === null || num === undefined || num === '' || isNaN(Number(num))) return '0.00';
|
||||
return Number(num).toFixed(2);
|
||||
}
|
||||
|
||||
// 输入框正则校验(仅正数 + 最多两位小数 + 不超过1亿元)
|
||||
$(document).on('input', '.actual-gls, .actual-money, .actual-dc-money', function () {
|
||||
this.value = this.value
|
||||
.replace(/[^0-9.]/g, '') // 过滤非法字符
|
||||
.replace(/\.{2,}/g, '.') // 单个小数点
|
||||
.replace(/^0+(?=\d)/, ''); // 去除开头多余0
|
||||
|
||||
if (this.value.indexOf('.') !== -1) {
|
||||
const parts = this.value.split('.');
|
||||
this.value = parts[0] + '.' + parts[1].substring(0, 2);
|
||||
}
|
||||
|
||||
const numValue = Number(this.value || 0);
|
||||
const maxAmount = 100000000;
|
||||
if (numValue > maxAmount) {
|
||||
this.value = maxAmount.toFixed(2);
|
||||
}
|
||||
});
|
||||
|
||||
// 失焦格式化
|
||||
$(document).on('blur', '.actual-gls, .actual-money, .actual-dc-money', function () {
|
||||
this.value = formatToTwoDecimals(this.value);
|
||||
});
|
||||
|
||||
// 关闭页面
|
||||
// ------------------- 关闭页面 -------------------
|
||||
function closePage(type){
|
||||
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
|
||||
if (type == 1) {
|
||||
window.parent.reloadData();
|
||||
}
|
||||
parent.layer.close(index); // 再执行关闭
|
||||
let index = parent.layer.getFrameIndex(window.name);
|
||||
if(type==1) window.parent.reloadData();
|
||||
parent.layer.close(index);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "expGls",
|
||||
width: '30%',
|
||||
width: '20%',
|
||||
title: "公里数",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -142,6 +142,14 @@ function initTable() {
|
|||
align: "center",
|
||||
sort:true,
|
||||
},
|
||||
{
|
||||
field: "ton",
|
||||
title: "吨位",
|
||||
width: '10%',
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort:true,
|
||||
},
|
||||
],
|
||||
],
|
||||
limits: [10, 15, 20, 25, 50, 100],
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@
|
|||
</div>
|
||||
</body>
|
||||
<script src="../../../lib/jquery-3.4.1/jquery-3.7.1.min.js" charset="utf-8"></script>
|
||||
<script src="../../../js/public.js" charset="utf-8"></script>
|
||||
<script src="../../../js/public.js" charset="utf-8"></script>;
|
||||
<script src="../../../lib/layui-v2.9.18/layui/layui.js" charset="utf-8"></script>
|
||||
<script src="../../../js/car_application_audit/car_audit_update.js" charset="utf-8"></script>
|
||||
<script src="../../../js/openIframe.js" charset="utf-8"></script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue