//初始化下标 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)); } //给明细添加弹出框 name = $this.attr('name'); if(name.indexOf("materialsUsingDetailsList") >= 0 && name.indexOf("pname") >= 0 ){ $this.attr("class","searchbox-inputtext"); $this.unbind("click"); $this.bind("click",function(){popClick_embed("materialsUsingDetailsList\["+i+"\]\.pnumber,materialsUsingDetailsList\["+i+"\]\.pname,materialsUsingDetailsList\["+i+"\]\.specType,materialsUsingDetailsList\["+i+"\]\.measureUnit,materialsUsingDetailsList\["+i+"\]\.purchasePrice,materialsUsingDetailsList\["+i+"\]\.goodsId,materialsUsingDetailsList\["+i+"\]\.money,materialsUsingDetailsList\["+i+"\]\.quantity" ,"goodsCode,goodsName,specification,salesUnit,goodsDesc,id,strEmpty,strEmpty","ordersController.do?selectReferGoods&classname=cn.com.lzt.goodsinfo.entity.TBGoodsInfoEntity&codefield=goodsCode&categoryfield=belongCategoryCode&categoryNamefield=belongCategoryName&namefield=goodsName&purchaseUnit=salesUnit&specification=specification&goodsDesc=goodsDesc&strEmpty=strEmpty") }); } // 价格改鬓添加事件 if(name.indexOf("materialsUsingDetailsList") >= 0 && name.indexOf("measureUnit") >= 0 ){ $this.unbind(); $this.bind("change",function(){ var goodsCodeNo = $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(0).val(); if(goodsCodeNo != null && goodsCodeNo != ''){ $.ajax({ url:"materialsUsingController.do?getPurchasePriceInfo", data:{goodsCode:goodsCodeNo,purchaseUnit:$this.val()}, type:"Post", dataType:"json", success:function(data){ if(data.status=="success" && data.pricinfo != null){ var purchasePrice = data.pricinfo.retailPrice;//采购零售价 $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(3).removeAttr("readonly"); }else if(data.msg != null){ $.messager.alert('提示信息',data.msg); $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(3).attr("readonly","readonly"); $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(3).val(''); getSumMoney(); }else{ $.messager.alert('提示信息',"计量单位在货品价格信息中没有设定,请在货品属性中先设定计量单位,或选择其他计量单位。"); $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(3).attr("readonly","readonly"); $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(3).val(''); getSumMoney(); } }}); } }); } } 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 updatewarehouse() { var warehouseid = $("#warehouseId").val(); var billID = $("#id").val(); //修改单据不刷新明细 if( billID != null && billID != '' ) return true; var url = "materialsUsingController.do?MaterialsUsingDetailsList&warehouseid=" + warehouseid; var currentTab = $('#tt').tabs('getSelected'); $('#tt').tabs('update', { tab : currentTab, options : { href : url } }); currentTab.panel('refresh'); return true; } // 总金额 计算方法 function getSumMoney(){ } // //通用弹出式文件上传 function commonUpload(callback,inputId){ $.dialog({ content: "url:systemController.do?commonUpload", lock : true, title:"文件上传", zIndex:2100, 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) {// 图片管理器,可多个上传共用 var finder = new CKFinder(); finder.selectActionFunction = function(fileUrl, data) {//设置文件被选中时的函数 $("#" + Img).attr("src", fileUrl); $("#" + inputId).attr("value", fileUrl); }; finder.resourceType = 'Images';// 指定ckfinder只为图片进行管理 finder.selectActionData = inputId; //接收地址的input ID finder.removePlugins = 'help';// 移除帮助(只有英文) finder.defaultLanguage = 'zh-cn'; finder.popup(); } function browseFiles(inputId, file) {// 文件管理器,可多个上传共用 var finder = new CKFinder(); finder.selectActionFunction = function(fileUrl, data) {//设置文件被选中时的函数 $("#" + file).attr("href", fileUrl); $("#" + inputId).attr("value", fileUrl); decode(fileUrl, file); }; finder.resourceType = 'Files';// 指定ckfinder只为文件进行管理 finder.selectActionData = inputId; //接收地址的input ID finder.removePlugins = 'help';// 移除帮助(只有英文) finder.defaultLanguage = 'zh-cn'; finder.popup(); } function decode(value, id) {//value传入值,id接受值 var last = value.lastIndexOf("/"); var filename = value.substring(last + 1, value.length); $("#" + id).text(decodeURIComponent(filename)); }