materialsusing.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //初始化下标
  2. function resetTrNum(tableId) {
  3. $tbody = $("#"+tableId+"");
  4. $tbody.find('>tr').each(function(i){
  5. $(':input, select,button,a', this).each(function(){
  6. var $this = $(this), name = $this.attr('name'),id=$this.attr('id'),onclick_str=$this.attr('onclick'), val = $this.val();
  7. if(name!=null){
  8. if (name.indexOf("#index#") >= 0){
  9. $this.attr("name",name.replace('#index#',i));
  10. }else{
  11. var s = name.indexOf("[");
  12. var e = name.indexOf("]");
  13. var new_name = name.substring(s+1,e);
  14. $this.attr("name",name.replace(new_name,i));
  15. }
  16. //给明细添加弹出框
  17. name = $this.attr('name');
  18. if(name.indexOf("materialsUsingDetailsList") >= 0 && name.indexOf("pname") >= 0 ){
  19. $this.attr("class","searchbox-inputtext");
  20. $this.unbind("click");
  21. $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"
  22. ,"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")
  23. });
  24. }
  25. // 价格改鬓添加事件
  26. if(name.indexOf("materialsUsingDetailsList") >= 0 && name.indexOf("measureUnit") >= 0 ){
  27. $this.unbind();
  28. $this.bind("change",function(){
  29. var goodsCodeNo = $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(0).val();
  30. if(goodsCodeNo != null && goodsCodeNo != ''){
  31. $.ajax({
  32. url:"materialsUsingController.do?getPurchasePriceInfo",
  33. data:{goodsCode:goodsCodeNo,purchaseUnit:$this.val()},
  34. type:"Post",
  35. dataType:"json",
  36. success:function(data){
  37. if(data.status=="success" && data.pricinfo != null){
  38. var purchasePrice = data.pricinfo.retailPrice;//采购零售价
  39. $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(3).removeAttr("readonly");
  40. }else if(data.msg != null){
  41. $.messager.alert('提示信息',data.msg);
  42. $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(3).attr("readonly","readonly");
  43. $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(3).val('');
  44. getSumMoney();
  45. }else{
  46. $.messager.alert('提示信息',"计量单位在货品价格信息中没有设定,请在货品属性中先设定计量单位,或选择其他计量单位。");
  47. $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(3).attr("readonly","readonly");
  48. $("#add_materialsUsingDetails_table").find("tr").eq(i).find(":text").eq(3).val('');
  49. getSumMoney();
  50. }
  51. }});
  52. }
  53. });
  54. }
  55. }
  56. if(id!=null){
  57. if (id.indexOf("#index#") >= 0){
  58. $this.attr("id",id.replace('#index#',i));
  59. }else{
  60. var s = id.indexOf("[");
  61. var e = id.indexOf("]");
  62. var new_id = id.substring(s+1,e);
  63. $this.attr("id",id.replace(new_id,i));
  64. }
  65. }
  66. if(onclick_str!=null){
  67. if (onclick_str.indexOf("#index#") >= 0){
  68. $this.attr("onclick",onclick_str.replace(/#index#/g,i));
  69. }else{
  70. }
  71. }
  72. });
  73. $(this).find('div[name=\'xh\']').html(i+1);
  74. });
  75. }
  76. function updatewarehouse() {
  77. var warehouseid = $("#warehouseId").val();
  78. var billID = $("#id").val();
  79. //修改单据不刷新明细
  80. if( billID != null && billID != '' )
  81. return true;
  82. var url = "materialsUsingController.do?MaterialsUsingDetailsList&warehouseid=" + warehouseid;
  83. var currentTab = $('#tt').tabs('getSelected');
  84. $('#tt').tabs('update', {
  85. tab : currentTab,
  86. options : {
  87. href : url
  88. }
  89. });
  90. currentTab.panel('refresh');
  91. return true;
  92. }
  93. // 总金额 计算方法
  94. function getSumMoney(){
  95. }
  96. //
  97. //通用弹出式文件上传
  98. function commonUpload(callback,inputId){
  99. $.dialog({
  100. content: "url:systemController.do?commonUpload",
  101. lock : true,
  102. title:"文件上传",
  103. zIndex:2100,
  104. width:700,
  105. height: 200,
  106. parent:windowapi,
  107. cache:false,
  108. ok: function(){
  109. var iframe = this.iframe.contentWindow;
  110. iframe.uploadCallback(callback,inputId);
  111. return true;
  112. },
  113. cancelVal: '关闭',
  114. cancel: function(){
  115. }
  116. });
  117. }
  118. //通用弹出式文件上传-回调
  119. function commonUploadDefaultCallBack(url,name,inputId){
  120. $("#"+inputId+"_href").attr('href',url).html('下载');
  121. $("#"+inputId).val(url);
  122. }
  123. function browseImages(inputId, Img) {// 图片管理器,可多个上传共用
  124. var finder = new CKFinder();
  125. finder.selectActionFunction = function(fileUrl, data) {//设置文件被选中时的函数
  126. $("#" + Img).attr("src", fileUrl);
  127. $("#" + inputId).attr("value", fileUrl);
  128. };
  129. finder.resourceType = 'Images';// 指定ckfinder只为图片进行管理
  130. finder.selectActionData = inputId; //接收地址的input ID
  131. finder.removePlugins = 'help';// 移除帮助(只有英文)
  132. finder.defaultLanguage = 'zh-cn';
  133. finder.popup();
  134. }
  135. function browseFiles(inputId, file) {// 文件管理器,可多个上传共用
  136. var finder = new CKFinder();
  137. finder.selectActionFunction = function(fileUrl, data) {//设置文件被选中时的函数
  138. $("#" + file).attr("href", fileUrl);
  139. $("#" + inputId).attr("value", fileUrl);
  140. decode(fileUrl, file);
  141. };
  142. finder.resourceType = 'Files';// 指定ckfinder只为文件进行管理
  143. finder.selectActionData = inputId; //接收地址的input ID
  144. finder.removePlugins = 'help';// 移除帮助(只有英文)
  145. finder.defaultLanguage = 'zh-cn';
  146. finder.popup();
  147. }
  148. function decode(value, id) {//value传入值,id接受值
  149. var last = value.lastIndexOf("/");
  150. var filename = value.substring(last + 1, value.length);
  151. $("#" + id).text(decodeURIComponent(filename));
  152. }