//当前节点 入库质检
|
var layer;
|
var form;
|
var table;
|
var page = 1;
|
var limit = 10;
|
var curSampleData = null;// 当前编辑数据
|
var curCheckItems = null;// 当前数据的检查项信息
|
|
$(function () {
|
layui.use(['layer', 'laydate', 'form', 'table'], function () {
|
layer = layui.layer;
|
form = layui.form;
|
table = layui.table;
|
var laydate = layui.laydate;
|
|
laydate.render({
|
elem: '#start',
|
theme: '#7b8e9f',
|
value: startTime
|
});
|
|
laydate.render({
|
elem: '#end',
|
theme: '#7b8e9f',
|
value: endTime
|
});
|
|
laydate.render({
|
elem: '#foodYear',
|
theme: '#7b8e9f',
|
type: 'year',
|
});
|
|
// 初始化表单数据
|
renderTable();
|
|
// 监听行工具事件
|
table.on('tool(tableData)', function (obj) {
|
if (obj.event === 'edit') {
|
//展示数据
|
showDetail(obj);
|
}
|
});
|
|
//监听粮食品种
|
layui.form.on('select(select_foodVariety)', function (data) {
|
updateFoodVariety(data.value);
|
});
|
|
//监听化验结果单填写数据,并给出提示结果
|
table.on('edit(tableCheckItem)', function (obj) {
|
getResult(obj);
|
});
|
});
|
|
//显示入库流程
|
showProgress();
|
|
// 初始化WebSocket
|
initInoutWS(deptId, bizType, progress, userId);
|
});
|
|
|
// socket信息返回處理
|
function socketOnMessage(packet) {
|
layer.alert(packet.data);
|
window.parent.sysNotify(packet.data);
|
}
|
|
/**
|
* 条件查询
|
*/
|
function flushData() {
|
var index = layer.load();
|
var param = form.val("form-param");
|
|
table.reload('tableData', {
|
url: "../../basic/inout/page-sample-data",
|
where: param
|
});
|
|
$("thead tr").css({
|
"border-bottom": "2px solid #53adce",
|
"background": "#eff4f6"
|
});
|
layer.close(index);
|
}
|
|
/**
|
* 渲染表单数据
|
*/
|
function renderTable() {
|
var param = form.val("form-param");
|
// 清空数据
|
$("#tableData").empty();
|
table.render({
|
elem: '#tableData',
|
url: '../../basic/inout/page-sample-data',
|
page: true,
|
limit: limit,
|
even: true,
|
method: 'POST',
|
contentType: "application/json;charset=UTF-8",
|
cols: [[{
|
field: 'checkId',
|
title: '质检单号',
|
style: 'color: #f67d06;font-weight: bold'
|
}, {
|
field: 'plateNum',
|
title: '车船号',
|
width: '15%',
|
style: 'font-weight: bold'
|
}, {
|
field: 'registerTime',
|
title: '登记时间',
|
width: '15%'
|
}, {
|
field: 'sampleUser',
|
title: '扦样人',
|
width: '15%'
|
}, {
|
field: 'sampleTime',
|
title: '扦样时间',
|
width: '15%'
|
}, {
|
field: 'sampleType',
|
title: '扦样类型',
|
width: '10%',
|
templet: function (item) {
|
if (item.sampleType == null) {
|
return "其他";
|
}
|
if (item.sampleType == '0') {
|
return "人工";
|
}
|
if (item.sampleType == '1') {
|
return "自动";
|
}
|
if (item.sampleType == '2') {
|
return "智能随机";
|
}
|
}
|
}, {
|
field: 'sampleStatus',
|
title: '是否扦样',
|
width: '10%',
|
templet: function (item) {
|
if (item.sampleStatus == null) {
|
return "未扦样";
|
}
|
if (item.sampleStatus == 'NONE') {
|
return "未扦样";
|
}
|
if (item.sampleStatus == 'SAMPLE') {
|
return "已扦样";
|
}
|
}
|
}, {
|
field: '',
|
title: '操作',
|
width: '10%',
|
toolbar: "#barControl"
|
}]],
|
where: param,
|
parseData: function (res) {
|
if ("0000" == res.code) {
|
return {
|
"code": "0",
|
"msg": res.msg,
|
"count": res.data.total,
|
"data": res.data.records
|
}
|
} else {
|
return {
|
"code": "1",
|
"msg": res.msg
|
}
|
}
|
}
|
});
|
$("thead tr").css({
|
"border-bottom": "2px solid #53adce",
|
"background": "#eff4f6"
|
});
|
}
|
|
// 表单清空
|
function resetForm() {
|
$("#form-param")[0].reset();
|
form.render();
|
};
|
|
//根据填写化验数据,给出提醒是否合格
|
function getResult(obj) {
|
var data = obj.data;
|
//填写的数据值
|
var newValue = data.value;
|
//标准值
|
var limit = data.upperLimit;
|
//运算符
|
var symbol = data.operaSymbol;
|
|
if (symbol && limit) {
|
if (">=" == symbol) {
|
if (newValue < limit) {
|
data.remarks = "不合格";
|
} else {
|
data.remarks = "合格";
|
}
|
}
|
if ("<=" == symbol) {
|
if (newValue > limit) {
|
data.remarks = "不合格";
|
} else {
|
data.remarks = "合格";
|
}
|
}
|
if ("==" == symbol) {
|
if (newValue != limit) {
|
data.remarks = "不合格";
|
} else {
|
data.remarks = "合格";
|
}
|
}
|
}
|
obj.update(data);
|
//根据化验结果提醒是否合格
|
updateCheckResultTip();
|
}
|
|
//根据选择仓库显示粮食品种
|
function updateFoodVariety(foodVariety) {
|
if (null == foodVariety || "" == foodVariety) return;
|
form.val("form-detail", {
|
foodVariety: foodVariety
|
});
|
form.render();
|
|
flushCheckItem(foodVariety);
|
}
|
|
|
// 根据模式启动开始扦样
|
function checkExe(type) {
|
checkDto.type = type;
|
var param = JSON.stringify(checkDto);
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: "../../api/check/check-exe",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: param,
|
success: function (result) {
|
layer.close(index);
|
if (result.code != "0000") {
|
layer.alert(result.msg);
|
} else {
|
layer.msg("操作命令发送成功!");
|
}
|
},
|
error: function () {
|
layer.close(index);
|
layer.alert("后台异常,操作命令发送失败!");
|
}
|
});
|
};
|
|
// 关闭扦样机器
|
function checkStop() {
|
var param = JSON.stringify(checkDto);
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: "../../api/check/stop",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: param,
|
success: function (result) {
|
layer.close(index);
|
if (result.code != "0000") {
|
layer.alert(result.msg);
|
} else {
|
layer.msg("操作命令发送成功!");
|
}
|
},
|
error: function () {
|
layer.close(index);
|
layer.alert("后台异常,操作命令发送失败!");
|
}
|
});
|
};
|
|
// 扦样机复位
|
function checkReset() {
|
var param = JSON.stringify(checkDto);
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: "../../api/check/reset",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: param,
|
success: function (result) {
|
layer.close(index);
|
if (result.code != "0000") {
|
layer.alert(result.msg);
|
} else {
|
layer.msg("操作命令发送成功!");
|
}
|
},
|
error: function () {
|
layer.close(index);
|
layer.alert("后台异常,操作命令发送失败!");
|
}
|
});
|
}
|
|
// 扦样机解除急停
|
function checkResetStop() {
|
var param = JSON.stringify(checkDto);
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: "../../api/check/reset-stop",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: param,
|
success: function (result) {
|
layer.close(index);
|
if (result.code != "0000") {
|
layer.alert(result.msg);
|
} else {
|
layer.msg("操作命令发送成功!");
|
}
|
},
|
error: function () {
|
layer.close(index);
|
layer.alert("后台异常,操作命令发送失败!");
|
}
|
});
|
}
|
|
//隐藏信息--替换为*
|
function replaceStr(str) {
|
if (!str) {
|
return "";
|
}
|
var split = str.split("");
|
|
if (split.length == 1) {
|
return "*";
|
}
|
if (split.length == 2 || split.length == 3) {
|
return str.slice(0, 1) + "**"
|
}
|
return str.slice(0, 1) + "***" + str.slice(split.length - 1);
|
}
|
|
function showDetail(obj) {
|
curSampleData = obj.data;
|
|
// 赋值
|
form.val("form-detail", curSampleData);
|
form.render();
|
|
layer.open({
|
type: 1,
|
title: "扦样信息",
|
area: ['900px', '400px'],
|
shade: 0,
|
content: $('#checkDetail'),
|
btnAlign: 'c',
|
btn: ['保存提交', '关闭取消'],
|
yes: function () {
|
// 更新到页面
|
var data = form.val("form-detail");
|
obj.update(data);
|
// 合并更新當前编辑数据
|
Object.assign(curSampleData, data);
|
|
submit();
|
}, btn2: function () {
|
layer.closeAll();
|
},
|
closeBtn: 0
|
});
|
}
|
|
// 当前完成
|
function submit() {
|
|
if (!curSampleData.sampleUser) {
|
layer.alert("请输入扦样人!!");
|
return;
|
}
|
if (!curSampleData.sampleTime) {
|
layer.alert("请输入扦样时间!!");
|
return;
|
}
|
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: "../../basic/inout/update-sample",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(curSampleData),
|
success: function (result) {
|
if (result.code != "0000") {
|
layer.close(index);
|
notify(result.msg, result.data);
|
} else {
|
layer.closeAll();
|
curSampleData = null;
|
notify("数据提交成功", result.data);
|
flushData();
|
}
|
},
|
error: function () {
|
layer.close(index);
|
layer.alert("提交失败,请重新尝试!");
|
}
|
});
|
}
|
|
//控制流程环节显示
|
function showProgress() {
|
if (!inoutProgress) {
|
return;
|
}
|
if (inoutProgress.indexOf("REGISTER") == -1) {
|
$("#progress-register").css("display", "none");
|
}
|
if (inoutProgress.indexOf("CHECK") == -1) {
|
$("#progress-check").css("display", "none");
|
}
|
if (inoutProgress.indexOf("WEIGHT_FULL") == -1) {
|
$("#progress-fullWeight").css("display", "none");
|
}
|
if (inoutProgress.indexOf("HANDLE") == -1) {
|
$("#progress-hand").css("display", "none");
|
}
|
if (inoutProgress.indexOf("WEIGHT_EMPTY") == -1) {
|
$("#progress-emptyWeight").css("display", "none");
|
}
|
if (inoutProgress.indexOf("CARD_BACK") == -1) {
|
$("#progress-cardBack").css("display", "none");
|
}
|
}
|
|
/**
|
* 弹出提醒框
|
* @param msg 提醒信息
|
* @param data 数据信息,可能为空
|
*/
|
function notify(msg, data) {
|
if (data) {
|
//赋值
|
$("#resultMsg").text(msg);
|
$("#resultUserName").text(data.userName);
|
$("#resultPlateNum").text(data.plateNum);
|
if ("IN" == data.type) {
|
$("#resultType").text("入库-" + INOUT_PROGRESS_MSG(data.progress));
|
} else {
|
$("#resultType").text("出库-" + INOUT_PROGRESS_MSG(data.progress));
|
}
|
$("#resultIntelCard").text(data.intelCard);
|
|
layer.open({
|
type: 1,
|
offset: ['150px', '200px'],
|
area: '450px;',
|
shade: 0.8,
|
id: 'dialog_notify_info',
|
btn: ['确定'],
|
content: $('#dialog-from-notify'),
|
yes: function (index) {
|
layer.closeAll();
|
}
|
});
|
} else {
|
layer.alert(msg, {offset: ['300px', '300px']});
|
}
|
}
|