mail.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. layui.use([ 'laypage', 'layer', 'table', 'element','form'], function(){
  2. var laypage = layui.laypage //分页
  3. ,layer = layui.layer //弹层
  4. ,table = layui.table //表格
  5. ,element = layui.element //元素操作
  6. ,form = layui.form;
  7. //第一个实例
  8. table.render({
  9. elem: '#emailList'
  10. ,url: '/othermail/collecthomeform' //数据接口
  11. ,method:'post'
  12. ,page: true //开启分页
  13. ,text:'数据加载中'
  14. ,limit:20
  15. ,height : 600
  16. ,id:'actionemail'
  17. ,cols: [[ //表头
  18. {type:'numbers'}
  19. ,{field: 'email', title: '邮箱', align:'center'}
  20. ,{field: 'city_name', title: '区域', align:'center'}
  21. ,{field: 'name', title: '姓名', align:'center'}
  22. ,{fixed: 'right',title:'操作', width: 200, align:'center', toolbar: '#operate'}
  23. ]]
  24. });
  25. //列表操作
  26. table.on('tool(emailList)', function(obj){
  27. var layEvent = obj.event,
  28. data = obj.data;
  29. if(layEvent === 'edit'){
  30. layer.open({
  31. type: 2,
  32. title: '修改邮箱',
  33. area: ['600px', '500px'],
  34. content:'/othermail/collectedit?id='+data.id, //iframe的url,no代表不显示滚动条
  35. end:function () {
  36. table.reload('actionemail');
  37. }
  38. });
  39. } else if(layEvent === 'del') {
  40. layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
  41. $.post('/othermail/collectdel',{'id':data.id},function (data) {
  42. layer.msg(data.msg);
  43. table.reload('actionemail');
  44. })
  45. })
  46. }
  47. });
  48. var $ = layui.$, active = {
  49. addData: function(){ //获取选中数据
  50. layer.open({
  51. type: 2,
  52. title: '添加邮箱',
  53. area: ['600px', '500px'],
  54. content: '/othermail/collectadd', //iframe的url,no代表不显示滚动条
  55. end:function () {
  56. table.reload('actionemail');
  57. }
  58. });
  59. }
  60. };
  61. $('.demoTable .layui-btn').on('click', function(){
  62. var type = $(this).data('type');
  63. active[type] ? active[type].call(this) : '';
  64. });
  65. $('.imputSelect').find('input').removeAttr("readonly");
  66. //发件人设置
  67. form.on('submit(tijiao)', function(data){
  68. $.post('/othermail/homemailform',{'data':data.field},function (data) {
  69. layer.msg(data.msg);
  70. })
  71. return false;
  72. });
  73. //接受邮件测试
  74. form.on('submit(add_send_email)', function(data){
  75. $.post('/othermail/testemail',{'data':data.field},function (data) {
  76. layer.msg(data.msg);
  77. })
  78. return false;
  79. });
  80. //收件人添加
  81. form.on('submit(email_tijiao)', function(data){
  82. $.post('/othermail/collectaddform',{'data':data.field},function (data) {
  83. if(data.data != null){
  84. layer.msg(ReturnInfo(data.data),{icon:5});
  85. return ;
  86. }
  87. layer.msg(data.msg);
  88. })
  89. return false;
  90. });
  91. //收件人修改
  92. form.on('submit(email_edit)', function(data){
  93. $.post('/othermail/collecteditform',{'data':data.field},function (data) {
  94. if(data.data != null){
  95. layer.msg(ReturnInfo(data.data),{icon:5});
  96. return ;
  97. }
  98. layer.msg(data.msg);
  99. })
  100. return false;
  101. });
  102. });