list.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. const list = new Vue({
  2. el: '#list',
  3. filters: {
  4. dateFormat(date) {
  5. if (!date) return
  6. return dateFormat(new Date(date), 'yyyy-MM-dd')
  7. }
  8. },
  9. data: {
  10. windowName: 'supplier-entry-list',
  11. isPC: window.innerWidth > 768,
  12. listQuery: {
  13. shopId: '',
  14. id: '', //词条id,
  15. name: '', //词条名称
  16. typeId: '', //分类id
  17. auditStatus: '', //百科审核状态:1待审核,2审核通过,3审核失败
  18. onlineStatus: '', //百科上线状态:1待上线,2已上线,3已下线
  19. status: '', //状态:0保存草稿箱,1已发布
  20. pageNum: 1, //页数
  21. pageSize: 10 //条数
  22. },
  23. totalPage: 0,
  24. hasNextPage: false,
  25. list: [],
  26. typeList: []
  27. },
  28. computed: {
  29. pagiantion(){
  30. const total = this.totalPage > 0 ? this.totalPage : 1;
  31. const index = this.listQuery.pageNum,arr = [];
  32. if (total <= 6) {
  33. for (let i = 1; i <= total; i++) { arr.push(i); }
  34. return arr;
  35. }
  36. if (index <= 3) return [1, 2, 3, 4, 5, 0, total];
  37. if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total];
  38. return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total];
  39. }
  40. },
  41. created() {
  42. this.getList()
  43. this.fetchEntryTypeList()
  44. },
  45. mounted() {
  46. window.name = this.windowName
  47. $('.navLayout').find('.navList').removeClass("on").find('.con').hide().find('a').removeClass("on");
  48. $('.navLayout').find('.navList').eq(3).addClass("on").find('.con').show().find('a').eq(0).addClass("on");
  49. },
  50. methods: {
  51. // 页码跳转
  52. hanldePageClick(item){
  53. if(item === this.listQuery.pageNum) return
  54. this.listQuery.pageNum = item
  55. this.getList()
  56. },
  57. filterList() {
  58. this.listQuery.pageNum = 1
  59. this.getList()
  60. },
  61. getList() {
  62. const self = this
  63. if(this.listQuery.pageNum > this.totalPage){
  64. this.listQuery.pageNum = this.totalPage
  65. }
  66. if(this.listQuery.pageNum < 1){
  67. this.listQuery.pageNum = 1
  68. }
  69. this.listQuery.shopId = GLOBAL_SHOP_ID
  70. shopBikeApi.FetchEntryList(this.listQuery, function (res) {
  71. self.list = res.data.results
  72. self.totalPage = res.data.totalPage
  73. self.hasNextPage = res.data.hasNextPage
  74. })
  75. },
  76. // 添加词条
  77. handleAddEntery() {
  78. window.open('/supplier/encyclopedia/edit.html');
  79. },
  80. // 发布词条
  81. handlePublishEntry(item) {
  82. const self = this
  83. shopBikeApi.UpdateEntryStatus({id: item.id, status: 1}, function (res) {
  84. CAIMEI.dialog('词条已发布', false);
  85. self.getList()
  86. })
  87. },
  88. // 保存草稿箱
  89. handleStorageEntry(item) {
  90. const self = this
  91. shopBikeApi.UpdateEntryStatus({id: item.id, status: 0}, function (res) {
  92. CAIMEI.dialog('词条暂不发布', false);
  93. self.getList()
  94. })
  95. },
  96. // 编辑词条
  97. handleEditEntry(item) {
  98. window.open('/supplier/encyclopedia/edit.html?id=' + item.id);
  99. },
  100. // 词条详情
  101. handleDetailEntry(item) {
  102. if (item.auditStatus !== 2) return CAIMEI.dialog('请等待审核通过后查看!');
  103. if (item.onlineStatus !== 2) return CAIMEI.dialog('请等待上线后查看!');
  104. if (!item.status) return CAIMEI.dialog('请发布后查看!');
  105. window.open('/encyclopedia/detail-' + item.id + '.html');
  106. },
  107. // 删除词条
  108. handleRemoveEntry(item) {
  109. const slef = this
  110. const params = {
  111. content: '确认删除该词条?',
  112. cancelBtnText: '取消',
  113. confitmBtnText: '删除',
  114. closeIcon: true
  115. };
  116. CAIMEI.Popup(params, function () {
  117. shopBikeApi.RemoveEntryById({id: item.id}, function () {
  118. CAIMEI.dialog('词条已删除', false);
  119. slef.getList()
  120. })
  121. });
  122. },
  123. // 获取词条分类
  124. fetchEntryTypeList() {
  125. const self = this
  126. shopBikeApi.FetchTypeList(function (res) {
  127. self.typeList = res.data
  128. })
  129. }
  130. }
  131. })