protector.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'comment'], function ($, undefined, Backend, Table, Form, Comment) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. var status = GetQueryString('status');
  6. Table.api.init({
  7. extend: {
  8. index_url: 'protector/index' + '/status/' + status,
  9. add_url: 'protector/add',
  10. edit_url: 'protector/edit',
  11. del_url: 'protector/del',
  12. multi_url: 'protector/multi',
  13. table: 'protector',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. columns: [
  23. [
  24. {field: 'unit_name', title: __('Unit_name')},
  25. {field: 'contacts', title: __('Contacts')},
  26. {field: 'con_position', title: __('Con_position')},
  27. {field: 'unit_type', title: __('Unit_type')},
  28. {field: 'number', title: __('Number')},
  29. {field: 'price', title: '单价', formatter:function (value) {
  30. return '¥' + value;
  31. }},
  32. {field: 'usr_nickname', title: '操作人'},
  33. {field: 'usr_depart', title: '操作人部门'},
  34. {field: 'pro_date', title: __('Pro_date'), operate:'RANGE', addclass:'datetimerange'},
  35. {field: 'ex_date', title: __('Ex_date'), operate:'RANGE', addclass:'datetimerange'},
  36. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  37. ]
  38. ]
  39. });
  40. // 为表格绑定事件
  41. Table.api.bindevent(table);
  42. },
  43. add: function () {
  44. Controller.api.bindevent();
  45. },
  46. edit: function () {
  47. Controller.api.bindevent();
  48. },
  49. api: {
  50. bindevent: function () {
  51. Form.api.bindevent($("form[role=form]"));
  52. }
  53. }
  54. };
  55. return Controller;
  56. });