<@p.form action="save.aj" refreshId="list-page" class="ajaxfrm" method="post" stopRefresh=false id="queryForm">
<div class="div-kuang">
<table width="760" border="0" cellpadding="0" cellspacing="5">
<tr>
<td colspan="3"><input name="button" type="button" class="input-m" id="button" value="添加商品" onClick="show();"></td>
</tr>
<tr>
<td width="49">类型:</td>
<td width="110"><label for="select4"></label>
<select name="applyTyp" class="input-m" id="applyTyp" οnchange="changeSel();">
<option value="1" selected=true>转仓</option>
<option value="2" >退仓</option>
</select></td>
<td colspan="3"> </td>
</tr>
<tr class="tc">
<td height="46" colspan="2">转出仓储公司及仓库</td>
<td width="109"><label for="select"></label>
<input type="hidden" id="fromCompanyName" name="fromCompanyName"/>
<select name="fromCompanyId" class="input-m" id="fromCompanyId">
</select></td>
<td width="105">
<input type="hidden" id="fromWhId" name="fromWhId"/>
<select name="fromWhName" class="input-m" id="fromWhName" >
</select></td>
</tr>
<tr class="tc">
<td colspan="5"> </td>
</tr>
<tr class="tc">
<td colspan="2">转入仓储公司及仓库</td>
<td width="109"><label for="select"></label>
<input type="hidden" id="toCompanyName" name="toCompanyName"/>
<select name="toCompanyId" class="input-m" id="toCompanyId">
</select></td>
<td width="105">
<input type="hidden" id="whName" name="toWhName" />
<select name="toWhId" class="input-m" id="toWhId" >
</select></td>
</tr>
<tr class="zc">
<td height="46" colspan="2">转出仓储公司及仓库</td>
<td width="109"><label for="select"></label>
<select name="select" class="input-m" id="tcCompany">
</select></td>
<td width="105"><select name="select2" class="input-m" id="tcHome">
</select></td>
</tr>
<tr class="zc">
<td colspan="2" rowspan="2">配送方式:</td>
<td><input type="radio" name="dlvWay" id="radio" value="1" checked />
<label for="radio">自有配送</label></td>
<td><label for="textfield"></label>
<input name="number" type="text" class="input-m" id="number1"/></td>
<td> </td>
</tr>
<tr class="zc">
<td><input type="radio" name="dlvWay" id="radio2" value="2" />
<label for="radio2">快递</label></td>
<td><input name="number" type="text" class="input-m" id="number2"/></td>
<td> </td>
</tr>
</table>
<table width="740" border="1" cellspacing="0" cellpadding="0" id="tableObj">
<tbody>
<tr>
<td bgcolor="#EBEBEB">商品SKU</td>
<td bgcolor="#EBEBEB">商品名称</td>
<td bgcolor="#EBEBEB">数量</td>
<td bgcolor="#EBEBEB">报警时间</td>
<td bgcolor="#EBEBEB">删除商品</td>
</tr>
</tbody>
</table>
</table>
<table width="760" border="0" cellspacing="10" cellpadding="0">
<tr>
<td align="center"><input type="button" name="button3" id="button3" value="保存" οnclick="javascript:save();"/>
<input type="button" name="button2" id="button2" value="取消" οnclick="javascript:back()" /></td>
</tr>
</table>
</div>
</@p.form >
<script>
<#--返回到主页-->
function back(){
window.location.href="index_list.j";
}
<#--保存验证-->
function save(){
//类型:1:转仓 2:退仓
var applyTyp=$('#applyTyp').find("option:selected").val();
var jsonArray=new Array();
if(applyTyp==1){
var ctcCompanyValue=$('#fromCompanyId').find("option:selected").val();
var ctcCompanyText=$('#fromCompanyId').find("option:selected").text();
var ctcHomeValue=$('#fromWhId').find("option:selected").val();
var ctcHomeText=$('#fromWhId').find("option:selected").text();
var ltcCompanyValue=$('#toCompanyId').find("option:selected").val();
var ltcCompanyText=$('#toCompanyId').find("option:selected").text();
var ltcHomeValue=$('#toWhId').find("option:selected").val();
var ltcHomeText=$('#toWhId').find("option:selected").text();
jsonArray[0]=applyTyp;
jsonArray[1]=ctcCompanyValue;
jsonArray[2]=ctcCompanyText;
jsonArray[3]=ctcHomeValue;
jsonArray[4]=ctcHomeText;
jsonArray[5]=ltcCompanyValue;
jsonArray[6]=ltcCompanyText;
jsonArray[7]=ltcHomeValue;
jsonArray[8]=ltcHomeText
//转仓和入仓不能相同
if(ctcCompanyValue==ltcCompanyValue){
if(ctcHomeValue==ltcHomeValue){
alert("相同仓储公司转仓与入仓仓库不能相同!");
return;
}
}
}else{
var tcCompanyValue=$('#tcCompany').find("option:selected").val();
var tcCompanyText=$('#tcCompany').find("option:selected").text();
var tcHomeValue=$('#tcHome').find("option:selected").val();
var tcHomeText=$('#tcHome').find("option:selected").text();
//配送方式 1:自有配送 2:快递
// 车牌号/单号(由配送方式决定)
var dlvWay=$('input:radio[name="dlvWay"]:checked').val();
var number;
//非空判断
if(dlvWay==1){
number=$('#number1').val();
if(null==number||number==""){
alert("请填写自有配送内容!");
return;
}
}else{
number=$('#number2').val();
if(null==number||number==""){
alert("请填写快递内容!");
return;
}
}
jsonArray[0]=applyTyp;
jsonArray[1]=tcCompanyValue;
jsonArray[2]=tcCompanyText;
jsonArray[3]=tcHomeValue;
jsonArray[4]=tcHomeText;
jsonArray[5]=tcCompanyValue;
jsonArray[6]=dlvWay;
jsonArray[7]=number;
}
if($("#tableObj").find("tr").length<=1){
alert("请选择商品!");
return;
}
//提交保存
//得到列表中的数据
var strData=tostrings();
$.ajax({cache: false,
url: "save.aj",
type:"post",
data: {
"applyTyp":applyTyp,
"jsonArray":jsonArray,
"strData":strData
},
success: function(data) {
alert(data);
console.log(data);
window.location.href="index_list.j";
},
error: function(data) {
alert("保存错误!"+ data);
console.log(data);
window.location.href="index_list.j";
}
});
}
<#--拼接字符数组-->
function tostrings(){
var strs="";
$("#table1").find(".storenext").each(function(){
strs+=$(this).val() + ",";
});
strs = strs.substr(0,strs.length-1);
return strs;
}
<#--动态删除商品行-->
var clicktimes = $("#table1").find("tr").length;
$("#table1").find(".dela").each(function(){
$(this).click(function(e){
e.preventDefault();
clicktimes--;
if(clicktimes>2){
$(this).parent("td").parent("tr").remove();
tostrings();
}else{
alert("不能删除所有的调拨商品!");
return;
}
});
});
<#--初始化隐藏 div 不能在table里-->
$(document).ready(function(){
$(".zc").hide();
});
<#--改变调拨类型画面-->
function changeSel(){
if($('#applyTyp').find("option:selected").val()==1){
$(".zc").hide();
$(".tc").show();
}else{
$(".tc").hide();
$(".zc").show();
}
}
<#--加载仓储公司-->
$(function(){
$.ajax({
type:"get",
dataType:"JSON",
url:"queryAllWarehouse.aj",
success:function(data){
var result = $.parseJSON(data.value);
var str1='';
var str2="";
$.each(result,function(key, val){
str1 += '<option value="'+val[0].companyId+'">'+val[0].companyName+'</option>';
});
$("#fromCompanyId").empty();
$("#fromCompanyId").append(str1);
$("#toCompanyId").empty();
$("#toCompanyId").append(str1);
$("#tcCompany").empty();
$("#tcCompany").append(str1);
var selectedval = $("#fromCompanyId option:selected").text();
var selectedval = $("#toCompanyId option:selected").text();
var dqdata = result[selectedval];
if (typeof(dqdata) != "undefined") {
$.each(dqdata,function(dqkey,dqval){
str2 += '<option value="'+dqval.whId+'">' + dqval.whName + '</option>';
});
$("#fromWhId").empty();
$("#fromWhId").append(str2);
$("#toWhId").empty();
$("#toWhId").append(str2);
$("#tcHome").empty();
$("#tcHome").append(str2);
}
$("#fromCompanyId").change(function(){
str2='';
var selectedval1 = $("#fromCompanyId option:selected").text();
var dqdata1 = result[selectedval1];
$.each(dqdata1,function(dqkey1, dqval1){
str2 += '<option value="'+dqval1.whId+'">' + dqval1.whName + '</option>';
});
$("#fromWhId").empty();
$("#fromWhId").append(str2);
str2="";
});
$("#toCompanyId").change(function(){
str2='';
var selectedval1 = $("#toCompanyId option:selected").text();
var dqdata1 = result[selectedval1];
$.each(dqdata1,function(dqkey1, dqval1){
str2 += '<option value="'+dqval1.whId+'">' + dqval1.whName + '</option>';
});
$("#toWhId").empty();
$("#toWhId").append(str2);
str2="";
});
$("#tcCompany").change(function(){
str2='';
var selectedval1 = $("#tcCompany option:selected").text();
var dqdata1 = result[selectedval1];
$.each(dqdata1,function(dqkey1, dqval1){
str2 += '<option value="'+dqval1.whId+'">' + dqval1.whName + '</option>';
});
$("#tcHome").empty();
$("#tcHome").append(str2);
str2="";
});
}
});
});
//选择商品
function show()
{
var a=window.showModalDialog('initproduct.aj',"pwin",'dialogWidth:780px;dialogHeight:360px;help:no;center:yes;resizable:no;scroll:no');
var arr=new Array();//商品信息(sku,名称 ,数量 ,报警时间 )
for(var i=0;i<a.length;i++){
arr=a[i].split(',');//注split可以用字符或字符串分割
var vTr= "<tr>";
for(var j=0;j<arr.length;j++)
{
if(j==2){
vTr=vTr+"<td><input type='hidden' value="+arr[j]+" name="stoInfoPoList["+i+"]."+arr[j]+"/><input type='text' value="+arr[j]+" /></td>";
}else{
vTr=vTr+"<td><input type='hidden' value="+arr[j]+" name="stoInfoPoList["+i+"]."+arr[j]+"/>"+arr[j]+"</td>";
}
}
vTr=vTr+"<td><input type='button' value='删除' class='dela' onClick='javascript:deletetr(this);'/></td>";
vTr=vTr+"</tr>";
$("#tableObj").append(vTr);
}
App.colorbox.resize();
}
//删除商品
function deletetr(obj){
$(obj).parent("td").parent("tr").remove();
App.colorbox.resize();
}
//提交保存
</script>
js验证
最新推荐文章于 2024-07-18 18:51:11 发布