index.php 4.3 KB

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