message.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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: 'system/message/index' + location.search,
  8. add_url: 'system/message/add',
  9. edit_url: 'system/message/edit',
  10. del_url: 'system/message/del',
  11. multi_url: 'system/message/multi',
  12. import_url: 'system/message/import',
  13. send_message: 'system/message/send_message',
  14. table: 'system_message',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'id', title: __('Id')},
  27. {
  28. field: 'identity_type',
  29. title: __('Identity_type'),
  30. searchList: {
  31. "agent": __('Agent'),
  32. "store": __('Store'),
  33. "massager": __('Massager'),
  34. "user": __('User')
  35. },
  36. formatter: Table.api.formatter.normal
  37. },
  38. {field: 'user.nickname', title: __('用户昵称'), operate: 'LIKE'},
  39. {field: 'massager.name', title: __('助教昵称'), operate: 'LIKE'},
  40. {field: 'title', title: __('Title'), operate: 'LIKE'},
  41. {field: 'is_read', title: __('Is_read'), formatter: (value) => ["否", "是"][value]},
  42. {
  43. field: 'updatetime',
  44. title: __('Updatetime'),
  45. operate: 'RANGE',
  46. addclass: 'datetimerange',
  47. autocomplete: false,
  48. formatter: Table.api.formatter.datetime
  49. },
  50. {
  51. field: 'operate',
  52. title: __('Operate'),
  53. table: table,
  54. events: Table.api.events.operate,
  55. formatter: Table.api.formatter.operate
  56. }
  57. ]
  58. ]
  59. });
  60. // 为表格绑定事件
  61. Table.api.bindevent(table);
  62. },
  63. add: function () {
  64. Controller.api.bindevent();
  65. },
  66. edit: function () {
  67. Controller.api.bindevent();
  68. },
  69. send_message: function () {
  70. $("#c-identity-type").change(function () {
  71. var identity_type = $("#c-identity-type").val();
  72. var group_type = $("#c-group_type").val();
  73. if (identity_type === "user") {
  74. $("#target_massager_div").css("display", "none");
  75. $("#user_group").css("display", group_type === "ALL" ? "none" : "block");
  76. $("#target_user_div").css("display", group_type === "ALL" ? "none" : "block");
  77. } else {
  78. $("#user_group").css("display", "none");
  79. $("#target_user_div").css("display", "none");
  80. $("#target_massager_div").css("display", group_type === "ALL" ? "none" : "block");
  81. }
  82. });
  83. $("#group_type").change(function () {
  84. var group_type = $("#c-group_type").val();
  85. var identity_type = $("#c-identity-type").val();
  86. if (identity_type === "user") {
  87. $("#target_massager_div").css("display", "none");
  88. $("#user_group").css("display", group_type === "ALL" ? "none" : "block");
  89. $("#target_user_div").css("display", group_type === "ALL" ? "none" : "block");
  90. } else {
  91. $("#user_group").css("display", "none");
  92. $("#target_user_div").css("display", "none");
  93. $("#target_massager_div").css("display", group_type === "ALL" ? "none" : "block");
  94. }
  95. });
  96. Controller.api.bindevent();
  97. },
  98. api: {
  99. bindevent: function () {
  100. Form.api.bindevent($("form[role=form]"));
  101. }
  102. }
  103. };
  104. return Controller;
  105. });