index.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>客户报备</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport"
  9. content="width=customer-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  10. <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  11. <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
  12. <style type="text/css">
  13. .seach_items {
  14. float: right;
  15. margin-left: 10px;
  16. }
  17. </style>
  18. <style type="text/css">
  19. .LAY-btns .layui-nav {
  20. padding-left: 0;
  21. padding-right: 10px;
  22. top: -4px;
  23. margin: 0 10px;
  24. border: 0;
  25. background-color: #009688;
  26. }
  27. .LAY-btns .layui-nav .layui-nav-item {
  28. line-height: 40px;
  29. }
  30. .LAY-btns .layui-nav .layui-nav-child {
  31. top: 34px;
  32. }
  33. .LAY-btns .layui-nav .layui-nav-bar {
  34. display: none;
  35. }
  36. .LAY-btns .layui-nav .layui-nav-child dd.layui-this a {
  37. color: #333;
  38. background-color: #fff;
  39. }
  40. .LAY-btns .layui-nav .layui-nav-child dd.layui-this a:hover {
  41. background-color: #f2f2f2;
  42. color: #000;
  43. }
  44. </style>
  45. </head>
  46. <body>
  47. <div class="layui-fluid">
  48. <div class="layui-card">
  49. <div class="layui-card-body" pad15>
  50. <div class="layui-row layui-col-space15">
  51. <div class="layui-col-md12">
  52. <div class="LAY-btns" style="margin-bottom: 10px;">
  53. <div style="float: left">
  54. <button class="layui-btn" id="customer_add" data-permission="customer.add_report_customer"><i
  55. class="layui-icon layui-icon-add-circle"></i>添加
  56. </button>
  57. </div>
  58. <form class="layui-form" lay-filter="query-form-element1">
  59. <div class="seach_items">
  60. <button class="layui-btn" lay-submit lay-filter="query-form-element1"><i
  61. class="layui-icon layui-icon-search"></i>查询
  62. </button>
  63. </div>
  64. <div class="seach_items">
  65. <select name="source" id="id_source" style="width: 40px;">
  66. <option value="">请选择来源</option>
  67. </select>
  68. </div>
  69. <div class="seach_items">
  70. <input type="text" name="name" autocomplete="off" class="layui-input"
  71. placeholder="姓名"/>
  72. </div>
  73. </form>
  74. <div style="clear: both;"></div>
  75. </div>
  76. <table class="layui-hide" id="customer_datagrid" lay-filter="customer-operate"></table>
  77. <script type="text/html" id="customer-operate-bar">
  78. <div class="layui-btn-group">
  79. <a class="layui-btn layui-btn-xs" lay-event="customer_edit"
  80. data-permission="customer.add_report_customer"
  81. >修改</a>
  82. </div>
  83. <div class="layui-btn-group">
  84. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="customer_del"
  85. data-permission="customer.delete_report_customer"
  86. >删除</a>
  87. </div>
  88. </script>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. <script src="../../layuiadmin/layui/layui.js?t=1"></script>
  95. <script>
  96. layui.config({
  97. base: '../../../layuiadmin/' //静态资源所在路径
  98. }).extend({
  99. index: 'lib/index' //主入口模块
  100. }).use(['index', 'table', 'form',], function () {
  101. var $ = layui.$;
  102. var table = layui.table
  103. , form = layui.form
  104. , admin = layui.admin;
  105. table.render({
  106. elem: '#customer_datagrid'
  107. , url: '/customer/report_customer/'
  108. , cols: [[
  109. {field: 'name', title: '姓名', width: 120}
  110. , {field: 'gender_text', title: "性别", width: 70}
  111. , {field: 'tel', title: '电话', width: 120}
  112. , {field: 'village', title: '小区', width: 150}
  113. , {field: 'address', title: '地址', width: 200}
  114. , {field: 'source_text', title: '来源', width: 100}
  115. , {field: 'project_text', title: '项目', width: 200}
  116. , {field: 'notes', title: '备注', width: 200}
  117. , {field: 'report_status_text', title: '报备状态', width: 100}
  118. , {field: 'check_user_text', title: '审核人', width: 100}
  119. , {field: 'check_time', title: '审核时间', width: 160}
  120. , {width: 130, align: 'center', fixed: 'right', toolbar: '#customer-operate-bar'}
  121. ]]
  122. , page: true
  123. , height: 'full-108'
  124. });
  125. admin.req({
  126. url: '/customer/dict/',
  127. done: function (res) {
  128. var data = res.data.source;
  129. var source_node = $('#id_source');
  130. for (var i in data) {
  131. var pid = data[i].id;
  132. var name = data[i].name;
  133. source_node.append("<option value='" + pid + "'>" + name + "</option>");
  134. }
  135. form.render('select');
  136. }
  137. });
  138. //监听工具条
  139. table.on('tool(customer-operate)', function (obj) {
  140. var data = obj.data;
  141. if (obj.event === 'customer_del') {
  142. if(data.report_status !== 0){
  143. layer.msg("只有待审核才允许删除");
  144. return
  145. }
  146. layer.confirm('确定要删除吗?', function (index) {
  147. layer.close(index);
  148. admin.req({
  149. url: '/customer/report_customer/' + data.id + '/'
  150. , type: 'delete'
  151. , done: function (res) {
  152. if(res.code === 0){
  153. layer.msg('删除成功!', {icon: 1})
  154. }
  155. table.reload('customer_datagrid', {});
  156. }
  157. });
  158. });
  159. } else if (obj.event === 'customer_edit') {
  160. if(data.report_status !== 0){
  161. layer.msg("只有待审核才允许修改");
  162. return
  163. }
  164. table.editdata = data;
  165. layer.open({
  166. type: 2,
  167. title: '修改',
  168. shadeClose: false,
  169. area: ['45%', '80%'],
  170. btn: ['保存', '取消'],
  171. yes: function (index, dom) {
  172. layui.onSubmitChild = function (res) {
  173. if(res.code === 0){
  174. layer.msg('修改成功!', {icon: 1})
  175. }
  176. layer.close(index);
  177. table.reload('customer_datagrid', {});
  178. };
  179. layui.submitChild();
  180. },
  181. btn2: function (index, layero) {
  182. layer.close(index);//关闭当前按钮
  183. },
  184. content: 'edit.html?id=' + data.id
  185. });
  186. }
  187. });
  188. form.on('submit(query-form-element1)', function (data) {
  189. table.reload('customer_datagrid', {
  190. where: data.field
  191. , page: {curr: 1}
  192. });
  193. layer.closeAll();
  194. return false
  195. });
  196. $('#customer_add').on('click', function () {
  197. layer.open({
  198. type: 2,
  199. title: '添加',
  200. area: ['45%', '80%'],
  201. btn: ['保存', '取消'],
  202. yes: function (index, dom) {
  203. layui.onSubmitChild = function (res) {
  204. if(res.code === 0){
  205. layer.msg('添加成功!', {icon: 1})
  206. }
  207. layer.close(index);
  208. table.reload('customer_datagrid', {});
  209. };
  210. layui.submitChild();
  211. },
  212. btn2: function (index, layero) {
  213. layer.close(index);//关闭当前按钮
  214. },
  215. content: 'edit.html'
  216. });
  217. });
  218. });
  219. </script>
  220. </body>
  221. </html>