|
layui.use(['form','table', 'admin', 'ax', 'func'], function () {
|
var $ = layui.$;
|
var table = layui.table;
|
var $ax = layui.ax;
|
var admin = layui.admin;
|
var func = layui.func;
|
var form = layui.form;
|
|
|
/**
|
* 看板配置管理
|
*/
|
var KanbanConf = {
|
tableId: "kanbanConfTable"
|
};
|
|
/**
|
* bom信息管理
|
*/
|
var BomInfo = {
|
tableId: "bomInfoTable"
|
};
|
|
/**
|
* bom信息管理
|
*/
|
var MaterialShortage = {
|
tableId: "materialShortageTable"
|
};
|
|
$(document).ready(function() {
|
console.log("111111111111111111111");
|
$.ajax({
|
type: "POST",
|
contentType: "application/json;charset=UTF-8",
|
url: Feng.ctxPath + '/lineInfo/list',
|
success: function (result) {
|
$('#lineCode').empty();
|
$('#lineCode').append(new Option("请选择产线", ""));// 下拉菜单里添加元素
|
|
$.each(result.data, function (index, value) {
|
$('#lineCode').append(new Option(value.lineCode, value.lineCode));// 下拉菜单里添加元素
|
});
|
layui.form.render("select");//重新渲染 固定写法
|
},
|
});
|
});
|
|
form.on("select", function (data) {
|
if (data.value !== "") {
|
if (data.elem.id === "lineCode") {
|
$.ajax({
|
type: "POST",
|
contentType: "application/json;charset=UTF-8",
|
url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+ $('#lineCode').val(),
|
success: function (result) {
|
$('#locationCode').empty();
|
$('#locationCode').append(new Option("请选择工位", ""));// 下拉菜单里添加元素
|
|
$.each(result.data, function (index, value) {
|
$('#locationCode').append(new Option(value.locationCode, value.locationCode));// 下拉菜单里添加元素
|
});
|
layui.form.render("select");//重新渲染 固定写法
|
},
|
});
|
}
|
if (data.elem.id === "locationCode") {
|
$.ajax({
|
type: "POST",
|
contentType: "application/json;charset=UTF-8",
|
url: Feng.ctxPath + '/scrapCategoryConf/list?locationCode='+ $('#locationCode').val(),
|
success: function (result) {
|
$('#scrapReason').empty();
|
$('#scrapCategory').empty();
|
$.each(result.data, function (index, value) {
|
$('#scrapCategory').append(new Option(value.scrapCategory, value.scrapCategory));// 下拉菜单里添加元素
|
$('#scrapReason').append(new Option(value.scrapReason, value.scrapReason));// 下拉菜单里添加元素
|
});
|
if($('#scrapCategory option').length === 0){
|
Feng.error("该工位没有报废类目配置");
|
}
|
layui.form.render("select");//重新渲染 固定写法
|
},
|
});
|
}
|
}
|
});
|
|
initPageInfo();
|
async function initPageInfo() {
|
await initKanBanConfInfo();//初始化配置信息
|
await initOrderInfo();
|
initBomTable();
|
initMaterialShortage();
|
/* xR();
|
xa();*/
|
}
|
|
function initKanBanConfInfo() {
|
// 根据ip查询配置信息
|
var ajax = new $ax(Feng.ctxPath + "/scrapBoard/qryKBConflist?pageCode=" + 'KB_WLDJ_004');
|
var result = ajax.start();
|
if (result.data.length > 0) {
|
let msg = result.data[0];
|
$('#id').val(msg.id);
|
$('#ipAddress').val(msg.ipAddress);
|
$('#pageCode').val(msg.pageCode);
|
$('#workshopCode').val(msg.workshopCode);
|
$('#lineCode').val(msg.lineCode);
|
$('#locationCode').val(msg.locationCode);
|
|
$('#scrapCategory').val(msg.warehouseCode);
|
$('#scrapReason').val(msg.warehouseName);
|
console.log(msg)
|
|
}
|
}
|
|
function initOrderInfo() {
|
// 根据ip查询配置信息
|
var ajax = new $ax(Feng.ctxPath + "/productionOrdeInfo/list?orderStatus=" + '3');
|
var result = ajax.start();
|
if (result.data.length > 0) {
|
let msg = result.data[0];
|
$('#orderId').val(msg.id);
|
$('#workOrderNo').val(msg.workOrderNo);
|
$('#materialCode').val(msg.materialCode);
|
$('#materialName').val(msg.materialName);
|
$('#planQty').val(msg.planQty);
|
|
$('#custom').val(msg.custom);
|
$('#createTime').val(msg.createTime);
|
$('#actualQty').val(msg.actualQty);
|
$('#planStartTime').val(msg.planStartTime);
|
$('#planEndTime').val(msg.planEndTime);
|
}
|
}
|
|
function initBomTable(){
|
var queryData = {};
|
queryData['loadingCode'] = $("#locationCode").val();
|
// queryData['workOrderNo'] = $("#workOrderNo").val();
|
|
// 渲染表格
|
var tableResult = table.render({
|
elem: '#' + BomInfo.tableId,
|
url: Feng.ctxPath + '/bomInfo/kbListTable',
|
// page: true,
|
// height: 475,
|
height: 435,
|
cellMinWidth: 100,
|
where:queryData,
|
cols: BomInfo.initColumn()
|
});
|
}
|
/**
|
* 物料Bom初始化表格的列
|
*/
|
BomInfo.initColumn = function () {
|
return [[
|
// {type: 'checkbox'},
|
/* {type:"numbers" ,title:'序号',width:40,fixed:'left'},*/
|
{field: 'id', hide: true, title: 'ID'},
|
{field: 'materialCode', sort: true, title: '物料编号'},
|
{field: 'materialName', sort: true, title: '物料名称'},
|
// {field: 'workorderNo', sort: true, title: '工单编号'},
|
// {field: 'productCode', sort: true, title: '产品编号'},
|
{field: 'locationCode', sort: true, title: '工位编号'},
|
{field: 'loadingCode', sort: true, title: '上料工位编号'},
|
// {field: 'state', sort: true, title: '是否扫码'},
|
// {field: 'batchCode', sort: true, title: '批次码'},
|
]];
|
};
|
|
/**
|
* 缺料报警初始化表格的列
|
*/
|
MaterialShortage.initColumn = function () {
|
return [[
|
{field: 'id', hide: true, title: '主键id'},
|
{field: 'workOrderNo', sort: true, title: '生产工单号',minWidth:160},
|
// {field: 'sfcCode', sort: true, title: '总成序列号',minWidth:160},
|
{field: 'lineCode', sort: true, title: '产线编号',minWidth:125},
|
// {field: 'lineName', sort: true, title: '产线名称',minWidth:160},
|
{field: 'locationCode', sort: true, title: '工位编号',minWidth:125},
|
// {field: 'locationName', sort: true, title: '工位名称',minWidth:160},
|
{field: 'scrapCategory', sort: true, title: '报废类目',minWidth:125},
|
{field: 'scrapQuantity', sort: true, title: '报废数量',minWidth:125},
|
{field: 'scrapReason', sort: true, title: '报废原因',minWidth:160},
|
{field: 'operateUser', sort: true, title: '操作用户',minWidth:125},
|
{field: 'createTime', sort: true, title: '报废时间',minWidth:160},
|
]];
|
};
|
|
function initMaterialShortage(){
|
var queryData = {};
|
// queryData['workOrderNo'] = $("#workOrderNo").val();
|
// queryData['loadingCode'] = $("#locationCode").val();
|
|
// 渲染表格
|
var tableResult = table.render({
|
elem: '#' + MaterialShortage.tableId,
|
url: Feng.ctxPath + '/scrapCategoryRecord/list',
|
// page: true,
|
height: 350,
|
cellMinWidth: 80,
|
where:queryData,
|
cols: MaterialShortage.initColumn()
|
});
|
}
|
|
|
// 生产工单设置按钮点击事件
|
$('#orderBtnSet').click(function () {
|
KanbanConf.openOrderEditPage();
|
});
|
|
// 设置按钮点击事件
|
$('#btnSet').click(function () {
|
var id = $("#id").val();
|
if(id == "" || id == undefined){
|
KanbanConf.openAddDlg();
|
}else{
|
KanbanConf.openEditPage(id);
|
}
|
|
});
|
|
$('#enter').click(function (enterNum){
|
if($('#lineCode').val() === null){
|
Feng.error("请选择产线!")
|
return;
|
}
|
if($('#locationCode').val() === null){
|
Feng.error("请选择工位!")
|
return;
|
}
|
if($('#scrapCategory').val() === null){
|
Feng.error("请选择报废类目!")
|
return;
|
}
|
if($('#scrapReason').val() === null){
|
Feng.error("请选择报废原因!")
|
return;
|
}
|
if($('#scrapNumber').val() < 1){
|
Feng.error("请输入数量!")
|
return;
|
}
|
let ajaxEnter = new $ax(Feng.ctxPath + "/scrapCategoryRecord/addItem", function (data) {
|
}, function (data) {
|
Feng.error("添加失败!" + data.responseJSON.message)
|
});
|
ajaxEnter.set("lineCode", $('#lineCode').val());
|
ajaxEnter.set("locationCode", $('#locationCode').val());
|
ajaxEnter.set("scrapCategory", $('#scrapCategory').val());
|
ajaxEnter.set("scrapReason", $('#scrapReason').val());
|
ajaxEnter.set("scrapQuantity", $('#scrapNumber').val());
|
ajaxEnter.set("workOrderNo", $('#workOrderNo').val());
|
ajaxEnter.start();
|
initMaterialShortage();
|
});
|
|
/**
|
* 弹出添加页面设置对话框
|
*/
|
KanbanConf.openAddDlg = function () {
|
console.log("弹出添加页面设置对话框");
|
layer.open({
|
type: 2,
|
area: ['1000px', '600px'],
|
title: '添加看板配置',
|
content: Feng.ctxPath + '/scrapBoard/add',
|
success: function (layero, index) {
|
let body = layer.getChildFrame('body', index);
|
body.find('form').find('#testlineCode').val($('#lineCode').val());
|
body.find('form').find('#testlocationCode').val($('#locationCode').val());
|
body.find('form').find('#testscrapCategory').val($('#scrapCategory').val());
|
body.find('form').find('#testscrapReason').val($('#scrapReason').val());
|
},
|
end: function () {
|
console.log("end")
|
let lineCode = JSON.parse(window.localStorage.getItem('lineCode'));
|
let locationCode = JSON.parse(window.localStorage.getItem('locationCode'));
|
$('#lineCode').val(lineCode);
|
$('#locationCode').val(locationCode);
|
initKanBanConfInfo()
|
}
|
});
|
};
|
|
/**
|
* 弹出编辑页面设置对话框
|
*
|
* @param data 点击按钮时候的行数据
|
*/
|
KanbanConf.openEditPage = function (data) {
|
func.open({
|
title: '添加看板配置',
|
content: Feng.ctxPath + '/materialRegistration/edit?id=' + data,
|
//tableId: KanbanConf.tableId
|
});
|
|
};
|
|
$('#revert').click(function () {
|
window.location.href = Feng.ctxPath + '/badBoard/boardHome'
|
});
|
|
KanbanConf.openOrderEditPage = function (data) {
|
layer.open({
|
type: 2,
|
area: ['1000px', '600px'],
|
title: '工单配置',
|
content: Feng.ctxPath + '/materialRegistration/orderEdit',
|
success: function () {
|
console.log($('#lineCode').val());
|
window.lineCode = $('#lineCode').val();
|
},
|
end: function () {
|
let msg = JSON.parse(window.localStorage.getItem('message'));
|
console.log("选择工单_id", msg.id)
|
$('#orderId').val(msg.id);
|
$('#workOrderNo').val(msg.workOrderNo);
|
$('#materialCode').val(msg.materialCode);
|
$('#materialName').val(msg.materialName);
|
$('#planQty').val(msg.planQty);
|
$('#createTime').val(msg.createTime);
|
$('#actualQty').val(msg.actualQty);
|
initMaterialShortage();
|
}
|
});
|
};
|
});
|