article.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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: 'article/article/index' + location.search,
  8. add_url: 'article/article/add',
  9. edit_url: 'article/article/edit',
  10. del_url: 'article/article/del',
  11. multi_url: 'article/article/multi',
  12. import_url: 'article/article/import',
  13. table: 'article',
  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. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'cid', title: __('Cid')},
  27. {field: 'article_category_id', title: __('Article_category_id'), operate: 'LIKE'},
  28. {field: 'title', title: __('Title'), operate: 'LIKE'},
  29. {field: 'author', title: __('Author'), operate: 'LIKE'},
  30. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  31. {field: 'visit', title: __('Visit')},
  32. {field: 'url', title: __('Url'), operate: 'LIKE', formatter: Table.api.formatter.url},
  33. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  34. {field: 'releasetime', title: __('Releasetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  35. {field: 'hide', title: __('Hide')},
  36. {field: 'admin_id', title: __('Admin_id')},
  37. {field: 'is_hotdata', title: __('Is_hotdata'), searchList: {"0":__('Is_hotdata 0'),"1":__('Is_hotdata 1')}, formatter: Table.api.formatter.normal},
  38. {field: 'is_recdata', title: __('Is_recdata'), searchList: {"0":__('Is_recdata 0'),"1":__('Is_recdata 1')}, formatter: Table.api.formatter.normal},
  39. {field: 'sort', title: __('Sort')},
  40. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
  41. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  42. ]
  43. ]
  44. });
  45. // 为表格绑定事件
  46. Table.api.bindevent(table);
  47. },
  48. add: function () {
  49. $("#c-article_category_id").data("params", function (obj) {
  50. return {custom: {cid: $("#c-cid").val()},isTree:1};
  51. });
  52. Controller.api.bindevent();
  53. },
  54. edit: function () {
  55. $("#c-article_category_id").data("params", function (obj) {
  56. return {custom: {cid: $("#c-cid").val()},isTree:1};
  57. });
  58. // $("#c-article_category_id").attr("data-field","")
  59. // $("#c-article_category_id").attr("data-field",attr)
  60. Controller.api.bindevent();
  61. },
  62. api: {
  63. bindevent: function () {
  64. console.log('修改')
  65. Form.api.bindevent($("form[role=form]"));
  66. }
  67. }
  68. };
  69. return Controller;
  70. });