123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- $(document).on("click",".allgroups",function(){
- if($(this).prop("checked")){
- $(".checkgroup").prop("checked",true);
- }else{
- $(".checkgroup").prop("checked",false);
- }
- });
- $(document).on("click",".checkgroup",function(){
- $(".allgroups").prop("checked",$(".checkgroup:checked").length<Config.groupcount?false:true)
- });
- var adminShowGroups = [1, 2, 6, 11];
- var adminEditGroups = [6, 11];
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'notice/index',
- add_url: 'notice/add',
- edit_url: 'notice/edit',
- del_url: 'notice/del',
- multi_url: 'notice/multi',
- table: 'notice',
- },
- showRefresh:true,
- showToggle:false,
- showColumns:false,
- showExport:false,
- searchFormVisible: true,
- search:false,
- });
- $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
- var panel = $($(this).attr("href"));
- if (panel.size() > 0) {
- Controller.table[panel.attr("id")].call(this);
- }
- //移除绑定的事件
- $(this).unbind('shown.bs.tab');
- });
- //必须默认触发shown.bs.tab事件
- $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
- $(document).on('click','.layer-open',function () {
- Fast.api.open($(this).attr('href'), '公告', {});
- return false;
- })
- },
- table: {
- first: function () {
- var table = $("#table1");
- // 初始化渠道商表格
- table.bootstrapTable({
- url: 'notice/index?notice_type=1',
- pk: 'id',
- sortName: 'createtime',
- toolbar : "#toolbar1",
- extend: {
- add_url: 'notice/add?notice_type=1',
- edit_url: 'notice/edit',
- del_url: 'notice/del',
- multi_url: 'notice/multi',
- table: 'notice',
- },
- columns: [
- [
- {checkbox: true, visible: adminShowGroups.indexOf(Config.group) > -1},
- // {field: 'id', title: __('Id'),operate:false},
- {
- field: 'title',
- title: __('Title'),
- formatter: Controller.api.formatter.link,
- operate: 'LIKE %...%'
- },
- // {field: 'show_level', title: __('Show_level'), visible:false, searchList: {"show_level 1":'超管可见',"show_level 2":'超管、普管可见',"show_level 3":'超管、普管、渠道商可见',"show_level 4":'超管、普管、渠道商、代理商可见'},operate:false},
- // {field: 'show_level_text', title: __('Show_level'), visible:adminShowGroups.indexOf(Config.group) > -1, operate:false},
- {
- field: 'dialog_type',
- title: __('Dialog_type'),
- visible: false,
- searchList: {
- "1": __('Dialog_type 1'),
- "2": __('Dialog_type 2'),
- "3": __('Dialog_type 3')
- },
- operate: false
- },
- {
- field: 'dialog_type_text',
- title: __('Dialog_type'),
- visible: adminShowGroups.indexOf(Config.group) > -1,
- operate: false
- },
- {
- field: 'groupsname',
- title: __('显示范围'),
- visible: adminShowGroups.indexOf(Config.group) > -1,
- operate: false
- },
- {
- field: 'status',
- title: __('Status'),
- visible: adminEditGroups.indexOf(Config.group) > -1,
- searchList: {"normal": __('status normal'), "hidden": __('status hidden')},
- formatter: Controller.api.formatter.toggle,
- operate: false
- },
- // {field: 'status_text', title: __('Status'), operate:false},
- {
- field: 'createtime',
- title: __('Createtime'),
- operate: 'RANGE',
- visible: adminShowGroups.indexOf(Config.group) > -1,
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime,
- operate: false
- },
- {
- field: 'updatetime',
- title: __('时间'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime,
- operate: false
- },
- {
- field: 'operate',
- title: __('Operate'),
- visible: adminEditGroups.indexOf(Config.group) > -1,
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格1绑定事件
- Table.api.bindevent(table);
- Controller.api.bindevent();
- },
- second: function () {
- var table = $("#table2");
- // 初始化渠道商表格
- table.bootstrapTable({
- url: 'notice/index?notice_type=2',
- pk: 'id',
- sortName: 'createtime',
- toolbar : "#toolbar2",
- extend: {
- add_url: 'notice/add?notice_type=2',
- edit_url: 'notice/edit',
- del_url: 'notice/del',
- multi_url: 'notice/multi',
- table: 'notice',
- },
- columns: [
- [
- {checkbox: true, visible: adminShowGroups.indexOf(Config.group) > -1},
- // {field: 'id', title: __('Id'),operate:false},
- {
- field: 'title',
- title: __('Title'),
- formatter: Controller.api.formatter.link,
- operate: 'LIKE %...%'
- },
- {
- field: 'dialog_type',
- title: __('Dialog_type'),
- visible: false,
- searchList: {
- "1": __('Dialog_type 1'),
- "2": __('Dialog_type 2'),
- "3": __('Dialog_type 3')
- },
- operate: false
- },
- {
- field: 'dialog_type_text',
- title: __('Dialog_type'),
- visible: adminShowGroups.indexOf(Config.group) > -1,
- operate: false
- },
- {
- field: 'groupsname',
- title: __('显示范围'),
- visible: adminShowGroups.indexOf(Config.group) > -1,
- operate: false
- },
- {
- field: 'status',
- title: __('Status'),
- visible: adminEditGroups.indexOf(Config.group) > -1,
- searchList: {"normal": __('status normal'), "hidden": __('status hidden')},
- formatter: Controller.api.formatter.toggle,
- operate: false
- },
- // {field: 'status_text', title: __('Status'), operate:false},
- {
- field: 'createtime',
- title: __('Createtime'),
- operate: 'RANGE',
- visible: adminShowGroups.indexOf(Config.group) > -1,
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime,
- operate: false
- },
- {
- field: 'updatetime',
- title: __('时间'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime,
- operate: false
- },
- {
- field: 'operate',
- title: __('Operate'),
- visible: adminEditGroups.indexOf(Config.group) > -1,
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格1绑定事件
- Table.api.bindevent(table);
- Controller.api.bindevent();
- },
- third: function () {
- var table = $("#table3");
- // 初始化渠道商表格
- table.bootstrapTable({
- url: 'notice/index?notice_type=3',
- pk: 'id',
- sortName: 'createtime',
- toolbar : "#toolbar3",
- extend: {
- add_url: 'notice/add?notice_type=3',
- edit_url: 'notice/edit',
- del_url: 'notice/del',
- multi_url: 'notice/multi',
- table: 'notice',
- },
- columns: [
- [
- {checkbox: true, visible: adminShowGroups.indexOf(Config.group) > -1},
- // {field: 'id', title: __('Id'),operate:false},
- {
- field: 'title',
- title: __('Title'),
- formatter: Controller.api.formatter.link,
- operate: 'LIKE %...%'
- },
- {
- field: 'dialog_type',
- title: __('Dialog_type'),
- visible: false,
- searchList: {
- "1": __('Dialog_type 1'),
- "2": __('Dialog_type 2'),
- "3": __('Dialog_type 3')
- },
- operate: false
- },
- {
- field: 'dialog_type_text',
- title: __('Dialog_type'),
- visible: adminShowGroups.indexOf(Config.group) > -1,
- operate: false
- },
- {
- field: 'groupsname',
- title: __('显示范围'),
- visible: adminShowGroups.indexOf(Config.group) > -1,
- operate: false
- },
- {
- field: 'status',
- title: __('Status'),
- visible: adminEditGroups.indexOf(Config.group) > -1,
- searchList: {"normal": __('status normal'), "hidden": __('status hidden')},
- formatter: Controller.api.formatter.toggle,
- operate: false
- },
- // {field: 'status_text', title: __('Status'), operate:false},
- {
- field: 'createtime',
- title: __('Createtime'),
- operate: 'RANGE',
- visible: adminShowGroups.indexOf(Config.group) > -1,
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime,
- operate: false
- },
- {
- field: 'updatetime',
- title: __('时间'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime,
- operate: false
- },
- {
- field: 'operate',
- title: __('Operate'),
- visible: adminEditGroups.indexOf(Config.group) > -1,
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格1绑定事件
- Table.api.bindevent(table);
- Controller.api.bindevent();
- },
- },
- add: function () {
- Controller.api.bindevent();
- $('#c-dialog_type').change(function(){
- var dialogType = $(this).children('option:selected').val();
- if (dialogType == 5){
- $('.pop_num').show();
- }else{
- $('.pop_num').hide();
- }
- });
- },
- edit: function () {
- Controller.api.bindevent();
- var dialog = $('#c-dialog_type').children('option:selected').val();
- if (dialog == 5){
- $('.pop_num').show();
- }
- $('#c-dialog_type').change(function(){
- var dialogType = $(this).children('option:selected').val();
- if (dialogType == 5){
- $('.pop_num').show();
- }else{
- $('.pop_num').hide();
- }
- });
- },
- show: function () {
- $(document).on('click', '.btn-close', function () {
- Fast.api.close();
- });
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- link: function (value, row, index) {
- titleRed = '';
- img = '';
- if (row.important_type == 1) {
- titleRed = ' style="color: #d81e06; font-size: 14px; font-weight:1000"';
- img = '<img style="height: 36px; margin-left: 5px;" src="../../assets/img/new_icon.png">';
- }
- return '<a href="notice/show/ids/' + row.id + '" ' + titleRed + 'class="layer-open">' + value + img + '</a>';
- },
- toggle: function (value, row, index) {
- 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>';
- }
- }
- }
- };
- return Controller;
- });
|