配件入库

This commit is contained in:
cwchen 2024-11-12 16:15:07 +08:00
parent 1d5ffe52a1
commit c8593e3f8b
3 changed files with 266 additions and 90 deletions

View File

@ -219,7 +219,7 @@ function chooseFitType() {
/* if (jjDataArr && jjDataArr.length > 0) {
params.jjDataArrStr = JSON.stringify(jjDataArr);
} */
openIframeByParamObj("choose_fit_type", '选择入库配件类型', "./choose_fit_type_list.html", '82%', '90%', params);
openIframeByParamObj("choose_fit_type", '选择入库配件类型', "./choose_fit_type_list.html", '92%', '95%', params);
}
function addJjDatas(data) {

View File

@ -1,15 +1,19 @@
let objParam;
let form, table, element, tableIns, layer;
let form, table, element, tableIns, layer, util;
let pageNum = 1;
let quanju = new Array();//全局
let huancun = new Array();//缓存
let huancunObj = new Array();//缓存2
function setParams(obj) {
objParam = JSON.parse(obj);
console.log(objParam);
$('#proName').html(objParam.proName);
layui.use(["form", "table", 'element', 'layer'], function () {
layui.use(["form", "table", 'element', 'layer', 'util'], function () {
form = layui.form;
table = layui.table;
element = layui.element;
layer = layui.layer;
util = layui.util;
initTable();
});
}
@ -19,17 +23,13 @@ function queryTable(type) {
if (type === 1) {
reloadTable(1);
} else if (type === 2) {
$('#keyWord').val('');
$('#name').val('');
$('#module').val('');
layui.form.render();
reloadTable(1);
}
}
// 刷新页面数据
function reloadData() {
reloadData(pageNum);
}
// 重载表格
function reloadTable(pageNum) {
table.reload("currentTableId", {
@ -38,27 +38,29 @@ function reloadTable(pageNum) {
},
where: {
encryptedData: JSON.stringify({
'keyWord': $('#keyWord').val(),
'proId': objParam.proId
'name': $('#name').val(),
'module': $('#module').val(),
}),
},
},
);
}
// 表格数据
function initTable() {
tableIns = table.render({
elem: "#currentTableId",
id: 'currentTableId',
height: "full-200",
headers: {
authorization: sessionStorage.getItem("gz-token"),
},
height: "full-180",
url: dataUrl + "backstage/planOut/getProPlanListByProId",
url: dataUrl + "backstage/planOut/getPorInfoDetail",
where: {
encryptedData: JSON.stringify({
'keyWord': $('#keyWord').val(),
'proId': objParam.proId
'name': $('#name').val(),
'module': $('#module').val(),
}),
},
request: {
@ -66,6 +68,17 @@ function initTable() {
limitName: 'pageSize'
},
parseData: function (res) { // res 即为原始返回的数据
/* if (jjDetailArr && res.list) {
$.each(res.list, function (index, item) {
$.each(jjDetailArr, function (index2, item2) {
if (item.id === item2.id) {
item.num = item2.num;
item.tzNum = item2.tzNum;
item.outId = item2.outId;
}
});
});
} */
return {
"code": 0, // 解析接口状态
"msg": '获取成功', // 解析提示文本
@ -75,106 +88,228 @@ function initTable() {
},
cols: [
[
{ type: 'checkbox', width: '5%' },
{
width: '9.9%',
width: '6%',
title: "序号",
align: "center",
unresize: true,
templet: function (d) {
return d.LAY_NUM;
},
},
{
field: "code",
field: "type",
width: '11.8%',
title: "配件类型",
unresize: true,
align: "center",
},
{
field: "name",
width: '12%',
title: "配件名称",
unresize: true,
align: "center",
},
{
field: "module",
width: '10%',
title: "规格型号",
unresize: true,
align: "center",
},
{
field: "unit",
title: "单位",
width: '8%',
unresize: true,
align: "center",
},
{
field: "num",
width: '10%',
title: "<span style='color:red'> * </span>本次入库量",
unresize: true,
align: "center",
edit: 'text',
style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
},
{
field: "num",
width: '9.8%',
title: "单价(元)",
unresize: true,
align: "center",
edit: 'text',
style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
},
{
field: "num",
width: '15%',
title: "计划编号",
unresize: true,
align: "center",
},
{
field: "proName",
width: '20%',
title: "工程名称",
unresize: true,
align: "center",
},
{
field: "needTime",
width: '10%',
title: "需用日期",
unresize: true,
align: "center",
},
{
field: "creator",
width: '10%',
title: "申请人 ",
unresize: true,
align: "center",
},
{
field: "createTime",
width: '10%',
title: "申请时间",
title: "<span style='color:red'> * </span>配件厂家",
unresize: true,
align: "center",
templet: '#TPL-select-demo'
// style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
},
{
field: "remark",
width: '15%',
title: "计划说明 ",
width: '12%',
title: "备注",
unresize: true,
align: "center",
edit: 'textarea',
style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;'
},
{
width: '10%',
title: "操作 ",
unresize: true,
align: "center",
templet: function (d) {
let html = "";
html += "<a onclick='plan_detail(" + JSON.stringify(d) + ")'>详情</a>";
return html;
},
},
]
],
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
done: function (res, curr, count) {
pageNum = tableIns.config.page.curr;
element.render();
var options = this;
table.resize("currentTableId");
pageNum = tableIns.config.page.curr;
// layui form select 事件
form.on('select(select-demo)', function (obj) {
console.log(obj);
var value = obj.value; // 获取选中项 value
// 获取当前行数据(如 id 等字段,以作为数据修改的索引)
var data = table.getRowData(options.id, obj.elem);
// 更新数据中对应的字段
data.city = value;
// 显示当前行最新数据 - 仅用于示例展示
showData(data);
});
// 展示数据 - 仅用于演示
var showData = function (data) {
return layer.msg('当前行最新数据:<br>' + util.escape(JSON.stringify(data)), {
offset: '16px',
anim: 'slideDown'
});
};
// 获取当前行数据 - 自定义方法
table.getRowData = function (tableId, elem) {
var index = $(elem).closest('tr').data('index');
return table.cache[tableId][index] || {};
};
//设置全部数据到全局变量
quanju = res.data;
//在缓存中找到id ,然后设置data表格中的选中状态
//循环所有数据找出对应关系设置checkbox选中状态
for (var i = 0; i < res.data.length; i++) {
for (var j = 0; j < huancun.length; j++) {
//数据id和要勾选的id相同时checkbox选中
if (res.data[i].id === huancun[j]) {
//这里才是真正的有效勾选
res.data[i]["LAY_CHECKED"] = 'true';
//找到对应数据改变勾选样式,呈现出选中效果
var index = res.data[i]['LAY_INDEX'];
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
}
}
}
//设置全选checkbox的选中状态只有改变LAY_CHECKED的值 table.checkStatus才能抓取到选中的状态
let checkStatus = table.checkStatus('currentTableId');//这里的lightTable是指分页中的id
if (checkStatus.isAll) {//是否全选
//layTableAllChoose
$('.layui-table th[data-field="0"] input[type="checkbox"]').prop('checked', true);//data-field值默认为0如果在分页部分自定义了属性名则需要改成对应的属性名
$('.layui-table th[data-field="0"] input[type="checkbox"]').next().addClass('layui-form-checked');//data-field值默认为0如果在分页部分自定义了属性名则需要改成对应的属性名
}
},
});
table.on('edit(currentTableId)', function (obj) {
console.log(obj);
var field = obj.field; // 得到修改的字段
var value = obj.value // 得到修改后的值
var oldValue = obj.oldValue // 得到修改前的值 -- v2.8.0 新增
var data = obj.data // 得到所在行所有键值
var col = obj.getCol(); // 得到当前列的表头配置属性 -- v2.8.0 新增
if (field === 'num' || field === 'tzNum') { // 本次发货量/调整量
if (value) {
const regex = /^(0|[1-9]\d{0,6})$/;
if (!regex.test(value)) {
obj.reedit();
return layer.msg('格式不正确最大输入6位数且为正整数', { icon: 7 })
}
}
} else if (field === 'outId') { // 备注
if (value) {
if (value.length > 255) {
obj.reedit();
return layer.msg('备注最多输入255位', { icon: 7 })
}
}
}
// 显示 - 仅用于演示
// layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改值为:' + util.escape(value));
let id = obj.data.id;
let num = obj.data.num;
let tzNum = obj.data.tzNum;
let outId = obj.data.outId;
let type = obj.data.type;
let name = obj.data.name;
let module = obj.data.module;
let objParam = {
id: id,
num: num,
tzNum: tzNum,
outId: outId,
type: type,
name: name,
module: module,
remarks: outId
}
updateOrAddObject(id, objParam);
});
//复选框选中监听,将选中的id 设置到缓存数组,或者删除缓存数组
table.on('checkbox(currentTableId2)', function (obj) {
alert(12);
if (obj.checked === true) {
if (obj.type === 'one' && huancun.indexOf(obj.data.id) === -1) {
huancun.push(obj.data.id);
} else {
for (let i = 0; i < quanju.length; i++) {
if (huancun.indexOf(quanju[i].id) === -1) {
huancun.push(quanju[i].id);
}
}
}
} else {
if (obj.type === 'one') {
for (let i = 0; i < huancun.length; i++) {
if (huancun[i] === obj.data.id) {
removeByValue(huancun, huancun[i]);//调用自定义的根据值移除函数
}
}
} else {
for (let i = 0; i < quanju.length; i++) {
for (let j = 0; j < huancun.length; j++) {
if (huancun[j] === quanju[i].id) {
removeByValue(huancun, +huancun[j]);//调用自定义的根据值移除函数
}
}
}
}
}
});
}
// 数量颜色 1.需要量 2.已发货量 3.待发货量
function setNumColor(value, type) {
let color = "#409Eff";
if (type === 1) {
color = "#409Eff";
} else if (type === 2) {
color = "#19be6b";
} else if (type === 3) {
color = "#f56c6c";
}
return '<span style="color:' + color + '">' + value + "</span>";
}
// 导出
function exportExcel() {
let params = {
'keyWord': $('#keyWord').val(),
'proId': objParam.proId
}
let url = dataUrl + "backstage/export/export";
exportExcelUtil(url, '需求计划', JSON.stringify(params));
}
// 需求计划编号
// 配件类型
function addFitTypeData() {
openIframeByParamObj2("add_fit_type_data", "配件类型", "../../../page/basic/fit_type_list.html", "82%", "90%", {});
openIframeByParamObj2("add_fit_type_data", "配件类型", "../../../page/basic/fit_type_list.html", "92%", "95%", {});
}
function closePage(type) {
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
parent.layer.close(index); // 再执行关闭
if (type == 1) {
window.parent.reloadData();
}
}

View File

@ -15,6 +15,22 @@
padding: 0;
height: 100%;
}
.layui-table-view .layui-table th {
font-size: 18px;
color: #262626;
letter-spacing: 1px;
outline: none !important;
}
.btn-box {
width: 100%;
height: 60px;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
}
</style>
<body>
@ -26,9 +42,21 @@
<form class="layui-form layui-form-pane" action="#" onsubmit="return false;">
<div class="layui-form-item">
<div class="layui-inline">
<div class="layui-input-inline" style="width: 300px;">
<div class="layui-input-inline" style="width: 160px;">
<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 class="layui-inline">
<div class="layui-input-inline" style="width: 160px;">
<input type="text" name="keyWord" id="keyWord" autocomplete="off"
class="layui-input" lay-affix="clear" placeholder="输入配件名称" maxlength="30">
</div>
</div>
<div class="layui-inline">
<div class="layui-input-inline" style="width: 160px;">
<input type="text" name="keyWord" id="keyWord" autocomplete="off"
class="layui-input" lay-affix="clear" placeholder="输入规格型号" maxlength="30">
</div>
</div>
<div class="layui-inline">
@ -50,9 +78,22 @@
<div class="table-box" table-responsive style="z-index: 1;">
<table class="layui-hide" id="currentTableId" lay-filter="currentTableId2"></table>
</div>
<div class="btn-box">
<button class="layui-btn layui-bg-blue save" onclick="saveData2()">确定</button>
<button class="layui-btn layui-btn-primary cancel" onclick="closePage()">取消</button>
</div>
</div>
</div>
</body>
<script type="text/html" id="TPL-select-demo">
{{# var cityList = d.cityList || ["北京","上海","广州","城市-1"]; }}
<select name="city" lay-filter="select-demo" lay-append-to="body" lay-search>
<option value="">select 方式</option>
{{# layui.each(cityList, function(i, v){ }}
<option value="{{= v }}" {{= v === d.city ? 'selected' : '' }}>{{= v }}</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>