contactManage.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>联系方式</title>
  6. <script src="../../js/min-loader-next.js"></script>
  7. </head>
  8. <body class="body-content">
  9. <div class="order-body">
  10. <div class="order-tiaojian back-gray">
  11. <div class="tiaojian-part1" id="conditions">
  12. <div class="fl f12-gray4-op mt4">所选条件:</div>
  13. </div>
  14. <div class="tiaojian-part2 fr demoTable">
  15. <button class="order-bnt1" onclick="loadAA();">查询</button>
  16. <button class="order-bnt2" onclick="cancle();">重置</button>
  17. <a href="#" id="toggle" class="top">收起<i class="iconfont up iconSelect_drop-down"></i></a>
  18. </div>
  19. </div>
  20. <form class="layui-form" id = "formName" >
  21. <div class="order-select back-border" id="content" style="display: block;">
  22. <div class="layui-inline">
  23. <label class="f12-gray4">姓名:</label>
  24. <input type="tel" name="accName" id ="accName" autocomplete="off" placeholder="请输入姓名" class="search-select">
  25. </div>
  26. </div>
  27. </form>
  28. </div>
  29. <div class="shadow-content" >
  30. <div class="gray-title demoTable" >
  31. <button class="layui-btn left-bnt1 in-b" data-type="addContact" id="addContact">
  32. <i class="layui-icon">&#xe608;</i>添加
  33. </button>
  34. </div>
  35. <table id="tabletest" lay-filter="tableFilter"></table>
  36. </div>
  37. <!--操作功能-->
  38. <script type="text/html" id="barDemo1">
  39. <a class="f12-blue ml0-4" lay-event="edit">编辑</a>
  40. <a class="f12-red2 ml0-4" lay-event="delete">删除</a>
  41. </script>
  42. <script>
  43. $("#toggle").click(function() {
  44. $(this).html($("#content").is(":hidden") ? "收起" + "<i class='iconfont up iconSelect_drop-down'/></i>" : "展开" +
  45. "<i class='iconfont up iconSelect_drop-down'/></i>");
  46. $("#content").slideToggle();
  47. });
  48. var rowData = layui.sessionData("ROW_DATA").NOW_ROW;
  49. layui.use('element', function(){
  50. var element = layui.element;
  51. });
  52. var table;
  53. layui.use('table', function(){
  54. var aciId = rowData.aciId;
  55. table = layui.table;
  56. table.render({
  57. id : 'tabletest'
  58. ,elem: '#tabletest'
  59. ,limit:10
  60. ,url: 'ContactManageAction/queryContact' //数据接口
  61. ,method: 'post'
  62. ,where:{MINView:"JSON", aciId:aciId}
  63. ,page: true //开启分页
  64. ,cols: [[ //表头
  65. {type:'numbers',title: '序号',width:"5%"}
  66. ,{field: 'aciName', title: '客户名称', width:"25%"}
  67. ,{field: 'accName', title: '姓名', width:"10%"}
  68. ,{field: 'phone', title: '电话号', width:"15%"}
  69. ,{field: 'remarks', title: '备注', width:"25%"}
  70. ,{field: 'operate', title: '操作',width:"20%", toolbar: '#barDemo1'}
  71. ]]
  72. ,done: function(res, curr, count){
  73. //如果是异步请求数据方式,res即为你接口返回的信息。
  74. console.log(res);
  75. //得到当前页码
  76. console.log(curr);
  77. //得到数据总量
  78. console.log(count);
  79. }
  80. ,even: true //开启隔行背景
  81. });
  82. // 监听工具条(操作)
  83. table.on('tool(tableFilter)', function(obj){ //注:tool是工具条事件名,tableFilter是table原始容器的属性 lay-filter="对应的值"
  84. var data = obj.data; //获得当前行数据
  85. var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
  86. var tr = obj.tr; //获得当前行 tr 的DOM对象
  87. var accId = data.accId;
  88. if(layEvent === 'delete'){ //删除
  89. layer.confirm('确认删除当前联系人吗?', function(index){
  90. layer.close(index);
  91. //向服务端发送删除指令roleDelete
  92. $.request({
  93. action : "ContactManageAction/deleteContact",
  94. data : {
  95. accId : accId,
  96. State : 01
  97. },
  98. success : function(resData) {
  99. if (resData.MINStatus == 0) {
  100. layer.alert('操作成功!', {icon: 1});
  101. obj.del(); //删除对应行(tr)的DOM结构,并更新缓存
  102. window.location.reload();
  103. } else {
  104. layer.alert(resData.MINErrorMessage, {
  105. icon: 5,
  106. title: "提示"
  107. });
  108. }
  109. },
  110. error : function(data2){
  111. layer.alert(data2.MINErrorMessage, {
  112. icon: 5,
  113. title: "提示"
  114. });
  115. }
  116. });
  117. });
  118. }
  119. else if(layEvent === 'edit'){ //编辑
  120. editDetail(data);
  121. }
  122. });
  123. $('.demoTable .layui-btn').on('click', function(){
  124. var type = $(this).data('type');
  125. active[type] ? active[type].call(this) : '';
  126. });
  127. });
  128. //新增
  129. $(document).on('click','#addContact',function(data){
  130. // 寄存当前数据
  131. layer.open({
  132. type: 2,
  133. title: '新增',
  134. shadeClose: true,
  135. // shade: true ,
  136. shade: 0.8,
  137. //maxmin: true, //开启最大化最小化按钮
  138. area: ['55%', '65%'],
  139. content: '../contactManage/addContact.html'
  140. });
  141. });
  142. //编辑
  143. function editDetail(data) {
  144. var params = {};
  145. params.columnNumber = 2; //每行显示两个字段
  146. // 寄存当前数据
  147. layui.sessionData("ROW_DATA", {key:"NOW_ROW", value:data});
  148. layer.open({
  149. type: 2,
  150. title: '编辑',
  151. shadeClose: true,
  152. // shade: true ,
  153. shade: 0.8,
  154. //maxmin: true, //开启最大化最小化按钮
  155. area: ['55%', '65%'],
  156. content: '../contactManage/editContact.html'
  157. });
  158. }
  159. function loadAA() {
  160. var accName = $('#accName').val();
  161. //执行重载
  162. table.reload('tabletest', {
  163. page: {
  164. curr: 1 //重新从第 1 页开始
  165. }
  166. ,where: {
  167. accName : accName
  168. }
  169. });
  170. }
  171. //重置
  172. function cancle(){
  173. $('#formName')[0].reset();
  174. }
  175. </script>
  176. </body>
  177. </html>