intention.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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')},
  28. {field: 'unit_type', title: __('Unit_type')},
  29. {field: 'number', title: __('Number')},
  30. {field: 'price', title: '单价', formatter:function (value) {
  31. return '¥ ' + value;
  32. }},
  33. {field: 'usr_nickname', title: '操作人'},
  34. {field: 'usr_depart', title: '操作人部门'},
  35. {field: 'created_at', title: '创建时间', operate:'RANGE', addclass:'datetimerange'},
  36. // {field: 'operate', title: __('Operate'),
  37. // table: table, events: Table.api.events.operate,
  38. // formatter: Table.api.formatter.operate,
  39. // }
  40. ]
  41. ]
  42. });
  43. // 为表格绑定事件
  44. Table.api.bindevent(table);
  45. },
  46. add: function () {
  47. $.ajax({
  48. url: 'intention/unitTypeList',
  49. type: 'post',
  50. dataType: 'json',
  51. success: function success(res) {
  52. var data = res.rows;
  53. $('#c-unit_type').selectPage({
  54. data : data,
  55. });
  56. console.log(data);
  57. }
  58. });
  59. Controller.api.bindevent();
  60. },
  61. edit: function () {
  62. Controller.api.bindevent();
  63. },
  64. api: {
  65. bindevent: function () {
  66. Form.api.bindevent($("form[role=form]"));
  67. }
  68. }
  69. };
  70. return Controller;
  71. });