123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- "use strict";
- console.log(123);
- var productList = new Vue({
- el: '#productList',
- data: {
- name: 'supplier-instrument-list',
- refreshType: '',
- hidden: '',
- visibilityChange: '',
- listRecord: 0,
- shopId: GLOBAL_SHOP_ID || 0,
- listQuery: {
- commodityType: 2,
- productId: '',
- name: '',
- auditStatus: '',
- onlineStatus: '',
- status: '',
- typeId: '',
- pageNum: 1,
- pageSize: 10
- },
- pageInput: 1,
- pageTotal: 0,
- productList: [],
- productTypeList: [],
- categoryKeyMap: {
- name: 'typeName',
- value: 'typeId'
- },
- auditStatusList: [
- {
- name: '全部',
- value: '',
- },
- {
- name: '待审核',
- value: 1,
- },
- {
- name: '审核通过',
- value: 2,
- },
- {
- name: '审核未通过',
- value: 3,
- }
- ]
- },
- computed: {
- pageTotal: function pageTotal() {
- var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
- return total > 0 ? total : 1;
- },
- showPageBtn: function showPageBtn() {
- var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
- total = total > 0 ? total : 1;
- var index = this.listQuery.pageNum,
- arr = [];
- if (total <= 6) {
- for (var 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];
- }
- },
- filters: {
- // 时间格式化
- formatDate: function formatDate(date) {
- if (!date) return '---';
- return dateFormat(new Date(date));
- }
- },
- created: function created() {
- this.getArticleList();
- this.fetchArticleCatagory();
- },
- mounted: function mounted() {
- window.name = this.name;
- $('.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(1).addClass("on");
- },
- methods: {
- // 获取文章列表
- getArticleList: function getArticleList() {
- var that = this;
- this.listQuery.shopId = this.shopId;
- SupplierApi.GetShopBaikeProductList(this.listQuery, function (res) {
- console.log(res);
- if (res.code === 0) {
- that.listRecord = res.data.total;
- that.productList = res.data.list;
- that.pageTotal = res.data.pages;
- } else {
- CAIMEI.Alert(res.msg, '确定', false);
- }
- });
- },
- //表格操作按钮点击
- clickOption: function clickOption(product, type) {
- var handles = {
- 1: this.toEdit,
- 2: this.changeStatus,
- 3: this.toDetail,
- 4: this.handleDelete,
- 5: this.handleEditRecommend
- };
- handles[type](product);
- },
- // 配置推荐信息
- handleEditRecommend(product){
- localStorage.setItem('target-name', this.name);
- window.open('/supplier/encyclopedia/recommend-edit.html?type=2&id=' + product.productId + '&name=' + encodeURIComponent(product.name));
- },
- //跳转编辑页面
- toEdit: function toEdit(product) {
- localStorage.setItem('productId', product.productId);
- window.open('/supplier/encyclopedia/instrument-edit.html');
- },
- //修改状态
- changeStatus: function changeStatus(product) {
- var newStatus = 1;
- if (product.status === 1) {
- newStatus = 0;
- }
- if(product.emptyNum > 0 && newStatus === 1){
- this.$confirm('您还剩余' + product.emptyNum + '项未完善,将会导致用户对您产品/仪器的认识度不够,确认是否提交?', '提示', {
- confirmButtonText: '是',
- cancelButtonText: '否'
- }).then(() => {
- this.ShopBaikeProductStatusUpdate(newStatus,product)
- })
- } else{
- this.ShopBaikeProductStatusUpdate(newStatus,product)
- }
- },
- ShopBaikeProductStatusUpdate(newStatus, product){
- SupplierApi.ShopBaikeProductStatusUpdate({
- productId: product.productId,
- shopId: this.shopId,
- status: newStatus
- }, function (res) {
- if (res.code === 0) {
- // 不刷新数据更新
- product.status = newStatus;
- const tip = newStatus ? '文章已发布' : '文章已存入草稿箱';
- CAIMEI.dialog(tip);
- } else {
- CAIMEI.dialog('修改状态失败!');
- }
- });
- },
- //查看
- toDetail: function toDetail(product) {
- if (product.auditStatus !== 2) return CAIMEI.dialog('请等待审核通过后查看!');
- if (product.onlineStatus !== 2) return CAIMEI.dialog('请等待文章上线后查看!');
- if (!product.status) return CAIMEI.dialog('请发布后查看!');
- window.open('/encyclopedia/instrument-' + product.productId + '.html');
- },
- // 跳转添加文章页面
- handleAddArticle: function handleAddArticle() {
- window.open('/supplier/encyclopedia/instrument-edit.html');
- },
- // 查询文章列表
- handleSearchList: function handleSearchList() {
- this.listQuery.pageNum = 1;
- this.getArticleList();
- },
- // 获取文章列表
- fetchArticleCatagory: function fetchArticleCatagory() {
- var that = this;
- SupplierApi.ShopBaikeProductTypeList({ commodityType: 2 }, function (res) {
- if (res.code === 0) {
- that.productTypeList = res.data;
- } else {
- CAIMEI.Alert(res.msg, '确定', false);
- }
- });
- },
- //删除确认
- handleDelete: function handleDelete(product) {
- var that = this;
- var params = {
- content: '确认删除该仪器信息?',
- cancelBtnText: '取消',
- confitmBtnText: '删除'
- };
- CAIMEI.Popup(params, function () {
- that.productDelete(product);
- });
- },
- // 删除文章
- productDelete: function productDelete(product) {
- var that = this;
- SupplierApi.ShopBaikeProductDelete({
- productId: product.productId
- }, function (res) {
- if (res.code === 0) {
- that.getArticleList();
- CAIMEI.dialog('删除成功!');
- } else {
- CAIMEI.dialog('删除失败!');
- }
- });
- },
- //页码跳转
- toPagination: function toPagination(pageNum) {
- if (pageNum <= this.pageTotal) {
- this.listQuery.pageNum = pageNum; // console.log('页码跳转');
- this.getArticleList();
- $('html ,body').animate({scrollTop: 0}, 400, 'linear'); // 页面置顶
- }
- },
- // 输入框设置页码
- checkNum: function checkNum() {
- if (this.pageInput > this.pageTotal) {
- this.pageInput = this.pageTotal;
- } else if (this.pageInput < 1) {
- this.pageInput = 1;
- }
- },
- cateSelectChange(data) {
- console.log(data);
- this.listQuery.typeId = data.typeId;
- this.getArticleList()
- },
- auditStatusChange(data){
- this.listQuery.auditStatus = data.value
- this.getArticleList()
- }
- }
- });
|