title.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'send/message/title/index',
  8. table: 'send_title',
  9. }
  10. });
  11. var table = $("#table");
  12. // 初始化表格
  13. table.bootstrapTable({
  14. url: $.fn.bootstrapTable.defaults.extend.index_url,
  15. pk: 'id',
  16. sortName: 'id',
  17. columns: [
  18. [
  19. {checkbox: true},
  20. {field: 'id', title: __('Id'),operate: false},
  21. {field: 'title', title: __('Title')},
  22. ]
  23. ]
  24. });
  25. $('.btn-add-title-list').on('click',function () {
  26. var ids = Table.api.selectedids(table);
  27. if(ids.length ==0 || ids.length>1){
  28. Layer.alert('只能选择一项');
  29. return false;
  30. }
  31. var title = $(document).find('.selected').children('td')[2].innerHTML;
  32. //ids = Table.api.getrowdata(table,ss);
  33. $(parent.document).find('#c-title').val(title);
  34. Fast.api.close();
  35. });
  36. // 为表格绑定事件
  37. Table.api.bindevent(table);
  38. },
  39. add: function () {
  40. Controller.api.bindevent();
  41. },
  42. edit: function () {
  43. Controller.api.bindevent();
  44. },
  45. api: {
  46. bindevent: function () {
  47. Form.api.bindevent($("form[role=form]"));
  48. }
  49. }
  50. };
  51. return Controller;
  52. });