This commit is contained in:
parent
7b0af67c09
commit
ca087e6a7b
|
|
@ -2,6 +2,8 @@ let objParam, dataObj, fileList = new Array(), imgListUp = new Array();
|
|||
let form, laydate, layer, upload, table, util;
|
||||
let pageNum = 1, tableIns; // 定义分页
|
||||
let supplierList = []; // 供应商下拉选
|
||||
let data=[];
|
||||
let delIdArr =[];
|
||||
getProList()
|
||||
function setParams(obj) {
|
||||
objParam = JSON.parse(obj);
|
||||
|
|
@ -160,7 +162,7 @@ function beforeSubmitApply() {
|
|||
}
|
||||
}
|
||||
}
|
||||
openIframeByParamObj("quickAddForm", "采购发货确认", "./send_out_confirm.html", "92%", "92%", dataList);
|
||||
openIframeByParamObj("quickAddForm", "采购发货确认", "./send_out_confirm.html", "92%", "92%", dataList,1);
|
||||
}
|
||||
|
||||
// 提交
|
||||
|
|
@ -296,11 +298,23 @@ function maTypeCheck(modelId) {
|
|||
}
|
||||
|
||||
function addFitDatas(params,pageSource){
|
||||
let data = JSON.parse(params)
|
||||
data.map(item => {
|
||||
item.unit = item.unitName
|
||||
item.modelId = item.id
|
||||
})
|
||||
let newData = JSON.parse(params);
|
||||
|
||||
newData.forEach(item => {
|
||||
item.unit = item.unitName;
|
||||
item.modelId = item.id;
|
||||
|
||||
// 查找是否已存在
|
||||
let existingIndex = data.findIndex(row => row.modelId === item.modelId);
|
||||
|
||||
if (existingIndex !== -1) {
|
||||
// 如果存在,则更新(可根据需要只更新某些字段)
|
||||
data[existingIndex] = { ...data[existingIndex], ...item };
|
||||
} else {
|
||||
// 不存在,新增
|
||||
data.push(item);
|
||||
}
|
||||
});
|
||||
setBaseTable(data);
|
||||
}
|
||||
|
||||
|
|
@ -365,16 +379,7 @@ function getBaseTableData() {
|
|||
|
||||
// 关闭页面
|
||||
function closePage(data) {
|
||||
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
|
||||
if (data) {
|
||||
let obj = {
|
||||
resultData:data.resultData,
|
||||
resultData2:data.resultData2,
|
||||
id:data.planId
|
||||
};
|
||||
let frameId = parent.document.getElementById('sendOutProDetail').getElementsByTagName("iframe")[0];
|
||||
frameId.contentWindow.sendOutSuccess(JSON.stringify(obj));
|
||||
}
|
||||
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索
|
||||
parent.layer.close(index); // 再执行关闭
|
||||
}
|
||||
|
||||
|
|
@ -398,3 +403,76 @@ function chooseFitTypeTwo() {
|
|||
let params = {};
|
||||
openIframeByParamObj("choose_type_two", '选择需求计划安全工器具类型', "./choose_type_list.html", '92%', '95%', params);
|
||||
}
|
||||
|
||||
|
||||
function delFitTypeTwo() {
|
||||
if (delIdArr.length === 0) {
|
||||
layer.msg('请先选择需要删除的数据!', { icon: 7 });
|
||||
return;
|
||||
}
|
||||
|
||||
let layerIndex = layer.confirm('<h5 style="color:red">确定要删除选中数据吗!</h5>', { title: '操作提示' }, function () {
|
||||
layer.close(layerIndex);
|
||||
|
||||
// 删除数据(修改 jjDataArr)
|
||||
for (let i = 0; i < delIdArr.length; i++) {
|
||||
for (let j = 0; j < data.length; j++) {
|
||||
let id = data[j].id;
|
||||
if (delIdArr[i] == id) {
|
||||
data.splice(j, 1); // 删除对应项
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 页面无数据时隐藏表格
|
||||
if (data.length === 0) {
|
||||
$('#no_data_title').removeAttr('style');
|
||||
$('#search-info').hide();
|
||||
$('#table-box').hide();
|
||||
} else {
|
||||
// 同步更新页面表格
|
||||
handleDelTableData(delIdArr);
|
||||
}
|
||||
|
||||
// 清空删除 id 列表
|
||||
delIdArr.splice(0, delIdArr.length);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 删除表格数据
|
||||
function handleDelTableData(delIdArr) {
|
||||
if (delIdArr.length > 0) {
|
||||
$.each(delIdArr, function (index, item) {
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let id = $(this).attr('id');
|
||||
if (parseInt(id) === item) {
|
||||
$(this).remove();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
$('#baseTable tbody tr').each(function (index, item) {
|
||||
$(this).find('td').eq(1).html(index + 1);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 单个选中
|
||||
function sel(selectStatus, that, id) {
|
||||
if (selectStatus) {
|
||||
$(that).prop('checked', true);
|
||||
delIdArr.push(id);
|
||||
} else {
|
||||
$(that).prop('checked', false);
|
||||
for (let i = 0; i < delIdArr.length; i++) {
|
||||
if (delIdArr[i] == id) {
|
||||
delIdArr.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,299 @@
|
|||
function setBaseTable(results) {
|
||||
let html = "";
|
||||
if (results && results.length > 0) {
|
||||
for (var i = 0; i < results.length; i++) {
|
||||
var l = results[i];
|
||||
html += "<tr id='" + l.modelId + "' class='mainTr model" + l.modelId + "' planId='" + l.planId + "' detailId='" + l.detailId + "'>";
|
||||
html += '<td><input onclick="sel(this.checked,this,' + l.modelId + ')" name="check" type="checkbox"></td>';
|
||||
html += "<td style='vertical-align:middle;'>"
|
||||
+ (i + 1) + "</td>";
|
||||
html += "<td>" + l.type + "</td>";
|
||||
html += "<td>" + l.name + "</td>";
|
||||
html += "<td>" + l.model + "</td>";
|
||||
html += "<td>" + l.unit + "</td>";
|
||||
html += "<td>" + l.needNum + "</td>";
|
||||
html += "<td>" + setFormInput(0, 1, l.modelId) + "</td>";
|
||||
html += "<td>" + setFormInput(0, 2, l.modelId) + "</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>";
|
||||
}
|
||||
} else {
|
||||
html += "<tr><td colspan='13' class='center'>没有相关数据</td></tr>";
|
||||
}
|
||||
$("#baseTable tbody").empty().append(html);
|
||||
laydate.render({
|
||||
elem: '.cjDate'
|
||||
});
|
||||
laydate.render({
|
||||
elem: '.jyDate'
|
||||
});
|
||||
layui.form.render();
|
||||
}
|
||||
|
||||
function setFormInput(value, type, id) {
|
||||
let html = '<form class="layui-form layuimini-form"><div class="layui-inline">';
|
||||
if (type === 1) { // 采购量
|
||||
html += '<input class="layui-input num' + id + '" modelId=' + id + ' name="num" onblur="checkValue(this,1)" value="' + setNullValue(value) + '" autocomplete="off" lay-verify="required" maxlength="9">';
|
||||
} else if (type === 2) { // 利库量
|
||||
html += '<input class="layui-input lkNum' + id + '" modelId=' + id + ' name="lkNum" onblur="checkValue(this,2)" value="' + setNullValue(value) + '" autocomplete="off" lay-verify="required" maxlength="9">';
|
||||
} else if (type === 3) { // 供应商
|
||||
html += '<select class="layui-select supplier' + id + '" modelId=' + id + ' name="supplier" id="supplier" lay-search lay-filter="supplier">' +
|
||||
setSelectData(id) +
|
||||
'</select>';
|
||||
} else if (type === 4) { // 出厂日期
|
||||
html += '<input class="layui-input cjDate cjDate' + id + '" modelId=' + id + ' name="cjDate" readonly>';
|
||||
} else if (type === 5) { // 检验日期
|
||||
html += '<input class="layui-input jyDate jyDate' + id + '" modelId=' + id + ' name="jyDate" readonly>';
|
||||
} else if (type === 6) { // 备注
|
||||
html += '<input class="layui-input remark' + id + '" modelId=' + id + ' placeholder="请输入备注" name="remark" value="' + setNullValue(value) + '" maxLength="60" lay-affix="clear"></input>';
|
||||
}
|
||||
html += '</div></form>';
|
||||
return html;
|
||||
}
|
||||
|
||||
function setSelectData(modelId) {
|
||||
let html = "<option value=''>请选择供应商</option>";
|
||||
$.each(supplierList, function (index, item) {
|
||||
html += "<option value=" + item.supId + " item=" + JSON.stringify(item) + " modelId=" + modelId + ">" + item.supName + "</option>";
|
||||
})
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
// 校验数据
|
||||
function checkValue(that, type) {
|
||||
let value = $(that).val();
|
||||
if (type === 1) { // 采购量
|
||||
const regex = /^(0|[1-9]\d{0,6})$/;
|
||||
if (!regex.test(value) && value) {
|
||||
$(that).val(0);
|
||||
return layer.msg('采购量输入有误,请重新输入!', { icon: 5 })
|
||||
}
|
||||
// if (value) {
|
||||
// // 采购量不能大于需要量
|
||||
// let needNum = $(that).parents('td').prev().html();
|
||||
// if (parseInt(value) > parseInt(needNum)) {
|
||||
// $(that).val(0);
|
||||
// return layer.msg('采购量不能大于需要量,请重新输入!', { icon: 5 })
|
||||
// }
|
||||
// }
|
||||
} else if (type === 2) { // 利库量
|
||||
const regex = /^(0|[1-9]\d{0,6})$/;
|
||||
if (!regex.test(value) && value) {
|
||||
$(that).val(0);
|
||||
return layer.msg('利库量输入有误,请重新输入!', { icon: 5 })
|
||||
}
|
||||
if (value) {
|
||||
// 利库量与库存量校验
|
||||
let modelId = $(that).attr('modelId');
|
||||
let num = maTypeCheck(modelId);
|
||||
if (parseInt(value) > num) {
|
||||
$(that).val(0);
|
||||
return layer.msg('利库量不能大于库存量,请重新输入!', { icon: 5 })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 复选框全选
|
||||
function selectAll(selectStatus) {//传入参数(全选框的选中状态)
|
||||
if (selectStatus) {
|
||||
$("input[name='check']").each(function (i, n) {
|
||||
n.checked = true;
|
||||
});
|
||||
$.each(data, function (index, item) {
|
||||
delIdArr.push(item.id);
|
||||
})
|
||||
} else {
|
||||
$("input[name='check']").each(function (i, n) {
|
||||
n.checked = false;
|
||||
});
|
||||
delIdArr.splice(0, delIdArr.length);
|
||||
}
|
||||
}
|
||||
|
||||
// 拆分
|
||||
function split() {
|
||||
let splitModelIdArr = []; // 要拆分的数据的ID
|
||||
$("input[name='check']").each(function (i, n) {
|
||||
if (n.checked === true) {
|
||||
splitModelIdArr.push($(this).parents('tr').attr('id'));
|
||||
}
|
||||
});
|
||||
console.log(splitModelIdArr);
|
||||
if (splitModelIdArr.length === 0) {
|
||||
return layer.msg('未选择拆分数据', { icon: 7 });
|
||||
}
|
||||
$.each(splitModelIdArr, function (index, item) {
|
||||
let idx = $('.model' + item).length;
|
||||
for (let i = 0; i < 7; i++) {
|
||||
$('.model' + item).eq(0).find('td').eq(i).attr('rowspan', idx + 1);
|
||||
}
|
||||
splitTr(item, idx);
|
||||
})
|
||||
laydate.render({
|
||||
elem: '.cjDate'
|
||||
});
|
||||
laydate.render({
|
||||
elem: '.jyDate'
|
||||
});
|
||||
layui.form.render();
|
||||
// 拆分表格
|
||||
function splitTr(modelId, idx) {
|
||||
let html = '';
|
||||
html += "<tr id='" + modelId + "' class='model" + modelId + "'>";
|
||||
html += "<td>" + setFormInput(0, 1, modelId) + "</td>";
|
||||
html += "<td>" + setFormInput(0, 2, modelId) + "</td>";
|
||||
html += "<td>" + setFormInput('', 3, modelId) + "</td>";
|
||||
html += "<td>" + setFormInput('', 4, modelId) + "</td>";
|
||||
html += "<td>" + setFormInput('', 5, modelId) + "</td>";
|
||||
html += "<td>" + setFormInput('', 6, modelId) + "</td>";
|
||||
html += "</tr>";
|
||||
$('.model' + modelId).eq(idx - 1).after(html);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 取消拆分
|
||||
function cancelSplit() {
|
||||
let splitModelIdArr = []; // 要拆分的数据的ID
|
||||
$("input[name='check']").each(function (i, n) {
|
||||
if (n.checked === true) {
|
||||
splitModelIdArr.push($(this).parents('tr').attr('id'));
|
||||
}
|
||||
});
|
||||
console.log(splitModelIdArr);
|
||||
if (splitModelIdArr.length === 0) {
|
||||
return layer.msg('未选择要取消拆分数据', { icon: 7 });
|
||||
}
|
||||
$.each(splitModelIdArr, function (index, item) {
|
||||
let idx = $('.model' + item).length;
|
||||
if (idx > 1) {
|
||||
$('.model' + item).eq(idx - 1).remove();
|
||||
for (let i = 0; i < 7; i++) {
|
||||
$('.model' + item).eq(0).find('td').eq(i).attr('rowspan', idx - 1);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 快速录入
|
||||
function quickAdd() {
|
||||
let modelIdArr = [];
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let modelId = $(this).attr('id');
|
||||
modelIdArr.push(modelId);
|
||||
})
|
||||
// 去重后的数据
|
||||
let newModelIdArr = removeDuplicates(modelIdArr);
|
||||
if (modelIdArr.length > newModelIdArr.length) {
|
||||
return layer.msg('使用快捷录入前,请先确保数据未被拆分', { icon: 7 });
|
||||
}
|
||||
openIframeByParamObj("quickAddForm", "快捷录入", "./quick_add_form.html", "50%", "85%", objParam);
|
||||
}
|
||||
|
||||
|
||||
function removeDuplicates(arr) {
|
||||
return [...new Set(arr)];
|
||||
}
|
||||
|
||||
// 快速赋值
|
||||
function quickAddData(data) {
|
||||
console.error(JSON.parse(data));
|
||||
let obj = JSON.parse(data);
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let modelId = $(this).attr('id');
|
||||
let needNum = $(this).find('td').eq(6).html();
|
||||
if (obj.allSend) { // 全部发货
|
||||
$('.num' + modelId).eq(0).val(needNum);
|
||||
} else {
|
||||
$('.num' + modelId).eq(0).val(0);
|
||||
}
|
||||
if (obj.supplier) {
|
||||
$('.supplier' + modelId).eq(0).val(obj.supplier);
|
||||
} else {
|
||||
$('.supplier' + modelId).eq(0).val('');
|
||||
}
|
||||
if (obj.cjDate) {
|
||||
$('.cjDate' + modelId).eq(0).val(obj.cjDate);
|
||||
} else {
|
||||
$('.cjDate' + modelId).eq(0).val('');
|
||||
}
|
||||
if (obj.jyDate) {
|
||||
$('.jyDate' + modelId).eq(0).val(obj.jyDate);
|
||||
} else {
|
||||
$('.jyDate' + modelId).eq(0).val('');
|
||||
}
|
||||
})
|
||||
|
||||
layui.form.render();
|
||||
}
|
||||
|
||||
// 查询
|
||||
function search() {
|
||||
let keyWord = $('#name').val();
|
||||
let keyWord2 = $('#model').val();
|
||||
if (keyWord && !keyWord2) {
|
||||
$('#baseTable tbody tr.mainTr').each(function () {
|
||||
let name = $(this).find('td').eq(3).html();
|
||||
let modelId = $(this).attr('id');
|
||||
if (name.indexOf(keyWord) < 0) {
|
||||
$(this).removeAttr('style');
|
||||
$(this).css({ 'display': 'none' });
|
||||
$('.model' + modelId).css({ 'display': 'none' });
|
||||
}
|
||||
});
|
||||
resetXh();
|
||||
} else if (!keyWord && keyWord2) {
|
||||
$('#baseTable tbody tr.mainTr').each(function () {
|
||||
let model = $(this).find('td').eq(4).html();
|
||||
let modelId = $(this).attr('id');
|
||||
if (model.indexOf(keyWord2) < 0) {
|
||||
$(this).removeAttr('style');
|
||||
$(this).css({ 'display': 'none' });
|
||||
$('.model' + modelId).css({ 'display': 'none' });
|
||||
}
|
||||
});
|
||||
resetXh();
|
||||
} else if (keyWord && keyWord2) {
|
||||
$('#baseTable tbody tr.mainTr').each(function () {
|
||||
let name = $(this).find('td').eq(3).html();
|
||||
let model = $(this).find('td').eq(4).html();
|
||||
let modelId = $(this).attr('id');
|
||||
if (name.indexOf(keyWord) < 0 || model.indexOf(keyWord2) < 0) {
|
||||
$(this).removeAttr('style');
|
||||
$(this).css({ 'display': 'none' });
|
||||
$('.model' + modelId).css({ 'display': 'none' });
|
||||
}
|
||||
});
|
||||
resetXh();
|
||||
} else {
|
||||
resetSearch();
|
||||
}
|
||||
}
|
||||
|
||||
// 重置查询
|
||||
function resetSearch() {
|
||||
$('#name').val('');
|
||||
$('#model').val('');
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
$(this).removeAttr('style');
|
||||
});
|
||||
resetXh();
|
||||
}
|
||||
|
||||
// 重置序号
|
||||
function resetXh() {
|
||||
let index = 0;
|
||||
$('#baseTable tbody tr.mainTr').each(function () {
|
||||
let style = $(this).attr('style');
|
||||
if (!style) {
|
||||
index += 1
|
||||
$(this).find('td').eq(1).html(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -107,6 +107,7 @@
|
|||
<button class="layui-btn layui-bg-blue" onclick="chooseFitTypeTwo()"><i
|
||||
class="layui-icon layui-icon-add-1"></i> 添 加 明 细
|
||||
</button>
|
||||
<button class="layui-btn layui-bg-red" onclick="delFitTypeTwo()">删除选中</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -147,7 +148,7 @@
|
|||
<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/openIframe.js" charset="utf-8"></script>
|
||||
<script src="../../../js/aq_demand_plan/child/send_out_form_table.js" charset="utf-8"></script>
|
||||
<script src="../../../js/aq_demand_plan/child/send_out_unplanned_form_table.js" charset="utf-8"></script>
|
||||
<script src="../../../js/aq_demand_plan/child/send_out_unplanned_form.js" charset="utf-8"></script>
|
||||
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in New Issue