rock_city.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php if(!defined('HOST'))die('not access');?>
  2. <script >
  3. $(document).ready(function(){
  4. var type = 0,pid=0;
  5. var a = $('#veiw_{rand}').bootstable({
  6. tablename:'city',celleditor:true,sort:'sort',dir:'asc',url:js.getajaxurl('getdata','{mode}','{dir}'),
  7. columns:[{
  8. text:'名称',dataIndex:'name',editor:true,align:'left'
  9. },{
  10. text:'拼音',dataIndex:'pinyin',editor:true,sortable:true
  11. },{
  12. text:'拼音简称',dataIndex:'pinyins',editor:true
  13. },{
  14. text:'排序号',dataIndex:'sort',editor:true,sortable:true
  15. },{
  16. text:'级别',dataIndex:'type'
  17. },{
  18. text:'ID',dataIndex:'id',sortable:true
  19. },{
  20. text:'上级ID',dataIndex:'pid'
  21. },{
  22. text:'',dataIndex:'opt',renderer:function(v,d){
  23. return '<a href="javascript:;" onclick="opensho{rand}('+d.id+')">打开</a>';
  24. }
  25. }],
  26. itemclick:function(){
  27. btn(false);
  28. },
  29. load:function(ds){
  30. var darr = ds.path;
  31. var s = '<a href="javascript:;" onclick="opensho{rand}(0)">顶级</a>';
  32. for(var i=0;i<darr.length;i++){
  33. s+='/<a href="javascript:;" onclick="opensho{rand}('+darr[i].id+')">'+darr[i].name+'</a>';
  34. }
  35. $('#path_{rand}').html(s);
  36. type = ds.type;
  37. pid = ds.pid;
  38. btn(true);
  39. },
  40. beforeload:function(){
  41. btn(true);
  42. }
  43. });
  44. var c = {
  45. del:function(){
  46. a.del({url:js.getajaxurl('deldata','{mode}','{dir}')});
  47. },
  48. open:function(id){
  49. a.setparams({id:id}, true);
  50. },
  51. clickwin:function(o1,lx){
  52. var h = $.bootsform({
  53. title:'城市',height:300,width:400,
  54. tablename:'city',isedit:lx,
  55. submitfields:'name,pinyin,pinyins,type,pid',
  56. items:[{
  57. labelText:'名称',name:'name',required:true
  58. },{
  59. labelText:'拼音',name:'pinyin'
  60. },{
  61. labelText:'拼音简称',name:'pinyins'
  62. },{
  63. labelText:'',name:'type',type:'hidden'
  64. },{
  65. labelText:'',name:'pid',type:'hidden'
  66. },{
  67. labelText:'序号',name:'sort',type:'number',value:'0'
  68. }],
  69. success:function(){
  70. a.reload();
  71. }
  72. });
  73. h.setValue('type', type);
  74. h.setValue('pid', pid);
  75. if(lx==1){
  76. h.setValues(a.changedata);
  77. }
  78. h.getField('name').focus();
  79. },
  80. refresh:function(){
  81. a.reload();
  82. },
  83. initdata:function(o1){
  84. js.msg('wait','处理中...');
  85. o1.disabled=true;
  86. js.ajax(js.getajaxurl('initdata','{mode}','{dir}'),false,function(ret){
  87. if(ret.success){
  88. js.msg('success', ret.data);
  89. a.reload();
  90. }else{
  91. o1.disabled=false;
  92. js.msg('msg', ret.msg);
  93. }
  94. },'get,json');
  95. },
  96. clearchahe:function(){
  97. js.ajax(js.getajaxurl('clearchahe','{mode}','{dir}'),false,function(ret){
  98. js.msg('success', '已清除');
  99. });
  100. }
  101. };
  102. function btn(bo){
  103. get('del_{rand}').disabled = bo;
  104. get('edit_{rand}').disabled = bo;
  105. }
  106. js.initbtn(c);
  107. opensho{rand}=function(id){
  108. c.open(id);
  109. }
  110. });
  111. </script>
  112. <div>
  113. <table width="100%"><tr>
  114. <td nowrap>
  115. <button class="btn btn-primary" click="clickwin,0" type="button"><i class="icon-plus"></i> 新增</button> &nbsp;
  116. <button class="btn btn-default" click="refresh" type="button"><i class="icon-refresh"></i> 刷新</button> &nbsp;
  117. <button class="btn btn-default" click="initdata" type="button">导入数据</button>
  118. </td>
  119. <td width="80%">
  120. &nbsp; 当前路径:<span id="path_{rand}"></span>
  121. </td>
  122. <td align="right" nowrap>
  123. <button class="btn btn-default" click="clearchahe" type="button">清除城市数据缓存</button> &nbsp;
  124. <button class="btn btn-danger" id="del_{rand}" click="del" disabled type="button"><i class="icon-trash"></i> 删除</button> &nbsp;
  125. <button class="btn btn-info" id="edit_{rand}" click="clickwin,1" disabled type="button"><i class="icon-edit"></i> 编辑 </button>
  126. </td>
  127. </tr>
  128. </table>
  129. </div>
  130. <div class="blank10"></div>
  131. <div id="veiw_{rand}"></div>
  132. <div class="tishi"></div>
粤ICP备19079148号