This commit is contained in:
cwchen 2024-11-13 16:02:00 +08:00
parent 6ca121f3a5
commit 14c7cdc643
4 changed files with 40 additions and 107 deletions

View File

@ -4,6 +4,7 @@ let pageNum = 1, tableIns; // 定义分页
let jjDataArr = []; // 入库配件数据
let cjList = []; // 厂家下拉选
let delIdArr = [];
let checkUserId;
function setParams(obj) {
objParam = JSON.parse(obj);
layui.use(['form', 'layer', 'laydate', 'upload', 'table'], function () {
@ -20,6 +21,16 @@ function setParams(obj) {
form.on('submit(formData)', function (data) {
submitApply(data);
});
form.on('select(inputUser)', function (data) {
if (checkUserId && data.value !== checkUserId) {
// 清空退料配件明细数据
jjDataArr.splice(0, jjDataArr.length);
setTableData(jjDataArr);
$('#no_data_title').removeAttr('style');
$('#search-info').css({ 'display': 'none' });
$('#table-box').css({ 'display': 'none' });
}
})
form.render();
let uploadObj = upload.render({
elem: '#test2',
@ -248,7 +259,8 @@ function resetSearch() {
}
// 子页面回调数据
function addFitDatas(data) {
function addFitDatas(data, userId) {
checkUserId = userId;
console.log('新增的数据:' + data);
if (jjDataArr.length > 0) { // 继续添加数据
let newJjDataArr = JSON.parse(data);
@ -278,7 +290,7 @@ function addFitDatas(data) {
}
}
// 入库配件明细表格赋值
// 退件配件明细表格赋值
function setTableData(results) {
$('#allCheck').prop('checked', false)
var html = "";
@ -294,9 +306,7 @@ function setTableData(results) {
html += "<td>" + l.model + "</td>";
html += "<td>" + 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>" + setFormInput(l.remarks, 2) + "</td>";
html += "</tr>";
}
} else {
@ -308,15 +318,9 @@ function setTableData(results) {
function setFormInput(value, type) {
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">';
} 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 += '<select class="layui-select" name="manufacturer" id="manufacturer" lay-search>' +
setSelectData(value) +
'</select>';
} else if (type === 4) { // 备注
} 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>';
@ -324,35 +328,6 @@ function setFormInput(value, type) {
}
function setSelectData(value) {
let html = '';
$.each(cjList, function (index, item) {
if (item.id === value) {
html += '<option value="' + item.id + '" selected>' + item.name + '</option>'
} else {
html += '<option value="' + item.id + '">' + item.name + '</option>'
}
})
return html;
}
// 厂家下拉选
function getVendList() {
cjList.splice(0, cjList.length);
let encryptedData = {};
let url = dataUrl + 'backstage/paType/getVendList?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData));
ajaxRequest(url, "GET", null, false, function () {
}, function (result) {
console.log(result);
if (result.code === 200) {
cjList = result.data;
}
}, function (xhr, status, error) {
errorFn(xhr, status, error)
}, null);
}
// 复选框全选
function selectAll(selectStatus) {//传入参数(全选框的选中状态)
if (selectStatus) {
@ -417,16 +392,10 @@ function delFitType() {
// 校验数据
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 })
layer.msg(' 本次退回量输入不合法,请重新输入!', { icon: 5 })
$(that).val('');
}
}

View File

@ -1,13 +1,13 @@
let objParam;
let objParam, userId;
let form, table, element, tableIns, layer, util;
let pageNum = 1;
let quanju = new Array();//全局
let huancun = new Array();//缓存
let huancunObj = new Array();//缓存2
let cjList = [];
let jjDetailArr = []; // 入库配件类型数据
let jjDetailArr = []; // 退料配件类型数据
function setParams(obj) {
objParam = JSON.parse(obj);
userId = objParam.userId;
console.log(objParam);
layui.use(["form", "table", 'element', 'layer', 'util'], function () {
form = layui.form;
@ -15,27 +15,10 @@ function setParams(obj) {
element = layui.element;
layer = layui.layer;
util = layui.util;
getVendList();
initTable();
});
}
// 厂家下拉选
function getVendList() {
cjList.splice(0, cjList.length);
let encryptedData = {};
let url = dataUrl + 'backstage/paType/getVendList?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData));
ajaxRequest(url, "GET", null, false, function () {
}, function (result) {
console.log(result);
if (result.code === 200) {
cjList = result.data;
}
}, function (xhr, status, error) {
errorFn(xhr, status, error)
}, null);
}
// 查询/重置
function queryTable(type) {
if (type === 1) {
@ -82,6 +65,7 @@ function initTable() {
'type': $('#type').val(),
'name': $('#name').val(),
'model': $('#model').val(),
'userId': userId
}),
},
request: {
@ -112,7 +96,7 @@ function initTable() {
[
{ type: 'checkbox', width: '5%' },
{
width: '6%',
width: '9.9%',
title: "序号",
align: "center",
templet: function (d) {
@ -121,14 +105,14 @@ function initTable() {
},
{
field: "type",
width: '11.8%',
width: '10%',
title: "配件类型",
unresize: true,
align: "center",
},
{
field: "name",
width: '12%',
width: '15%',
title: "配件名称",
unresize: true,
align: "center",
@ -143,39 +127,29 @@ function initTable() {
{
field: "unit",
title: "单位",
width: '8%',
width: '10%',
unresize: true,
align: "center",
},
{
field: "num",
width: '10%',
title: "<span style='color:red'> * </span>本次入库量",
title: "累计领料数量",
unresize: true,
align: "center",
edit: 'text',
style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
},
{
field: "price",
width: '9.8%',
title: "单价(元)",
width: '10%',
title: "<span style='color:red'> * </span>本次退回量",
unresize: true,
align: "center",
edit: 'text',
style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
},
{
field: "manufacturer",
width: '15%',
title: "<span style='color:red'> * </span>配件厂家",
unresize: true,
align: "center",
templet: '#TPL-select-demo'
},
{
field: "remarks",
width: '12%',
width: '20%',
title: "备注",
unresize: true,
align: "center",
@ -373,7 +347,7 @@ function closePage(type,params) {
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
parent.layer.close(index); // 再执行关闭
if (type == 1) {
window.parent.addFitDatas(params);
window.parent.addFitDatas(params, userId);
}
}

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">
<select class="layui-select" name="inputUser" id="inputUser">
<select class="layui-select" name="inputUser" id="inputUser" lay-filter="inputUser">
<option value="">请选择</option>
<option value="1">张三</option>
<option value="2">李四</option>
@ -96,7 +96,7 @@
class="layui-icon"></i> 搜 索</button>
<button class="layui-btn layui-btn-primary" onclick="resetSearch()"><i
class="layui-icon layui-icon-refresh"></i> 重 置</button>
<button class="layui-btn layui-bg-blue" onclick="chooseFitType()">选择入库配件类型</button>
<button class="layui-btn layui-bg-blue" onclick="chooseFitType()">选择退回配件</button>
<button class="layui-btn layui-bg-red" onclick="delFitType()">删除选中</button>
</div>
</div>
@ -110,14 +110,12 @@
<th style="width: 5%" class="center">
<input id="allCheck" onclick="selectAll(this.checked)" type="checkbox">
</th>
<th style="width: 5%" class="center">序号</th>
<th style="width: 10%" class="center">配件类型</th>
<th style="width: 10%" class="center">配件名称</th>
<th style="width: 10%" class="center">规格型号</th>
<th style="width: 10%" class="center">序号</th>
<th style="width: 15%" class="center">配件类型</th>
<th style="width: 15%" class="center">配件名称</th>
<th style="width: 15%" class="center">规格型号</th>
<th style="width: 10%" class="center">单位</th>
<th style="width: 10%" class="center"><span style="color: red;">*</span> 本次入库量</th>
<th style="width: 10%" class="center">单价(元)</th>
<th style="width: 15%" class="center"><span style="color: red;">*</span> 配件厂家</th>
<th style="width: 15%" class="center"><span style="color: red;">*</span> 本次退回量</th>
<th style="width: 15%" class="center">备注</th>
</tr>
</thead>

View File

@ -79,14 +79,6 @@
</div>
</div>
</body>
<script type="text/html" id="TPL-select-demo">
{{# var manufacturerList = cjList; }}
<select name="city" lay-filter="select-demo" lay-append-to="body" lay-search>
{{# layui.each(manufacturerList, function(i, v){ }}
<option value="{{= v.id }}" {{=v.id===d.manufacturer ? 'selected' : '' }}>{{= v.name }}</option>
{{# }); }}
</select>
</script>
<script src="../../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../../../js/public.js" charset="utf-8"></script>
<script src="../../../js/Print.js" charset="utf-8"></script>