123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- Table.api.init({
- extend: {
- index_url: 'auth/userrecentreadcount/index/ids/' + Config.id
- },
- searchFormVisible: false,
- search: false,
- commonSearch: false,
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true, visible: false},
- {field: 'updatetime', title: __('时间'), operate: false},
- {field: 'bookname', title: __('小说'), operate: false},
- {field: 'chapter_name', title: __('章节'), operate: false,formatter: Controller.api.formatter.formateChapter}
- ]
- ]
- });
- Table.api.bindevent(table);
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- formateChapter: function (value, row, index) {
- console.log(row);
- var SiteUrl = $("#hiddenSiteUrl").val();
- var html = '';
- html += row.chapter_name;
- html += '<button class="btn btn-xs btn-copy" type="button" data-clipboard-text="' + SiteUrl + 'index/book/chapter?book_id=' + row.book_id + '&chapter_id=' + row.chapter_id + '">'
- + '<span class="fa fa-copy" aria-hidden="true"></span>复制链接</button>';
- return html;
- }
- }
- }
- };
- return Controller;
- });
- var clipboard = new Clipboard('.btn-copy');
- clipboard.on('success', function (e) {
- e.clearSelection();
- Toastr.success('复制成功');
- });
- clipboard.on('error', function (e) {
- e.clearSelection();
- Toastr.error("复制失败");
- });
|