jishuguifan.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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: 'jishuguifan/index' + location.search,
  8. add_url: 'jishuguifan/add',
  9. edit_url: 'jishuguifan/edit',
  10. del_url: 'jishuguifan/del',
  11. multi_url: 'jishuguifan/multi',
  12. import_url: 'jishuguifan/import',
  13. table: 'jishuguifan',
  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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'company_id', title: __('Company_id')},
  29. {field: 'company.companyname', title: __('Company.companyname'), operate: 'LIKE'},
  30. {field: 'pid', title: __('Pid')},
  31. {field: 'tid', title: __('Tid')},
  32. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  33. {field: 'ismenu', title: __('Ismenu'), searchList: {"1":__('Ismenu 1'),"0":__('Ismenu 0')}, formatter: Table.api.formatter.normal},
  34. {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  35. // {field: 'file', title: __('File'), operate: false, formatter: Table.api.formatter.file},
  36. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  39. ]
  40. ]
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. },
  45. add: function () {
  46. Controller.api.bindevent();
  47. },
  48. edit: function () {
  49. Controller.api.bindevent();
  50. },
  51. api: {
  52. bindevent: function () {
  53. Form.api.bindevent($("form[role=form]"));
  54. }
  55. }
  56. };
  57. return Controller;
  58. });
  59. $("#c-pid").data("params", function (obj) {
  60. return {
  61. custom: {company_id: $("#c-company_id").val()},
  62. isTree: 1
  63. };
  64. });
  65. $(document).on("change","#c-company_id",function(){
  66. $("#c-pid").selectPageClear();
  67. })