<!DOCTYPE html>
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<title>组托模块</title>
|
<meta name="renderer" content="webkit">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
|
<script src="../../../layuiadmin/layui/layui.js"></script>
|
<script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
|
<script src="../../../layuiadmin/PubCustom.js"></script>
|
<script src="../../../layuiadmin/MESLanguage.js"></script>
|
<script src="../../../layuiadmin/Scripts/webConfig.js"></script>
|
<style>
|
.layui-form-item .layui-inline {
|
margin-right: 0;
|
}
|
|
html {
|
background-color: white;
|
color: white;
|
}
|
|
.bottom-btn {
|
position: fixed;
|
bottom: 0;
|
left: 0;
|
right: 0;
|
background: white;
|
padding: 15px;
|
border-top: 1px solid #e6e6e6;
|
text-align: right;
|
z-index: 1000;
|
}
|
|
.btn-a {
|
background-color: #3A78FF;
|
color: #fff;
|
border: none;
|
}
|
|
.btn-c {
|
background-color: #acacac;
|
color: #fff;
|
border: none;
|
}
|
|
.btn-d {
|
background-color: #ff8901;
|
color: #fff;
|
border: none;
|
}
|
|
.result-modal {
|
position: fixed;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 100%;
|
z-index: 9999;
|
}
|
|
.modal-mask {
|
position: absolute;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 100%;
|
background: rgba(0, 0, 0, 0.5);
|
}
|
|
.modal-content {
|
position: absolute;
|
top: 50%;
|
left: 50%;
|
transform: translate(-50%, -50%);
|
width: 90%;
|
max-width: 800px;
|
background: #fff;
|
border-radius: 4px;
|
overflow: hidden;
|
}
|
|
.modal-header {
|
padding: 15px;
|
border-bottom: 1px solid #eee;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
}
|
|
.modal-body {
|
padding: 15px;
|
max-height: 60vh;
|
overflow-y: auto;
|
}
|
|
.modal-footer {
|
padding: 15px;
|
border-top: 1px solid #eee;
|
display: flex;
|
align-items: center;
|
}
|
|
.form-container {
|
padding-bottom: 80px;
|
}
|
|
.layui-table {
|
width: 100%;
|
}
|
|
.layui-tab-content {
|
min-height: 400px;
|
}
|
|
.layui-form-checkbox[lay-skin=primary] span {
|
padding-left: 28px;
|
}
|
|
.layui-form-checkbox[lay-skin=primary] i {
|
left: 0;
|
}
|
</style>
|
</head>
|
|
<body>
|
<div class="layui-fluid" style="padding: 0;">
|
<div class="layui-card" style="padding: 2px;background-color: #efefef;">
|
<div class="layui-card-body" style="padding: 1px;">
|
<div class="layui-card-header">
|
<div class="layui-btn-group">
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-radius" id="btnAddNew">新增</button>
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-radius" id="btnExit">退出</button>
|
</div>
|
</div>
|
<div class="form-container">
|
<div class="layui-form" action="" lay-filter="formData" style="background-color:white;">
|
<div class="layui-form-item" style="padding-top: 10px;">
|
<div class="layui-row">
|
<div class="layui-col-xs4 layui-inline">
|
<h1 style="text-align:center;"><b>扫码组托</b></h1>
|
</div>
|
<div class="layui-col-xs4 layui-inline">
|
<label class="layui-form-label"><span style="color:red;">*</span>条码</label>
|
<div class="layui-input-inline">
|
<input type="text" name="HBarCode" id="HBarCode" placeholder="请键入后回车" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<div class="layui-tab" lay-filter="tab-PackUnionBill">
|
<ul class="layui-tab-title" lay-filter="tab-all">
|
<li lay-id="1" style="padding:1px;" class="layui-this">装箱信息</li>
|
<li lay-id="2" style="padding:1px;">单据信息</li>
|
</ul>
|
<div class="layui-tab-content">
|
<div class="layui-tab-item layui-show">
|
<table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
|
</div>
|
|
|
<div class="layui-tab-item">
|
<div class="layui-form-item">
|
<div class="layui-row">
|
<div class="layui-col-xs4 layui-inline">
|
<label class="layui-form-label">单据日期</label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" name="HDate" id="HDate" readonly>
|
</div>
|
</div>
|
<div class="layui-col-xs4 layui-inline">
|
<label class="layui-form-label">制单人</label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" name="HMaker" id="HMaker" readonly>
|
</div>
|
</div>
|
<div class="layui-col-xs4 layui-inline">
|
<label class="layui-form-label">单据号</label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" name="HBillNo" id="HBillNo" readonly>
|
</div>
|
</div>
|
</div>
|
<div class="layui-row">
|
<div class="layui-col-xs4 layui-inline">
|
<label class="layui-form-label">单据ID</label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" name="HInterID" id="HInterID" readonly>
|
</div>
|
</div>
|
<div class="layui-col-xs4 layui-inline">
|
<label class="layui-form-label">组织</label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" name="HStockOrgName" id="HStockOrgName" readonly>
|
</div>
|
</div>
|
<div class="layui-col-xs4 layui-inline">
|
<label class="layui-form-label">质量审批</label>
|
<div class="layui-input-inline">
|
<input type="checkbox" name="HQualityApproval" id="HQualityApproval" lay-skin="primary" title="质量审批">
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<div class="bottom-btn">
|
<button type="button" class="layui-btn btn-a" id="btnSubmit">提交</button>
|
<button type="button" class="layui-btn btn-d" id="btnDelete">删除</button>
|
<button type="button" class="layui-btn btn-c" id="btnExit2">退出</button>
|
</div>
|
|
<div class="result-modal" id="resultModal" style="display: none;">
|
<div class="modal-mask" id="modalMask"></div>
|
<div class="modal-content">
|
<div class="modal-header">
|
<span class="modal-title">装箱结果</span>
|
<i class="layui-icon layui-icon-close" id="closeModal" style="cursor:pointer;"></i>
|
</div>
|
<div class="modal-body">
|
<table class="layui-hide" id="resultTable" lay-filter="resultTable"></table>
|
</div>
|
<div class="modal-footer">
|
<button type="button" class="layui-btn btn-a" id="btnAddNew2">新增</button>
|
<div style="flex: 1;"></div>
|
<button type="button" class="layui-btn btn-c" id="closeModal2">关闭</button>
|
<button type="button" class="layui-btn btn-d" id="btnPrint">打印</button>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<script>
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index' //主入口模块
|
}).use(['index', 'form', 'laydate', 'table', 'element'], function () {
|
var $ = layui.$
|
, admin = layui.admin
|
, layer = layui.layer
|
, table = layui.table
|
, form = layui.form
|
, element = layui.element;
|
|
// 公共变量
|
var EnableSubmit = true;
|
var HBarCode = '';
|
var tabs = 0;
|
var HBillType = '3783';
|
var HBillSubType = '1';
|
var OperationType = 1;
|
var HMaterNumber_Pack = "";
|
var listData = [];
|
var selectedRows = [];
|
var HModName = "Sc_PackUnionBill_Packing_PDA";
|
var ModRightName = "CE_PackUnionBill_Packing";
|
var titleData = [];
|
var OperationType = 1;
|
var HBarCode_Pack_Temp = "";
|
var tableHeight = 400;
|
|
// 表单提交值
|
var hform = {
|
HBarCode_middle:[],
|
HDate: getCurrentDate(),
|
HMaker: sessionStorage["Czybm"],
|
HInterID: '',
|
HStockOrgName: sessionStorage["Organization"],
|
HStockOrgID: '1',
|
HQualityApproval: false,
|
HMainID: '',
|
HSubID: '',
|
HSourceBillSEQ: '',
|
HBillNo: '',
|
HMaterNumber: '',
|
HMaterID: '',
|
HMaterName: '',
|
HMaterModel: '',
|
HCusModel: '',
|
HCusMaterName: '',
|
HEmpID: '001',
|
HEmpNumber: '001',
|
HEmpName: 'admin',
|
HGroupID: 0,
|
HGroupNumber: '',
|
HGroupName: '',
|
HMTONo: '',
|
HCheckEmpName: '',
|
HExpiryDate: getCurrentDate(),
|
HExpirationDateFlag: 0,
|
HRemark: '',
|
HCoilNO: '',
|
HFurnaceNO: '',
|
HFactory: '',
|
HAuxQty: 0,
|
HheatNO: '',
|
HProduceDate: getCurrentDate(),
|
HSPID: 0,
|
HSPCode: '',
|
HSPName: '',
|
HWHID: 0,
|
HWHCode: '',
|
HWHName: '',
|
HQtyMust: 0,
|
HQty: 1,
|
HBQty: 1,
|
HMinQty: 1,
|
HPackQty: 0,
|
HPrice: 0,
|
HMoney: 0,
|
HUseLife: 0,
|
HLeaveLife: 0,
|
HDesignLife: 0,
|
};
|
function init() {
|
form.val('formData', hform);
|
getMaxNo();
|
initTable();
|
initResultTable();
|
calculateTableHeight();
|
bindEvents();
|
}
|
|
function getCurrentDate() {
|
var now = new Date();
|
var year = now.getFullYear();
|
var month = (now.getMonth() + 1).toString().padStart(2, '0');
|
var day = now.getDate().toString().padStart(2, '0');
|
return year + '-' + month + '-' + day;
|
}
|
|
// 获取最大单据号
|
function getMaxNo() {
|
$.ajax({
|
url: GetWEBURL() + "/WEBSController/GetMaxBillNoAndID_Json",
|
type: "GET",
|
data: { "HBillType": HBillType },
|
success: function (d) {
|
var data = d.data[0];
|
if (d.count == 1) {
|
hform.HInterID = data.HInterID;
|
hform.HBillNo = data.HBillNo;
|
form.val('formData', hform);
|
} else {
|
layer.alert(d.Message || '获取单据号失败', { icon: 5 });
|
}
|
},
|
error: function () {
|
layer.alert('获取单据号失败,请检查网络连接', { icon: 5 });
|
}
|
});
|
}
|
function initTable() {
|
table.render({
|
elem: '#mainTable',
|
height: tableHeight,
|
cols: [[
|
{ type: 'checkbox', fixed: 'left' },
|
{ type: 'numbers', field: '序号', title: '序号', totalRow: true },
|
{ field: '条码编号', title: '条码编号', width: 120 },
|
{ field: '数量', title: '数量', width: 100 },
|
{ field: '物料代码', title: '物料代码', width: 120 },
|
{ field: '物料名称', title: '物料名称', width: 120 },
|
{ field: '条码个数', title: '条码个数', width: 100 },
|
{ field: 'HInterID', title: 'HInterID', width: 100, hide: true }
|
]],
|
data: listData,
|
page: false
|
});
|
}
|
|
function initResultTable() {
|
table.render({
|
elem: '#resultTable',
|
cols: [[
|
{ field: 'hmainid', title: 'hmainid', width: 120, hide: true },
|
{ field: '栈板码', title: '栈板码', width: 120 },
|
{ field: '中箱码', title: '中箱码', width: 120 },
|
{ field: '日期', title: '日期', width: 100 },
|
{ field: '物料', title: '物料', width: 100 }
|
]],
|
data: [],
|
page: false
|
});
|
}
|
|
function calculateTableHeight() {
|
var windowHeight = $(window).height();
|
var otherElementsHeight = 300; // 估算其他元素的高度
|
tableHeight = windowHeight - otherElementsHeight;
|
table.resize('mainTable');
|
}
|
|
function bindEvents() {
|
$('#HBarCode').on('keydown', function (e) {
|
if (e.keyCode === 13) {
|
GetMeesageByBarCode();
|
}
|
});
|
|
$('#btnSubmit').on('click', function () {
|
cmdSubmit();
|
});
|
|
$('#btnDelete').on('click', function () {
|
cmdDelete();
|
});
|
|
$('#btnPrint').on('click', function () {
|
var resultTableData = table.cache['resultTable'];
|
|
if (resultTableData.length > 0) {
|
var rows = '';
|
for (var i = 0; i < resultTableData.length; i++) {
|
if (resultTableData[i]['hmainid']) {
|
rows += resultTableData[i]['hmainid'] + ',';
|
}
|
}
|
if (rows.length > 0) {
|
rows = rows.substring(0, rows.length - 1);
|
}
|
layer.open({
|
type: 2
|
, area: ['40%', '80%']
|
, title: '打印模版选择'
|
, shade: 0.6 //遮罩透明度
|
, maxmin: false //允许全屏最小化
|
, anim: 0 //0-6的动画形式,-1不开启
|
, content: ['../../BaseSet/SRM_OpenTmpList.html?linterid=' + rows + '&MyMsg=' + rows + '&Type=HGy_BarCodeBill_xiaowei', 'yes']
|
, resize: false
|
})
|
}
|
else {
|
layer.msg(get_MessageError('[0000-1-016]请选择数据打印!', sessionStorage["HTranSlate"]));
|
}
|
});
|
|
$('#btnAddNew').on('click', function () {
|
toAddNew();
|
});
|
|
$('#btnAddNew2').on('click', function () {
|
toAddNew();
|
});
|
|
$('#btnExit, #btnExit2').on('click', function () {
|
cmdExit();
|
});
|
|
$('#closeModal, #closeModal2, #modalMask').on('click', function () {
|
closeResultTable();
|
});
|
|
$(window).on('resize', function () {
|
calculateTableHeight();
|
});
|
}
|
|
// 获取条码信息
|
function GetMeesageByBarCode() {
|
var sBarCode = $('#HBarCode').val();
|
if (!sBarCode) {
|
layer.msg('条码不能为空,请扫描条码!', { icon: 2 });
|
return;
|
}
|
hform.HBarCode_middle.push(sBarCode);
|
console.log(hform.HBarCode_middle)
|
// 如果已有条码数据(不是第一条)
|
if (listData.length > 0) {
|
// 获取当前条码的后9-10位(从后往前数第9和第8位)
|
if (sBarCode.length >= 10) {
|
var currentLast9to10 = sBarCode.substr(-10, 2); // 获取倒数第9位开始的2位字符
|
// 获取上一条条码的对应位置
|
var lastBarCode = listData[listData.length - 1]['条码编号'];
|
if (lastBarCode.length >= 10) {
|
var lastLast9to10 = lastBarCode.substr(-10, 2);
|
if (currentLast9to10 !== lastLast9to10) {
|
layer.msg(`当前条码倒数10-11位(${currentLast9to10})与上一条条码(${lastLast9to10})不同,请检查!`, { icon: 5 });
|
$('#HBarCode').val('');
|
return;
|
}
|
}
|
}
|
}
|
FindMaterial(sBarCode).then(function (materialInfo) {
|
if (!materialInfo) {
|
layer.msg('未找到物料信息', { icon: 2 });
|
return;
|
}
|
hform.HMaterID = materialInfo.HMaterID;
|
hform.HMaterNumber = materialInfo.HMaterNumber;
|
hform.HMaterName = materialInfo.HMaterName;
|
hform.HMaterModel = materialInfo.HMaterModel;
|
$.ajax({
|
url: GetWEBURL() + '/WEBSController/get_BarCode_PackUnionBill_New_Json_xiaowei',
|
type: 'GET',
|
data: {
|
"HInterID": hform.HInterID,
|
"HBarCode": sBarCode,
|
"HBillType": HBillType,
|
"HBillSubType": HBillSubType,
|
"HBarCode_Pack": '',
|
"HBillNo": hform.HBillNo,
|
"HMaterNumber_Pack": HMaterNumber_Pack,
|
"HMaker": hform.HMaker,
|
"HStockOrgID": hform.HStockOrgID
|
},
|
success: function (res) {
|
if (res.count == 1) {
|
layer.msg('条码处理成功', { icon: 1 });
|
listData.push({
|
条码编号: sBarCode,
|
数量: 1,
|
物料代码: hform.HMaterNumber,
|
物料名称: hform.HMaterName,
|
条码个数: 1,
|
HInterID: hform.HInterID
|
});
|
|
table.reload('mainTable', {
|
data: listData
|
});
|
|
$('#HBarCode').val('');
|
} else {
|
layer.msg(res.Message || '条码处理失败', { icon: 2 });
|
}
|
},
|
error: function () {
|
layer.msg('条码处理失败,请检查网络连接', { icon: 2 });
|
}
|
});
|
}).catch(function (error) {
|
layer.msg('查找物料失败: ' + error, { icon: 2 });
|
});
|
}
|
|
|
function FindMaterial(sBarCode) {
|
return new Promise(function (resolve, reject) {
|
$.ajax({
|
url: GetWEBURL() + '/Gy_Material/findMaterialByNumber',
|
type: 'GET',
|
data: {
|
"HbarCode": sBarCode,
|
"HSTOCKORGID": hform.HStockOrgID
|
},
|
success: function (res) {
|
let data = res.data;
|
if (res.count == 1) {
|
resolve({
|
HMaterID: data[0].HMaterID,
|
HMaterNumber: data[0].HMaterNumber,
|
HMaterName: data[0].HMaterName_m,
|
HMaterModel: data[0].HMaterModel
|
});
|
} else {
|
resolve(null);
|
}
|
},
|
error: function () {
|
reject('查找物料失败,请检查网络连接');
|
}
|
});
|
});
|
}
|
|
function submitPreCheck() {
|
if (!hform.HInterID) {
|
layer.msg('单据内码获取失败,错误的单据内码!', { icon: 2 });
|
return false;
|
}
|
if (!hform.HBillNo) {
|
layer.msg('单据号获取失败,错误的单据号!', { icon: 2 });
|
return false;
|
}
|
if (listData.length < 1) {
|
layer.msg('没有扫码信息,请先扫描条码,确认无误后再提交!', { icon: 2 });
|
return false;
|
}
|
return true;
|
}
|
|
// 删除选中行
|
function cmdDelete() {
|
var checkStatus = table.checkStatus('mainTable');
|
if (checkStatus.data.length !== 1) {
|
layer.msg('请选择一行记录,进行删除!', { icon: 2 });
|
return;
|
}
|
|
layer.confirm('确认要删除选中行所有扫码记录?删除后将不可恢复!', { icon: 3, title: '删除确认' }, function (index) {
|
var selectedRow = checkStatus.data[0];
|
var indexToRemove = listData.findIndex(function (item) {
|
return item['条码编号'] === selectedRow['条码编号'];
|
});
|
|
if (indexToRemove > -1) {
|
listData.splice(indexToRemove, 1);
|
}
|
|
table.reload('mainTable', {
|
data: listData
|
});
|
|
layer.msg('删除成功!', { icon: 1 });
|
layer.close(index);
|
});
|
}
|
|
// 提交
|
function cmdSubmit() {
|
var checkRes = submitPreCheck();
|
if (!checkRes) {
|
return;
|
}
|
EnableSubmit = false;
|
$('#btnSubmit').addClass('layui-btn-disabled').attr('disabled', true);
|
|
// 生成条码
|
getBarCode_pack().then(function () {
|
console.log(HBillType)
|
$.ajax({
|
url: GetWEBURL() + '/WEBSController/set_SavePackUnionBill_Json',
|
type: 'GET',
|
data: {
|
"HInterID": hform.HInterID,
|
"HBillType": HBillType,
|
"HBillNo": hform.HBillNo,
|
"HBarCode_Pack": HBarCode_Pack,
|
"HMaker": hform.HMaker,
|
"HStockOrgID": hform.HStockOrgID
|
},
|
success: function (res) {
|
console.log(HBarCode_Pack);
|
if (res.count == 1) {
|
layer.msg('提交成功', { icon: 1 });
|
|
getResultTableData();
|
} else {
|
layer.msg(res.Message || '提交失败', { icon: 2 });
|
EnableSubmit = true;
|
$('#btnSubmit').removeClass('layui-btn-disabled').attr('disabled', false);
|
}
|
},
|
error: function () {
|
layer.msg('提交失败,请检查网络连接', { icon: 2 });
|
EnableSubmit = true;
|
$('#btnSubmit').removeClass('layui-btn-disabled').attr('disabled', false);
|
}
|
});
|
}).catch(function (error) {
|
layer.msg('条码生成失败: ' + error, { icon: 2 });
|
EnableSubmit = true;
|
$('#btnSubmit').removeClass('layui-btn-disabled').attr('disabled', false);
|
});
|
}
|
|
// 生成条码
|
function getBarCode_pack() {
|
return new Promise(function (resolve, reject) {
|
var sBarCode = hform.HBarCode_middle[0];
|
var sMainStr = JSON.stringify(hform);
|
var omain = sMainStr + ';' + hform.HStockOrgName + ';' + hform.HEmpName + ';' + sBarCode;
|
|
$.ajax({
|
url: GetWEBURL() + '/Sc_BarCode/Sub_SaveBill_xiaowei',
|
type: 'POST',
|
data: { "msg": omain },
|
success: function (res) {
|
if (res.count == 1) {
|
HBarCode_Pack = res.data[0]['条码编号'];
|
resolve(HBarCode_Pack);
|
} else {
|
reject(res.Message || '条码生成失败');
|
}
|
},
|
error: function () {
|
reject('条码生成请求失败');
|
}
|
});
|
});
|
}
|
|
function getResultTableData() {
|
$.ajax({
|
url: GetWEBURL() + '/WEBSController/get_SavePackUnion_xiaowei',
|
type: 'GET',
|
data: { "HBarCode_Pack": HBarCode_Pack },
|
success: function (res) {
|
if (res.count == 1) {
|
var resultData = res.data;
|
|
table.reload('resultTable', {
|
data: resultData
|
});
|
|
$('#resultModal').show();
|
} else {
|
layer.msg(res.Message || '获取数据失败', { icon: 2 });
|
EnableSubmit = true;
|
$('#btnSubmit').removeClass('layui-btn-disabled').attr('disabled', false);
|
}
|
},
|
error: function () {
|
layer.msg('获取结果数据失败,请检查网络连接', { icon: 2 });
|
EnableSubmit = true;
|
$('#btnSubmit').removeClass('layui-btn-disabled').attr('disabled', false);
|
}
|
});
|
}
|
|
// 新增
|
function toAddNew() {
|
$('#resultModal').hide();
|
HBarCode_Pack = '';
|
$('#HBarCode').val('');
|
listData = [];
|
table.reload('mainTable', { data: listData });
|
getMaxNo();
|
EnableSubmit = true;
|
$('#btnSubmit').removeClass('layui-btn-disabled').attr('disabled', false);
|
}
|
|
|
function closeResultTable() {
|
$('#resultModal').hide();
|
}
|
|
// 退出
|
function cmdExit() {
|
layer.confirm('您确定要退出吗?', { icon: 3, title: '提示' }, function (index) {
|
|
console.log('退出操作');
|
layer.close(index);
|
});
|
}
|
|
init();
|
});
|
</script>
|
</body>
|
</html>
|