telrecord.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. layui.use([ 'laypage', 'layer', 'table', 'element','form','treetable'], function(){
  2. var laypage = layui.laypage //分页
  3. ,$ = layui.jquery
  4. ,layer = layui.layer //弹层
  5. ,table = layui.table //表格
  6. ,element = layui.element //元素操作
  7. ,form = layui.form
  8. ,treetable = layui.treetable;
  9. //第一个实例
  10. table.render({
  11. elem: '#menulist'
  12. ,url: '/othertel/recordform' //数据接口
  13. ,where:{token:csrfToken}
  14. ,method:'post'
  15. ,page: true //开启分页
  16. ,height:600
  17. ,id:'tablerReload'
  18. ,limit:20
  19. ,text:'数据加载中'
  20. ,cols: [[ //表头
  21. {type:'numbers',title:'序号'}
  22. ,{field: 'user_name', title: '操作人', align:'center',width:200}
  23. ,{field: 'name', title: '方案名称', align:'center',width:200}
  24. ,{field: 'front', title: '操作前', align:'left'}
  25. ,{field: 'after', title: '操作后', align:'left'}
  26. ,{field: 'type', title: '操作类型', align:'left'}
  27. // ,{fixed: 'right',title:'操作', width: 200, align:'center', toolbar: '#operate'}
  28. ]]
  29. });
  30. table.reload('tablerReload'); //重新加载
  31. //列表操作
  32. table.on('tool(menulist)', function(obj){
  33. var layEvent = obj.event,
  34. data = obj.data;
  35. if(layEvent === 'edit'){
  36. layer.open({
  37. type: 2,
  38. title: '修改方案',
  39. closeBtn: 1, //不显示关闭按钮
  40. shade: [0],
  41. area: ['600px', '500px'],
  42. anim: 2,
  43. content:'/othertel/edit?id='+data.id,
  44. end:function () {
  45. table.reload('tablerReload');
  46. }
  47. });
  48. } else if(layEvent === 'del') {
  49. layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
  50. $.post('/othertel/del',{'id':data.id},function (data) {
  51. layer.msg(data.msg);
  52. table.reload('tablerReload');
  53. })
  54. })
  55. }else if(layEvent === 'tel_city'){
  56. layer.open({
  57. type: 2,
  58. title: '添加区域',
  59. closeBtn: 1, //不显示关闭按钮
  60. shade: [0],
  61. area: ['600px', '500px'],
  62. anim: 2,
  63. content:'/othertel/cityascription?id='+data.id, //iframe的url,no代表不显示滚动条
  64. });
  65. }
  66. });
  67. table.on('tool(citytellist)', function(obj){
  68. var layEvent = obj.event,
  69. data = obj.data;
  70. if(layEvent === 'tel_city'){
  71. layer.open({
  72. type: 2,
  73. title: '加载方案',
  74. closeBtn: 1, //不显示关闭按钮
  75. shade: [0],
  76. area: ['600px', '500px'],
  77. anim: 2,
  78. content:'/othertel/cityascription?id='+data.id,
  79. end:function () {
  80. renderTable();
  81. }
  82. });
  83. }
  84. });
  85. var $ = layui.$, active = {
  86. addData: function(){ //获取选中数据
  87. layer.open({
  88. type: 2,
  89. title: '添加电话',
  90. closeBtn: 1, //不显示关闭按钮
  91. shade: [0],
  92. area: ['600px', '500px'],
  93. anim: 2,
  94. content: '/othertel/add', //iframe的url,no代表不显示滚动条
  95. end: function(){ //此处用于演示
  96. table.reload('tablerReload');
  97. }
  98. });
  99. },
  100. reload:function () {
  101. var form = pfgs_serialize($('form'));
  102. var name = '';
  103. var tel = '';
  104. // console.log($('form').serializeArray());
  105. if(form.input_house == 'name'){
  106. name = form.input_house_text;
  107. } else if(form.input_house == 'user_name'){
  108. tel = form.input_house_text;
  109. }
  110. table.reload('tablerReload',{
  111. where:{
  112. name:name,
  113. user_name:tel,
  114. type:form.type
  115. },
  116. page:{
  117. curr:1
  118. }
  119. })
  120. },
  121. record:function () {
  122. var index = layui.layer.open({
  123. title : "操作记录",
  124. type : 2,
  125. area:['','100%'],
  126. maxmin: true,
  127. content : "/house/create.html",
  128. })
  129. layui.layer.full(index);
  130. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  131. $(window).on("resize",function(){
  132. layui.layer.full(index);
  133. })
  134. }
  135. };
  136. $('.demoTable .layui-btn').on('click', function(){
  137. var type = $(this).data('type');
  138. active[type] ? active[type].call(this) : '';
  139. });
  140. form.on('submit(edittel)', function(data){
  141. $.post('/othertel/editform',{'data':data.field},function (data) {
  142. if(data.code == 200)
  143. {
  144. layer.msg(data.msg);
  145. parent.layui.table.reload('menulist');
  146. } else if(data.code == 300 ) {
  147. layer.msg(data.msg);
  148. layer.msg(ReturnInfo(data.data),{icon:5});
  149. }
  150. })
  151. return false;
  152. });
  153. form.on('submit(tijiao)', function(data){
  154. $.post('/othertel/addform',{'data':data.field},function (data) {
  155. if(data.code == 200)
  156. {
  157. layer.msg(data.msg);
  158. parent.layui.table.reload('menulist');
  159. // TableClose();
  160. } else if(data.code == 300 ) {
  161. layer.msg(data.msg);
  162. layer.msg(ReturnInfo(data.data),{icon:5});
  163. }
  164. })
  165. return false;
  166. });
  167. form.on('submit(unload_tel)', function(data){
  168. var index = top.layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  169. var formData = new FormData($('#cityForm')[0]);
  170. $.ajax({
  171. cache : true,
  172. type : "post",
  173. url : "/othertel/addcityascription",
  174. data : formData, // 你的formid
  175. async : false,
  176. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  177. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  178. error : function(request) {
  179. top.layer.close(index); //关闭数据提交信息
  180. layer.alert("网络超时");
  181. },
  182. success : function(data) {
  183. top.layer.close(index); //关闭数据提交信息
  184. if (data.code == 200) {
  185. layer.msg(data.msg);
  186. parent.layui.table.reload('menulist');
  187. // TableClose();
  188. } else if(data.code == 300){
  189. layer.msg(data.msg);
  190. if(data.data.length > 0){
  191. layer.msg(ReturnInfo(data.data),{icon:5});
  192. }
  193. }
  194. }
  195. });
  196. return false;
  197. });
  198. });