notice_template.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
  2. var Controller = {
  3. index : function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend : {
  7. index_url : 'qingdong/general/notice_template/index',
  8. table : 'field'
  9. }
  10. });
  11. var table = $("#table");
  12. // 初始化表格
  13. table.bootstrapTable({
  14. url : $.fn.bootstrapTable.defaults.extend.index_url,
  15. sortName : 'id',
  16. pageSize:1000,
  17. columns : [
  18. [
  19. {field : 'name', title : __('模块'), width : 200},
  20. {
  21. field : '微信公众号',
  22. title : "微信公众号",
  23. table : table,
  24. events : Table.api.events.operate,
  25. formatter : Table.api.formatter.operate,
  26. buttons: [
  27. {
  28. text : "修改模板",
  29. title : __('修改模板'),
  30. classname: 'records btn-dialog',
  31. url: 'qingdong/general/notice_template/edit?id={ids}',
  32. visible: function (row) {
  33. if(row.data && row.data.template_id){
  34. return true;
  35. }
  36. //返回true时按钮显示,返回false隐藏
  37. return false;
  38. }
  39. },
  40. {
  41. text : "未设置",
  42. title : __('未设置'),
  43. classname: 'records btn-dialog',
  44. url: 'qingdong/general/notice_template/edit?id={ids}',
  45. visible: function (row) {
  46. if(row.data && row.data.template_id){
  47. return false;
  48. }
  49. //返回true时按钮显示,返回false隐藏
  50. return true;
  51. }
  52. },
  53. ],
  54. },
  55. {
  56. field : '企业微信',
  57. title : "企业微信",
  58. table : table,
  59. events : Table.api.events.operate,
  60. formatter : Table.api.formatter.operate,
  61. buttons: [
  62. {
  63. text : "修改模板",
  64. title : __('修改模板'),
  65. classname: 'records btn-dialog',
  66. url: 'qingdong/general/notice_template/edit_enterprise?id={ids}',
  67. visible: function (row) {
  68. if(row.enterprise_data && row.enterprise_data.first){
  69. return true;
  70. }
  71. //返回true时按钮显示,返回false隐藏
  72. return false;
  73. }
  74. },
  75. {
  76. text : "未设置",
  77. title : __('未设置'),
  78. classname: 'records btn-dialog',
  79. url: 'qingdong/general/notice_template/edit_enterprise?id={ids}',
  80. visible: function (row) {
  81. if(row.enterprise_data && row.enterprise_data.first){
  82. return false;
  83. }
  84. //返回true时按钮显示,返回false隐藏
  85. return true;
  86. }
  87. },
  88. ],
  89. },
  90. ]
  91. ],
  92. pageList:['ALL'],
  93. //启用普通表单搜索
  94. commonSearch : false,
  95. searchFormVisible : false,
  96. });
  97. // 为表格绑定事件
  98. Table.api.bindevent(table);
  99. $('.search').hide();
  100. $('.btn-import').hide();
  101. },
  102. edit : function () {
  103. $(document).on('change','.keyword_color',function (){
  104. var color = $(this).val();
  105. $(this).next('.input-color').css('background-color',color);
  106. $(this).parent().parent().find('input').css('color',color);
  107. }).on('click','.variable_name',function (){
  108. var input_1=$(this).parents('.input-group').find('input');
  109. console.log(input_1.val())
  110. input_1.val(input_1.val()+$(this).data('value'));
  111. });
  112. $('.keyword_color').trigger('change');
  113. Controller.api.bindevent();
  114. },
  115. edit_enterprise : function () {
  116. $(document).on('change','.keyword_color',function (){
  117. var color = $(this).val();
  118. $(this).next('.input-color').css('background-color',color);
  119. $(this).parent().parent().find('input').css('color',color);
  120. }).on('click','.variable_name',function (){
  121. var input_1=$(this).parents('.input-group').find('input');
  122. console.log(input_1.val())
  123. input_1.val(input_1.val()+$(this).data('value'));
  124. });
  125. $('.keyword_color').trigger('change');
  126. Controller.api.bindevent();
  127. },
  128. api : {
  129. bindevent : function () {
  130. Form.api.bindevent($("form[role=form]"));
  131. },
  132. formatter : {
  133. thumb : function (value, row, index) {
  134. var style = row.storage == 'upyun' ? '!/fwfh/120x90' : '';
  135. return '<img src="' + row.image + '" data-tips-image alt="" title="封面图" style="max-height:90px;max-width:120px">';
  136. },
  137. }
  138. }
  139. };
  140. return Controller;
  141. });