option.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /**
  2. * 系统选项分类操作
  3. */
  4. function optionclass(cans){
  5. var me = this;
  6. this.sspid = 0;
  7. this.typeid = 0;
  8. this.reloadtype = function(){
  9. this.at.reload();
  10. }
  11. this.clicktypeeidt = function(){
  12. var d = this.at.changedata;
  13. if(d.id)this.clicktypewin(false, 1, d);
  14. }
  15. this.clicktypewin = function(o1, lx, da){
  16. var h = $.bootsform({
  17. title:this.title,height:250,width:300,
  18. tablename:'option',labelWidth:50,
  19. isedit:lx,submitfields:'name,sort,pid',cancelbtn:false,
  20. items:[{
  21. labelText:'名称',name:'name',required:true
  22. },{
  23. labelText:'上级id',name:'pid',value:0,type:'hidden'
  24. },{
  25. labelText:'排序号',name:'sort',type:'number',value:0
  26. }],
  27. success:function(){
  28. me.reloadtype();
  29. }
  30. });
  31. if(lx==1)h.setValues(da);
  32. if(lx==0)h.setValue('pid',this.typeid);
  33. h.form.name.focus();
  34. return h;
  35. }
  36. this.typedel = function(o1){
  37. this.at.del({
  38. url:js.getajaxurl('deloption','option','system'),params:{'stable':this.stable}
  39. });
  40. }
  41. this.optionmove = function(){
  42. var d = this.at.changedata;
  43. if(!d || !d.id){js.msg('msg','没有选中行');return;}
  44. this.movedata = d;
  45. js.msg('success','请在5秒内选择其他分类确认移动');
  46. clearTimeout(this.cmoeefese);
  47. this.cmoeefese=setTimeout(function(){me.movedata=false;},5000);
  48. }
  49. this.ismoveok=function(d){
  50. var md = this.movedata;
  51. if(md && md.id && md.id!=d.id){
  52. js.confirm('确定要将['+md.name+']移动到['+d.name+']下吗?',function(jg){
  53. if(jg=='yes'){
  54. me.movetoss(md.id,d.id,0);
  55. }
  56. });
  57. }
  58. }
  59. this.optionmoveto=function(){
  60. var d = this.at.changedata;
  61. if(!d || !d.id || this.sspid==0)return;
  62. js.confirm('确定要将['+d.name+']移动到顶级吗?',function(jg){
  63. if(jg=='yes'){
  64. me.movetoss(d.id,me.sspid,1);
  65. }
  66. });
  67. }
  68. this.movetoss=function(id,toid,lx){
  69. js.ajax(js.getajaxurl('movetype','option','system'),{'id':id,'toid':toid,'lx':lx},function(s){
  70. if(s!='ok'){
  71. js.msg('msg', s);
  72. }else{
  73. me.reloadtype();
  74. }
  75. },'get',false, '移动中...,移动成功');
  76. this.movedata=false;
  77. }
  78. this.createtable=function(){
  79. this.at = $('#'+this.optionview+'').bootstree({
  80. url:js.getajaxurl('gettreedata','option','system',{'num':this.optionnum}),
  81. columns:[{
  82. text:this.title,dataIndex:'name',align:'left',xtype:'treecolumn',width:'79%'
  83. },{
  84. text:'序号',dataIndex:'sort',width:'20%'
  85. }],
  86. load:function(d){
  87. if(me.sspid==0){
  88. me.sspid = d.pid;
  89. me.allshow();
  90. }
  91. },
  92. itemdblclick:function(d){
  93. me.typeid = d.id;
  94. me.loadfile(d.id,d.name);
  95. },
  96. itemclick:function(d){
  97. me.ismoveok(d);
  98. }
  99. });
  100. }
  101. this.allshow=function(){
  102. this.typeid = this.sspid;
  103. this.at.changedata={};
  104. this.loadfile('0','所有'+this.title+'');
  105. }
  106. this.loadfile=function(spd,nsd){
  107. $('#megss'+this.rand+'').html(nsd);
  108. this.mobj.setparams({'typeid':spd}, true);
  109. }
  110. this.showfooter=function(){
  111. var s= '<div class="panel-footer"><a href="javascript:;" style="TEXT-DECORATION:none" title="新增" click="clicktypewin,0" onclick="return false"><i class="icon-plus"></i></a>&nbsp; &nbsp;<a href="javascript:;" style="TEXT-DECORATION:none" title="编辑" click="clicktypeeidt" onclick="return false"><i class="icon-edit"></i></a>&nbsp; &nbsp;<a href="javascript:;" style="TEXT-DECORATION:none" title="删除" click="typedel" onclick="return false"><i class="icon-trash"></i></a>&nbsp; &nbsp;<a href="javascript:;" style="TEXT-DECORATION:none" title="刷新" click="reloadtype" onclick="return false"><i class="icon-refresh"></i></a>&nbsp; &nbsp; <a href="javascript:;" style="TEXT-DECORATION:none" title="移动" click="optionmove" onclick="return false"><i class="icon-move"></i></a>&nbsp; &nbsp;<a href="javascript:;" title="移动到顶级" style="TEXT-DECORATION:none" click="optionmoveto" onclick="return false"><i class="icon-arrow-up"></i></a>&nbsp; &nbsp; <a href="javascript:;" style="TEXT-DECORATION:none" title="所有'+this.title+'" click="allshow" onclick="return false"><i class="icon-search"></i></a></div>';
  112. $('#'+this.optionview+'').after(s);
  113. return true;
  114. }
  115. //初始化
  116. this.init_option=function(){
  117. this.createtable(); //创建表格
  118. this.showfooter(); //显示底部
  119. $('#'+this.optionview+'').css('height',''+(viewheight-70)+'px');
  120. }
  121. for(var oc in cans)this[oc]=cans[oc];
  122. this.init_option();
  123. }