models.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. define(['jquery', 'table', 'form'], function($, Table, Form) {
  2. var Controller = {
  3. index: function() {
  4. Table.init = {
  5. table_elem: '#currentTable',
  6. table_render_id: 'currentTable',
  7. add_url: "cms.models/add",
  8. edit_url: "cms.models/edit",
  9. delete_url: "cms.models/del",
  10. multi_url: 'cms.models/multi',
  11. field_url: 'cms.field/index',
  12. };
  13. Table.render({
  14. init: Table.init,
  15. toolbar: ['refresh', 'add'],
  16. url: 'cms.models/index',
  17. search: false,
  18. cols: [
  19. [
  20. { field: 'id', width: 70, title: 'ID' },
  21. { field: 'name', width: 120, title: '模型名称' },
  22. { field: 'tablename', width: 120, title: '数据表' },
  23. { field: 'description', align: "left", title: '描述' },
  24. { field: 'type', width: 120, title: '类型', templet: '<div>{{# if(d.type==1){ }} 独立表 {{# } else { }} 主附表 {{# } }} </div>' },
  25. { field: 'create_time', width: 180, title: '创建时间' },
  26. { field: 'status', width: 100, title: '状态', unresize: true, templet: Table.formatter.switch },
  27. {
  28. width: 150,
  29. title: '操作',
  30. templet: Table.formatter.tool,
  31. operat: [
  32. {
  33. text: '字段管理',
  34. url: Table.init.field_url + '?modelid={id}',
  35. auth: 'field',
  36. class: 'layui-btn layui-btn-xs layui-btn-normal',
  37. extend: '',
  38. },
  39. 'edit', 'delete'
  40. ]
  41. }
  42. ]
  43. ]
  44. });
  45. Table.api.bindevent();
  46. },
  47. add: function() {
  48. Controller.api.bindevent();
  49. },
  50. edit: function() {
  51. Controller.api.bindevent();
  52. },
  53. api: {
  54. bindevent: function() {
  55. Form.api.bindevent($("form.layui-form"));
  56. }
  57. }
  58. };
  59. return Controller;
  60. });