rock_option.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?php if(!defined('HOST'))die('not access');?>
  2. <script >
  3. $(document).ready(function(){
  4. {params};
  5. var num = params.num,pid,optlx=0,dpid=0,nowid=0;
  6. var at = $('#optionview_{rand}').bootstable({
  7. tablename:'option',celleditor:true,sort:'sort',dir:'asc',url:js.getajaxurl('getlist', 'option', 'system'),
  8. params:{num:num,name:nowtabs.name},
  9. columns:[{
  10. text:'名称',dataIndex:'name',align:'left'
  11. },{
  12. text:'编号',dataIndex:'num'
  13. },{
  14. text:'序号',dataIndex:'sort',editor:true,sortable:true
  15. },{
  16. text:'ID',dataIndex:'id'
  17. }],
  18. itemclick:function(ad,oi,e){
  19. //c.showmenu(ad,e);
  20. },
  21. itemdblclick:function(ad,oi,e){
  22. c.zhankai(ad);
  23. },
  24. load:function(ad){
  25. pid = ad.pid;
  26. if(dpid==0)dpid=pid;
  27. }
  28. });
  29. var a = $('#view_{rand}').bootstable({
  30. tablename:'option',celleditor:true,sort:'sort',dir:'asc',modedir:'{mode}:{dir}',storeafteraction:'downshuafter',storebeforeaction:'downshubefore',
  31. autoLoad:false,params:{pid:-1},bodyStyle:'height:'+(viewheight-72)+'px;overflow:auto',
  32. columns:[{
  33. text:'名称',dataIndex:'name',sortable:true,editor:true
  34. },{
  35. text:'对应值',dataIndex:'value',editor:true,sortable:true
  36. },{
  37. text:'编号',dataIndex:'num',editor:true
  38. },{
  39. text:'排序号',dataIndex:'sort',editor:true,sortable:true
  40. },{
  41. text:'下级数',dataIndex:'dcount'
  42. },{
  43. text:'启用',dataIndex:'valid',type:'checkbox',editor:true
  44. },{
  45. text:'说明',dataIndex:'explain',type:'textarea',editor:true,align:'left'
  46. },{
  47. text:'ID',dataIndex:'id'
  48. },{
  49. text:'',dataIndex:'optd',renderer:function(v,d,oi){
  50. var s = '&nbsp;';
  51. s='<a href="javascript:;" onclick="zhankai{rand}('+oi+')">展开</a>';
  52. return s;
  53. }
  54. }],
  55. load:function(d){
  56. get('add_{rand}').disabled=false;
  57. get('del_{rand}').disabled=true;
  58. c.showdownlist(d.darr);
  59. },
  60. itemclick:function(){
  61. get('del_{rand}').disabled=false;
  62. },
  63. beforeload:function(){
  64. get('del_{rand}').disabled=true;
  65. }
  66. });
  67. zhankai{rand}=function(oi){
  68. var d=a.getData(oi);
  69. c.zhankai(d);
  70. }
  71. var c = {
  72. zhankai:function(ad){
  73. $('#downshow_{rand}').html('<b>['+ad.id+'.'+ad.name+']</b>的下级选项');
  74. this.showdown(ad.id);
  75. },
  76. showdownlist:function(dl){
  77. var str='<b>路径:</b>';
  78. for(var i=0;i<dl.length;i++){
  79. if(i>0)str+=' <font color="#cccccc">&gt;</font> ';
  80. str+=' <a href="javascript:;" onclick="option{rand}.showdown('+dl[i].id+')">'+dl[i].name+'</a> ';
  81. }
  82. $('#downshow_{rand}').html(str);
  83. },
  84. showdown:function(id1){
  85. nowid = id1;
  86. a.setparams({'pid':id1}, true);
  87. },
  88. search:function(){
  89. var s = get('key_{rand}').value;
  90. at.setparams({key:s},true);
  91. },
  92. showmenu:function(d,e){
  93. if(!this.menuobj)this.menuobj = $.rockmenu({data:[],width:150,itemsclick:function(d){
  94. c.cliemmenus(d);
  95. }});
  96. this.optdata = d;
  97. var da = [{name:'打开选项',lx:0},{name:'编辑',lx:3}];
  98. if(d.stotal>0)da.push({name:'管理下级',lx:1});
  99. if(d.pid!=dpid)da.push({name:'↑回到上级',lx:2});
  100. this.menuobj.setData(da);
  101. setTimeout(function(){c.menuobj.showAt(e.clientX,e.clientY);},0);
  102. },
  103. cliemmenus:function(d){
  104. var ad = this.optdata;
  105. if(d.lx==0){
  106. $('#downshow_{rand}').html('<b>['+ad.id+'.'+ad.name+']</b>的下级选项');
  107. //a.search("and `pid`="+ad.id+"");
  108. a.setparams({'pid':ad.id}, true);
  109. }
  110. if(d.lx==1){
  111. c.xiajili();
  112. }
  113. if(d.lx==2){
  114. this.showdwon(num);
  115. }
  116. if(d.lx==3){
  117. this.clicktypeeidt();
  118. }
  119. },
  120. reload:function(){
  121. at.reload();
  122. },
  123. xiajili:function(){
  124. if(at.changeid==0)return;
  125. var bh = at.changedata.num;
  126. this.showdwon(bh);
  127. },
  128. showdwon:function(bh){
  129. if(isempt(bh))return;
  130. at.setparams({num:bh},true);
  131. },
  132. dingji:function(bh){
  133. this.showdwon(num);
  134. },
  135. clickwin:function(o, lx){
  136. var as = this.clicktypewin(false, 0);
  137. optlx = 1;
  138. as.setValue('pid', nowid);
  139. },
  140. clicktypeeidt:function(){
  141. var d = at.changedata;
  142. if(d.id)c.clicktypewin(false, 1, d);
  143. },
  144. clicktypewin:function(o1, lx, da){
  145. var h = $.bootsform({
  146. title:'选项',height:250,width:300,
  147. tablename:'option',labelWidth:50,
  148. isedit:lx,
  149. submitfields:'num,name,sort,pid',cancelbtn:false,
  150. items:[{
  151. labelText:'名称',name:'name',required:true
  152. },{
  153. labelText:'上级id',name:'pid',value:0,type:'hidden'
  154. },{
  155. labelText:'编号',name:'num'
  156. },{
  157. labelText:'排序号',name:'sort',type:'number',value:0
  158. }],
  159. success:function(){
  160. if(optlx==0)at.reload();
  161. if(optlx==1)a.reload();
  162. }
  163. });
  164. if(lx==1)h.setValues(da);
  165. if(lx==0)h.setValue('pid', pid);
  166. optlx = 0;
  167. return h;
  168. },
  169. typedel:function(o1){
  170. at.del({url:js.getajaxurl('deloption','option','system')});
  171. },
  172. del:function(){
  173. a.del({url:js.getajaxurl('deloption','option','system')});
  174. }
  175. };
  176. js.initbtn(c);
  177. $('#optionview_{rand}').css('height',''+(viewheight-142)+'px');
  178. option{rand} = c;
  179. });
  180. </script>
  181. <table width="100%">
  182. <tr valign="top">
  183. <td width="350">
  184. <div class="panel panel-info" style="margin:0px">
  185. <div class="panel-heading">
  186. <h3 class="panel-title">选项列表(双击展开)</h3>
  187. </div>
  188. <div>
  189. <div class="input-group" style="width:200px">
  190. <input class="form-control" id="key_{rand}" placeholder="选项名称/编号">
  191. <span class="input-group-btn">
  192. <button class="btn btn-default" click="search" type="button"><i class="icon-search"></i></button>
  193. </span>
  194. </div>
  195. </div>
  196. <div id="optionview_{rand}" style="height:400px;overflow:auto"></div>
  197. <div class="panel-footer">
  198. <a href="javascript:" click="clicktypewin,0" onclick="return false"><i class="icon-plus"></i></a>&nbsp; &nbsp;
  199. <a href="javascript:" click="clicktypeeidt" onclick="return false"><i class="icon-edit"></i></a>&nbsp; &nbsp;
  200. <a href="javascript:" click="reload" onclick="return false"><i class="icon-refresh"></i></a>
  201. &nbsp;
  202. <a href="javascript:" click="xiajili" onclick="return false">[管理下级]</a>&nbsp;
  203. <a href="javascript:" click="dingji" onclick="return false">[回到顶级]</a>
  204. <a href="javascript:" style="float:right" click="typedel" onclick="return false"><i class="icon-trash"></i></a>
  205. </div>
  206. </div>
  207. </td>
  208. <td width="10"></td>
  209. <td>
  210. <div>
  211. <ul class="floats">
  212. <li class="floats70">
  213. <button class="btn btn-primary" click="clickwin,0" disabled id="add_{rand}" type="button"><i class="icon-plus"></i> 新增对应下级</button>&nbsp;&nbsp;
  214. <span id="downshow_{rand}">双击左边选项列表行打开选项</span>
  215. </li>
  216. <li class="floats30" style="text-align:right">
  217. <button class="btn btn-danger" id="del_{rand}" disabled click="del" type="button"><i class="icon-trash"></i> 删除</button>
  218. </li>
  219. </ul>
  220. </div>
  221. <div class="blank10"></div>
  222. <div id="view_{rand}"></div>
  223. </td>
  224. </tr>
  225. </table>
粤ICP备19079148号