index.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <style>
  4. a:hover{
  5. color: #0e9aef;
  6. }
  7. </style>
  8. <div class="row">
  9. <div class="col-sm-12">
  10. <div class="ibox">
  11. <div class="ibox-title">
  12. {if condition="$pid neq 0"}
  13. <a type="button" class="btn btn-w-m btn-primary" href="{:Url('index')}">返回</a>
  14. {/if}
  15. <button type="button" class="btn btn-w-m btn-primary"
  16. onclick="$eb.createModalFrame(this.innerText,'{$addurl}')">添加城市
  17. </button>
  18. <div class="ibox-tools">
  19. <button class="btn btn-w-m btn-primary clean-cache"
  20. data-url="{:Url('clean_cache')}" type="button"><i
  21. class="fa fa-warning"></i> 清除缓存
  22. </button>
  23. </div>
  24. </div>
  25. <div class="ibox-content">
  26. <div class="table-responsive">
  27. <table class="table table-striped table-bordered">
  28. <thead>
  29. <tr>
  30. <th class="text-center">编号</th>
  31. <th class="text-center">上级名称</th>
  32. <th class="text-center">地区名称</th>
  33. <!-- <th class="text-center">父级</th>-->
  34. <th class="text-center">操作</th>
  35. </tr>
  36. </thead>
  37. <tbody class="">
  38. {volist name="list" id="vo"}
  39. <tr>
  40. <td class="text-center">
  41. {$vo.id}
  42. </td>
  43. <td class="text-center">
  44. {$vo.parent_id}
  45. </td>
  46. <td class="text-center">
  47. <a href="{:Url('index',array('parent_id'=>$vo['city_id']))}">{$vo.name}</a>
  48. </td>
  49. <!-- <td class="text-center">-->
  50. <!-- {$vo.parent_id}-->
  51. <!-- </td>-->
  52. <td class="text-center">
  53. <button class="btn btn-info btn-xs" type="button"
  54. onclick="$eb.createModalFrame(this.innerText,'{:Url('edit',array('id'=>$vo['id']))}')">
  55. <i class="fa fa-edit"></i> 编辑
  56. </button>
  57. <button class="btn btn-danger btn-xs "
  58. data-url="{:Url('delete',array('city_id'=>$vo['city_id']))}" type="button"><i
  59. class="fa fa-warning"></i> 删除
  60. </button>
  61. </td>
  62. </tr>
  63. {/volist}
  64. </tbody>
  65. </table>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. {/block}
  72. {block name="script"}
  73. <script>
  74. $('.btn-danger').on('click', function () {
  75. var _this = $(this), url = _this.data('url');
  76. $eb.$swal('delete', function () {
  77. $eb.axios.get(url).then(function (res) {
  78. console.log(res);
  79. if (res.status == 200 && res.data.code == 200) {
  80. $eb.$swal('success', res.data.msg);
  81. _this.parents('tr').remove();
  82. } else
  83. return Promise.reject(res.data.msg || '删除失败')
  84. }).catch(function (err) {
  85. $eb.$swal('error', err);
  86. });
  87. })
  88. });
  89. $('.clean-cache').on('click', function () {
  90. var _this = $(this), url = _this.data('url');
  91. $eb.$swal('delete', function () {
  92. $eb.axios.get(url).then(function (res) {
  93. if (res.status == 200 && res.data.code == 200) {
  94. $eb.$swal('success', res.data.msg);
  95. } else
  96. return Promise.reject(res.data.msg || '清除失败')
  97. }).catch(function (err) {
  98. $eb.$swal('error', err);
  99. });
  100. },{'title':'您确定要清除城市缓存吗?','text':'清除后系统会自动生成','confirm':'是的,我要清除'})
  101. });
  102. </script>
  103. {/block}