//当前节点 入库质检
|
var layer;
|
var form;
|
var table;
|
var page = 1;
|
var limit = 15;
|
var recordData = null;
|
var snapData;//系统抓拍对象信息
|
var timerWeight;
|
var curProgress = 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'
|
});
|
|
// 监听行工具事件
|
table.on('tool(tableData)', function (obj) {
|
if (obj.event === 'edit') {
|
//展示弹窗
|
afreshGetData(obj);
|
}
|
});
|
|
// 初始化表单数据
|
renderTable();
|
});
|
|
// 监听重量变化
|
$(".weight").blur(function () {
|
deAuto(this.name);
|
});
|
});
|
|
window.onload = function () {
|
//自动连接地磅信息,2.5秒获取一次地磅重量信息
|
clearInterval(timerWeight);
|
timerWeight = setInterval(function () {
|
flushWeight();
|
}, 2500);
|
|
// 加载视频
|
initVideo(snapDto1, snapDto2, snapDto3);
|
|
//设置地磅
|
$("#scaleName").val(weightDto.sort);
|
|
//监听地磅选择
|
$("#scaleName").change(function () {
|
layer.confirm('调整地磅需重新加载页面,确定调整?', {
|
btn: ['确定', '取消']
|
}, function () {
|
updateWeight();
|
});
|
});
|
};
|
|
//根据条件查询数据
|
function flushData() {
|
var index = layer.load();
|
var param = form.val("form-param");
|
param.weightTag = "WEIGHT";
|
table.reload('tableData', {
|
url: "/basic/inout/page-inout-data",
|
where: param
|
});
|
$("thead tr").css({
|
"border-bottom": "2px solid #53adce",
|
"background": "#eff4f6"
|
});
|
layer.close(index);
|
}
|
|
// 渲染表单数据
|
function renderTable() {
|
var param = form.val("form-param");
|
param.weightTag = "WEIGHT";
|
// 清空数据
|
$("#tableData").empty();
|
table.render({
|
elem: '#tableData',
|
url: '/basic/inout/page-inout-data',
|
page: true,
|
limit: limit,
|
even: true,
|
method: 'POST',
|
contentType: "application/json;charset=UTF-8",
|
cols: [[{
|
type: 'numbers',
|
title: '序号'
|
}, {
|
field: 'id',
|
title: '单据号',
|
width: '13%',
|
style: 'color: #f67d06;font-weight: bold'
|
}, {
|
field: 'plateNum',
|
title: '车牌',
|
width: '11%',
|
style: 'font-weight: bold'
|
}, {
|
field: 'type',
|
title: '类型',
|
templet: function (item) {
|
var result = item.type;
|
return result == "IN" ? "入库" : "出库";
|
}
|
}, {
|
field: 'customerName',
|
title: '往来单位'
|
}, {
|
field: 'depotId',
|
title: '装卸仓库',
|
width: '10%',
|
templet: function (item) {
|
var result = item.depotId;
|
$.each(listDepot, function (index, data) {
|
if (item.depotId == data.id) {
|
result = data.name;
|
return true;
|
}
|
});
|
return result == null ? "" : result;
|
}
|
}, {
|
field: 'foodVariety',
|
title: '品种',
|
width: '10%',
|
templet: function (item) {
|
var result = item.foodVariety;
|
$.each(listFoodVariety, function (index, data) {
|
if (item.foodVariety == data.dictValue) {
|
result = data.dictLabel;
|
return true;
|
}
|
});
|
return result == null ? "" : result;
|
}
|
}, {
|
field: 'progress',
|
title: '流程进度',
|
width: '10%',
|
style: 'font-weight: bold',
|
templet: function (item) {
|
return INOUT_PROGRESS_MSG(item.progress);
|
}
|
}, {
|
field: '',
|
title: '操作',
|
width: '9%',
|
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"
|
});
|
}
|
|
/**
|
* 称重弹窗重新查询数据
|
* @param obj
|
*/
|
function afreshGetData(obj) {
|
var index = layer.load();
|
recordData = null;
|
var data = obj.data;
|
var param = {
|
type: data.type,
|
progress: data.progress,
|
id: data.id,
|
plateNum: data.plateNum
|
};
|
$.ajax({
|
type: "POST",
|
url: "/basic/inout/inout-query",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(param),
|
success: function (result) {
|
if (result.code != "0000") {
|
layer.alert("请刷新页面后,重新操作!!");
|
} else {
|
recordData = result.data;
|
curProgress = recordData.progress;
|
showWindows();
|
}
|
layer.close(index);
|
},
|
error: function () {
|
layer.close(index);
|
layer.alert("请刷新页面后,重新操作!!");
|
}
|
});
|
}
|
|
/**
|
* 登记弹窗
|
*/
|
function quickRegister() {
|
$("#form-data")[0].reset();
|
form.render();
|
//登记按钮放开
|
$("#btn_register").css("display", "block");
|
$("#text-info").removeClass("text-info");
|
//称重操作弹窗
|
var pro = '登记称重';
|
recordData = null;
|
updateEditAndProgress();
|
flushPage();
|
layer.open({
|
type: 1,
|
title: pro,
|
area: ['1283px', '815px'],
|
cancel: function (index, layero) {
|
$("#weightDetail").css("display", "none");
|
},
|
shade: 0,
|
scrollbar: 0,
|
content: $('#weightDetail'),
|
offset: ['16px', '16px']
|
});
|
}
|
|
/**
|
* 称重弹窗
|
* @param progress
|
*/
|
function showWindows() {
|
$("#form-data")[0].reset();
|
form.render();
|
//登记按钮隐藏
|
$("#btn_register").css("display", "none");
|
$("#text-info").addClass("text-info");
|
//称重操作弹窗
|
var pro = '空车称重';
|
if (curProgress == 'WEIGHT_FULL') {
|
pro = '满车称重';
|
}
|
updateEditAndProgress();
|
flushPage();
|
layer.open({
|
type: 1,
|
title: "称重" + pro + " - 单号:" + recordData.id,
|
area: ['1283px', '815px'],
|
cancel: function (index, layero) {
|
$("#weightDetail").css("display", "none");
|
},
|
shade: 0,
|
scrollbar: 0,
|
content: $('#weightDetail'),
|
offset: ['16px', '16px']
|
});
|
}
|
|
/**
|
* 根据业务数据更新页面中的状态
|
*/
|
function updateEditAndProgress() {
|
//当前流程节点
|
if (curProgress == null) {
|
if (type === "IN") {
|
curProgress = "WEIGHT_FULL";
|
}
|
if (type === "OUT") {
|
curProgress = "WEIGHT_EMPTY";
|
}
|
}
|
//显示当前流程
|
if (type === "IN") {
|
$("#rk-progress-register").addClass("active");
|
if (curProgress === InoutProgress.WEIGHT_FULL) {
|
$("#rk-progress-fullWeight").addClass("active");
|
$("#rk-progress-hand").removeClass("active");
|
$("#rk-progress-emptyWeight").removeClass("active");
|
|
//满车重量可编辑
|
$("#fullWeight").removeClass("rkbk-search-input");
|
$("#fullWeight").attr("disabled", false);
|
|
//空车重量不能编辑
|
$("#emptyWeight").addClass("rkbk-search-input");
|
$("#emptyWeight").attr("disabled", true);
|
}
|
if (curProgress === InoutProgress.WEIGHT_EMPTY) {
|
$("#rk-progress-fullWeight").addClass("active");
|
$("#rk-progress-hand").addClass("active");
|
$("#rk-progress-emptyWeight").addClass("active");
|
|
//满车重量不能编辑
|
$("#fullWeight").addClass("rkbk-search-input");
|
$("#fullWeight").attr("disabled", true);
|
|
//空车重量可编辑
|
$("#emptyWeight").removeClass("rkbk-search-input");
|
$("#emptyWeight").attr("disabled", false);
|
}
|
}
|
if (type === "OUT") {
|
$("#ck-progress-register").addClass("active");
|
if (curProgress === InoutProgress.WEIGHT_EMPTY) {
|
$("#ck-progress-emptyWeight").addClass("active");
|
$("#ck-progress-hand").removeClass("active");
|
$("#ck-progress-fullWeight").removeClass("active");
|
|
//满车重量不能编辑
|
$("#fullWeight").addClass("rkbk-search-input");
|
$("#fullWeight").attr("disabled", true);
|
|
//空车重量可编辑
|
$("#emptyWeight").removeClass("rkbk-search-input");
|
$("#emptyWeight").attr("disabled", false);
|
}
|
if (curProgress === InoutProgress.WEIGHT_FULL) {
|
$("#ck-progress-emptyWeight").addClass("active");
|
$("#ck-progress-hand").addClass("active");
|
$("#ck-progress-fullWeight").addClass("active");
|
|
//满车重量可编辑
|
$("#fullWeight").removeClass("rkbk-search-input");
|
$("#fullWeight").attr("disabled", false);
|
|
//空车重量不能编辑
|
$("#emptyWeight").addClass("rkbk-search-input");
|
$("#emptyWeight").attr("disabled", true);
|
}
|
}
|
//流程显示
|
if (inoutProgress) {
|
if (inoutProgress.indexOf("REGISTER") === -1) {
|
$("#rk-progress-register").css("display", "none");
|
$("#ck-progress-register").css("display", "none");
|
}
|
if (inoutProgress.indexOf("WEIGHT_FULL") === -1) {
|
$("#rk-progress-fullWeight").css("display", "none");
|
$("#ck-progress-fullWeight").css("display", "none");
|
}
|
if (inoutProgress.indexOf("HANDLE") === -1) {
|
$("#rk-progress-hand").css("display", "none");
|
$("#ck-progress-hand").css("display", "none");
|
}
|
if (inoutProgress.indexOf("WEIGHT_EMPTY") === -1) {
|
$("#rk-progress-emptyWeight").css("display", "none");
|
$("#ck-progress-emptyWeight").css("display", "none");
|
}
|
if (inoutProgress.indexOf("CARD_BACK") === -1) {
|
$("#rk-progress-cardBack").css("display", "none");
|
$("#ck-progress-cardBack").css("display", "none");
|
}
|
|
if (type === "IN") {
|
$("#rk_progress").css("display", "block");
|
$("#ck_progress").css("display", "none");
|
}
|
if (type === "OUT") {
|
$("#ck_progress").css("display", "block");
|
$("#rk_progress").css("display", "none");
|
}
|
}
|
//根据配置信息设置地磅是否可编辑
|
if (weightEditTag && weightEditTag == 'N') {
|
$("#fullWeight").addClass("rkbk-search-input");
|
$("#fullWeight").attr("disabled", true);
|
|
$("#emptyWeight").addClass("rkbk-search-input");
|
$("#emptyWeight").attr("disabled", true);
|
}
|
}
|
|
/*-----------------------弹窗显示渲染-结束------------------------------*/
|
|
/*-----------------------称重操作-开始------------------------------*/
|
|
//自动连接地磅信息,2.5秒获取一次地磅重量信息
|
function timerGetWeight() {
|
clearInterval(timerWeight);
|
timerWeight = setInterval(function () {
|
flushWeight();
|
}, 2500);
|
}
|
|
//发送请求获取称重数据
|
function flushWeight() {
|
var ip = "127.0.0.1";
|
if (weightDto.ip) {
|
ip = weightDto.ip;
|
}
|
var port = "9111";
|
if (weightDto.port) {
|
port = weightDto.port;
|
}
|
var sn = "WEIGHT";
|
if (weightDto.sn) {
|
sn = weightDto.sn;
|
}
|
var url = "http://" + ip + ":" + port + "/" + sn;
|
$.ajax({
|
type: "GET",
|
async: true,
|
timeout: 2000,
|
url: url,
|
data: {},
|
dataType: "json",
|
success: function (json) {
|
var data = json.content;
|
if (!data) data = 0.0;
|
weightDto.weight = data;
|
$("#weightValue").text(data);
|
$("#img_scale_statule").attr("src", "/img/web/inout/icon-gree.png");
|
},
|
error: function () {
|
weightDto.weight = 0.0;
|
$("#weightValue").text("0.0");
|
$("#img_scale_statule").attr("src", "/img/web/inout/icon-red.png");
|
}
|
});
|
}
|
|
//点击称重
|
function weight() {
|
// 如果是空车称重
|
if (InoutProgress.WEIGHT_EMPTY === curProgress) {
|
form.val("form-data", {
|
emptyWeight: weightDto.weight
|
});
|
form.render();
|
}
|
// 如果是满车称重
|
if (InoutProgress.WEIGHT_FULL === curProgress) {
|
form.val("form-data", {
|
fullWeight: weightDto.weight
|
});
|
form.render();
|
}
|
|
var data = form.val("form-data");
|
if (!data.plateNum) {
|
alertError("提示:填写登记车牌信息");
|
return;
|
}
|
|
// 点击称重自动调用抓拍
|
snapData = {
|
companyId: companyId,
|
deptId: deptId,
|
progress: curProgress,
|
bizType: type,
|
id1: snapDto1.id,
|
id2: snapDto2.id,
|
id3: snapDto3.id,
|
sort: $("#scaleName").val()
|
};
|
|
//当前AJAX服务为同步服务,返回数据包装照片信息
|
var index = layer.load();
|
$.ajax({
|
sync: false,
|
type: "POST",
|
url: "/inout/api/snap-img",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(snapData),
|
success: function (result) {
|
layer.close(index);
|
if (result.code != "0000") {
|
alertError(result.msg);
|
} else {
|
layer.msg("抓拍成功");
|
snapData = result.data;
|
}
|
},
|
error: function () {
|
layer.close(index);
|
alertError("后台调用截图失败,请重新尝试");
|
}
|
});
|
}
|
|
/**
|
* 点击打印,系统判断是否已经执行完成,如果已经完成,直接打印,如果未完成则先执行完成
|
*/
|
function printBill() {
|
if (!recordData) {
|
alertError("没有获取到业务数据,打印被拒绝!");
|
return;
|
}
|
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: "/basic/print/bill-weight",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(recordData),
|
success: function (result) {
|
layer.close(index);
|
if (result.code != "0000") {
|
alertError(result.msg);
|
} else {
|
layer.msg("开始渲染打印单……");
|
printWeight(result.data);
|
}
|
},
|
error: function () {
|
layer.close(index);
|
alertError("获取打印模版失败,请联系管理员查看原因");
|
}
|
});
|
}
|
/**
|
* 称重提交
|
*/
|
function submit() {
|
|
var data = form.val("form-data");
|
if (!data.depotId) {
|
alertError("提示:装卸仓库必填");
|
return;
|
}
|
if (!data.customerName) {
|
alertError("提示:通知单信息必填");
|
return;
|
}
|
if (!data.foodVariety) {
|
alertError("提示:粮食品种必填");
|
return;
|
}
|
|
// 校验-入库满车称重
|
if (InoutProgress.WEIGHT_FULL === curProgress) {
|
if (data.fullWeight <= 0.0) {
|
alertError("提示:满车称重信息必填");
|
return;
|
}
|
}
|
if (InoutProgress.WEIGHT_EMPTY === curProgress) {
|
if (data.emptyWeight <= 0.0) {
|
alertError("提示:空车称重信息必填");
|
return;
|
}
|
}
|
|
if(recordData){
|
//合并数据
|
Object.assign(recordData, data);
|
}else {
|
recordData = data;
|
}
|
recordData.progress = curProgress;
|
|
// 获取照片
|
var files = [{
|
fileName: snapData.fileName1
|
}, {
|
fileName: snapData.fileName2
|
}, {
|
fileName: snapData.fileName3
|
}];
|
recordData.files = files;
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: "/basic/inout/submit-weight",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(recordData),
|
success: function (result) {
|
if (result.code != "0000") {
|
alertError(result.msg);
|
} else {
|
curProgress = null;
|
clearInterval(timerWeight);
|
notify("数据提交成功", result.data);
|
//第一次称重后,刷新页面
|
if (recordData.recordWeight <= 0.0) {
|
$("#form-data")[0].reset();
|
form.render();
|
}
|
}
|
layer.close(index);
|
},
|
error: function () {
|
layer.close(index);
|
alertError("提交失败,请重新尝试");
|
}
|
});
|
}
|
|
//重新称重时,表单不清空,按钮重置
|
function flushPage() {
|
weightDto.weight = 0.0;
|
$("#weightValue").text("0.0");
|
$("#img_scale_statule").attr("src", "/img/web/inout/icon-red.png");
|
timerGetWeight();
|
|
//表单数据重置
|
form.val("form-data", recordData);
|
form.render();
|
}
|
|
/**
|
* 读取身份证
|
*/
|
function flushIdCard() {
|
var index = layer.load();
|
$.ajax({
|
type: "GET",
|
async: true,
|
url: "http://127.0.0.1:9111/IDCARD",
|
data: {},
|
dataType: "json",
|
success: function (json) {
|
layer.close(index);
|
var data = json;
|
if (data.code === "200" || data.code == 200) {
|
// 临时赋值
|
$("#userName").val(data.cnName);
|
$("#userAddress").val(data.address);
|
$("#userId").val(data.idNum);
|
} else {
|
alertError("没有获取到身份证信息!");
|
return;
|
}
|
},
|
error: function () {
|
layer.alert("身份证读取失败!", {
|
offset: ['300px', '300px']
|
});
|
layer.close(index);
|
}
|
});
|
}
|
|
/**
|
* 读取车牌号
|
*/
|
function flushPlateNum() {
|
var param = JSON.stringify(snapDto1);
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: "/inout/api/get-plateNum",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: param,
|
success: function (result) {
|
if (result.code != "0000") {
|
alertError(result.msg);
|
} else {
|
$("#plateNum").val(result.data.plateNum);
|
}
|
layer.close(index);
|
},
|
error: function () {
|
layer.close(index);
|
alertError("车牌识别失败!");
|
}
|
});
|
}
|
|
/**
|
* 弹出提醒框
|
* @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);
|
|
var indexNotify = 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.close(indexNotify);
|
}
|
});
|
} else {
|
layer.alert(msg, {offset: ['300px', '300px']});
|
}
|
};
|