mail.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. ,height:600
  14. , text: '数据加载中'
  15. , limit: 20
  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. reload: function () {//搜索
  61. var form = pfgs_serialize($('form'));
  62. var name = '';
  63. var email = '';
  64. if (form.input_house == 'name') {
  65. name = form.input_house_text;
  66. } else if (form.input_house == 'email') {
  67. email = form.input_house_text;
  68. }
  69. table.reload('actionemail', {
  70. where: {
  71. name: name,
  72. email: email,
  73. city: form.input_city,
  74. },
  75. page: {
  76. curr: 1
  77. }
  78. }
  79. )
  80. },
  81. };
  82. $('.demoTable .layui-btn').on('click', function () {
  83. var type = $(this).data('type');
  84. active[type] ? active[type].call(this) : '';
  85. });
  86. $('.imputSelect').find('input').removeAttr("readonly");
  87. //发件人设置
  88. form.on('submit(tijiao)', function (data) {
  89. $.post('/othermail/homemailform', {'data': data.field}, function (data) {
  90. layer.msg(data.msg);
  91. })
  92. return false;
  93. });
  94. //接受邮件测试
  95. form.on('submit(add_send_email)', function (data) {
  96. $.post('/othermail/testemail', {'data': data.field}, function (data) {
  97. layer.msg(data.msg);
  98. })
  99. return false;
  100. });
  101. //收件人添加
  102. form.on('submit(email_tijiao)', function (data) {
  103. $.post('/othermail/collectaddform', {'data': data.field}, function (data) {
  104. if (data.data != null) {
  105. layer.msg(ReturnInfo(data.data), {icon: 5});
  106. return;
  107. }
  108. layer.msg(data.msg);
  109. })
  110. return false;
  111. });
  112. //收件人修改
  113. form.on('submit(email_edit)', function (data) {
  114. $.post('/othermail/collecteditform', {'data': data.field}, function (data) {
  115. if (data.data != null) {
  116. layer.msg(ReturnInfo(data.data), {icon: 5});
  117. return;
  118. }
  119. layer.msg(data.msg);
  120. })
  121. return false;
  122. });
  123. });