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, commonSearch: false, columns: [ [ {field: 'id', title: __('Id')}, {field: 'image', title: '封面', operate:false, formatter: Controller.api.formatter.image}, {field: 'name', title: '名称', operate:false, formatter: Controller.api.formatter.name_text}, {field: 'price', title: '单价(元)', operate:false, formatter: Controller.api.formatter.price}, {field: 'sex', title:'频道',formatter: Controller.api.formatter.sex_text,searchList: {'1':'男频','2':'女频'},operate:false,}, {field: 'book_category_id', title: '类别',formatter: Controller.api.formatter.category_text,searchList:$.getJSON('book/category/categorylist'),operate:false,}, {field: 'is_finish', title:'完结状态',formatter:Controller.api.formatter.is_finish_text,searchList:{'1':'完结','0':'连载'},operate:false,}, {field: 'state', title:'上架状态',visible:(Config.group<3),formatter:Controller.api.formatter.state_text,searchList:{'1':'上架','-1':'入库'},operate:false,}, {field: 'idx', title: '派单指数',operate:'BETWEEN',searchList:{'91,100':'100-91','81,90':'90-81','61,80':'80-61','0,60':'60以下'},operate:false,}, {field: 'keywords',title:'关键字搜索',operate:false,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; }); $(document).on('click','.book_but',function () { Fast.api.open($(this).attr('href'), '推广连接', {}); return false; }); require(['vue','component','ELEMENT'], function (Vue, component, ELEMENT) { Vue.use(ELEMENT); Vue.use(component); var refreshTable = function (form) { var options = table.bootstrapTable('getOptions'); options.pageNumber = 1; options.queryParams = function (params) { var submit = $.extend({ sort: params.sort, order: params.order, offset: params.offset, limit: params.limit, name: name }, form); return submit; }; table.bootstrapTable('refresh', {}); } var Main = { el: '#book', data: function () { return { list_value: [ { type: "input", data: { input: '', placeholder: '书籍ID/名称/主角名搜索', size: 'medium', field: 'name' } }, { type: "pick", data: { label: '小说属性:', data: Config.filter.property, active: '', field: 'corner_mark', } }, { type: "pick", data: { label: '读者性别:', data: Config.filter.sex, active: '', field: 'sex', } }, { type: "pick", data: { label: '连载状态:', data: Config.filter.is_finish, active: '', field: 'is_finish', } }, { type: "pick", data: { label: '字数筛选:', data: Config.filter.word_count, active: '', field: 'word_count', } }, { type: "pick", data: { label: '上架状态:', data: Config.filter.state, active: '', field: 'state', } }, { type: "pick", data: { label: '小说类型:', data: Config.filter.category_all, active: '', field: 'book_category_id', } }, { type: "pick", data: { label: '派单指数:', data: Config.filter.idx, active: '', field: 'idx', } } ] } }, methods: { commit: function (form) { if (form.sex) { if (form.sex == 2) { this.list_value[6].data.data = Config.filter.category_girl } else { this.list_value[6].data.data = Config.filter.category_boy } } else { this.list_value[6].data.data = Config.filter.category_all } refreshTable(form) } } }; new Vue(Main) }); }, info: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'referral/book/info', } }); var table = $("#table"); var tableOptions = { 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(); } }; if (Config.show_all_select) { tableOptions.columns[0].push({field: 'uv', title: '阅读人数'}) tableOptions.columns[0].push({field: 'uv_rate', title: '占比', formatter: function (value) { if (value !== undefined) { return value + '%' } }}) } // 初始化表格 table.bootstrapTable(tableOptions); // 为表格绑定事件 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 '
'; } if(row.book_tags_text){ return '
' + '' + value + '' + '' + is_finish + '' + row.book_tags_text + '
' +free_text+ chapter_num + '' + '' + value + '' + '' + is_finish + '' + mark + '
' +free_text+ chapter_num + '