//初始化下标 function resetTrNum(tableId) { $tbody = $("#"+tableId+""); $tbody.find('>tr').each(function(i){ $(':input, select,button,a', this).each(function(){ var $this = $(this), name = $this.attr('name'),id=$this.attr('id'),onclick_str=$this.attr('onclick'), val = $this.val(); if(name!=null){ if (name.indexOf("#index#") >= 0){ $this.attr("name",name.replace('#index#',i)); }else{ var s = name.indexOf("["); var e = name.indexOf("]"); var new_name = name.substring(s+1,e); $this.attr("name",name.replace(new_name,i)); } } //add_clothingApplyDetail_table var warehouseid = $("#warehouseid").val(); var departid = $("#departid").val(); //给明细添加弹出框 name = $this.attr('name'); if(name.indexOf("clothingApplyDetailList") >= 0 && name.indexOf("realname") >= 0 ){ $this.attr("class","searchbox-inputtext"); $this.unbind("click"); $this.bind("click",function(){ myPopClick_embed("clothingApplyDetailList\["+i+"\]\.realname,clothingApplyDetailList\["+i+"\]\.userid,clothingApplyDetailList\["+i+"\]\.entrydate" ,"realName,id,contractStime" ,"publicpageController.do?userSelectSameAndSubDepart&departid="+departid ,"realname"); }); } if(name.indexOf("clothingApplyDetailList") >= 0 && name.indexOf("clothingname") >= 0 ){ $this.attr("class","searchbox-inputtext"); $this.unbind("click"); $this.bind("click",function(){ var clothids = $("[name='clothingApplyDetailList\["+i+"\]\.clothingid']").val(); myPopClick_embed("clothingApplyDetailList\["+i+"\]\.clothingname,clothingApplyDetailList\["+i+"\]\.clothingid,clothingApplyDetailList\["+i+"\]\.unit,clothingApplyDetailList\["+i+"\]\.type,clothingApplyDetailList\["+i+"\]\.price" ,"name,id,unit,type,price" ,"publicpageController.do?clothingSelectAll&checkbox=true&ids="+clothids ,"clothingname",function(selectRow){ for(var j=0;j0){//复制行 var tr = $("#add_clothingApplyDetail_table tr:eq("+(newIndex-1)+")"); var cloneTr = tr.clone(); tr.after(cloneTr); // $("#add_clothingApplyDetail_table").append(tr); resetTrNum('add_clothingApplyDetail_table'); } var newIndex = i+j; $("[name='clothingApplyDetailList\["+newIndex+"\]\.clothingname']").val(one.name); $("[name='clothingApplyDetailList\["+newIndex+"\]\.clothingid']").val(one.id); $("[name='clothingApplyDetailList\["+newIndex+"\]\.unit']").val(one.unit); $("[name='clothingApplyDetailList\["+newIndex+"\]\.type']").val(one.type); $("[name='clothingApplyDetailList\["+newIndex+"\]\.price']").val(one.price?one.price:0); $("[name='clothingApplyDetailList\["+newIndex+"\]\.quantity']").val(1); setMoney(newIndex); // 设置服装启用日期,上次申领日期 setClothTime(newIndex); } }); // $("[name='"+"clothingApplyDetailList["+i+"].quantity']").val(1); }); } if(id!=null){ if (id.indexOf("#index#") >= 0){ $this.attr("id",id.replace('#index#',i)); }else{ var s = id.indexOf("["); var e = id.indexOf("]"); var new_id = id.substring(s+1,e); $this.attr("id",id.replace(new_id,i)); } } if(onclick_str!=null){ if (onclick_str.indexOf("#index#") >= 0){ $this.attr("onclick",onclick_str.replace(/#index#/g,i)); }else{ } } }); $(this).find('div[name=\'xh\']').html(i+1); }); } //通用弹出式文件上传 function commonUpload(callback,inputId){ $.dialog({ content: "url:systemController.do?commonUpload", lock : true, title:"文件上传", zIndex:getzIndex(), width:700, height: 200, parent:windowapi, cache:false, ok: function(){ var iframe = this.iframe.contentWindow; iframe.uploadCallback(callback,inputId); return true; }, cancelVal: '关闭', cancel: function(){ } }); } //通用弹出式文件上传-回调 function commonUploadDefaultCallBack(url,name,inputId){ $("#"+inputId+"_href").attr('href',url).html('下载'); $("#"+inputId).val(url); } function browseImages(inputId, Img) {// 图片管理器,可多个上传共用 } function browseFiles(inputId, file) {// 文件管理器,可多个上传共用 } function decode(value, id) {//value传入值,id接受值 var last = value.lastIndexOf("/"); var filename = value.substring(last + 1, value.length); $("#" + id).text(decodeURIComponent(filename)); } function setClothTime(lineNo) { $.ajax({ url:"clothingApplyController.do?getClothingUserInfo", data:{userid:$("[name='clothingApplyDetailList["+lineNo+"].userid']").val(),clothingid:$("[name='clothingApplyDetailList["+lineNo+"].clothingid']").val()}, type:"Post", dataType:"json", success:function(data){ if(data.status=="success" && data.startdate != null){ var startdate = data.startdate; var lastdate = data.lastdate; $("[name='clothingApplyDetailList["+lineNo+"].startdate']").val(startdate); $("[name='clothingApplyDetailList["+lineNo+"].lastdate']").val(lastdate); } } }); } function myPopClick_embed(obj,name,url,objectname,cb) { $.dialog.setting.zIndex = getzIndex(true); var names = name.split(","); var objs = obj.split(","); $.dialog({ content: "url:"+url, zIndex: getzIndex(), lock : true, title:"选择", width:900, height: 600, parent:windowapi, cache:true, ok: function(){ iframe = this.iframe.contentWindow; var selected = iframe.getSelectRows(); //alert(JSON.stringify(selected)); //alert(names); if (selected == '' || selected == null ){ alert("请选择"); return false; }else { for(var i1=0;i1=1){ $("#"+objs[i1]).val(""); $("#"+objs[i1]).val(str); }else{ $("[name='"+objs[i1]+"']").val(""); $("[name='"+objs[i1]+"']").val(str); if(objs[i1].indexOf("entrydate") > -1){ $("[name='"+objs[i1]+"']").val(str.substring(0,10)); } } } if(cb) cb(selected); return true; } }, cancelVal: '关闭', cancel: true /*为true等价于function(){}*/ }); } function beforeSave(){ $tbody = $("#add_clothingApplyDetail_table"); $tbody.find('>tr').each(function(i){ $(':input, select,button,a', this).each(function(){ $("#add_clothingApplyDetail_table").find("tr").eq(i).find("select").eq(0).removeAttr("disabled"); }); }); return true; }