notice.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. $(document).on("click",".allgroups",function(){
  3. if($(this).prop("checked")){
  4. $(".checkgroup").prop("checked",true);
  5. }else{
  6. $(".checkgroup").prop("checked",false);
  7. }
  8. });
  9. $(document).on("click",".checkgroup",function(){
  10. $(".allgroups").prop("checked",$(".checkgroup:checked").length<Config.groupcount?false:true)
  11. });
  12. var adminShowGroups = [1, 2, 6, 11];
  13. var adminEditGroups = [6, 11];
  14. var Controller = {
  15. index: function () {
  16. // 初始化表格参数配置
  17. Table.api.init({
  18. extend: {
  19. index_url: 'notice/index',
  20. add_url: 'notice/add',
  21. edit_url: 'notice/edit',
  22. del_url: 'notice/del',
  23. multi_url: 'notice/multi',
  24. table: 'notice',
  25. },
  26. showRefresh:true,
  27. showToggle:false,
  28. showColumns:false,
  29. showExport:false,
  30. searchFormVisible: true,
  31. search:false,
  32. });
  33. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  34. var panel = $($(this).attr("href"));
  35. if (panel.size() > 0) {
  36. Controller.table[panel.attr("id")].call(this);
  37. }
  38. //移除绑定的事件
  39. $(this).unbind('shown.bs.tab');
  40. });
  41. //必须默认触发shown.bs.tab事件
  42. $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
  43. $(document).on('click','.layer-open',function () {
  44. Fast.api.open($(this).attr('href'), '公告', {});
  45. return false;
  46. })
  47. },
  48. table: {
  49. first: function () {
  50. var table = $("#table1");
  51. // 初始化渠道商表格
  52. table.bootstrapTable({
  53. url: 'notice/index?notice_type=1',
  54. pk: 'id',
  55. sortName: 'createtime',
  56. toolbar : "#toolbar1",
  57. extend: {
  58. add_url: 'notice/add?notice_type=1',
  59. edit_url: 'notice/edit',
  60. del_url: 'notice/del',
  61. multi_url: 'notice/multi',
  62. table: 'notice',
  63. },
  64. columns: [
  65. [
  66. {checkbox: true, visible: adminShowGroups.indexOf(Config.group) > -1},
  67. // {field: 'id', title: __('Id'),operate:false},
  68. {
  69. field: 'title',
  70. title: __('Title'),
  71. formatter: Controller.api.formatter.link,
  72. operate: 'LIKE %...%'
  73. },
  74. // {field: 'show_level', title: __('Show_level'), visible:false, searchList: {"show_level 1":'超管可见',"show_level 2":'超管、普管可见',"show_level 3":'超管、普管、渠道商可见',"show_level 4":'超管、普管、渠道商、代理商可见'},operate:false},
  75. // {field: 'show_level_text', title: __('Show_level'), visible:adminShowGroups.indexOf(Config.group) > -1, operate:false},
  76. {
  77. field: 'dialog_type',
  78. title: __('Dialog_type'),
  79. visible: false,
  80. searchList: {
  81. "1": __('Dialog_type 1'),
  82. "2": __('Dialog_type 2'),
  83. "3": __('Dialog_type 3')
  84. },
  85. operate: false
  86. },
  87. {
  88. field: 'dialog_type_text',
  89. title: __('Dialog_type'),
  90. visible: adminShowGroups.indexOf(Config.group) > -1,
  91. operate: false
  92. },
  93. {
  94. field: 'groupsname',
  95. title: __('显示范围'),
  96. visible: adminShowGroups.indexOf(Config.group) > -1,
  97. operate: false
  98. },
  99. {
  100. field: 'status',
  101. title: __('Status'),
  102. visible: adminEditGroups.indexOf(Config.group) > -1,
  103. searchList: {"normal": __('status normal'), "hidden": __('status hidden')},
  104. formatter: Controller.api.formatter.toggle,
  105. operate: false
  106. },
  107. // {field: 'status_text', title: __('Status'), operate:false},
  108. {
  109. field: 'createtime',
  110. title: __('Createtime'),
  111. operate: 'RANGE',
  112. visible: adminShowGroups.indexOf(Config.group) > -1,
  113. addclass: 'datetimerange',
  114. formatter: Table.api.formatter.datetime,
  115. operate: false
  116. },
  117. {
  118. field: 'updatetime',
  119. title: __('时间'),
  120. operate: 'RANGE',
  121. addclass: 'datetimerange',
  122. formatter: Table.api.formatter.datetime,
  123. operate: false
  124. },
  125. {
  126. field: 'operate',
  127. title: __('Operate'),
  128. visible: adminEditGroups.indexOf(Config.group) > -1,
  129. table: table,
  130. events: Table.api.events.operate,
  131. formatter: Table.api.formatter.operate
  132. }
  133. ]
  134. ]
  135. });
  136. // 为表格1绑定事件
  137. Table.api.bindevent(table);
  138. Controller.api.bindevent();
  139. },
  140. second: function () {
  141. var table = $("#table2");
  142. // 初始化渠道商表格
  143. table.bootstrapTable({
  144. url: 'notice/index?notice_type=2',
  145. pk: 'id',
  146. sortName: 'createtime',
  147. toolbar : "#toolbar2",
  148. extend: {
  149. add_url: 'notice/add?notice_type=2',
  150. edit_url: 'notice/edit',
  151. del_url: 'notice/del',
  152. multi_url: 'notice/multi',
  153. table: 'notice',
  154. },
  155. columns: [
  156. [
  157. {checkbox: true, visible: adminShowGroups.indexOf(Config.group) > -1},
  158. // {field: 'id', title: __('Id'),operate:false},
  159. {
  160. field: 'title',
  161. title: __('Title'),
  162. formatter: Controller.api.formatter.link,
  163. operate: 'LIKE %...%'
  164. },
  165. {
  166. field: 'dialog_type',
  167. title: __('Dialog_type'),
  168. visible: false,
  169. searchList: {
  170. "1": __('Dialog_type 1'),
  171. "2": __('Dialog_type 2'),
  172. "3": __('Dialog_type 3')
  173. },
  174. operate: false
  175. },
  176. {
  177. field: 'dialog_type_text',
  178. title: __('Dialog_type'),
  179. visible: adminShowGroups.indexOf(Config.group) > -1,
  180. operate: false
  181. },
  182. {
  183. field: 'groupsname',
  184. title: __('显示范围'),
  185. visible: adminShowGroups.indexOf(Config.group) > -1,
  186. operate: false
  187. },
  188. {
  189. field: 'status',
  190. title: __('Status'),
  191. visible: adminEditGroups.indexOf(Config.group) > -1,
  192. searchList: {"normal": __('status normal'), "hidden": __('status hidden')},
  193. formatter: Controller.api.formatter.toggle,
  194. operate: false
  195. },
  196. // {field: 'status_text', title: __('Status'), operate:false},
  197. {
  198. field: 'createtime',
  199. title: __('Createtime'),
  200. operate: 'RANGE',
  201. visible: adminShowGroups.indexOf(Config.group) > -1,
  202. addclass: 'datetimerange',
  203. formatter: Table.api.formatter.datetime,
  204. operate: false
  205. },
  206. {
  207. field: 'updatetime',
  208. title: __('时间'),
  209. operate: 'RANGE',
  210. addclass: 'datetimerange',
  211. formatter: Table.api.formatter.datetime,
  212. operate: false
  213. },
  214. {
  215. field: 'operate',
  216. title: __('Operate'),
  217. visible: adminEditGroups.indexOf(Config.group) > -1,
  218. table: table,
  219. events: Table.api.events.operate,
  220. formatter: Table.api.formatter.operate
  221. }
  222. ]
  223. ]
  224. });
  225. // 为表格1绑定事件
  226. Table.api.bindevent(table);
  227. Controller.api.bindevent();
  228. },
  229. third: function () {
  230. var table = $("#table3");
  231. // 初始化渠道商表格
  232. table.bootstrapTable({
  233. url: 'notice/index?notice_type=3',
  234. pk: 'id',
  235. sortName: 'createtime',
  236. toolbar : "#toolbar3",
  237. extend: {
  238. add_url: 'notice/add?notice_type=3',
  239. edit_url: 'notice/edit',
  240. del_url: 'notice/del',
  241. multi_url: 'notice/multi',
  242. table: 'notice',
  243. },
  244. columns: [
  245. [
  246. {checkbox: true, visible: adminShowGroups.indexOf(Config.group) > -1},
  247. // {field: 'id', title: __('Id'),operate:false},
  248. {
  249. field: 'title',
  250. title: __('Title'),
  251. formatter: Controller.api.formatter.link,
  252. operate: 'LIKE %...%'
  253. },
  254. {
  255. field: 'dialog_type',
  256. title: __('Dialog_type'),
  257. visible: false,
  258. searchList: {
  259. "1": __('Dialog_type 1'),
  260. "2": __('Dialog_type 2'),
  261. "3": __('Dialog_type 3')
  262. },
  263. operate: false
  264. },
  265. {
  266. field: 'dialog_type_text',
  267. title: __('Dialog_type'),
  268. visible: adminShowGroups.indexOf(Config.group) > -1,
  269. operate: false
  270. },
  271. {
  272. field: 'groupsname',
  273. title: __('显示范围'),
  274. visible: adminShowGroups.indexOf(Config.group) > -1,
  275. operate: false
  276. },
  277. {
  278. field: 'status',
  279. title: __('Status'),
  280. visible: adminEditGroups.indexOf(Config.group) > -1,
  281. searchList: {"normal": __('status normal'), "hidden": __('status hidden')},
  282. formatter: Controller.api.formatter.toggle,
  283. operate: false
  284. },
  285. // {field: 'status_text', title: __('Status'), operate:false},
  286. {
  287. field: 'createtime',
  288. title: __('Createtime'),
  289. operate: 'RANGE',
  290. visible: adminShowGroups.indexOf(Config.group) > -1,
  291. addclass: 'datetimerange',
  292. formatter: Table.api.formatter.datetime,
  293. operate: false
  294. },
  295. {
  296. field: 'updatetime',
  297. title: __('时间'),
  298. operate: 'RANGE',
  299. addclass: 'datetimerange',
  300. formatter: Table.api.formatter.datetime,
  301. operate: false
  302. },
  303. {
  304. field: 'operate',
  305. title: __('Operate'),
  306. visible: adminEditGroups.indexOf(Config.group) > -1,
  307. table: table,
  308. events: Table.api.events.operate,
  309. formatter: Table.api.formatter.operate
  310. }
  311. ]
  312. ]
  313. });
  314. // 为表格1绑定事件
  315. Table.api.bindevent(table);
  316. Controller.api.bindevent();
  317. },
  318. },
  319. add: function () {
  320. Controller.api.bindevent();
  321. $('#c-dialog_type').change(function(){
  322. var dialogType = $(this).children('option:selected').val();
  323. if (dialogType == 5){
  324. $('.pop_num').show();
  325. }else{
  326. $('.pop_num').hide();
  327. }
  328. });
  329. },
  330. edit: function () {
  331. Controller.api.bindevent();
  332. var dialog = $('#c-dialog_type').children('option:selected').val();
  333. if (dialog == 5){
  334. $('.pop_num').show();
  335. }
  336. $('#c-dialog_type').change(function(){
  337. var dialogType = $(this).children('option:selected').val();
  338. if (dialogType == 5){
  339. $('.pop_num').show();
  340. }else{
  341. $('.pop_num').hide();
  342. }
  343. });
  344. },
  345. show: function () {
  346. $(document).on('click', '.btn-close', function () {
  347. Fast.api.close();
  348. });
  349. },
  350. api: {
  351. bindevent: function () {
  352. Form.api.bindevent($("form[role=form]"));
  353. },
  354. formatter: {
  355. link: function (value, row, index) {
  356. titleRed = '';
  357. img = '';
  358. if (row.important_type == 1) {
  359. titleRed = ' style="color: #d81e06; font-size: 14px; font-weight:1000"';
  360. img = '<img style="height: 36px; margin-left: 5px;" src="../../assets/img/new_icon.png">';
  361. }
  362. return '<a href="notice/show/ids/' + row.id + '" ' + titleRed + 'class="layer-open">' + value + img + '</a>';
  363. },
  364. toggle: function (value, row, index) {
  365. return '<i class="fa ' + (value == 'normal' ? 'fa-toggle-on' : 'fa-toggle-off') + ' text-success fa-2x btn-change" data-params="status=' + (value == 'normal' ? 'hidden' : 'normal') + '" data-id="' + row.id + '"></i>';
  366. }
  367. }
  368. }
  369. };
  370. return Controller;
  371. });