|
|
|
/*** *** add product *****///获取当前路径a=self.location.toString();var b="";for(i=0;i<a.split("/").length-2 ;i++){b=b+a.split("/")[i].toString()+"/";}function saveProduct() { var myBoolean = new Boolean(true); var menuTwo = $('#menuTwo').val(); if(menuTwo == '0') { myBoolean = false; alert('请选择 2 级菜单!'); } var menuThree = $('#menuThree').val(); if(menuThree == '0') { myBoolean = false; alert('请选择 3 级菜单!'); } var fileName = $('#upload').val(); if(fileName == '') { myBoolean = false; alert('请上传图片'); } if(fileName != '') { //获取 图片 后缀名(小写) var last = fileName.lastIndexOf(".")+1; var gs = fileName.substring(last,fileName.length).toLowerCase(); if(gs != 'jpg' && gs != 'gif' && gs != 'jpeg') { myBoolean = false; alert('图片格式不正确,请选择图片文件.'); } } //获取所有属性值 -- 属性var ps ='';$('select[name="selectName"]').each(function(){ps += $(this).val()+'select';;});$('#productSelect').val(ps);//alert('所有下拉属性:'+ps); //获取所有文本值 -- 属性 var pt = ''; $('input[name="textName"]').each(function(){pt += $(this).val()+'textName';});$('#productTextValue').val(pt); //alert('所有文本属性值-'+ps); //所有文本属性名称 var rs = ''; $('input[name="radioName"]').each( function() { rs += $(this).val()+'radioName'; });//alert('所有文本的属性名称-'+rs);$('#productText').val(rs); if(myBoolean) { document.frm.submit(); } }function queryMenuTwo(){document.getElementById('propertyList').innerHTML = '';var data = 'id='+$('#menuTwo').val();$.ajax({ url:'queryMenuThree.action', data:data, type:'post', cache:false, error:function(){ }, success:function(result){ document.getElementById('menuThreeDIV').innerHTML = result ;},error:function(){alert('请稍后再试或联系管理员.');} });}function queryMenuThree(){document.getElementById('propertyList').innerHTML = '';var data = 'id='+$('#menuThree').val();$.ajax({ url:'queryProductProperty.action', data:data, type:'post', cache:false, error:function(){ }, success:function(result){ //alert(result); var str = '<table>'; var result = eval('('+result+')'); var obj = {}; for(var i=0;i<result.length;i++) {//[{"classId":10,"id":4,"meij":0,"propertyDesc":"","propertyName":"期数","state":1}] for(var j in result[i]) { if(j == 'classId') { obj.classId = result[i][j]; }else if(j == 'id') { obj.id = result[i][j]; }else if(j == 'meij') { obj.meij = result[i][j]; }else if(j == 'propertyDesc') { obj.propertyDesc = result[i][j]; }else if(j == 'propertyName') { obj.propertyName = result[i][j]; }else if(j == 'state') { obj.state = result[i][j]; } } //******************************************************* //捞取 枚举信息 返回 JSON obj.valJson //拼凑 属性 :值 ( 容积:420,430,440 ) // 组装 table if(obj.meij == '0') { str += '<tr><td>'+'<div style=\"display:none\"><input type=\"radio\" id=\"radioName\" name=\"radioName\" value='+obj.id +' checked /></div>'+obj.propertyName+'<input type=\"text\" id=\"textName\" name=\"textName\" ></td></tr>'; }else { var data = 'classId='+obj.classId+'&propertyId='+obj.id+'&meij='+obj.meij; var url = b+'category/getBeanList.action'; $.ajax({ url:url, data:data, type:'post', cache:false, error:function(){ }, success:function(result){ str += '<tr><td>'+'<select id=\"selectName\" name=\"selectName\">'; var objP = {}; var result = eval('('+result+')'); for(var i=0;i<result.length;i++) {//[{"end":0,"id":1,"name":"420","start":0},{"end":0,"id":2,"name":"450","start":0}] for(var j in result[i]) { if(j == 'id') { objP.id = result[i][j]; }else if(j == 'name') { objP.name = result[i][j]; }else if(j == 'propertyId') { objP.propertyId = result[i][j]; }else if(j == 'propertyName') { objP.propertyName = result[i][j]; } } str += '<option value='+objP.propertyId+'cry'+objP.id+'>'+objP.name+'--'+objP.propertyName+'</option>'; } str += '</select></td></tr></table>'; document.getElementById('propertyList').innerHTML = str;},error:function(){alert('请稍后再试或联系管理员.');} }); } }},error:function(){alert('请稍后再试或联系管理员.');} });} |
|