index.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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="tel" autocomplete="off" class="layui-input"
  71. placeholder="电话"/>
  72. </div>
  73. <div class="seach_items">
  74. <input type="text" name="name" autocomplete="off" class="layui-input"
  75. placeholder="姓名"/>
  76. </div>
  77. </form>
  78. <div style="clear: both;"></div>
  79. </div>
  80. <table class="layui-hide" id="customer_datagrid" lay-filter="customer-operate"></table>
  81. <script type="text/html" id="customer-operate-bar">
  82. <div class="layui-btn-group">
  83. <a class="layui-btn layui-btn-xs" lay-event="customer_edit"
  84. data-permission="customer.add_report_customer"
  85. >修改</a>
  86. </div>
  87. <div class="layui-btn-group">
  88. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="customer_del"
  89. data-permission="customer.delete_report_customer"
  90. >删除</a>
  91. </div>
  92. </script>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. <script src="../../layuiadmin/layui/layui.js?t=1"></script>
  99. <script>
  100. layui.config({
  101. base: '../../../layuiadmin/' //静态资源所在路径
  102. }).extend({
  103. index: 'lib/index' //主入口模块
  104. }).use(['index', 'table', 'form',], function () {
  105. var $ = layui.$;
  106. var table = layui.table
  107. , form = layui.form
  108. , admin = layui.admin;
  109. table.render({
  110. elem: '#customer_datagrid'
  111. , url: '/customer/report_customer/'
  112. , cols: [[
  113. {field: 'name', title: '姓名', width: 120}
  114. , {field: 'gender_text', title: "性别", width: 70}
  115. , {field: 'tel', title: '电话', width: 120}
  116. , {field: 'village', title: '小区', width: 150}
  117. , {field: 'address', title: '地址', width: 200}
  118. , {field: 'source_text', title: '来源', width: 100}
  119. , {field: 'project_text', title: '项目', width: 200}
  120. , {field: 'notes', title: '备注', width: 200}
  121. , {field: 'report_status_text', title: '报备状态', width: 100}
  122. , {field: 'create_user_text', title: '报备人', width: 150}
  123. , {field: 'create_time_f', title: '报备时间', width: 150}
  124. , {field: 'check_user_text', title: '审核人', width: 100}
  125. , {field: 'check_time_f', title: '审核时间', width: 160}
  126. , {width: 130, align: 'center', fixed: 'right', toolbar: '#customer-operate-bar'}
  127. ]]
  128. , page: true
  129. , height: 'full-108'
  130. });
  131. admin.req({
  132. url: '/customer/dict/',
  133. done: function (res) {
  134. var data = res.data.source;
  135. var source_node = $('#id_source');
  136. for (var i in data) {
  137. var pid = data[i].id;
  138. var name = data[i].name;
  139. source_node.append("<option value='" + pid + "'>" + name + "</option>");
  140. }
  141. form.render('select');
  142. }
  143. });
  144. //监听工具条
  145. table.on('tool(customer-operate)', function (obj) {
  146. var data = obj.data;
  147. if (obj.event === 'customer_del') {
  148. if(data.report_status !== 0){
  149. layer.msg("只有待审核才允许删除");
  150. return
  151. }
  152. layer.confirm('确定要删除吗?', function (index) {
  153. layer.close(index);
  154. admin.req({
  155. url: '/customer/report_customer/' + data.id + '/'
  156. , type: 'delete'
  157. , done: function (res) {
  158. if(res.code === 0){
  159. layer.msg('删除成功!', {icon: 1})
  160. }
  161. table.reload('customer_datagrid', {});
  162. }
  163. });
  164. });
  165. } else if (obj.event === 'customer_edit') {
  166. if(data.report_status !== 0){
  167. layer.msg("只有待审核才允许修改");
  168. return
  169. }
  170. table.editdata = data;
  171. layer.open({
  172. type: 2,
  173. title: '修改',
  174. shadeClose: false,
  175. area: ['45%', '80%'],
  176. btn: ['保存', '取消'],
  177. yes: function (index, dom) {
  178. layui.onSubmitChild = function (res) {
  179. if(res.code === 0){
  180. layer.msg('修改成功!', {icon: 1})
  181. }
  182. layer.close(index);
  183. table.reload('customer_datagrid', {});
  184. };
  185. layui.submitChild();
  186. },
  187. btn2: function (index, layero) {
  188. layer.close(index);//关闭当前按钮
  189. },
  190. content: 'edit.html?id=' + data.id
  191. });
  192. }
  193. });
  194. form.on('submit(query-form-element1)', function (data) {
  195. table.reload('customer_datagrid', {
  196. where: data.field
  197. , page: {curr: 1}
  198. });
  199. layer.closeAll();
  200. return false
  201. });
  202. $('#customer_add').on('click', function () {
  203. layer.open({
  204. type: 2,
  205. title: '添加',
  206. area: ['45%', '80%'],
  207. btn: ['保存', '取消'],
  208. yes: function (index, dom) {
  209. layui.onSubmitChild = function (res) {
  210. parent.layui.getTipsData();
  211. layer.close(index);
  212. table.reload('customer_datagrid', {});
  213. };
  214. layui.submitChild();
  215. },
  216. btn2: function (index, layero) {
  217. layer.close(index);//关闭当前按钮
  218. },
  219. content: 'edit.html'
  220. });
  221. });
  222. });
  223. </script>
  224. </body>
  225. </html>