config.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. define(['jquery', 'table', 'form','layui','clipboard'], function($, Table, Form,layui, ClipboardJS) {
  2. var form = layui.form;
  3. var Controller = {
  4. index: function() {
  5. Table.init = {
  6. table_elem: '#currentTable',
  7. table_render_id: 'currentTable',
  8. add_url: "general.config/add" + (Config.group ? "?groupType=" + Config.group : ""),
  9. edit_url: "general.config/edit",
  10. delete_url: 'general.config/del',
  11. multi_url: 'general.config/multi',
  12. };
  13. Table.render({
  14. init: Table.init,
  15. toolbar: ['refresh', 'add'],
  16. url: 'general.config/index'+ (Config.group ? "?group=" + Config.group : ""),
  17. search: false,
  18. cols: [
  19. [
  20. { field: 'listorder', width: 70, title: '排序', edit: 'text' },
  21. { field: 'name', minWidth: 150, align: "left", title: '名称' },
  22. { field: 'title', minWidth: 150, align: "left", title: '标题' },
  23. { field: 'ftitle', width: 150, title: '类型' },
  24. { field: 'update_time', width: 200, title: '更新时间' },
  25. { field: 'status', title: '状态', width: 100, unresize: true, templet: Table.formatter.switch },
  26. { fixed: 'right', width: 160, title: '操作', toolbar: '#barTool' }
  27. ]
  28. ],
  29. });
  30. //点击复制
  31. var clipboard = new ClipboardJS('.copy');
  32. clipboard.on('success', function(e) {
  33. Layer.msg("复制成功",{ icon: 1});
  34. });
  35. clipboard.on('error', function(e) {
  36. Layer.msg("复制失败!请手动调用",{ icon: 2});
  37. });
  38. Table.api.bindevent();
  39. },
  40. add: function() {
  41. Controller.api.bindevent();
  42. },
  43. edit: function() {
  44. Controller.api.bindevent();
  45. },
  46. setting: function() {
  47. Form.api.bindevent($("form.layui-form"));
  48. },
  49. api: {
  50. bindevent: function() {
  51. form.on('select(fieldType)', function(data) {
  52. if (data.value == 'checkbox' || data.value == 'select' || data.value == 'selects' || data.value == 'radio' || data.value == 'selectpage' || data.value == 'custom') {
  53. if (data.value == 'selectpage') {
  54. $('#options').html($('#options2').html());
  55. }else if(data.value == 'custom'){
  56. $('#options').html($('#options3').html());
  57. }else{
  58. $('#options').html($('#options1').html());
  59. }
  60. $('#options').show();
  61. form.render();
  62. }else{
  63. $('#options').hide();
  64. }
  65. });
  66. Form.api.bindevent($("form.layui-form"));
  67. }
  68. }
  69. };
  70. return Controller;
  71. });