//当前节点 入库登记
|
var layer;
|
var form;
|
var curCheckItems;//当前化验列表
|
var curCheckData = null;// 当前化验数据
|
var table;
|
|
$(function () {
|
layui.use(['layer', 'laydate', 'form', 'table'], function () {
|
var laydate = layui.laydate;
|
layer = layui.layer;
|
form = layui.form;
|
table = layui.table;
|
laydate.render({
|
elem: '#userBirthday'
|
});
|
|
//监听品种
|
layui.form.on('select(select_foodVariety)', function (data) {
|
updateFoodVariety(data.value);
|
});
|
|
//监听化验结果单填写数据,并给出提示结果
|
table.on('edit(tableCheckItem)', function (obj) {
|
getResult(obj);
|
});
|
});
|
|
var rightH = $(".rkbk-left-wrap").height();
|
$(".rkbk-right-wrap").height(rightH);
|
|
$(window).resize(function () {
|
var rightH = $(".rkbk-left-wrap").height();
|
$(".rkbk-right-wrap").height(rightH);
|
});
|
|
// 初始化WebSocket
|
initInoutWS(companyId, bizType, progress, userId);
|
|
});
|
|
|
//根据填写化验数据,给出提醒是否合格
|
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 updateCheckResultTip() {
|
if (!curCheckItems || curCheckItems.length == 0) {
|
return;
|
}
|
var msg;
|
$.each(curCheckItems, function (index, data) {
|
if (!data.remarks) {
|
return true;
|
}
|
if (data.remarks == "不合格") {
|
msg = "不合格";
|
return false;
|
}
|
if (data.remarks == "合格") {
|
msg = "合格";
|
}
|
});
|
if (msg) {
|
$("#check-result-tip").text("检验结果:" + msg);
|
} else {
|
$("#check-result-tip").text("检验结果:合格");
|
}
|
}
|
|
//使用自己插件获取省份证
|
function flushIdCard() {
|
var index = layer.load();
|
$.ajax({
|
type: "GET",
|
async: true,
|
url: "http://127.0.0.1:9111/IDCARD",
|
data: {},
|
dataType: "jsonp",
|
jsonp: "callback",
|
jsonpCallback: "jsonpCallback",
|
success: function (json) {
|
layer.close(index);
|
//console.log(json);
|
var data = json.content;
|
//console.log(data);
|
if (data === "not found") {
|
layer.alert("没有获取到身份证信息!", {
|
offset: ['300px', '300px']
|
});
|
return;
|
}
|
//data = JSON.parse(data);
|
// 临时赋值
|
$("#userName").val(data.cnName);
|
$("#userSex").val(data.sex);
|
$("#userNation").val(data.nation);
|
$("#userAddress").val(data.address);
|
$("#userBirthday").val(data.birthdate);
|
$("#userId").val(data.idNum);
|
//$("#id_img_pers").attr("src",data.Image);
|
},
|
error: function () {
|
layer.alert("身份证读取失败!", {
|
offset: ['300px', '300px']
|
});
|
layer.close(index);
|
}
|
});
|
}
|
|
/**
|
* 弹出化验单信息
|
*/
|
function showCheckDetail() {
|
// 赋值
|
var data = form.val("form-data");
|
data.checkUser = checkUser;
|
form.val("form-detail", data);
|
form.render();
|
|
layer.open({
|
type: 1,
|
title: "化验单明细",
|
area: ['900px', '600px'],
|
shade: 0,
|
content: $('#checkDetail'),
|
btnAlign: 'c',
|
btn: ['确定', '关闭取消'],
|
yes: function () {
|
curCheckData = form.val("form-detail");
|
|
if (null == curCheckData.foodVariety) {
|
notify("请填写粮食品种!");
|
return;
|
}
|
form.val("form-data", {
|
foodVariety: curCheckData.foodVariety
|
});
|
layer.closeAll();
|
},
|
btn2: function () {// 读取化验结果
|
curCheckData = null;
|
curCheckItems = null;
|
layer.closeAll();
|
},
|
closeBtn: 0
|
});
|
|
flushCheckItem(data.foodVariety);
|
}
|
|
//根据选择仓库显示粮食品种
|
function updateFoodVariety(foodVariety) {
|
if (null == foodVariety || "" == foodVariety) return;
|
form.val("form-detail", {
|
foodVariety: foodVariety
|
});
|
form.render();
|
|
flushCheckItem(foodVariety);
|
}
|
|
/**
|
* 重新加载
|
*/
|
function flushCheckItem(foodVariety) {
|
|
curCheckItems = null;
|
$("#check-result-tip").text("检验结果:#");
|
var data = form.val("form-detail");
|
data.companyId = companyId;
|
data.deptId = deptId;
|
data.foodVariety = foodVariety;
|
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: "../../basic/inout/get-check-item",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(data),
|
success: function (result) {
|
if (result.code != "0000") {
|
layer.msg(result.msg);
|
} else {
|
curCheckItems = result.data;
|
// 页面渲染检测项
|
renderTableCheckItem();
|
layer.close(index);
|
}
|
},
|
error: function () {
|
layer.close(index);
|
layer.msg("后台异常,请重试或者联系管理员!!");
|
}
|
});
|
}
|
|
/**
|
* 渲染表格
|
*/
|
function renderTableCheckItem() {
|
// 清空数据
|
$("#tableCheckItem").empty();
|
table.render({
|
elem: '#tableCheckItem',
|
data: curCheckItems,
|
page: false,
|
// skin: 'line',
|
even: true,
|
cols: [[{
|
field: 'standardName',
|
title: '化验项目',
|
align: 'center',
|
width: '20%'
|
}, {
|
field: 'value',
|
title: '化验结果',
|
align: 'center',
|
width: '20%',
|
edit: 'text'
|
}, {
|
field: 'unit',
|
title: '单位',
|
align: 'center',
|
width: '10%'
|
}, {
|
field: 'standardValue',
|
title: '化验标准',
|
align: 'center',
|
width: '15%'
|
}, {
|
field: 'remarks',
|
title: '说 明',
|
align: 'center',
|
edit: 'text'
|
}]]
|
});
|
|
$("thead tr").css({
|
"border-bottom": "2px solid #53adce",
|
"background": "#eff4f6"
|
});
|
}
|
|
// 表单清空
|
function resetForm() {
|
$("#form-data")[0].reset();
|
form.render();
|
|
// 身份证重置
|
$("#id_img_pers").attr("src", "../../static/images/rkbk-photo_03.png");
|
}
|
|
// 当前完成
|
function submit() {
|
var data = form.val("form-data");
|
if (!data.userName) {
|
notify("承运人信息不能为空", null);
|
return;
|
}
|
if (!data.userId) {
|
notify("身份证号不能为空", null);
|
return;
|
}
|
if (!data.plateNum) {
|
notify("车船号不能为空", null);
|
return;
|
}
|
if (!data.customerId) {
|
notify("往来单位不能为空", null);
|
return;
|
}
|
if (!data.foodVariety) {
|
notify("粮食品种不能为空", null);
|
return;
|
}
|
|
data.checkItems = curCheckItems;
|
// 合并更新當前编辑数据
|
Object.assign(data, curCheckData);
|
|
var index = layer.load();
|
|
$.ajax({
|
type: "POST",
|
url: "../../basic/inout/inout-ship-register",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(data),
|
success: function (result) {
|
layer.close(index);
|
if (result.code != "0000") {
|
notify(result.msg, result.data);
|
} else {
|
notify("数据提交成功", result.data);
|
// 重置页面
|
resetForm();
|
}
|
},
|
error: function () {
|
layer.close(index);
|
layer.alert("提交失败,请重新尝试!!");
|
}
|
});
|
}
|
|
|
/**
|
* 弹出提醒框
|
* @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']});
|
}
|
}
|
|
// ---------------------------往来人员操作-开始 -------------------//
|
// 弹出往来单位下拉框
|
function showNotice() {
|
var index = layer.load();
|
var param = {
|
type: type
|
};
|
// 渲染往来单位列表
|
table.render({
|
elem: '#tableNotice',
|
url: '../../basic/inout/list-notice-in',
|
page: false,
|
even: true,
|
method: 'POST',
|
contentType: "application/json;charset=UTF-8",
|
cols: [[{
|
field: 'name',
|
title: '通知单名称',
|
width: '15%'
|
}, {
|
field: 'customerName',
|
title: '发货单位'
|
}, {
|
field: 'foodVarietyName',
|
title: '粮食品种',
|
width: '12%'
|
}, {
|
field: 'year',
|
title: '年份',
|
width: '10%'
|
}, {
|
field: 'depotName',
|
title: "所涉仓库"
|
}, {
|
field: 'contractName',
|
title: '所属合同'
|
}]],
|
where: param,
|
parseData: function (res) {
|
if ("0000" == res.code) {
|
return {
|
"code": "0",
|
"msg": res.msg,
|
"data": res.data
|
}
|
} else {
|
return {
|
"code": "1",
|
"msg": res.msg
|
}
|
}
|
},
|
done: function (res) {
|
layer.close(index);
|
}
|
});
|
|
//双击显示选中数据
|
table.on('rowDouble(tableNotice)', function (obj) {
|
var data = obj.data;
|
form.val("form-data", {
|
customerId: data.customerId,
|
customerName: data.customerName,
|
noticeId: data.id
|
});
|
// 关闭
|
layer.closeAll();
|
});
|
|
// 弹出对话框
|
layer.open({
|
type: 1,
|
title: "入库通知单",
|
area: ['850px', '600px'],
|
shade: 0,
|
content: $('#listNotice'),
|
btn: 0,
|
btn: ['取消'],
|
yes: function () {
|
layer.closeAll();
|
},
|
closeBtn: 0
|
});
|
}
|
|
// ---------------------------粮食产地 -开始 -------------------//
|
// 弹出粮食产地下拉框
|
function showFoodLocation() {
|
var index = layer.load();
|
// 渲染往来单位列表
|
table.render({
|
elem: '#tableFoodLoaction',
|
url: '../../basic/common/page-dicArea',
|
page: false,
|
toolbar: '#toolbarFoodLocaton',
|
even: true,
|
method: 'POST',
|
contentType: "application/json;charset=UTF-8",
|
cols: [[{
|
field: 'code',
|
title: '编码'
|
}, {
|
field: 'simple',
|
title: '简拼'
|
}, {
|
field: 'name',
|
title: '名称',
|
width: '60%'
|
}]],
|
where: {
|
"page": 1,
|
"limit": 100
|
},
|
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
|
}
|
}
|
},
|
done: function (res) {
|
layer.close(index);
|
}
|
});
|
|
//双击显示选中数据
|
table.on('rowDouble(tableFoodLoaction)', function (obj) {
|
var data = obj.data;
|
// 赋值
|
form.val("form-data", {
|
foodLocation: data.name
|
});
|
// 关闭
|
layer.close(index2);
|
});
|
|
// 弹出对话框
|
var index2 = layer.open({
|
type: 1,
|
title: "选择粮产地",
|
area: ['600px', '600px'],
|
shade: 0,
|
content: $('#listFoodLocation'),
|
btn: 0,
|
btn: ['取消'],
|
yes: function () {
|
// 关闭
|
layer.close(index2);
|
},
|
closeBtn: 0
|
});
|
|
}
|
|
// 刷新
|
function flushFoodLocation() {
|
var key = $("#key2").val();
|
table.reload('tableFoodLoaction', {
|
url: "../../basic/common/page-dicArea",
|
where: {
|
key: key
|
},
|
done: function (res) {
|
if (key) {
|
$("#key2").val(key);
|
}
|
}
|
});
|
}
|