|
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 KanbanConf = {
|
tableId: "kanbanConfTable"
|
};
|
|
/**
|
* bom信息管理
|
*/
|
var BomInfo = {
|
tableId: "bomInfoTable"
|
};
|
|
/**
|
* bom信息管理
|
*/
|
var MaterialShortage = {
|
tableId: "materialShortageTable"
|
};
|
|
initPageInfo();
|
async function initPageInfo() {
|
await initKanBanConfInfo();//初始化配置信息
|
await initPoorLine();
|
await initOrderInfo();
|
initBomTable();
|
initMaterialShortage();
|
/* xR();
|
xa();*/
|
}
|
|
function initPoorLine(){
|
$.ajax({
|
type: "POST",
|
contentType: "application/json;charset=UTF-8",
|
url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+ $('#lineCode').val(),
|
success: function (result) {
|
$('#poorLocationCode').empty();
|
$('#poorLocationCode').append(new Option("请选择工位", ""));// 下拉菜单里添加元素
|
|
$.each(result.data, function (index, value) {
|
$('#poorLocationCode').append(new Option(value.locationCode, value.locationCode));// 下拉菜单里添加元素
|
});
|
layui.form.render("select");//重新渲染 固定写法
|
},
|
});
|
}
|
|
function initKanBanConfInfo() {
|
// 根据ip查询配置信息
|
var ajax = new $ax(Feng.ctxPath + "/scrapBoard/qryKBConflist?pageCode=" + 'KB_WLDJ_006');
|
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(sfc) {
|
// 根据ip查询配置信息
|
var ajax = new $ax(Feng.ctxPath + "/repairManageInfo/list?sfc=" + sfc);
|
// var ajax = new $ax(Feng.ctxPath + "/repairManageInfo/list?sfc=222222222");
|
var result = ajax.start();
|
if (result.data.length > 0) {
|
let msg = result.data[0];
|
$('#orderId').val(msg.id);
|
$('#workOrderNo').val(msg.workOrderNo);
|
$('#productName').val(msg.productName);
|
$('#productCode').val(msg.productCode);
|
$('#sfc1').val(msg.sfc);
|
$('#locationCode1').val(msg.locationCode);
|
$('#productionLine1').val(msg.productionLine);
|
$('#poorLocationCode1').val(msg.poorLocationCode);
|
$('#poorContent1').val(msg.poorContent);
|
|
}
|
}
|
|
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: 'barcode', sort: true, title: '扫码条码',width:330},
|
{field: 'locationCode', sort: true, title: '工位'},
|
{field: 'duaDate', sort: true, title: '到期时间'},
|
// {field: 'state', sort: true, title: '状态'},
|
{field: 'createUser', sort: true, title: '更新用户'},
|
{field: 'createTime', sort: true, title: '更新时间'},
|
]];
|
};
|
|
function initMaterialShortage(){
|
var queryData = {};
|
queryData['manageType'] = "2";
|
|
// 渲染表格
|
var tableResult = table.render({
|
elem: '#' + MaterialShortage.tableId,
|
url: Feng.ctxPath + '/greaseManage/list',
|
// page: true,
|
height: 360,
|
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 (){
|
if($('#barcode').val().length===0) {
|
Feng.error("请输入总成编码!")
|
return;
|
}
|
let ajaxEnter = new $ax(Feng.ctxPath + "/greaseBoard/updategreaseManage", function (data) {
|
Feng.success("添加成功!")
|
}, function (data) {
|
Feng.error("添加失败!" + data.responseJSON.message)
|
});
|
ajaxEnter.set("barcode", $('#barcode').val());
|
ajaxEnter.start();
|
initMaterialShortage();
|
});
|
|
/**
|
* 弹出添加页面设置对话框
|
*/
|
KanbanConf.openAddDlg = function () {
|
console.log("弹出添加页面设置对话框");
|
layer.open({
|
type: 2,
|
area: ['1000px', '600px'],
|
title: '添加看板配置',
|
content: Feng.ctxPath + '/reworkAndLaunch/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());
|
},
|
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'
|
});
|
|
var websocket = null;
|
//判断当前浏览器是否支持WebSocket
|
if('WebSocket' in window) {
|
//改成你的地址
|
websocket = new WebSocket('ws://127.0.0.1:8083/websocket/greaseBoard');
|
} else {
|
alert('当前浏览器 Not support websocket')
|
}
|
//接收到消息的回调方法
|
websocket.onmessage = function(event) {
|
$('#barcode').val(event.data);
|
// initOrderInfo(event.data);
|
}
|
|
//连接成功建立的回调方法
|
websocket.onopen = function() {
|
Feng.info("扫码枪连接建立成功")
|
}
|
|
//连接关闭的回调方法
|
websocket.onclose = function() {
|
Feng.info("扫码枪连接已关闭")
|
}
|
|
window.onunload = function(){
|
websocket.close();
|
}
|
|
});
|