clothingApply.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. //add_clothingApplyDetail_table
  18. var warehouseid = $("#warehouseid").val();
  19. var departid = $("#departid").val();
  20. //给明细添加弹出框
  21. name = $this.attr('name');
  22. if(name.indexOf("clothingApplyDetailList") >= 0 && name.indexOf("realname") >= 0 ){
  23. $this.attr("class","searchbox-inputtext");
  24. $this.unbind("click");
  25. $this.bind("click",function(){
  26. myPopClick_embed("clothingApplyDetailList\["+i+"\]\.realname,clothingApplyDetailList\["+i+"\]\.userid,clothingApplyDetailList\["+i+"\]\.entrydate"
  27. ,"realName,id,contractStime"
  28. ,"publicpageController.do?userSelectSameAndSubDepart&departid="+departid
  29. ,"realname");
  30. });
  31. }
  32. if(name.indexOf("clothingApplyDetailList") >= 0 && name.indexOf("clothingname") >= 0 ){
  33. $this.attr("class","searchbox-inputtext");
  34. $this.unbind("click");
  35. $this.bind("click",function(){
  36. var clothids = $("[name='clothingApplyDetailList\["+i+"\]\.clothingid']").val();
  37. myPopClick_embed("clothingApplyDetailList\["+i+"\]\.clothingname,clothingApplyDetailList\["+i+"\]\.clothingid,clothingApplyDetailList\["+i+"\]\.unit,clothingApplyDetailList\["+i+"\]\.type,clothingApplyDetailList\["+i+"\]\.price"
  38. ,"name,id,unit,type,price"
  39. ,"publicpageController.do?clothingSelectAll&checkbox=true&ids="+clothids
  40. ,"clothingname",function(selectRow){
  41. for(var j=0;j<selectRow.length;j++){
  42. var one = selectRow[j];
  43. var newIndex = i+j;
  44. if(j>0){//复制行
  45. var tr = $("#add_clothingApplyDetail_table tr:eq("+(newIndex-1)+")");
  46. var cloneTr = tr.clone();
  47. tr.after(cloneTr);
  48. // $("#add_clothingApplyDetail_table").append(tr);
  49. resetTrNum('add_clothingApplyDetail_table');
  50. }
  51. var newIndex = i+j;
  52. $("[name='clothingApplyDetailList\["+newIndex+"\]\.clothingname']").val(one.name);
  53. $("[name='clothingApplyDetailList\["+newIndex+"\]\.clothingid']").val(one.id);
  54. $("[name='clothingApplyDetailList\["+newIndex+"\]\.unit']").val(one.unit);
  55. $("[name='clothingApplyDetailList\["+newIndex+"\]\.type']").val(one.type);
  56. $("[name='clothingApplyDetailList\["+newIndex+"\]\.price']").val(one.price?one.price:0);
  57. $("[name='clothingApplyDetailList\["+newIndex+"\]\.quantity']").val(1);
  58. setMoney(newIndex);
  59. // 设置服装启用日期,上次申领日期
  60. setClothTime(newIndex);
  61. }
  62. });
  63. // $("[name='"+"clothingApplyDetailList["+i+"].quantity']").val(1);
  64. });
  65. }
  66. if(id!=null){
  67. if (id.indexOf("#index#") >= 0){
  68. $this.attr("id",id.replace('#index#',i));
  69. }else{
  70. var s = id.indexOf("[");
  71. var e = id.indexOf("]");
  72. var new_id = id.substring(s+1,e);
  73. $this.attr("id",id.replace(new_id,i));
  74. }
  75. }
  76. if(onclick_str!=null){
  77. if (onclick_str.indexOf("#index#") >= 0){
  78. $this.attr("onclick",onclick_str.replace(/#index#/g,i));
  79. }else{
  80. }
  81. }
  82. });
  83. $(this).find('div[name=\'xh\']').html(i+1);
  84. });
  85. }
  86. //通用弹出式文件上传
  87. function commonUpload(callback,inputId){
  88. $.dialog({
  89. content: "url:systemController.do?commonUpload",
  90. lock : true,
  91. title:"文件上传",
  92. zIndex:getzIndex(),
  93. width:700,
  94. height: 200,
  95. parent:windowapi,
  96. cache:false,
  97. ok: function(){
  98. var iframe = this.iframe.contentWindow;
  99. iframe.uploadCallback(callback,inputId);
  100. return true;
  101. },
  102. cancelVal: '关闭',
  103. cancel: function(){
  104. }
  105. });
  106. }
  107. //通用弹出式文件上传-回调
  108. function commonUploadDefaultCallBack(url,name,inputId){
  109. $("#"+inputId+"_href").attr('href',url).html('下载');
  110. $("#"+inputId).val(url);
  111. }
  112. function browseImages(inputId, Img) {// 图片管理器,可多个上传共用
  113. }
  114. function browseFiles(inputId, file) {// 文件管理器,可多个上传共用
  115. }
  116. function decode(value, id) {//value传入值,id接受值
  117. var last = value.lastIndexOf("/");
  118. var filename = value.substring(last + 1, value.length);
  119. $("#" + id).text(decodeURIComponent(filename));
  120. }
  121. function setClothTime(lineNo) {
  122. $.ajax({
  123. url:"clothingApplyController.do?getClothingUserInfo",
  124. data:{userid:$("[name='clothingApplyDetailList["+lineNo+"].userid']").val(),clothingid:$("[name='clothingApplyDetailList["+lineNo+"].clothingid']").val()},
  125. type:"Post",
  126. dataType:"json",
  127. success:function(data){
  128. if(data.status=="success" && data.startdate != null){
  129. var startdate = data.startdate;
  130. var lastdate = data.lastdate;
  131. $("[name='clothingApplyDetailList["+lineNo+"].startdate']").val(startdate);
  132. $("[name='clothingApplyDetailList["+lineNo+"].lastdate']").val(lastdate);
  133. }
  134. }
  135. });
  136. }
  137. function myPopClick_embed(obj,name,url,objectname,cb) {
  138. $.dialog.setting.zIndex = getzIndex(true);
  139. var names = name.split(",");
  140. var objs = obj.split(",");
  141. $.dialog({
  142. content: "url:"+url,
  143. zIndex: getzIndex(),
  144. lock : true,
  145. title:"选择",
  146. width:900,
  147. height: 600,
  148. parent:windowapi,
  149. cache:true,
  150. ok: function(){
  151. iframe = this.iframe.contentWindow;
  152. var selected = iframe.getSelectRows();
  153. //alert(JSON.stringify(selected));
  154. //alert(names);
  155. if (selected == '' || selected == null ){
  156. alert("请选择");
  157. return false;
  158. }else {
  159. for(var i1=0;i1<names.length;i1++){
  160. var str = "";
  161. $.each( selected, function(i, n){
  162. if (i==0)
  163. str+= n[names[i1]];
  164. else{
  165. str+= ",";
  166. str+=n[names[i1]];
  167. }
  168. });
  169. if($("#"+objs[i1]).length>=1){
  170. $("#"+objs[i1]).val("");
  171. $("#"+objs[i1]).val(str);
  172. }else{
  173. $("[name='"+objs[i1]+"']").val("");
  174. $("[name='"+objs[i1]+"']").val(str);
  175. if(objs[i1].indexOf("entrydate") > -1){
  176. $("[name='"+objs[i1]+"']").val(str.substring(0,10));
  177. }
  178. }
  179. }
  180. if(cb) cb(selected);
  181. return true;
  182. }
  183. },
  184. cancelVal: '关闭',
  185. cancel: true /*为true等价于function(){}*/
  186. });
  187. }
  188. function beforeSave(){
  189. $tbody = $("#add_clothingApplyDetail_table");
  190. $tbody.find('>tr').each(function(i){
  191. $(':input, select,button,a', this).each(function(){
  192. $("#add_clothingApplyDetail_table").find("tr").eq(i).find("select").eq(0).removeAttr("disabled");
  193. });
  194. });
  195. return true;
  196. }