option.js 4.4 KB

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