items.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. define(['jquery', 'table', 'form'], function($, Table, Form) {
  2. var Controller = {
  3. items: function() {
  4. var url = window.location.href;
  5. var match = url.match(/[?&]id=(\d+)/);
  6. var id = match ? match[1] : 0;
  7. Table.init = { table_elem: '#currentTable', table_render_id: 'currentTable' };
  8. Table.render({
  9. init: Table.init,
  10. toolbar: ['refresh'],
  11. url: 'emailbroadcast/items?id=' + id,
  12. cols: [[
  13. {field:'id', width:80, title:'ID', sort:true},
  14. {field:'subscribe_id', width:100, title:'订阅ID'},
  15. {field:'email', minWidth:220, title:'邮箱'},
  16. {field:'lang', width:100, title:'语言'},
  17. {field:'status', width:100, title:'状态', templet:function(d){ var map={0:'待发送',1:'成功',2:'失败',9:'已跳过'}; return map[d.status] || d.status; }},
  18. {field:'response_code', width:130, title:'返回码'},
  19. {field:'response_msg', minWidth:260, title:'返回信息'},
  20. {field:'retry_count', width:100, title:'重试次数'},
  21. {field:'send_time', width:170, title:'发送时间', templet:function(d){ return d.send_time ? Table.formatter.datetime.call(this, d.send_time) : '-'; }},
  22. {field:'createtime', width:170, title:'创建时间', templet: Table.formatter.datetime}
  23. ]],
  24. page: {}
  25. });
  26. $('#searchBtn').on('click', function() {
  27. layui.table.reload('currentTable', { where: {
  28. email: $('#email').val(), status: $('#status').val()
  29. }, page: {curr: 1} });
  30. });
  31. $('#resetBtn').on('click', function() {
  32. $('#email,#status').val('');
  33. layui.form.render('select');
  34. layui.table.reload('currentTable', { where: {}, page: {curr: 1} });
  35. });
  36. Table.api.bindevent();
  37. Form.api.bindevent($('form.layui-form'));
  38. }
  39. };
  40. return Controller;
  41. });