<!DOCTYPE html>
|
<html>
|
<head>
|
<meta 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.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
|
<style type="text/css">
|
.layui-table-cell, .layui-table-box{
|
overflow: visible;
|
}
|
td .layui-form-select {
|
margin-top: -10px;
|
margin-left: -15px;
|
margin-right: -15px;
|
}
|
</style>
|
</head>
|
<body>
|
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
|
<div class="layui-form-item">
|
<label class="layui-form-label">入库单号</label>
|
<div class="layui-input-inline" style="width: 20%;">
|
<input type="text" name="ImportBillCode" disabled="disabled" placeholder="自动生成单号" autocomplete="off" class="layui-input">
|
</div>
|
<label class="layui-form-label">单据类型</label>
|
<div class="layui-input-inline" style="width: 20%;">
|
<select name="ImportBillType" id="ImportBillType" lay-verify="required" lay-filter="ImportBillType" lay-search>
|
<option value=""></option>
|
</select>
|
</div>
|
<label class="layui-form-label">入库仓库</label>
|
<div class="layui-input-inline" style="width: 20%;">
|
<select name="ImportWarehouseId" id="ImportWarehouseId" lay-verify="required" lay-filter="ImportWarehouseId" lay-search>
|
<option value=""></option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-form-item">
|
<label class="layui-form-label">区域</label>
|
<div class="layui-input-inline" style="width: 20%;">
|
<select name="LanewayCode" id="LanewayCode" lay-search>
|
<option value=""></option>
|
</select>
|
</div>
|
<label class="layui-form-label">所属客户</label>
|
<div class="layui-input-inline" style="width: 20%;">
|
<select name="ImportCustomerName" id="ImportCustomerName" lay-verify="" lay-search>
|
<option value=""></option>
|
</select>
|
</div>
|
<!-- <label class="layui-form-label">物品状态</label>
|
<div class="layui-input-inline" style="width: 20%;">
|
<input type="checkbox" name="ImportGoodsStatus" id="ImportGoodsStatus" lay-skin="switch" checked lay-text="合格|待检" >
|
</div> -->
|
</div>
|
<div class="layui-form-item">
|
<div class="layui-card">
|
<div class="layui-card-body">
|
<div style="padding-bottom: 6px;">
|
<button class="layui-btn layui-btn-sm layuiadmin-btn-list" data-type="add">添加明细</button>
|
</div>
|
<table id="LAY-app-content-list" name="LAY-app-content-list" lay-filter="LAY-app-content-list"></table>
|
<script type="text/html" id="table-content-list">
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"> <i class="layui-icon layui-icon-delete"></i>删除</a>
|
</script>
|
<button type="submit" class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-submit="" lay-filter="form1">立即提交</button>
|
</div>
|
</div>
|
</div>
|
</div>
|
<script id="tpl1" type="text/html">
|
<select name="tvalue" lay-filter="select1" style="z-index: 1000;">
|
<option value=""></option>
|
<option value="合格" selected="selected">合格</option>
|
<option value="待检">待检</option>
|
</select>
|
</script>
|
<script id="tpl2" type="text/html">
|
|
</script>
|
|
<script src="../../../layuiadmin/layui/layui.js"></script>
|
<script src="../../../js/public.js"></script>
|
<script src="../../../js/jquery-3.5.1.min.js"></script>
|
<script src="../../../js/jquery.cookie.js"></script>
|
<script>
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index' //主入口模块
|
}).use(['index', 'form', 'layer', 'laydate', 'table'], function() {
|
var $ = layui.$,
|
form = layui.form,
|
laydate = layui.laydate,
|
table = layui.table,
|
layer = layui.layer;
|
var id = getQueryString('id');
|
|
laydate.render({
|
elem: '#test1'
|
});
|
var username = $.cookie('userName');
|
var userid = $.cookie('userId');
|
var day1 = new Date();
|
var year = day1.getFullYear();
|
var month = day1.getMonth()+1;
|
if (month < 10) {
|
month = '0' + month;
|
}
|
var day = day1.getDate();
|
window.success = function(data){
|
refreshTable(data);
|
};
|
function PrefixZero(num, n) {
|
return (Array(n).join(0) + num).slice(-n);
|
}
|
var arr = [];
|
function refreshTable(data) {
|
for (var i in data) {
|
//data[i].ImportLotNo = year + '' + month + '' + PrefixZero(day,2);
|
// $("select[name='select2']").val("1");
|
// form.render('select');
|
|
data[i].ImportGoodsStatus = "待检";
|
var isHave = 0;
|
for(var j in arr)
|
{
|
if(data[i].GoodsCode == arr[j].GoodsCode){
|
isHave = 1;
|
break;
|
}
|
}
|
if(isHave == 0){
|
data[i].ImportLotNo = "";
|
data[i].ImportQuantity = 0;
|
data[i].ImportCustomerNameX = "";
|
data[i].CustomerNameX = "";
|
arr.push(data[i]); //属性
|
}
|
}
|
$.extend(infoOptions, {
|
data: arr
|
});
|
infoOptions.page = {
|
curr: 1
|
}
|
table.render(infoOptions);
|
}
|
|
window.success2 = function(data){
|
var GoodCode = data.GoodCode;
|
for (var i in arr) {
|
if (arr[i].GoodsCode == GoodCode) {
|
arr[i].GoodsPackaging = data.PackagingId;
|
arr[i].GoodsPackagingname = data.PackagingName;
|
arr[i].ImportQuantity = arr[i].ImportQuantity;
|
}
|
}
|
refreshTable(arr);
|
}
|
|
window.success3 = function(data){
|
var GoodCode = data.GoodCode;
|
for (var i in arr) {
|
if (arr[i].GoodsCode == GoodCode) {
|
arr[i].ImportCustomerNameX = data.ImportCustomerNameX;
|
arr[i].CustomerNameX = data.ImportCustomerNameXName;
|
arr[i].ImportQuantity = arr[i].ImportQuantity;
|
}
|
}
|
refreshTable(arr);
|
console.log(arr);
|
}
|
|
var infoOptions = {
|
elem: '#LAY-app-content-list',
|
height: 'full-260',
|
id: 'LAY-app-content-list',
|
page: true,
|
limit: pageCnt,
|
limits: pageLimits,
|
cellMinWidth: 60, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
|
cols: [
|
[ //标题栏
|
{
|
field: 'GoodId',
|
title: '物品Id',
|
width: 120,
|
align:'center',
|
fixed:'left',
|
hide:true,
|
},
|
{
|
field: 'GoodsCode',
|
title: '物品编码',
|
width: 100,
|
align:'center',
|
fixed:'left',
|
}, {
|
field: 'GoodsName',
|
title: '物品名称',
|
minWidth: 150,
|
align:'center',
|
fixed:'left',
|
}, {
|
field: 'GoodsStandard',
|
title: '物品规格',
|
align:'center',
|
minWidth: 100
|
}, {
|
field: 'UnitName',
|
title: '计量单位',
|
align:'center',
|
width: 60
|
}
|
, {
|
field: 'ImportLotNo',
|
title: '批次',
|
align:'center',
|
edit: 'text',
|
width: 100
|
}
|
, {
|
field: 'ImportQuantity',
|
title: '数量',
|
align:'center',
|
width: 80,
|
edit: 'number',
|
event:'dataNumber'
|
}
|
// , {
|
// field: 'ImportProductionDate',
|
// title: '生产日期',
|
// width: 200,
|
// align:'center'
|
// }
|
, {
|
field: 'ImportGoodsStatus',
|
title: '状态',
|
width: 60
|
}, {
|
field: 'GoodsPackaging',
|
title: '包装',
|
width: 200,
|
hide:true
|
}, {
|
field: 'GoodsPackagingname',
|
title: '物品包装',
|
width: 200,
|
event: 'setSign'
|
}
|
, {
|
field: 'CustomerNameX',
|
title: '所属客户',
|
width: 200,
|
event: 'EditKH'
|
}
|
, {
|
title: '操作',
|
fixed: 'right',
|
align:'center',
|
templet: '#table-content-list',
|
width: 90
|
}
|
]
|
]
|
};
|
$("input[name='ImportDate']").val(year + '-' + month + '-' + day);
|
var tableIns;
|
refreshTable(null);
|
var $ = layui.$,
|
active = {
|
add: function() {
|
layer.open({
|
type: 2,
|
title: '选择物品信息',
|
content: 'ImportBillGoodsListForm.html?WarehouseId='+$("#ImportWarehouseId").val(),
|
maxmin: true,
|
area: ['950px', '90%'],
|
fixed: false,
|
});
|
}
|
};
|
$('.layui-btn.layuiadmin-btn-list').on('click', function() {
|
var type = $(this).data('type');
|
active[type] ? active[type].call(this) : '';
|
});
|
var ImportId = 0;
|
table.on('tool(LAY-app-content-list)', function(obj) {
|
var data = obj.data;
|
if (obj.event === 'del') {
|
var ii = -1;
|
for(var j in arr)
|
{
|
if(obj.data.GoodId == arr[j].GoodId){
|
ii = j;
|
break;
|
}
|
}
|
if(ii>-1)
|
{
|
arr.splice(ii, 1);
|
}
|
obj.del();
|
} else if (obj.event === 'finish') {
|
layer.confirm('确定完成此单据吗?', function(index) {
|
ImportId = data.ImportId;
|
var param = {
|
Id: ImportId,
|
Status:2
|
};
|
sendData(IP + "/Import/EditImportBill", param, 'post', function(res) {
|
if (res.code == 1) { //成功
|
layer.msg(res.msg, {
|
icon: 1,
|
time: 1000 //1秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable();
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
});
|
}else if(obj.event === 'dataNumber')
|
{
|
$("table input").attr("type","number");
|
$("table input").attr("step","1");
|
$("table input").attr("oninput","value=value.replace(/^(0+)|[^\\d]+/g,'')");
|
}else if(obj.event === 'dataDate')
|
{
|
$("table input").attr("type","date");
|
}
|
else if(obj.event === 'setSign'){
|
layer.open({
|
type: 2,
|
title: '选择物品包装',
|
content: 'packagingxz.html?GoodCode=' + obj.data.GoodsCode,
|
maxmin: true,
|
area: ['460px', '300px'],
|
fixed: false,
|
});
|
}
|
else if(obj.event === 'EditKH'){
|
//console.log($("#ImportBillType").val());
|
layer.open({
|
type: 2,
|
title: '选择物品客户',
|
content: 'Customerxz.html?GoodCode=' + obj.data.GoodsCode + '&BillTypeId=' + $("#ImportBillType").val(),
|
maxmin: true,
|
area: ['460px', '300px'],
|
fixed: false,
|
});
|
}
|
});
|
|
|
var Laneway = "";
|
var ImportWarehouseId = "";
|
var ImportCustomerName = "";
|
if(!id){
|
id = "";
|
|
sendData(IP + "/ImportNotify/GetAllSelect", "", 'post', function(res) {
|
if (res.code == 1) { //成功
|
for (var i = 0; i < res.BillTypedata.length; i++) {
|
$("#ImportBillType").append('<option value =' + res.BillTypedata[i].BillTypeCode + '>' + res.BillTypedata[i].BillTypeName +
|
'</option>');
|
}
|
// for (var i = 0; i < res.Customerdata.length; i++) {
|
// $("#ImportCustomerName").append('<option value =' + res.Customerdata[i].CustomerCode + '>' + res.Customerdata[i].CustomerName +
|
// '</option>');
|
// }
|
form.render('select');
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
}
|
else{
|
|
var param = {
|
id: $.cookie('userId'),
|
};
|
|
sendData(IP + "/ImportNotify/GetAllSelect", "", 'post', function(res) {
|
if (res.code == 1) { //成功
|
for (var i = 0; i < res.BillTypedata.length; i++) {
|
$("#ImportBillType").append('<option value =' + res.BillTypedata[i].BillTypeCode + '>' + res.BillTypedata[i].BillTypeName +
|
'</option>');
|
}
|
// for (var i = 0; i < res.Customerdata.length; i++) {
|
// $("#ImportCustomerName").append('<option value =' + res.Customerdata[i].CustomerCode + '>' + res.Customerdata[i].CustomerName +
|
// '</option>');
|
// }
|
form.render('select');
|
var param = {
|
id: id,
|
};
|
sendData(IP + "/ImportNotify/GetImportNotifyById", param, 'post', function(res) {
|
if (res.code == 1) { //成功
|
//页面赋值
|
$("input[name='ImportBillCode']").val(res.data.ImportBillCode);
|
//$("select[name='ImportBillType']").val(res.data.ImportBillType);
|
//$("select[name='ImportWarehouseId']").val(res.data.ImportWarehouseId);
|
//$("select[name='ImportCustomerName']").val(res.data.ImportCustomerName);
|
ImportCustomerName = res.data.ImportCustomerName;
|
//$("select[name='LanewayCode']").val(res.data.LanewayCode);
|
Laneway = res.data.LanewayCode;
|
ImportWarehouseId = res.data.ImportWarehouseId;
|
var select = "dd[lay-value='"+res.data.ImportBillType+"']";
|
$('#ImportBillType').siblings("div.layui-form-select").find('dl').find(select).click();
|
for (var i in res.data.WmsImportNotifyList) {
|
var isHave = 0;
|
for(var j in arr)
|
{
|
if(res.data.WmsImportNotifyList[i].GoodsCode == arr[j].GoodsCode){
|
isHave = 1;
|
break;
|
}
|
}
|
if(isHave == 0){
|
arr.push(res.data.WmsImportNotifyList[i]); //属性
|
}
|
}
|
$.extend(infoOptions, {
|
data: res.data.WmsImportNotifyList
|
});
|
infoOptions.page = {
|
curr: 1
|
}
|
table.render(infoOptions);
|
//arr = res.data.WmsImportNotifyList;
|
console.log(arr);
|
form.render('select');
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
}
|
|
|
|
form.on('select(ImportWarehouseId)',function (data) {
|
var type = data.value;
|
var param = {
|
Msg: type
|
};
|
sendData(IP + "/ImportNotify/GetLaneway", param, 'post', function(res) {
|
if (res.code == 1) { //成功
|
$("#LanewayCode").empty();
|
$("#LanewayCode").append("<option value =''></option>");
|
for (var i = 0; i < res.data.length; i++) {
|
$("#LanewayCode").append('<option value =' + res.data[i].LanewayCode + '>' + res.data[i].LanewayName +
|
'</option>');
|
}
|
form.render('select');
|
$("select[name='LanewayCode']").val(Laneway);
|
form.render('select');
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
});
|
|
|
form.on('select(ImportBillType)',function (data) {
|
var type = data.value;
|
var param = {
|
Msg: type
|
};
|
var param2 = {
|
BillTypeId: type
|
};
|
|
sendData(IP + "/ImportNotify/GetWmsBaseWarehouse", param, 'post', function(res) {
|
if (res.code == 1) { //成功
|
$("#ImportWarehouseId").empty();
|
$("#ImportWarehouseId").append("<option value =''></option>");
|
for (var i = 0; i < res.data.length; i++) {
|
$("#ImportWarehouseId").append('<option value =' + res.data[i].WarehouseCode + '>' + res.data[i].WarehouseName +
|
'</option>');
|
}
|
form.render('select');
|
var select = "dd[lay-value='"+ImportWarehouseId+"']";
|
$('#ImportWarehouseId').siblings("div.layui-form-select").find('dl').find(select).click();
|
form.render('select');
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
|
sendData(IP + "/ImportNotify/GetWmsBaseCustomer2", param2, 'post', function(res) {
|
if (res.code == 1) { //成功
|
$("#ImportCustomerName").empty();
|
$("#ImportCustomerName").append("<option value =''></option>");
|
for (var i = 0; i < res.Customerdata.length; i++) {
|
$("#ImportCustomerName").append('<option value =' + res.Customerdata[i].CustomerCode + '>' + res.Customerdata[i].CustomerName +
|
'</option>');
|
}
|
form.render('select');
|
var select = "dd[lay-value='"+ImportCustomerName+"']";
|
$('#ImportCustomerName').siblings("div.layui-form-select").find('dl').find(select).click();
|
form.render('select');
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
});
|
|
|
|
form.verify({
|
emptyNo: function(value) {
|
if (value == '') {
|
return '';
|
} else {
|
var ver = /^[0-9]+$/;
|
if (!ver.test(value)) {
|
return '只能输入正整数';
|
}
|
}
|
}
|
});
|
|
var doing = true;
|
form.on('submit(form1)', function(data){
|
|
//data.field.aaa = "123";
|
//console.log(data.field);
|
//console.log(infoOptions.data);
|
//console.log(arr);
|
var reg = /^([0]|[0-9][0-9]*)$/;
|
//var reg = /^[0-9]+.?[0-9]*$/;
|
if(arr.length == 0)
|
{
|
layer.msg("请添加明细!", {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
|
});
|
return;
|
}
|
var DataList = [];
|
for (var i in arr) {
|
if(arr[i].ImportQuantity == ""){
|
layer.msg("请输入入库数量!", {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
|
});
|
return;
|
}
|
if(arr[i].ImportLotNo == ""){
|
layer.msg("请输入批次!", {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
|
});
|
return;
|
}
|
if(arr[i].ImportQuantity <= 0){
|
layer.msg("入库数量必须大于0!", {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
|
});
|
return;
|
}
|
//console.log(reg.test(arr[i].ImportQuantity));
|
if(!reg.test(arr[i].ImportQuantity)){
|
layer.msg("入库数量必须是大于0的整数", {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
|
});
|
return;
|
}
|
|
var item = {
|
ImportLotNo : arr[i].ImportLotNo,
|
//GoodId : arr[i].GoodId,
|
GoodsCode: arr[i].GoodsCode,
|
ImportProductionDate:arr[i].ImportProductionDate,
|
ImportQuantity:arr[i].ImportQuantity,
|
ImportGoodsStatus :arr[i].ImportGoodsStatus,
|
GoodsPackaging : arr[i].GoodsPackaging,
|
ImportCustomerNameX : arr[i].ImportCustomerNameX
|
};
|
DataList.push(item); //属性
|
}
|
var item2 = {
|
ImportBillCode : data.field.ImportBillCode,
|
ImportWarehouseId : data.field.ImportWarehouseId,
|
ImportBillType : data.field.ImportBillType,
|
LanewayCode : data.field.LanewayCode,
|
ImportCustomerName : data.field.ImportCustomerName,
|
ImportDate : data.field.ImportDate,
|
CreateUser:userid,
|
UpdateUSer:userid,
|
list:DataList
|
}
|
if(doing){
|
doing = false;
|
sendData(IP + "/ImportNotify/AddImportBill?UserId="+userid, item2, 'post', function(res) {
|
//console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg(res.msg, {
|
icon: 1,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
parent.location.reload();
|
parent.layer.close(layer.index);
|
doing = true
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {doing = true});
|
}
|
});
|
return false;
|
}
|
else{
|
console.log("123");
|
}
|
|
});
|
|
// form.on('select(ImportBillType)',function(data){
|
// var id = data.value;
|
// console.log(id);
|
// });
|
|
|
|
//获取浏览器参数
|
function getQueryString(name) {
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
var r = window.location.search.substr(1).match(reg);
|
if (r != null) return unescape(r[2]);
|
return null;
|
}
|
})
|
</script>
|
</body>
|
</html>
|