截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lists.html 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. {layout name="layout1" /}
  2. <div class="wrapper">
  3. <div class="layui-card">
  4. <!-- 操作提示 -->
  5. <div class="layui-card-body">
  6. <div class="layui-collapse" style="border:1px dashed #c4c4c4">
  7. <div class="layui-colla-item">
  8. <h2 class="layui-colla-title like-layui-colla-title">操作提示</h2>
  9. <div class="layui-colla-content layui-show">
  10. <p>*添加在线客服语术。方便客服快捷回复</p>
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. <!-- 主体区域 -->
  16. <div class="layui-card-body">
  17. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm layEvent" lay-event="add">新增话术</button>
  18. <table id="like-table-lists" lay-filter="like-table-lists"></table>
  19. <script type="text/html" id="table-operation">
  20. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
  21. <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
  22. </script>
  23. <script type="text/html" id="statusTpl">
  24. <input type="checkbox" lay-filter="switch-disable" data-id={{d.id}} lay-skin="switch"
  25. lay-text="开启|关闭" {{# if(d.disable==1){ }} checked {{# } }}/>
  26. </script>
  27. </div>
  28. </div>
  29. </div>
  30. <script>
  31. layui.use(["table", "form"], function () {
  32. var table = layui.table;
  33. var form = layui.form;
  34. like.tableLists("#like-table-lists", "{:url()}", [
  35. {field: "id", width: 60, title: "ID"}
  36. , {field: "title", align: "center", title: "标题"}
  37. , {field: "content", align: "center", title: "内容"}
  38. , {field: "sort", align: "center", title: "排序"}
  39. , {field: "create_time", align: "center", title: "创建时间"}
  40. , {title: "操作", align: "center", fixed: "right", toolbar: "#table-operation"}
  41. ]);
  42. var active = {
  43. add: function () {
  44. layer.open({
  45. type: 2
  46. , title: "新增话术"
  47. , content: "{:url('kefu.KefuLang/add')}"
  48. , area: ["90%", "90%"]
  49. , btn: ["确定", "取消"]
  50. , yes: function (index, layero) {
  51. var iframeWindow = window["layui-layer-iframe" + index];
  52. var submit = layero.find("iframe").contents().find("#addSubmit");
  53. iframeWindow.layui.form.on("submit(addSubmit)", function (data) {
  54. like.ajax({
  55. url: "{:url('kefu.KefuLang/add')}",
  56. data: data.field,
  57. type: "POST",
  58. success: function (res) {
  59. if (res.code === 1) {
  60. layui.layer.msg(res.msg);
  61. layer.close(index);
  62. table.reload("like-table-lists", {
  63. where: {},
  64. page: {cur: 1}
  65. });
  66. }
  67. }
  68. });
  69. });
  70. submit.trigger("click");
  71. }
  72. });
  73. },
  74. edit: function (obj) {
  75. layer.open({
  76. type: 2
  77. , title: "编辑话术"
  78. , content: "{:url('kefu.KefuLang/edit')}?id=" + obj.data.id
  79. , area: ["90%", "90%"]
  80. , btn: ["确定", "取消"]
  81. , yes: function (index, layero) {
  82. var iframeWindow = window["layui-layer-iframe" + index];
  83. var submit = layero.find("iframe").contents().find("#editSubmit");
  84. iframeWindow.layui.form.on("submit(editSubmit)", function (data) {
  85. data.field['id'] = obj.data.id;
  86. like.ajax({
  87. url: "{:url('kefu.KefuLang/edit')}",
  88. data: data.field,
  89. type: "POST",
  90. success: function (res) {
  91. if (res.code === 1) {
  92. layui.layer.msg(res.msg);
  93. layer.close(index);
  94. table.reload("like-table-lists", {
  95. where: {},
  96. page: {cur: 1}
  97. });
  98. }
  99. }
  100. });
  101. });
  102. submit.trigger("click");
  103. }
  104. });
  105. },
  106. del: function (obj) {
  107. layer.confirm("确定删除话术:" + obj.data.title, function (index) {
  108. like.ajax({
  109. url: "{:url('kefu.KefuLang/del')}",
  110. data: {id: obj.data.id},
  111. type: "POST",
  112. success: function (res) {
  113. if (res.code === 1) {
  114. layui.layer.msg(res.msg);
  115. layer.close(index);
  116. obj.del();
  117. table.reload("like-table-lists", {
  118. where: {},
  119. page: {cur: 1}
  120. });
  121. }
  122. }
  123. });
  124. layer.close(index);
  125. })
  126. }
  127. };
  128. like.eventClick(active);
  129. })
  130. </script>