intention.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form, Selectpage) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'intention/index',
  8. add_url: 'intention/add',
  9. edit_url: 'intention/edit',
  10. del_url: 'intention/del',
  11. multi_url: 'intention/multi',
  12. table: 'intention',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. showToggle: false,
  22. showColumns: false,
  23. columns: [
  24. [
  25. {field: 'unit_name', title: __('Unit_name')},
  26. {field: 'contacts', title: __('Contacts')},
  27. {field: 'con_position', title: __('Con_position'), searchable: false},
  28. {field: 'unit_type', title: __('Unit_type'), searchable: false},
  29. {field: 'number', title: __('Number'), searchable: false},
  30. {field: 'price', title: '单价', formatter:function (value) {
  31. return '¥ ' + value;
  32. }},
  33. {field: 'usr_nickname', title: '操作人'},
  34. {field: 'depart_id', title: '操作人部门',searchList: $.getJSON('auth/group/departList'),formatter:function (value, row) {
  35. return row.usr_depart;
  36. }},
  37. {field: 'created_at', title: '创建时间', operate:'RANGE', addclass:'datetimerange', searchable: false},
  38. // {field: 'operate', title: __('Operate'),
  39. // table: table, events: Table.api.events.operate,
  40. // formatter: Table.api.formatter.operate,
  41. // }
  42. ]
  43. ]
  44. });
  45. // 为表格绑定事件
  46. Table.api.bindevent(table);
  47. },
  48. add: function () {
  49. $.ajax({
  50. url: 'intention/unitTypeList',
  51. type: 'post',
  52. dataType: 'json',
  53. success: function success(res) {
  54. var data = res.rows;
  55. $('#c-unit_type').selectPage({
  56. data : data,
  57. });
  58. console.log(data);
  59. }
  60. });
  61. Controller.api.bindevent();
  62. },
  63. edit: function () {
  64. Controller.api.bindevent();
  65. },
  66. api: {
  67. bindevent: function () {
  68. Form.api.bindevent($("form[role=form]"));
  69. }
  70. }
  71. };
  72. return Controller;
  73. });