This commit is contained in:
cwchen 2024-11-16 12:37:09 +08:00
parent 199940b40e
commit 192da2a5b0
8 changed files with 86 additions and 60 deletions

View File

@ -176,7 +176,8 @@
let login_url = dataUrl + 'login/userLogin'
const params = {
"username": 'bns',
"password": '3NBzZK7qxhMhrmvi63FnuQ==',
// "password": '3NBzZK7qxhMhrmvi63FnuQ==',
"password": '1769fb2837e10e9d22c1c25add76355a',
}
ajaxRequest(login_url, "POST", params, true, function () {
}, function (result) {

View File

@ -378,7 +378,7 @@ function sel(selectStatus, that, id) {
$(that).prop('checked', false);
for (let i = 0; i < delIdArr.length; i++) {
if (delIdArr[i] == id) {
arr.splice(i, 1);
delIdArr.splice(i, 1);
break;
}
}

View File

@ -352,7 +352,7 @@ function sel(selectStatus, that, id) {
$(that).prop('checked', false);
for (let i = 0; i < delIdArr.length; i++) {
if (delIdArr[i] == id) {
arr.splice(i, 1);
delIdArr.splice(i, 1);
break;
}
}

View File

@ -378,7 +378,7 @@ function sel(selectStatus, that, id) {
$(that).prop('checked', false);
for (let i = 0; i < delIdArr.length; i++) {
if (delIdArr[i] == id) {
arr.splice(i, 1);
delIdArr.splice(i, 1);
break;
}
}

View File

@ -124,7 +124,7 @@ function initTable() {
align: "center",
},
{
field: "unit",
field: "price",
title: "平均单价(元)",
width: '9%',
unresize: true,
@ -163,7 +163,7 @@ function initTable() {
unresize: true,
align: "center",
// edit: 'text',
style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
// style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
},
{
field: "subNum",
@ -172,7 +172,7 @@ function initTable() {
unresize: true,
align: "center",
// edit: 'text',
style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
// style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
},
{
field: "remarks",

View File

@ -14,7 +14,7 @@ function setParams(obj) {
util = layui.util;
laydate.render({
elem: '#ID-laydate-rangeLinked',
range: ['#startDay', '#endDay'],
range: ['#startTime', '#endTime'],
rangeLinked: true
});
form.verify();
@ -34,7 +34,7 @@ function setParams(obj) {
bindAction: '#hideUpload', //绑定的按钮
choose: function (obj) {
let length = $('.file-iteme').length;
if(length >= 5){
if (length >= 5) {
return layer.msg('最多上传5个附件证明', { icon: 7 });
}
uploadObj.config.elem.next()[0].value = '';
@ -119,15 +119,14 @@ function submitApply(data) {
}
// 校验配件入库数量
if (list.length === 0) {
return layer.msg('未填写配件入库数量', { icon: 7 });
return layer.msg('未添加盘点明细数据', { icon: 7 });
}
for (let i = 0; i < list.length; i++) {
if (!list[i].inputNum || list[i].inputNum === '0') {
return layer.msg('入库配件明细,第' + (i + 1) + '行,未填写配件入库数量', { icon: 7 });
if (list[i].checkNum === 0) {
return layer.msg('盘点明细,第' + (i + 1) + '行,未填写本次盘点量', { icon: 7 });
}
}
data.field.details = list;
data.field.detailList = list;
let formData = new FormData();
//遍历最终文件集合
for (let i = 0; i < fileList.length; i++) {
@ -137,7 +136,7 @@ function submitApply(data) {
console.log(JSON.stringify(data.field));
let loadingMsg = layer.msg('正在提交保存,请稍等...', { icon: 16, shade: 0.01, time: '0' });
console.log(JSON.stringify(data.field));
let url = dataUrl + 'backstage/partInput/addInputData';
let url = dataUrl + 'backstage/partCheck/insertCheckData';
ajaxRequestByUploadFile(url, formData, function () {
$('.save').addClass("layui-btn-disabled").attr("disabled", true);
$('.cancel').addClass("layui-btn-disabled").attr("disabled", true);
@ -165,19 +164,19 @@ function submitApply(data) {
function getBaseTableData() {
let tableData = [];
$('#baseTable tbody tr').each(function (index, item) {
let price = $(this).find('td').eq(7).find('input[name="price"]').val();
let num = $(this).find('td').eq(6).find('input[name="num"]').val();
let checkNum = $(this).find('td').eq(8).find('input[name="checkNum"]').val();
tableData.push({
partId: $(this).attr('id'),
partType: $(this).find('td').eq(2).html(),
partName: $(this).find('td').eq(3).html(),
partModel: $(this).find('td').eq(4).html(),
partUnit: $(this).find('td').eq(5).html(),
inputNum: num ? num : 0,
partPrice: price ? price : 0,
vendId: $(this).find('td').eq(8).find('select[name="manufacturer"]').val(),
vendName: $(this).find('td').eq(8).find('select[name="manufacturer"]').find('option:checked').text(),
remark: $(this).find('td').eq(9).find('input[name="remarks"]').val(),
price: $(this).find('td').eq(5).html(),
partUnit: $(this).find('td').eq(6).html(),
num: $(this).find('td').eq(7).html(),
checkNum: checkNum ? checkNum : 0,
addNum: $(this).find('td').eq(9).html(),
subNum: $(this).find('td').eq(10).html(),
remark: $(this).find('td').eq(11).find('input[name="remarks"]').val(),
})
})
return tableData;
@ -288,31 +287,46 @@ function setTableData(results) {
html += "<td>" + l.type + "</td>";
html += "<td>" + l.name + "</td>";
html += "<td>" + l.model + "</td>";
html += "<td>" + l.model + "</td>";
html += "<td>" + l.price + "</td>";
html += "<td>" + l.unit + "</td>";
html += "<td style='color:#19BE6B;font-weight:bold;'>" + l.unit + "</td>";
html += "<td>" + setFormInput(l.num, 1) + "</td>";
html += "<td>" + setFormInput(l.price, 2) + "</td>";
html += "<td>" + setFormInput(l.manufacturer, 3) + "</td>";
html += "<td>" + setFormInput(l.remarks, 4) + "</td>";
html += "<td style='color:#19BE6B;font-weight:bold;'>" + l.num + "</td>";
html += "<td>" + setFormInput(l.checkNum, 1) + "</td>";
html += "<td>" + l.addNum + "</td>";
html += "<td>" + l.subNum + "</td>";
html += "<td>" + setFormInput(l.remarks, 2) + "</td>";
html += "</tr>";
}
} else {
html += "<tr><td colspan='10' class='center'>没有相关数据</td></tr>";
html += "<tr><td colspan='12' class='center'>没有相关数据</td></tr>";
}
$("#baseTable tbody").empty().append(html);
setNumAndPrice(jjDataArr);
layui.form.render();
}
// 盘盈 、盘亏数量和金额
function setNumAndPrice(list) {
if (list && list.length > 0) {
let addNum = 0, subNum = 0, addPrice = 0; subPrice = 0;
$.each(list, function (index, item) {
let price = item.price ? 2 : 2;
addNum += parseInt(item.addNum);
subNum += parseInt(item.subNum);
addPrice += parseInt(item.addNum) * parseFloat(price);
subPrice += parseInt(item.subNum) * parseFloat(price);
});
$('#addNum').html(addNum);;
$('#subNum').html(subNum);;
$('#addPrice').html(addPrice);;
$('#subPrice').html(subPrice);;
}
}
function setFormInput(value, type) {
let html = '<form class="layui-form layuimini-form"><div class="layui-inline">';
if (type === 1) { // 入库量
html += '<input class="layui-input" name="num" onblur="checkValue(this,1)" value="' + setNullValue(value) + '" autocomplete="off" lay-verify="required" maxlength="9" lay-affix="clear">';
} else if (type === 2) { // 单价
html += '<input class="layui-input" name="price" onblur="checkValue(this,2)" value="' + setNullValue(value) + '" autocomplete="off" lay-verify="required" maxlength="9" lay-affix="clear">';
} else if (type === 3) { // 厂家
html += '<input class="layui-input" name="price" onblur="checkValue(this,2)" value="' + setNullValue(value) + '" autocomplete="off" lay-verify="required" maxlength="9" lay-affix="clear">';
} else if (type === 4) { // 备注
if (type === 1) { // 本次盘点量
html += '<input class="layui-input" name="checkNum" onblur="checkValue(this,1)" value="' + setNullValue(value) + '" autocomplete="off" lay-verify="required" maxlength="9">';
} else if (type === 2) { // 备注
html += '<input class="layui-input" placeholder="请输入备注" id="remarks" name="remarks" value="' + setNullValue(value) + '" maxLength="255" lay-affix="clear"></input>';
}
html += '</div></form>';
@ -346,7 +360,7 @@ function sel(selectStatus, that, id) {
$(that).prop('checked', false);
for (let i = 0; i < delIdArr.length; i++) {
if (delIdArr[i] == id) {
arr.splice(i, 1);
delIdArr.splice(i, 1);
break;
}
}
@ -379,22 +393,33 @@ function delFitType() {
}
});
let list = getBaseTableData();
setNumAndPrice(list);
}
// 校验数据
function checkValue(that, type) {
let value = $(that).val();
if (type === 1) { // 入库
if (type === 1) { // 本次盘点
const regex = /^(0|[1-9]\d{0,6})$/;
if (!regex.test(value) && value) {
layer.msg('入库量输入不合法,请重新输入!', { icon: 5 })
$(that).val('');
}
} else if (type === 2) { // 单价
const regex = /^(?:1(?:\d{0,8}|[0-9]*\.\d{1,2})|(?:[1-9]\d{0,7}|[1-9]\d{0,6}\.\d{1,2}|[1-9]\d{1,7}\.\d{2}|100000000(?:\.00)?))$/;
if (!regex.test(value) && value) {
layer.msg('单价输入不合法,请重新输入!', { icon: 5 })
$(that).val('');
$(that).val(0);
let list = getBaseTableData();
setNumAndPrice(list);
return layer.msg('本次盘点量输入不合法最大输入6位数且为正整数请重新输入!', { icon: 5 })
} else if (value) {
let num = $(that).parents('td').prev().html(); // 库存量
let addNum = 0, subNum = 0; // 盘盈量、盘亏量
let syNum = num - value;
if (syNum > 0) {
subNum = syNum;
} else {
addNum = Math.abs(syNum);
}
$(that).parents('td').next().html(addNum);
$(that).parents('td').next().next().html(subNum);
let list = getBaseTableData();
setNumAndPrice(list);
}
}
}

View File

@ -176,5 +176,5 @@ function exportExcel() {
// 需求计划编号
function plan_detail(obj) {
openIframeByParamObj("plan_detail", "机具需求计划", "./apply_plan_detail.html", "92%", "95%", obj);
openIframeByParamObj2("plan_detail", "机具需求计划", "/page/demandPlan/child/apply_plan_detail.html", "92%", "95%", obj);
}

View File

@ -19,7 +19,7 @@
<div class="layui-inline">
<label class="layui-form-label required" style="width: 100px !important;">盘点人</label>
<div class="layui-input-inline">
<input class="layui-input" name="inputUser" id="inputUser" autocomplete="off"
<input class="layui-input" name="creator" id="creator" autocomplete="off"
lay-verify="required" maxlength="30" lay-affix="clear">
</div>
</div>
@ -27,12 +27,12 @@
<label class="layui-form-label required" style="width: 110px !important;">盘点日期</label>
<div class="layui-inline" id="ID-laydate-rangeLinked">
<div class="layui-input-inline">
<input type="text" autocomplete="off" id="startDay" class="layui-input"
<input type="text" autocomplete="off" name="startTime" id="startTime" class="layui-input"
placeholder="盘点开始日期" lay-verify="required" readonly style="cursor: pointer;">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" autocomplete="off" id="endDay" class="layui-input"
<input type="text" autocomplete="off" name="endTime" id="endTime" class="layui-input"
placeholder="盘点结束日期:" lay-verify="required" readonly style="cursor: pointer;">
</div>
</div>
@ -101,13 +101,13 @@
<button class="layui-btn layui-bg-red" onclick="delFitType()">删除选中</button>
</div>
<div class="layui-inline">
<div style="color: #19BE6B;" class="layout">
<p>盘盈:<span style="font-weight: bold;">653</span></p>
<p style="margin-left: 20px;">¥ <span style="font-weight: bold;">15,653</span></p>
<div style="color: #19BE6B;width: 300px;justify-content: start;" class="layout">
<p>盘盈:<span style="font-weight: bold;" id="addNum">653</span></p>
<p style="margin-left: 20px;">¥ <span style="font-weight: bold;" id="addPrice">0</span></p>
</div>
<div style="color:#f56c6c ;" class="layout">
<p>盘亏:<span style="font-weight: bold;">120</span></p>
<p style="margin-left: 20px;">¥ <span style="font-weight: bold;">12,120</span></p>
<div style="color:#f56c6c ;width: 300px;justify-content: start;" class="layout">
<p>盘亏:<span style="font-weight: bold;" id="subNum">120</span></p>
<p style="margin-left: 20px;">¥ <span style="font-weight: bold;" id="subPrice">0</span></p>
</div>
</div>
</div>
@ -129,9 +129,9 @@
<th style="width: 8%" class="center">单位</th>
<th style="width: 8%" class="center">库存量</th>
<th style="width: 10%" class="center"><span style="color: red;">*</span> 本次盘点量</th>
<th style="width: 10%" class="center"><span style="color: red;">*</span>盘盈量</th>
<th style="width: 10%" class="center"><span style="color: red;">*</span>盘亏量</th>
<th style="width: 10%" class="center">备注</th>
<th style="width: 8%" class="center"><span style="color: red;">*</span>盘盈量</th>
<th style="width: 8%" class="center"><span style="color: red;">*</span>盘亏量</th>
<th style="width: 14%" class="center">备注</th>
</tr>
</thead>
<tbody></tbody>