补发货修改
This commit is contained in:
parent
d4bd51714a
commit
9c73349f1b
|
|
@ -163,6 +163,96 @@ $(document).on("click", ".file-iteme .handle", function (event) {
|
|||
return false;
|
||||
});
|
||||
|
||||
//暂存
|
||||
function temporaryStorage(){
|
||||
delSupIdArr = [];
|
||||
|
||||
let data = form.val('formInfo');
|
||||
let dataList = getBaseTableData();
|
||||
// ========== 过滤采购量和利库量都为0的数据 ==========
|
||||
// 第一步:过滤主数据列表,只保留有有效数值的条目
|
||||
dataList = dataList.filter(item => {
|
||||
// 先计算当前条目的采购总量和利库总量
|
||||
let cgTotal = 0, lkTotal = 0;
|
||||
if (item.supList && item.supList.length > 0) {
|
||||
item.supList.forEach(supItem => {
|
||||
cgTotal += parseInt(supItem.cgNum || 0);
|
||||
lkTotal += parseInt(supItem.lkNum || 0);
|
||||
});
|
||||
}
|
||||
// 过滤条件:采购总量+利库总量 > 0
|
||||
return (cgTotal + lkTotal) > 0;
|
||||
});
|
||||
|
||||
// 第二步:进一步过滤每个条目中的supList,移除其中采购量和利库量都为0的子项
|
||||
dataList.forEach(item => {
|
||||
if (item.supList && item.supList.length > 0) {
|
||||
item.supList = item.supList.filter(supItem => {
|
||||
let cgNum = parseInt(supItem.cgNum || 0);
|
||||
let lkNum = parseInt(supItem.lkNum || 0);
|
||||
return (cgNum + lkNum) > 0;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
data.id = dataObj.id;
|
||||
data.detailsList = dataList;
|
||||
data.planId = objParam.id;
|
||||
data.proId = objParam.proId;
|
||||
|
||||
// 补充模式下,禁止删除原有文件,清空删除文件ID
|
||||
delImgIdList = [];
|
||||
let delFileId = '', delSupId = '';
|
||||
if (delImgIdList && delImgIdList.length > 0) {
|
||||
for (let i = 0; i < delImgIdList.length; i++) {
|
||||
if (i === delImgIdList.length - 1) {
|
||||
delFileId += delImgIdList[i];
|
||||
} else {
|
||||
delFileId += delImgIdList[i] + '@';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (delSupIdArr && delSupIdArr.length > 0) {
|
||||
for (let i = 0; i < delSupIdArr.length; i++) {
|
||||
if (i === delSupIdArr.length - 1) {
|
||||
delSupId += delSupIdArr[i];
|
||||
} else {
|
||||
delSupId += delSupIdArr[i] + '@';
|
||||
}
|
||||
}
|
||||
}
|
||||
data.delFileId = delFileId;
|
||||
data.delSupId = delSupId;
|
||||
let formData = new FormData();
|
||||
for (let i = 0; i < fileList.length; i++) {
|
||||
formData.append("file[]", fileList[i].file)
|
||||
}
|
||||
console.log(data);
|
||||
formData.append('params', JSON.stringify(data));
|
||||
let loadingMsg = layer.msg('正在提交补充,请稍等...', { icon: 16, shade: 0.01, time: '0' });
|
||||
let url = dataUrl + 'backstage/purchase/addPurchaseDataBySupplementAndTemporary';
|
||||
ajaxRequestByUploadFile(url, formData, function () {
|
||||
$('.save').addClass("layui-btn-disabled").attr("disabled", true);
|
||||
$('.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(result.data);
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2 });
|
||||
}
|
||||
}, function (xhr, status, error) {
|
||||
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)
|
||||
}, null);
|
||||
}
|
||||
|
||||
// 触发表单提交
|
||||
function saveData2() {
|
||||
$('#formSubmit').trigger('click')
|
||||
|
|
@ -492,12 +582,12 @@ function setSelectData(modelId, value) {
|
|||
function setFormInput(value, type, id) {
|
||||
let html = '<form class="layui-form layuimini-form"><div class="layui-inline">';
|
||||
// 核心修改:强制将所有指定字段的值置空
|
||||
let safeValue = '';
|
||||
let safeValue = setNullValue(value);
|
||||
|
||||
if (type === 1) { // 采购量 - 强制置空
|
||||
html += '<input class="layui-input num' + id + '" modelId=' + id + ' name="num" onblur="checkValue(this,1)" value="' + safeValue + '" autocomplete="off" lay-verify="required" maxlength="9">';
|
||||
} else if (type === 2) { // 利库量 - 强制置空
|
||||
let oldValue = 0; // 重置为0
|
||||
let oldValue = safeValue || 0; // 重置为0
|
||||
html += '<input class="layui-input lkNum' + id + '" oldValue="' + oldValue + '" modelId=' + id + ' name="lkNum" onblur="checkValue(this,2)" value="' + safeValue + '" autocomplete="off" lay-verify="required" maxlength="9">';
|
||||
} else if (type === 3) { // 供应商 - 强制置空(不选中任何选项)
|
||||
html += '<select class="layui-select supplier' + id + '" modelId=' + id + ' name="supplier" lay-search lay-filter="supplier">' +
|
||||
|
|
@ -526,27 +616,53 @@ function setBaseTable(data) {
|
|||
// 给每个输入框绑定index属性,确保提示功能能获取到正确索引
|
||||
let itemIndex = index;
|
||||
if (index === 0) {
|
||||
// 主行:带rowspan合并单元格
|
||||
html += "<tr id='" + l.modelId + "' class='mainTr model" + l.modelId + "' dataId='" + item.id + "' detailId='" + l.id + "' historyLkNum='" + 0 + "'>"; // 重置historyLkNum为0
|
||||
html += '<td rowspan=' + list.length + '><input name="check" type="checkbox"></td>';
|
||||
html += "<td style='vertical-align:middle;' rowspan=" + list.length + ">" + (i + 1) + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.type || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.name || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.model || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.unit || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.needNum-l.num || 0) + "</td>";
|
||||
// 采购量:添加index属性
|
||||
html += "<td>" + setFormInput(0, 1, l.modelId).replace('<input class="layui-input', '<input index="' + itemIndex + '" class="layui-input') + "</td>";
|
||||
// 利库量:添加index属性
|
||||
html += "<td>" + setFormInput(0, 2, l.modelId).replace('<input class="layui-input', '<input index="' + itemIndex + '" class="layui-input') + "</td>";
|
||||
html += "<td>" + setFormInput('', 3, l.modelId) + "</td>";
|
||||
// 出厂日期:强制置空
|
||||
html += "<td>" + setFormInput('', 4, l.modelId) + "</td>";
|
||||
// 检验日期:强制置空
|
||||
html += "<td>" + setFormInput('', 5, l.modelId) + "</td>";
|
||||
// 备注:强制置空
|
||||
html += "<td>" + setFormInput('', 6, l.modelId) + "</td>";
|
||||
html += "</tr>";
|
||||
if (item.status=='暂存'){
|
||||
// 主行:带rowspan合并单元格
|
||||
html += "<tr id='" + l.modelId + "' class='mainTr model" + l.modelId + "' dataId='" + item.id + "' detailId='" + l.id + "' historyLkNum='" + 0 + "'>"; // 重置historyLkNum为0
|
||||
html += '<td rowspan=' + list.length + '><input name="check" type="checkbox"></td>';
|
||||
html += "<td style='vertical-align:middle;' rowspan=" + list.length + ">" + (i + 1) + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.type || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.name || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.model || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.unit || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.needNum-l.num || 0) + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (item.status || '') + "</td>";
|
||||
// 采购量:添加index属性
|
||||
html += "<td>" + setFormInput(item.cgNum, 1, l.modelId).replace('<input class="layui-input', '<input index="' + itemIndex + '" class="layui-input') + "</td>";
|
||||
// 利库量:添加index属性
|
||||
html += "<td>" + setFormInput(item.lkNum, 2, l.modelId).replace('<input class="layui-input', '<input index="' + itemIndex + '" class="layui-input') + "</td>";
|
||||
html += "<td>" + setFormInput(item.supId, 3, l.modelId) + "</td>";
|
||||
// 出厂日期:强制置空
|
||||
html += "<td>" + setFormInput(item.ccDay, 4, l.modelId) + "</td>";
|
||||
// 检验日期:强制置空
|
||||
html += "<td>" + setFormInput(item.jyDay, 5, l.modelId) + "</td>";
|
||||
// 备注:强制置空
|
||||
html += "<td>" + setFormInput(item.remark, 6, l.modelId) + "</td>";
|
||||
html += "</tr>";
|
||||
} else {
|
||||
html += "<tr id='" + l.modelId + "' class='mainTr model" + l.modelId + "' dataId='" + item.id + "' detailId='" + l.id + "' historyLkNum='" + 0 + "'>"; // 重置historyLkNum为0
|
||||
html += '<td rowspan=' + list.length + '><input name="check" type="checkbox"></td>';
|
||||
html += "<td style='vertical-align:middle;' rowspan=" + list.length + ">" + (i + 1) + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.type || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.name || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.model || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.unit || '') + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + (l.needNum-l.num || 0) + "</td>";
|
||||
html += "<td rowspan=" + list.length + ">" + ('-') + "</td>";
|
||||
// 采购量:添加index属性
|
||||
html += "<td>" + setFormInput(0, 1, l.modelId).replace('<input class="layui-input', '<input index="' + itemIndex + '" class="layui-input') + "</td>";
|
||||
// 利库量:添加index属性
|
||||
html += "<td>" + setFormInput(0, 2, l.modelId).replace('<input class="layui-input', '<input index="' + itemIndex + '" class="layui-input') + "</td>";
|
||||
html += "<td>" + setFormInput('', 3, l.modelId) + "</td>";
|
||||
// 出厂日期:强制置空
|
||||
html += "<td>" + setFormInput('', 4, l.modelId) + "</td>";
|
||||
// 检验日期:强制置空
|
||||
html += "<td>" + setFormInput('', 5, l.modelId) + "</td>";
|
||||
// 备注:强制置空
|
||||
html += "<td>" + setFormInput('', 6, l.modelId) + "</td>";
|
||||
html += "</tr>";
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,15 +151,16 @@
|
|||
<table id="baseTable" class="classTable table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 4%" class="center">
|
||||
<th style="width: 3%" class="center">
|
||||
<input id="allCheck" onclick="selectAll(this.checked)" type="checkbox" disabled>
|
||||
</th>
|
||||
<th style="width: 5%" class="center">序号</th>
|
||||
<th style="width: 4%" class="center">序号</th>
|
||||
<th style="width: 8%" class="center">类型</th>
|
||||
<th style="width: 8%" class="center">名称</th>
|
||||
<th style="width: 8%" class="center">规格</th>
|
||||
<th style="width: 6%" class="center">单位</th>
|
||||
<th style="width: 6%" class="center">需要量</th>
|
||||
<th style="width: 4%" class="center">单位</th>
|
||||
<th style="width: 5%" class="center">需要量</th>
|
||||
<th style="width: 6%" class="center">状态</th>
|
||||
<th style="width: 6%" class="center"><span style="color: red;">*</span>采购量</th>
|
||||
<th style="width: 6%" class="center"><span style="color: red;">*</span>利库量</th>
|
||||
<th style="width: 15%" class="center">供应商</th>
|
||||
|
|
@ -174,6 +175,7 @@
|
|||
</div>
|
||||
<div class="btn-box">
|
||||
<button class="layui-btn layui-bg-blue save" onclick="saveData2()">补充发货</button>
|
||||
<button class="layui-btn layui-bg-blue save" onclick="temporaryStorage()">暂存</button>
|
||||
<button class="layui-btn layui-btn-primary cancel" onclick="closePage()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue