const list = new Vue({ el: '#list', filters: { dateFormat(date) { if (!date) return return dateFormat(new Date(date), 'yyyy-MM-dd') } }, data: { windowName: 'supplier-entry-list', isPC: window.innerWidth > 768, listQuery: { shopId: '', id: '', //词条id, name: '', //词条名称 typeId: '', //分类id auditStatus: '', //百科审核状态:1待审核,2审核通过,3审核失败 onlineStatus: '', //百科上线状态:1待上线,2已上线,3已下线 status: '', //状态:0保存草稿箱,1已发布 pageNum: 1, //页数 pageSize: 10 //条数 }, totalPage: 0, hasNextPage: false, list: [], typeList: [] }, computed: { pagiantion(){ const total = this.totalPage > 0 ? this.totalPage : 1; const index = this.listQuery.pageNum,arr = []; if (total <= 6) { for (let i = 1; i <= total; i++) { arr.push(i); } return arr; } if (index <= 3) return [1, 2, 3, 4, 5, 0, total]; if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total]; return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total]; } }, created() { this.getList() this.fetchEntryTypeList() }, mounted() { window.name = this.windowName $('.navLayout').find('.navList').removeClass("on").find('.con').hide().find('a').removeClass("on"); $('.navLayout').find('.navList').eq(3).addClass("on").find('.con').show().find('a').eq(0).addClass("on"); }, methods: { // 页码跳转 hanldePageClick(item){ if(item === this.listQuery.pageNum) return this.listQuery.pageNum = item this.getList() }, filterList() { this.listQuery.pageNum = 1 this.getList() }, getList() { const self = this if(this.listQuery.pageNum > this.totalPage){ this.listQuery.pageNum = this.totalPage } if(this.listQuery.pageNum < 1){ this.listQuery.pageNum = 1 } this.listQuery.shopId = GLOBAL_SHOP_ID shopBikeApi.FetchEntryList(this.listQuery, function (res) { self.list = res.data.results self.totalPage = res.data.totalPage self.hasNextPage = res.data.hasNextPage }) }, // 添加词条 handleAddEntery() { window.open('/supplier/encyclopedia/edit.html'); }, // 发布词条 handlePublishEntry(item) { const self = this shopBikeApi.UpdateEntryStatus({id: item.id, status: 1}, function (res) { CAIMEI.dialog('词条已发布', false); self.getList() }) }, // 保存草稿箱 handleStorageEntry(item) { const self = this shopBikeApi.UpdateEntryStatus({id: item.id, status: 0}, function (res) { CAIMEI.dialog('词条暂不发布', false); self.getList() }) }, // 编辑词条 handleEditEntry(item) { window.open('/supplier/encyclopedia/edit.html?id=' + item.id); }, // 词条详情 handleDetailEntry(item) { if (item.auditStatus !== 2) return CAIMEI.dialog('请等待审核通过后查看!'); if (item.onlineStatus !== 2) return CAIMEI.dialog('请等待上线后查看!'); if (!item.status) return CAIMEI.dialog('请发布后查看!'); window.open('/encyclopedia/detail-' + item.id + '.html'); }, // 删除词条 handleRemoveEntry(item) { const slef = this const params = { content: '确认删除该词条?', cancelBtnText: '取消', confitmBtnText: '删除', closeIcon: true }; CAIMEI.Popup(params, function () { shopBikeApi.RemoveEntryById({id: item.id}, function () { CAIMEI.dialog('词条已删除', false); slef.getList() }) }); }, // 获取词条分类 fetchEntryTypeList() { const self = this shopBikeApi.FetchTypeList(function (res) { self.typeList = res.data }) } } })