mode_custxiao.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //流程模块【custxiao.销售】下录入页面自定义js页面,初始函数
  2. function initbodys(){
  3. //记录原来选择的
  4. c.daossdts=[];
  5. c.onselectdatabefore=function(){
  6. this.daossdts = this.getsubdata(0);
  7. }
  8. //这个是很复杂的叠加关系,时间久了谁也不知道是干嘛用的
  9. c.onselectdataall=function(fid,seld,sna,sid){
  10. if(!seld || !sna)return;
  11. var da = [];
  12. if(!seld[0]){
  13. da[0]=seld;
  14. }else{
  15. da = seld;
  16. }
  17. var nam = this.getxuandoi(fid),snua;
  18. var dao=this.daossdts,i,j,bo,d,oi=parseFloat(nam[1]),oii=-1;
  19. for(i=0;i<da.length;i++){
  20. d = da[i];
  21. bo = false;
  22. for(j=0;j<dao.length;j++)if(dao[j].aid==d.value)bo=true;
  23. oii++;
  24. if(!bo){
  25. if(oii>0){
  26. snua= ''+nam[3]+''+nam[0]+'_'+(oi+oii)+'';
  27. if(!form(snua) || form(snua).value!=''){
  28. nam = this.insertrow(0,{},true);
  29. }else{
  30. nam[1]=parseFloat(nam[1])+1;
  31. }
  32. }
  33. this.setrowdata(nam[0],nam[1],{
  34. unit:d.unit,
  35. price:d.price,
  36. temp_aid:d.name,
  37. aid:d.value
  38. });
  39. }else{
  40. oii--;
  41. if(i==0){
  42. this.setrowdata(nam[0],nam[1],{
  43. unit:'',
  44. price:'0',
  45. temp_aid:'',
  46. aid:'0'
  47. });
  48. }
  49. }
  50. }
  51. }
  52. $(form('custractid')).change(function(){
  53. var val = this.value,txt='';
  54. custractidchange(val);
  55. });
  56. c.onselectdatabefore=function(fid){
  57. if(fid=='custname'){
  58. var val=form('custractid').value;
  59. if(val>'0' && form('custname').value!='')return '客户已关联合同不需要重新选择';
  60. }
  61. }
  62. }
  63. function changesubmit(){
  64. if(get('tablesub0')){
  65. var da = c.getsubdata(0),d1;
  66. for(var i=0;i<da.length;i++){
  67. d1 = da[i];
  68. if(!d1.aid)return '行['+(i+1)+']必须选择物品';
  69. if(d1.count<=0)return '行['+(i+1)+']数量必须大于0';
  70. }
  71. }
  72. }
  73. function eventaddsubrows(xu,oj){
  74. c.setrowdata(xu,oj,{
  75. aid:'0'
  76. });
  77. }
  78. function custractidchange(v){
  79. if(v=='' || v=='0'){
  80. form('custid').value='';
  81. form('custname').value='';
  82. return;
  83. }
  84. js.ajax(geturlact('ractchange'),{ractid:v},function(a){
  85. form('custid').value=a.custid;
  86. form('custname').value=a.custname;
  87. form('money').value=a.money;
  88. },'get,json');
  89. }