<!DOCTYPE html>
|
<html>
|
<head>
|
<meta charset="utf-8" />
|
<title>产线组装追溯单</title>
|
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
|
<script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
|
<script src="../../../layuiadmin/layui/layui.js"></script>
|
<script src="../../../layuiadmin/Scripts/json2.js"></script>
|
<script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
|
<script src="../../../layuiadmin/Scripts/webConfig.js"></script>
|
<script src="../../../layuiadmin/PubCustom.js"></script>
|
|
<style>
|
.main-btn { /*头部主按钮*/
|
padding: 0 2px; /*调整按钮左右空隙大小*/
|
height: 30px;
|
line-height: 30px;
|
}
|
|
.btn-title {
|
font-size: 16px;
|
}
|
</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;">
|
<form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
|
<div style="padding: 10px;">
|
<button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">保存</button>
|
<button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">退出</button>
|
</div>
|
<div class="layui-tab" lay-filter="tab-POStockInBill">
|
<ul class="layui-tab-title" lay-filter="tab-all">
|
<li lay-id="1" style="padding:1px;" class="layui-this">采集信息</li>
|
</ul>
|
<div class="layui-tab-content">
|
<!--基本信息-->
|
<div class="layui-tab-item layui-show">
|
<div class="layui-form-item" style="padding-top: 10px;">
|
<div class="layui-row">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">条形码:</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HBarCode" lay-verify="HBarCode" placeholder="请键入后回车" id="HBarCode" style="width: 500px;">
|
</div>
|
</div>
|
</div>
|
<div class="layui-row">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">单据号</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HBillNo" lay-verify="HBillNo" id="HBillNo" style="background-color:#efefef4d;" readonly>
|
<input type="hidden" name="HInterID" id="HInterID" lay-verify="HInterID">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">创建人</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HMaker" lay-verify="HMaker" id="HMaker" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 68px;">生产订单</label>
|
<div class="layui-input-block" style="margin-left: 100px;">
|
<input type="text" class="layui-input" name="HICMOBillNo" lay-verify="HICMOBillNo" id="HICMOBillNo" value="" style="background-color: #efefef4d; display: inline-block;" readonly>
|
<input type="hidden" id="HICMOInterID" name="HICMOInterID" value="0" />
|
<input type="hidden" id="HICMOEntryID" name="HICMOEntryID" value="0" />
|
</div>
|
</div>
|
</div>
|
<div class="layui-row">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">产品MAC</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" lay-verify="HMateMAC" name="HMateMAC" id="HMateMAC" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">产品SN</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HBarCode_P" lay-verify="HBarCode_P" id="HBarCode_P" style="background-color:#efefef4d;display: inline-block;" readonly>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 65px;">产品编码</label>
|
<div class="layui-input-block" style="margin-left: 100px;">
|
<input type="text" class="layui-input" lay-verify="HMaterNumber" name="HMaterNumber" id="HMaterNumber" style="background-color:#efefef4d;" readonly>
|
<input type="hidden" id="HMaterID" name="HMaterID" value="0" />
|
</div>
|
</div>
|
</div>
|
<div class="layui-row">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">产品名称</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" lay-verify="HMaterName" name="HMaterName" id="HMaterName" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">规格型号</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" lay-verify="HMaterModel" name="HMaterModel" id="HMaterModel" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 70px;">状态</label>
|
<div class="layui-input-block" style="margin-left: 100px; width: 184px;">
|
<select name="HAssemblyStatus" id="HAssemblyStatus" lay-verify="HAssemblyStatus">
|
<option value="生产中" selected>生产中</option>
|
<option value="汇报">汇报</option>
|
<option value="检验">检验</option>
|
<option value="包装">包装</option>
|
<option value="入库">入库</option>
|
</select>
|
</div>
|
</div>
|
</div>
|
<div class="layui-row">
|
<div class="layui-inline" style="width: 56%;">
|
<label class="layui-form-label" style="width: 85px;">备注</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HRemark" id="HRemark" lay-verify="HRemark" placeholder="请输入内容" onmouseover="this.title=this.value" style="width: 50%;">
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<div class="layui-tab layui-tab-card" style="width: 49%; float: left;">
|
<ul class="layui-tab-title">
|
<li class="layui-this">关键件清单</li>
|
</ul>
|
<div class="layui-tab-content">
|
<div class="layui-tab-item layui-show">
|
<!--关键件清单-->
|
<table class="layui-hide" id="mainTable2" lay-filter="mainTable2"></table>
|
</div>
|
</div>
|
</div>
|
<div class="layui-tab layui-tab-card" style="width: 49%; float: left; margin-left: 1%; ">
|
<ul class="layui-tab-title">
|
<li class="layui-this">采集记录</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>
|
</div>
|
<script type="text/html" id="toolbarDemo">
|
<div class="layui-btn-container">
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>增加一行</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
|
</div>
|
</script>
|
<script type="text/html" id="toolbarDemo2">
|
<div class="layui-btn-container">
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine2"><i class="layui-icon layui-icon-form"></i>增加一行</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine2"><i class="layui-icon layui-icon-form"></i>复制一行</button>
|
</div>
|
</script>
|
<input type="hidden" id="HProdOrgID" name="HProdOrgID" value="0" />
|
</form>
|
</div>
|
</div>
|
</div>
|
|
<script type="text/html" id="barDemo">
|
<!--<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
</script>
|
<script type="text/html" id="barDemo2">
|
<!--<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
</script>
|
|
<script>
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index' //主入口模块
|
}).use(['index', 'form', 'laydate', 'table', 'element'], function () {
|
|
//#region 公共变量
|
var $ = layui.$
|
, admin = layui.admin
|
, layer = layui.layer
|
, table = layui.table
|
, form = layui.form
|
, element = layui.element;
|
var option = [];
|
var option2 = [];
|
//#endregion
|
|
//#region 进入页面即加载
|
|
var params = getUrlVars();
|
var OperationType = params[params[0]]; //从参数中获取 数据类型 添加 保存
|
var linterid = params[params[1]]; //从参数中获取 单据内码
|
|
//判断是否新增
|
if (linterid == null || linterid == 0) {
|
OperationType = 1;
|
$.ajax({
|
url: GetWEBURL() + "/Web/GetMAXNum",
|
type: "GET",
|
data: { "HBillType": '3727' },
|
success: function (d) {
|
//赋值
|
$("#HInterID").val(d.data[0].HInterID);
|
$("#HBillNo").val(d.data[0].HBillNo);
|
}
|
});
|
}
|
|
//判断是否登录 未登录则跳到登录页
|
if (sessionStorage.login != "login") {
|
layer.confirm("登录失效,请重新登录!", {
|
icon: 4, skin: 'layui-layer-lan', title: "温馨提示", closeBtn: 0, btn: ['重新登录']
|
}, function () { window.location.href = "../../user/login.html"; });
|
}
|
|
//初始化界面
|
set_ClearBill();
|
|
|
//#endregion
|
|
//#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
|
|
//条形码回车方法
|
$('#HBarCode').on('keydown', function (event) {
|
var HBarCode = $('#HBarCode').val();
|
if (event.keyCode == 13) {
|
if (!HBarCode) {
|
layer.msg("条形码不能为空!")
|
return;
|
}
|
txtHBarCode_KeyDown(HBarCode);
|
}
|
});
|
|
|
|
////行内事件
|
//table.on('tool(mainTable)', function (obj) {
|
// set_GridDelete(obj); //行内删除
|
//});
|
|
////行内事件
|
//table.on('tool(mainTable2)', function (obj) {
|
// set_GridDelete2(obj); //行内删除
|
//});
|
|
|
//保存提交
|
form.on('submit(btnSave)', function (data) {//提交
|
//为空验证
|
if (AllowLoadData(data)) {
|
set_AddNew(data,3);
|
}
|
});
|
|
//#endregion
|
|
//#region 此页面所有的方法
|
|
// 初始化界面
|
function set_ClearBill() {
|
$("#HBarCode").focus(); //进入页面默认光标在条形码上
|
set_InitGrid();
|
set_InitGrid2();
|
//制单人
|
$("#HMaker").val(sessionStorage["HUserName"]);
|
$("#HProdOrgID").val(sessionStorage["OrganizationID"]);//组织
|
//初始化日期
|
$("#HPlanBeginDate").val(Format(new Date(), "yyyy-MM-dd"));
|
$("#HPlanEndDate").val(Format(new Date(), "yyyy-MM-dd"));
|
$("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
|
get_Display();
|
}
|
|
function set_InitGrid() {
|
//子表 初始化表格数据
|
option = {
|
elem: '#mainTable'
|
//, toolbar: '#toolbarDemo'
|
, limit: 500 //每页默认显示的数量
|
, cellMinWidth: 120
|
, height: 400
|
, cols: [[ //表头
|
{ type: 'checkbox', totalRowText: '合计行' }
|
, { type: 'numbers', title: '序号', totalRow: true }
|
, { field: '日期', title: '日期' }
|
, { field: '产品名称', title: '产品名称' }//f7
|
, { field: 'HMaterID', title: 'HMaterID ', hide: true }//f7
|
, { field: '产品条码', title: 'SN码' }
|
, { field: '配件条码', title: '配件SN码' }
|
, { field: '任务单号', title: '订单号' }
|
, { field: 'HPRDORGID', title: 'HPRDORGID', hide: true }
|
//, { fixed: 'right', title: '操作', toolbar: '#barDemo' }
|
]]
|
};
|
//var rowdata = [{
|
// "HDate": "", "HMaterName": "", "HMaterID": 0, "HBarCode": "", "HBarCode_P": "",
|
// "HICMOBillNo": ""
|
//}];
|
option.data = [];
|
table.render(option);
|
|
}
|
|
function set_InitGrid2() {
|
//子表 初始化表格数据
|
option2 = {
|
elem: '#mainTable2'
|
//, toolbar: '#toolbarDemo2'
|
, limit: 500 //每页默认显示的数量
|
, cellMinWidth: 120
|
, height: 400
|
, cols: [[ //表头
|
{ type: 'checkbox', totalRowText: '合计行' }
|
, { type: 'numbers', title: '序号', totalRow: true }
|
, { field: 'HDate', title: '日期', edit: 'text' }
|
, { field: 'HMaterName', title: '配件名称' }//f7
|
, { field: 'HMaterID', title: 'HMaterID ', hide: true }//f7
|
, { field: 'HMaterModel', title: '配件规格' }
|
, { field: 'HQty', title: '配件数量' }
|
, { field: 'HBardQty', title: '已扫数量' }
|
, { field: 'HPRDORGID', title: 'HPRDORGID', hide: true }
|
, { field: 'HBarCode', title: 'HBarCode', hide: true }
|
, { field: 'HEQty', title: 'HEQty', hide: true }
|
//, { fixed: 'right', title: '操作', toolbar: '#barDemo2' }
|
]]
|
};
|
var rowdata = [{
|
"HDate": "", "HMaterName": "", "HMaterID": 0, "HMaterModel": "", "HQty": 0,
|
"HBardQty": 0, "HPRDORGID": $("#HProdOrgID").val(), "HBarCode": "","HEQty":0
|
}];
|
option2.data = rowdata;
|
table.render(option2);
|
|
}
|
|
//初始化查询
|
function get_Display() {
|
var sWhere = " and HProdOrgID=" + sessionStorage["OrganizationID"] + " and 制单人='" + $("#HMaker").val() +"' and DATEDIFF(DAY,GETDATE(),日期)=0";
|
var ajaxLoad = layer.load();
|
$.ajax({
|
url: GetWEBURL() + '/Sc_AssemblyBill/Sc_AssemblyBillAddList',
|
type: "GET",
|
data: { "sWhere": sWhere },
|
success: function (data1) {
|
if (data1.count == 1) {
|
option.data = data1.data;
|
ins = table.render(option);
|
layer.close(ajaxLoad);
|
|
} else {
|
layer.close(ajaxLoad);
|
layer.alert(data1.code + data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(ajaxLoad);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
|
}
|
|
//条码回车查询
|
function txtHBarCode_KeyDown(HBarCode) {
|
|
var index = layer.load();
|
$.ajax({
|
type: "GET",
|
url: GetWEBURL() + "/Sc_AssemblyBill/HBardCodeList",
|
async: true,
|
data: { "HBarCode": HBarCode, "user": sessionStorage["HUserName"], "HICMOBillNo": $("#HICMOBillNo").val()},
|
dataType: "json",
|
success: function (data) {
|
if (data.count == 1) {
|
var data_1 = null;
|
var option_s = [];
|
if ($("#HICMOBillNo").val() == "") {
|
$("#HICMOBillNo").val(data.data[0]["FMOBILLNO"]);
|
$("#HICMOInterID").val(data.data[0]["HSourceInterID"]);
|
$("#HICMOEntryID").val(data.data[0]["HSourceEntryID"]);
|
$("#HBarCode_P").val($("#HBarCode").val());
|
$("#HMaterID").val(data.data[0]["HItemID"]);
|
$("#HMaterNumber").val(data.data[0]["HMaterNumber"]);
|
$("#HMaterName").val(data.data[0]["HMaterName"]);
|
$("#HMaterModel").val(data.data[0]["HMaterModel"]);
|
var num = [];
|
for (var i = 0; i < data.data.length; i++) {
|
num.push({
|
"HDate": Format(new Date().getTime(), 'yyyy-MM-dd hh:mm:ss'), "HMaterName": data.data[i]["HMaterName_z"], "HMaterID": data.data[i]["HMaterID"], "HMaterModel": data.data[i]["HMaterModel_z"], "HQty": data.data[i]["FMUSTQTY"],
|
"HBardQty": 0, "HPRDORGID": $("#HProdOrgID").val(), "HBarCode": "","HEQty":0
|
});
|
}
|
option2.data = num;
|
data_1 = set_AddNew({ "field": { "HInterID": $("#HInterID").val(), "HBillNo": $("#HBillNo").val(), "HICMOBillNo": $("#HICMOBillNo").val() } }, 1);
|
|
} else {
|
option_s = JSON.stringify(option2.data);
|
for (var i = 0; i < option2.data.length; i++) {
|
if (option2.data[i]["HMaterID"] == data.data[0]["HMaterID"]) {
|
option2.data[i]["HBardQty"] += data.data[0]["HQty"];
|
option2.data[i]["HBarCode"] = $("#HBarCode").val();
|
option2.data[i]["HEQty"] = data.data[0]["HQty"];
|
} else {
|
option2.data[i]["HBarCode"] = "";
|
}
|
}
|
data_1 = set_AddNew({ "field": { "HInterID": $("#HInterID").val(), "HBillNo": $("#HBillNo").val(), "HICMOBillNo": $("#HICMOBillNo").val() } }, 2);
|
|
}
|
if (data_1.count == 1) {
|
layer.msg("提交成功");
|
layer.close(index);
|
table.render(option2);
|
}
|
else {
|
option2.data = JSON.parse(option_s);
|
layer.msg(data_1.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
layer.close(index);
|
}
|
}
|
else {
|
layer.close(index);
|
layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
}
|
$("#HBarCode").val("");
|
},
|
error: function (err) {
|
layer.close(index);
|
layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
}
|
});
|
}
|
|
////行内删除
|
//function set_GridDelete(obj) {
|
// var data = obj.data;
|
// var rowIndex = $(obj.tr).attr("data-index");
|
// if (obj.event === 'del') {
|
// layer.confirm('真的删除行吗?', function (index) {
|
// if (rowIndex === '0') {
|
// layer.msg('首行无法删除!!!');
|
// } else {
|
// var oldData = table.cache["mainTable"];
|
// oldData.splice(obj.tr.data('index'), 1)
|
// option.data = oldData;//将数据绑定到data上
|
// table.render(option);
|
// layer.close(index);
|
// }
|
// });
|
// }
|
//}
|
|
////行内删除
|
//function set_GridDelete2(obj) {
|
// var data = obj.data;
|
// var rowIndex = $(obj.tr).attr("data-index");
|
// if (obj.event === 'del') {
|
// layer.confirm('真的删除行吗?', function (index) {
|
// if (rowIndex === '0') {
|
// layer.msg('首行无法删除!!!');
|
// } else {
|
// var oldData = table.cache["mainTable2"];
|
// oldData.splice(obj.tr.data('index'), 1)
|
// option2.data = oldData;//将数据绑定到data上
|
// table.render(option2);
|
// layer.close(index);
|
// }
|
// });
|
// }
|
//}
|
|
//保存数据
|
function set_AddNew(data, num) {
|
var data_1 = [];
|
//过滤子表删除之后留下的空数据
|
var num2 = [];
|
for (var i = 0; i < option2.data.length; i++) {
|
//给不能为空的数据 赋值(子)
|
if (option2.data[i] != "") {
|
num2.push(option2.data[i]);
|
}
|
}
|
|
var sMainStr = JSON.stringify(data.field);
|
var sSubStr = JSON.stringify(num2);
|
var sMainSub = sMainStr + ';' + sSubStr + ';' + num + ";" + sessionStorage["HUserName"];
|
var index = layer.load();
|
|
$.ajax({
|
type: "POST",
|
url: GetWEBURL() + "/Sc_AssemblyBill/AddBill",
|
async: false,
|
data: { "sMainSub": sMainSub },
|
dataType: "json",
|
success: function (res) {
|
layer.close(index);
|
if (num != 3) {
|
data_1 = res;
|
} else {
|
if (res.count == 1) {
|
layer.msg("提交成功", { time: 1 * 1000, icon: 1 }, function () {
|
location.replace('Cj_AssemblyTraceability.html');
|
});
|
}
|
else {
|
layer.msg(res.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
layer.close(index);
|
}
|
}
|
},
|
error: function (err) {
|
layer.close(index);
|
layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
}
|
});
|
return data_1;
|
}
|
|
//数据验证
|
function AllowLoadData(data) {
|
var HICMOBillNo = $("#HICMOBillNo").val();//生产订单
|
if (HICMOBillNo == "") {
|
layer.msg("请扫产品码!");
|
return false;
|
}
|
var count = 0;
|
for (var i = 0; i < option2.data.length; i++) {
|
if (option2.data[i]["HBardQty"] != 0) {
|
count += 1;
|
}
|
}
|
if (count == 0) {
|
layer.msg("请扫配件码!");
|
return false;
|
}
|
return true;
|
}
|
|
//获取参数
|
function getUrlVars() {
|
var vars = [], hash;
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
for (var i = 0; i < hashes.length; i++) {
|
hash = hashes[i].split('=');
|
vars.push(hash[0]);
|
vars[hash[0]] = hash[1];
|
}
|
return vars;
|
}
|
//#endregion
|
|
});
|
</script>
|
</body>
|
</html>
|