This commit is contained in:
cwchen 2024-11-16 12:56:11 +08:00
parent 01de3538d0
commit bc16bf5632
6 changed files with 40 additions and 52 deletions

View File

@ -7,7 +7,7 @@ layui.use(["form", "table", 'laydate'], function () {
laydate = layui.laydate; laydate = layui.laydate;
laydate.render({ laydate.render({
elem: '#ID-laydate-rangeLinked', elem: '#ID-laydate-rangeLinked',
range: ['#startDate', '#endDate'], range: ['#startDay', '#endDay'],
rangeLinked: true rangeLinked: true
}); });
initTable(); initTable();
@ -19,8 +19,8 @@ function queryTable(type) {
reloadTable(1); reloadTable(1);
} else if (type === 2) { } else if (type === 2) {
$('#keyWord').val(''); $('#keyWord').val('');
$('#startDate').val(''); $('#startDay').val('');
$('#endDate').val(''); $('#endDay').val('');
layui.form.render(); layui.form.render();
reloadTable(1); reloadTable(1);
} }
@ -40,8 +40,8 @@ function reloadTable(pageNum) {
where: { where: {
encryptedData: JSON.stringify({ encryptedData: JSON.stringify({
'keyWord': $('#keyWord').val(), 'keyWord': $('#keyWord').val(),
'startDate': $('#startDate').val(), 'startDay': $('#startDay').val(),
'endDate': $('#endDate').val() 'endDay': $('#endDay').val()
}), }),
}, },
}, },
@ -61,8 +61,8 @@ function initTable() {
where: { where: {
encryptedData: JSON.stringify({ encryptedData: JSON.stringify({
'keyWord': $('#keyWord').val(), 'keyWord': $('#keyWord').val(),
'startDate': $('#startDate').val(), 'startDay': $('#startDay').val(),
'endDate': $('#endDate').val() 'endDay': $('#endDay').val()
}), }),
}, },
request: { request: {
@ -148,11 +148,12 @@ function initTable() {
// 导出 // 导出
function exportExcel() { function exportExcel() {
let params = { let params = {
'proName': $('#proName').val(), 'keyWord': $('#keyWord').val(),
'status': $('#status').val() 'startDay': $('#startDay').val(),
'endDay': $('#endDay').val()
} }
let url = dataUrl + "backstage/export/exportFhList"; let url = dataUrl + "backstage/partScrap/export";
exportExcelUtil(url, '配件入库数据', JSON.stringify(params)); exportExcelUtil(url, '报废记录', JSON.stringify(params));
} }
// 详情 配件报废 // 详情 配件报废

View File

@ -13,7 +13,7 @@ function setParams(obj) {
table = layui.table; table = layui.table;
util = layui.util; util = layui.util;
laydate.render({ laydate.render({
elem: '#inputDay' elem: '#scrapDay'
}); });
form.verify(); form.verify();
form.on('submit(formData)', function (data) { form.on('submit(formData)', function (data) {
@ -32,7 +32,7 @@ function setParams(obj) {
bindAction: '#hideUpload', //绑定的按钮 bindAction: '#hideUpload', //绑定的按钮
choose: function (obj) { choose: function (obj) {
let length = $('.file-iteme').length; let length = $('.file-iteme').length;
if(length >= 5){ if (length >= 5) {
return layer.msg('最多上传5个附件证明', { icon: 7 }); return layer.msg('最多上传5个附件证明', { icon: 7 });
} }
uploadObj.config.elem.next()[0].value = ''; uploadObj.config.elem.next()[0].value = '';
@ -279,6 +279,8 @@ function setTableData(results) {
if (results && results.length > 0) { if (results && results.length > 0) {
for (var i = 0; i < results.length; i++) { for (var i = 0; i < results.length; i++) {
var l = results[i]; var l = results[i];
let scrapNum = l.scrapNum ? l.scrapNum : 0;
let price = l.price ? parseFloat(l.price) : 0;
html += "<tr id='" + l.id + "'>"; html += "<tr id='" + l.id + "'>";
html += '<td><input onclick="sel(this.checked,this,' + l.id + ')" name="check" type="checkbox"></td>'; html += '<td><input onclick="sel(this.checked,this,' + l.id + ')" name="check" type="checkbox"></td>';
html += "<td style='vertical-align:middle;' class='center hidden-480'>" html += "<td style='vertical-align:middle;' class='center hidden-480'>"
@ -287,10 +289,10 @@ function setTableData(results) {
html += "<td>" + l.name + "</td>"; html += "<td>" + l.name + "</td>";
html += "<td>" + l.model + "</td>"; html += "<td>" + l.model + "</td>";
html += "<td>" + l.unit + "</td>"; html += "<td>" + l.unit + "</td>";
html += "<td>" + l.unit + "</td>"; html += "<td>" + l.price + "</td>";
html += "<td>" + l.unit + "</td>"; html += "<td>" + l.num + "</td>";
html += "<td>" + setFormInput(l.num, 1) + "</td>"; html += "<td>" + setFormInput(l.scrapNum, 1) + "</td>";
html += "<td>" + l.unit + "</td>"; html += "<td>" + scrapNum * price + "</td>";
html += "<td>" + setFormInput(l.remarks, 2) + "</td>"; html += "<td>" + setFormInput(l.remarks, 2) + "</td>";
html += "</tr>"; html += "</tr>";
} }
@ -304,8 +306,8 @@ function setTableData(results) {
function setFormInput(value, type) { function setFormInput(value, type) {
let html = '<form class="layui-form layuimini-form"><div class="layui-inline">'; let html = '<form class="layui-form layuimini-form"><div class="layui-inline">';
if (type === 1) { // 报废数量 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">'; html += '<input class="layui-input" name="scrapNum" onblur="checkValue(this,1)" value="' + setNullValue(value) + '" autocomplete="off" lay-verify="required" maxlength="9" lay-affix="clear">';
}else if (type === 2) { // 备注 } else if (type === 2) { // 备注
html += '<input class="layui-input" placeholder="请输入备注" id="remarks" name="remarks" value="' + setNullValue(value) + '" maxLength="255" lay-affix="clear"></input>'; html += '<input class="layui-input" placeholder="请输入备注" id="remarks" name="remarks" value="' + setNullValue(value) + '" maxLength="255" lay-affix="clear"></input>';
} }
html += '</div></form>'; html += '</div></form>';
@ -390,11 +392,11 @@ function delFitType() {
// 校验数据 // 校验数据
function checkValue(that, type) { function checkValue(that, type) {
let value = $(that).val(); let value = $(that).val();
if (type === 1) { // 入库 if (type === 1) { // 报废数
const regex = /^(0|[1-9]\d{0,6})$/; const regex = /^(0|[1-9]\d{0,6})$/;
if (!regex.test(value) && value) { if (!regex.test(value) && value) {
layer.msg('入库量输入不合法,请重新输入!', { icon: 5 }) $(that).val(0);
$(that).val(''); return layer.msg('报废数量输入不合法,请重新输入!', { icon: 5 })
} }
} }
} }

View File

@ -76,10 +76,8 @@ function initTable() {
$.each(res.list, function (index, item) { $.each(res.list, function (index, item) {
$.each(jjDetailArr, function (index2, item2) { $.each(jjDetailArr, function (index2, item2) {
if (item.id === item2.id) { if (item.id === item2.id) {
item.num = item2.num; item.scrapNum = item2.scrapNum;
item.price = item2.price;
item.remarks = item2.remarks; item.remarks = item2.remarks;
item.manufacturer = item2.manufacturer;
} }
}); });
}); });
@ -104,21 +102,21 @@ function initTable() {
}, },
{ {
field: "type", field: "type",
width: '8%', width: '9.9%',
title: "配件类型", title: "配件类型",
unresize: true, unresize: true,
align: "center", align: "center",
}, },
{ {
field: "name", field: "name",
width: '9%', width: '13%',
title: "配件名称", title: "配件名称",
unresize: true, unresize: true,
align: "center", align: "center",
}, },
{ {
field: "model", field: "model",
width: '8%', width: '12%',
title: "规格型号", title: "规格型号",
unresize: true, unresize: true,
align: "center", align: "center",
@ -131,21 +129,21 @@ function initTable() {
align: "center", align: "center",
}, },
{ {
field: "unit", field: "price",
title: "平均单价(元)", title: "平均单价(元)",
width: '10%', width: '10%',
unresize: true, unresize: true,
align: "center", align: "center",
}, },
{ {
field: "unit", field: "num",
title: "库存量", title: "库存量",
width: '10%', width: '10%',
unresize: true, unresize: true,
align: "center", align: "center",
}, },
{ {
field: "num", field: "scrapNum",
width: '10%', width: '10%',
title: "报废数量", title: "报废数量",
unresize: true, unresize: true,
@ -153,15 +151,6 @@ function initTable() {
edit: 'text', edit: 'text',
style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
}, },
{
field: "price",
width: '10%',
title: "金额 (元)",
unresize: true,
align: "center",
edit: 'text',
style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
},
{ {
field: "remarks", field: "remarks",
width: '15%', width: '15%',
@ -207,7 +196,7 @@ function initTable() {
table.on('edit(currentTableId2)', function (obj) { table.on('edit(currentTableId2)', function (obj) {
var field = obj.field; // 得到修改的字段 var field = obj.field; // 得到修改的字段
var value = obj.value // 得到修改后的值 var value = obj.value // 得到修改后的值
if (field === 'num') { // 本次入库 if (field === 'scrapNum') { // 报废
if (value) { if (value) {
const regex = /^(0|[1-9]\d{0,6})$/; const regex = /^(0|[1-9]\d{0,6})$/;
if (!regex.test(value)) { if (!regex.test(value)) {
@ -215,12 +204,6 @@ function initTable() {
return layer.msg('格式不正确最大输入6位数且为正整数', { icon: 7 }) return layer.msg('格式不正确最大输入6位数且为正整数', { icon: 7 })
} }
} }
} else if (field === 'price') {
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)) {
obj.reedit();
return layer.msg('单价格式不正确!', { icon: 7 })
}
} else if (field === 'remarks') { // 备注 } else if (field === 'remarks') { // 备注
if (value) { if (value) {
if (value.length > 255) { if (value.length > 255) {

View File

@ -404,6 +404,8 @@ function checkValue(that, type) {
const regex = /^(0|[1-9]\d{0,6})$/; const regex = /^(0|[1-9]\d{0,6})$/;
if (!regex.test(value) && value) { if (!regex.test(value) && value) {
$(that).val(0); $(that).val(0);
$(that).parents('td').next().html(0);
$(that).parents('td').next().next().html(0);
let list = getBaseTableData(); let list = getBaseTableData();
setNumAndPrice(list); setNumAndPrice(list);
return layer.msg('本次盘点量输入不合法最大输入6位数且为正整数请重新输入!', { icon: 5 }) return layer.msg('本次盘点量输入不合法最大输入6位数且为正整数请重新输入!', { icon: 5 })

View File

@ -22,19 +22,19 @@
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline"> <div class="layui-inline">
<div class="layui-input-inline" style="width: 300px;"> <div class="layui-input-inline" style="width: 300px;">
<input type="text" name="proName" id="keyWord" autocomplete="off" <input type="text" name="keyWord" id="keyWord" autocomplete="off"
class="layui-input" lay-affix="clear" placeholder="请输入关键字" maxlength="30"> class="layui-input" lay-affix="clear" placeholder="请输入关键字" maxlength="30">
</div> </div>
</div> </div>
<div class="layui-inline" style="margin-bottom: 0;"> <div class="layui-inline" style="margin-bottom: 0;">
<div class="layui-inline" id="ID-laydate-rangeLinked"> <div class="layui-inline" id="ID-laydate-rangeLinked">
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" autocomplete="off" id="startDate" class="layui-input" <input type="text" autocomplete="off" id="startDay" class="layui-input"
placeholder="开始日期"> placeholder="开始日期">
</div> </div>
<div class="layui-form-mid">-</div> <div class="layui-form-mid">-</div>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" autocomplete="off" id="endDate" class="layui-input" <input type="text" autocomplete="off" id="endDay" class="layui-input"
placeholder="结束日期"> placeholder="结束日期">
</div> </div>
</div> </div>

View File

@ -19,7 +19,7 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label required" style="width: 100px !important;">报废人</label> <label class="layui-form-label required" style="width: 100px !important;">报废人</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input class="layui-input" name="inputUser" id="inputUser" autocomplete="off" lay-verify="required" maxlength="30" lay-affix="clear"> <input class="layui-input" name="userName" id="userName" autocomplete="off" lay-verify="required" maxlength="30" lay-affix="clear">
</div> </div>
</div> </div>
<div class="layui-inline"> <div class="layui-inline">
@ -28,7 +28,7 @@
<div class="layui-input-prefix"> <div class="layui-input-prefix">
<i class="layui-icon layui-icon-date"></i> <i class="layui-icon layui-icon-date"></i>
</div> </div>
<input class="layui-input" id="inputDay" autocomplete="off" name="inputDay" <input class="layui-input" id="scrapDay" autocomplete="off" name="scrapDay"
lay-verify="required" readonly style="cursor: pointer;"> lay-verify="required" readonly style="cursor: pointer;">
</div> </div>
</div> </div>