userdelrecentreadcount.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. Table.api.init({
  5. extend: {
  6. index_url: 'auth/userdelrecentreadcount/index/ids/' + Config.id
  7. },
  8. searchFormVisible: false,
  9. search: false,
  10. commonSearch: false,
  11. });
  12. var table = $("#table");
  13. // 初始化表格
  14. table.bootstrapTable({
  15. url: $.fn.bootstrapTable.defaults.extend.index_url,
  16. pk: 'id',
  17. sortName: 'id',
  18. columns: [
  19. [
  20. {checkbox: true, visible: false},
  21. {field: 'updatetime', title: __('时间'), operate: false},
  22. {field: 'bookname', title: __('小说'), operate: false},
  23. {field: 'chapter_name', title: __('章节'), operate: false,formatter: Controller.api.formatter.formateChapter}
  24. ]
  25. ]
  26. });
  27. Table.api.bindevent(table);
  28. },
  29. api: {
  30. bindevent: function () {
  31. Form.api.bindevent($("form[role=form]"));
  32. },
  33. formatter: {
  34. formateChapter: function (value, row, index) {
  35. var SiteUrl = $("#hiddenSiteUrl").val();
  36. var html = '';
  37. html += row.chapter_name;
  38. 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 + '">'
  39. + '<span class="fa fa-copy" aria-hidden="true"></span>复制链接</button>';
  40. return html;
  41. }
  42. }
  43. }
  44. };
  45. return Controller;
  46. });
  47. var clipboard = new Clipboard('.btn-copy');
  48. clipboard.on('success', function (e) {
  49. e.clearSelection();
  50. Toastr.success('复制成功');
  51. });
  52. clipboard.on('error', function (e) {
  53. e.clearSelection();
  54. Toastr.error("复制失败");
  55. });