index.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid">
  4. <div class="layui-row layui-col-space15" id="app" v-cloak>
  5. <div class="layui-col-md12">
  6. <div class="layui-card">
  7. <div class="layui-card-header">
  8. <div style="font-weight: bold;">关键词搜索</div>
  9. </div>
  10. <div class="layui-card-body">
  11. <div class="layui-row layui-col-space15">
  12. <div class="layui-col-md12">
  13. <form class="layui-form">
  14. <div class="layui-form-item">
  15. <label class="layui-form-label">关键词</label>
  16. <div class="layui-input-block">
  17. <input type="text" name="name" autocomplete="off" v-model="name" style="width: 30%;display:inline-block;margin-right: 10px;" class="layui-input" placeholder="请输入关键词名称">
  18. <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" @click="add">确认添加</button>
  19. </div>
  20. </div>
  21. </form>
  22. </div>
  23. <div class="layui-col-md12">
  24. <button class="layui-btn layui-btn-primary" v-for="(item,index) in searchList" style="position: relative;margin-left: 10px;margin-top: 10px">
  25. {{item.name}} <i class="layui-icon layui-icon-close lay-close" @click="del(item,index)"></i>
  26. </button>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <script type="text/javascript" src="{__ADMIN_PATH}js/layuiList.js"></script>
  35. {/block}
  36. {block name='script'}
  37. <script>
  38. var list=<?=count($list) ? json_encode($list) : "[]"?>;
  39. require(['vue'],function(Vue) {
  40. new Vue({
  41. el: "#app",
  42. data: {
  43. searchList:list,
  44. name:'',
  45. },
  46. methods:{
  47. add:function () {
  48. var that=this;
  49. layList.baseGet(layList.U({a:'save',q:{name:that.name}}),function (res) {
  50. that.searchList.push(res.data);
  51. that.$set(that,'searchList',that.searchList);
  52. layList.msg(res.msg);
  53. that.name='';
  54. });
  55. },
  56. del:function (item,index) {
  57. var that=this;
  58. layList.baseGet(layList.U({a:'del_search',q:{id:item.id}}),function (res) {
  59. that.searchList.splice(index,1);
  60. that.$set(that,'searchList',that.searchList);
  61. layList.msg(res.msg);
  62. });
  63. }
  64. },
  65. mounted:function () {
  66. }
  67. })
  68. })
  69. </script>
  70. {/block}