define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'referral/book/index', info_url: 'book/book/info', table: 'book', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'idx', search: false, showToggle:false, showColumns: false, showExport: false, searchFormVisible: true, columns: [ [ {field: 'id', title: __('Id')}, {field: 'image', title: '封面', operate:false, formatter: Controller.api.formatter.image}, {field: 'name', title:'名称',operate:'LIKE',formatter:Controller.api.formatter.name_text}, {field: 'sex', title:'频道',formatter: Controller.api.formatter.sex_text,searchList: {'1':'男频','2':'女频'}}, {field: 'book_category_id', title: '类别',formatter: Controller.api.formatter.category_text,searchList:$.getJSON('book/category/categorylist')}, {field: 'is_finish', title:'完结状态',formatter:Controller.api.formatter.is_finish_text,searchList:{'1':'完结','0':'连载'}}, {field: 'state', title:'上架状态',visible:(Config.group<3),formatter:Controller.api.formatter.state_text,searchList:{'1':'上架','-1':'入库'}}, {field: 'idx', title: '派单指数',operate:'BETWEEN',searchList:{'91,100':'100-91','81,90':'90-81','61,80':'80-61','0,60':'60以下'}}, {field: 'keywords',title:'关键字搜索',operate:'LIKE',visible:false}, {field: 'operate', title: '操作', formatter: Controller.api.formatter.tuiguang}, ] ] }); // 为表格绑定事件 Table.api.bindevent(table); // 弹窗绑定 $(document).on('click','.layer-open',function () { Fast.api.open($(this).attr('href'), $(this).text(), {}); return false; }) //book_but $(document).on('click','.book_but',function () { Fast.api.open($(this).attr('href'), '推广连接', {}); return false; }); }, info: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'referral/book/info', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', showColumns:false, showToggle:false, showExport:false, search:false, // commonSearch: false, columns: [ [ {field: 'id', title: __('Id')}, {field: 'name', title: '章节',formatter: Controller.api.formatter.name}, {field: 'operate', title: '操作', formatter: Controller.api.formatter.links} ] ], onLoadSuccess: function (data) { $("[data-toggle='tooltip']").tooltip(); } }); // 为表格绑定事件 Table.api.bindevent(table); // 获取推广链接 $(document).on('click','.layer-open',function () { Fast.api.open($(this).attr('href'), $(this).data('title')?$(this).data('title'):'获取推广链接', {}); return false; }); // 设置关注章节 $(document).on('click','.set-guide-chapter-idx',function () { $this = $(this); Fast.api.ajax({ 'url': $this.attr('href') }, function (data) { //success Config.guide_chapter_idx = data.guide_chapter_idx; //更新订购章节 table.bootstrapTable('refresh'); }, function (data) { //error }); return false; }); }, chapter: function () { $(document).on('click', '.btn-close', function () { Fast.api.close(); }); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); }, formatter: { // name: function (value, row, index) { // return '' + value + ''; // }, image: function (value, row, index) { return '
'; }, sex_text: function(value,row,index){return row.sex_text;}, category_text: function(value,row,index){return row.category_text}, state_text: function(value,row,index){return row.state_text}, is_finish_text: function(value,row,index){return row.is_finish_text}, tuiguang: function (value, row, index) { return '推广连接'; }, //章节名称的格式化 name: function (value, row, index) { bookinfo = Config.bookinfo; site = Config.site; mark = ''; if(row.idx <= Config.free_chapter_num ) { if(bookinfo.article_chapter_order == row.idx || (( bookinfo.article_chapter_order == 0 ) && site.article_chapter_order ==row.idx )){ mark = '推荐文案章节'; } if(bookinfo.attent_chapter_order == row.idx || ( (bookinfo.attent_chapter_order == 0) && site.attent_chapter_order == row.idx) ){ mark = '推荐关注章节'; } return '' + value + ''+mark; }else{ return value+' '+mark; } }, links: function (value, row, index) { html = []; if(row.idx <= Config.bookinfo.referral_num){ html.push('生成推广文案'); html.push('生成推广图片'); } if(row.idx <= Config.free_chapter_num) { html.push('获取推广链接'); if (row.idx == Config.guide_chapter_idx) { html.push(' 当前关注章节') } else { html.push('设为关注章节'); if(Config.agent_distribute){ html.push('生成关注二维码'); } } } return html.join('  '); }, name_text: function(value,row,index){ mark = ''; if(row.corner_mark == 'hot'){ mark = ''+row.corner_mark_text+''; }else if(row.corner_mark == 'exclusive'){ mark = ''+row.corner_mark_text+''; }else if(row.corner_mark == 'new'){ mark = ''+row.corner_mark_text+''; } else { } return value+mark; } } } }; return Controller; });