|
layui.use(['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 initOrderInfo();
|
initBomTable();
|
initMaterialShortage();
|
/* xR();
|
xa();*/
|
}
|
|
$('#revert').click(function () {
|
window.location.href = Feng.ctxPath + '/badBoard/boardHome'
|
});
|
|
function initKanBanConfInfo() {
|
// 根据ip查询配置信息
|
var ajax = new $ax(Feng.ctxPath + "/lineFeedingView/qryKBConflist?pageCode=" + 'KB_WLDJ_007');
|
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);
|
}
|
}
|
|
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(){
|
checkTable();
|
var queryData = {};
|
console.log($("#locationCode").val());
|
console.log($("#materialCode").val());
|
|
queryData['locationCode'] = $("#locationCode").val();
|
queryData['productCode'] = $("#materialCode").val();
|
queryData['stepSortFlag'] = "1";
|
|
// 渲染表格
|
var tableResult = table.render({
|
elem: '#' + BomInfo.tableId,
|
url: Feng.ctxPath + '/recipeManage/list',
|
// page: true,
|
// height: 475,
|
height: 530,
|
cellMinWidth: 100,
|
where:queryData,
|
cols: BomInfo.initColumn()
|
});
|
}
|
|
function checkTable(){
|
setTimeout(function() {
|
if($('#locationCode').val().length===null||$('#locationCode').val() === ""){
|
Feng.error("请选择工位!")
|
return;
|
}
|
if($('#materialCode').val().length===null||$('#materialCode').val() === ""){
|
Feng.error("请选择生产工单!")
|
return;
|
}
|
}, 2000);
|
}
|
|
|
|
/**
|
* 物料Bom初始化表格的列
|
*/
|
BomInfo.initColumn = function () {
|
return [[
|
{type:"numbers" ,title:'工步',width:40,fixed:'left'},
|
{field: 'id', hide: true, title: 'id'},
|
{field: 'operationSteps', sort: true, title: '操作内容', width: 210},
|
{field: 'spareField1', sort: true, title: '物料条码'},
|
{field: 'spareField2', sort: true, title: '数据', width: 200},
|
{field: 'spareField3', sort: true, title: '结果', width: 100},
|
{fixed: 'right', title:'操作', toolbar: '#barDemo', width: 70}
|
|
]];
|
};
|
|
/**
|
* 缺料报警初始化表格的列
|
*/
|
MaterialShortage.initColumn = function () {
|
return [[
|
{type: 'checkbox'},
|
{field: 'id', hide: true, title: 'ID'},
|
{field: 'workOrderNo', sort: true, title: '工单号', width: 165},
|
{field: 'productCode', sort: true, title: '产品编码'},
|
{field: 'materialCode', sort: true, title: '物料编号'},
|
{field: 'locationCode', sort: true, title: '工位编号', width: 105},
|
{field: 'lineCode', sort: true, title: '产线编号', width: 105},
|
]];
|
};
|
|
function initMaterialShortage(){
|
var queryData = {};
|
queryData['workOrderNo'] = $("#workOrderNo").val();
|
// 渲染表格
|
var tableResult = table.render({
|
elem: '#' + MaterialShortage.tableId,
|
url: Feng.ctxPath + '/materialTraceability/viewList',
|
page: true,
|
height: 257,
|
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);
|
}
|
|
});
|
|
/**
|
* 弹出添加页面设置对话框
|
*/
|
KanbanConf.openAddDlg = function () {
|
layer.open({
|
type: 2,
|
area: ['1000px', '600px'],
|
title: '添加看板配置',
|
content: Feng.ctxPath + '/lineFeedingView/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('#pageCode').val("KB_WLDJ_007");
|
},
|
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 + '/lineFeedingView/edit?id=' + data,
|
//tableId: KanbanConf.tableId
|
});
|
|
};
|
|
KanbanConf.openOrderEditPage = function (data) {
|
layer.open({
|
type: 2,
|
area: ['1000px', '600px'],
|
title: '工单配置',
|
content: Feng.ctxPath + '/lineFeedingView/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();
|
}
|
});
|
};
|
|
$('#btnClean').click(function (){
|
$('#barCode').val("");
|
});
|
|
$('#finish').click(function (){
|
var ajax = new $ax(Feng.ctxPath + "/recipeManage/finish?locationCode=" + $('#locationCode').val()+"&productCode="+$('#materialCode').val());
|
ajax.set("workOrderNo",$('#workOrderNo').val());
|
ajax.set("lineCode",$('#lineCode').val());
|
var result = ajax.start();
|
console.log("---------------"+result.data)
|
if(result.data === 0){
|
initBomTable();
|
Feng.success("已完成!");
|
}else if(result.data === 980){
|
Feng.error("未加载配方列表!");
|
|
}else {
|
Feng.error("请录入完整数据!");
|
}
|
|
});
|
|
$('#heavyLoad').click(function (){
|
checkTable();
|
var ajax = new $ax(Feng.ctxPath + "/recipeManage/heavyLoad?locationCode=" + $('#locationCode').val()+"&productCode="+$('#materialCode').val());
|
var result = ajax.start();
|
Feng.success("重载完成!");
|
initBomTable();
|
});
|
|
var ip = "";
|
$(document).ready(function () {
|
console.log($('#locationCode').val());
|
var ajax = new $ax(Feng.ctxPath + "/scannerConfig/getOneByLocationCode?locationCode=" + $('#locationCode').val());
|
var result = ajax.start();
|
console.log(result.data);
|
ip = result.data.ipAddress;
|
});
|
|
var websocket = null;
|
//判断当前浏览器是否支持WebSocket
|
if('WebSocket' in window) {
|
//改成你的地址
|
// websocket = new WebSocket('ws://'+ip+':8083/websocket/lineFeedingView');
|
websocket = new WebSocket('ws://127.0.0.1:8083/websocket/recipeManageView');
|
} else {
|
alert('当前浏览器 Not support websocket')
|
}
|
//接收到消息的回调方法
|
websocket.onmessage = function(event) {
|
console.log(event);
|
console.log(event.data)
|
$('#barCode').val(event.data);
|
var ajax = new $ax(Feng.ctxPath + "/recipeManage/editItemView?locationCode=" + $('#locationCode').val()+"&productCode="+$('#materialCode').val()+"&soketData="+event.data);
|
var result = ajax.start();
|
console.log(result.data);
|
if(result.data!==null&&result.data!==""){
|
Feng.info(result.data);
|
}
|
initBomTable();
|
|
}
|
|
//连接成功建立的回调方法
|
websocket.onopen = function() {
|
Feng.info("扫码枪连接建立成功")
|
}
|
|
//连接关闭的回调方法
|
websocket.onclose = function() {
|
Feng.info("扫码枪连接已关闭")
|
}
|
|
window.onunload = function(){
|
websocket.close();
|
}
|
|
table.on('tool(bomInfoTable)', function(obj){ // 双击 toolDouble
|
var data = obj.data;
|
if(obj.event === 'del'){
|
layer.confirm('真的删除行么', function(index){
|
obj.del();
|
layer.close(index);
|
console.log(data);
|
singleRowDelete(data);
|
});
|
}
|
});
|
|
function singleRowDelete(data){
|
console.log("id"+data.id);
|
var ajax = new $ax(Feng.ctxPath + "/recipeManage/singleRowDelete?id=" + data.id);
|
var result = ajax.start();
|
initBomTable();
|
}
|
|
});
|