/** * Created by ZHJY on 2020/9/17. */ ; $('.navLayout').find('.navList').removeClass("on").find('.con').hide().find('a').removeClass("on"); $('.navLayout').find('.navList').eq(1).addClass("on").find('.con').show().find('a').eq(2).addClass("on"); var releaseContainer = new Vue({ el:"#releaseContainer", data: { NODE_ENV_BASE_URL:'', releaseType:'', productId:'', activeNum:0, isSelectActive:0, isRequest:true, isAddBrand:false,//控制提交品牌弹窗 tagsText:'',//标签输入框 brandImage:'',//品牌LOGO brandTextarea:'',//品牌描述 brandAssociationList:[],//品牌联想 isNoneBrand:false, releaseParams:{ userId:0, shopId:0, name:'', //商品名称 aliasName:'',//内部商品名称 bigTypeId:'', smallTypeId:'', tinyTypeId:'',//三级分类ID brandId:'',//品牌ID tags:'',//商品标签 unit:'',//包装规格 productCode:'',//商品编码 productType:'',//商品类型, machineType:'',//医疗器械类型 searchKey:'',//搜索关键词 qualificationImg:"",//器械资质 normalPrice:'',//市场价 price:'',//售价 costPrice:'',//结算价 includedTax:1,//是否含税 invoiceType:1,//发票类型 taxPoint:13,//税率 minBuyNumber:'',//起订量 stock:'',//库存 step:1,//购买数量 // byFlag:0,//运费 allAreaFlag:1,//销售区域 provinceIds:0,//指定区域 detailInfo:'',//商品详情信息 orderInfo :'',//订购方案 serviceInfo:'',//服务详情 firstClassifyName:'', twoClassifyName:'', threeClassifyName:'', brandName:'', commodityType:1 }, params:{ param:[],//相关参数 image:[],//商品图片 }, viewer:{}, tagsList:[],//本地存储标签 searchKeyArr:[],//本地存储关键词 paramKeyList:[{paramsName:'',paramsContent:''}],//相关参数 formData:new FormData(), classificationFirstList:[{name:'请选择',value:''}], classificationTwoList:[], classificationThreeList:[], keywordText:'请务必准确定义关键词,关键词会影响商品的搜索结果,建议从品牌,商品学名,商品别名,商品大类别和商品小类别5个方面考虑,每个关键词不超过16个汉字', selectText:{ bigTypeID:'请选择一级分类', smallTypeID:'请选择二级分类', tinyTypeID:'请选择三级分类', goodsType:'请选择商品类型', apparatusType:'请选择器械类型', }, goodsTypeList:[ {name:'妆字号',value:1}, {name:'械字号',value:2}, {name:'其他',value:0}, ], apparatusTypeList:[ {name:'一类医疗器械',value:1}, {name:'二类医疗器械',value:2}, {name:'三类医疗器械',value:3}, ], searchKeyList:[ {placeholder:'建议输入品牌关键词',value:""}, {placeholder:'建议输入品牌学名关键词',value:""}, {placeholder:'建议输入商品别名/市场称呼关键词',value:""}, {placeholder:'建议输入商品大类别关键词',value:""}, {placeholder:'建议输入商品小类别关键词',value:""}, ], attributeList:[ {name:'产品',value:'1'}, {name:'仪器',value:'2'} ], productDetailInfoId:null, ProvinceList:[], GoodsImagesList:[], isProvince:false, provinceIns:0, oldNum:0, newNum: 0, orderingMin:0, orderingMax:500, severiMin:0, severiMax:500, isTaxPonitEditPopup:false, isTaxPonitEdit:false, fromMessage:'',//提示文字 isBrandAssociation:false, vShow_Name:false, vShow_AliasName:false, vShow_TinyTypeID:false, vShow_BrandID:false, vShow_GoodsType:false, vShow_QualificationImg:false, vShow_Tags:false, vShow_Unit:false, vShow_NormalPrice:false, vShow_Price1:false, vShow_includedTax:false, vShow_MinBuyNumber:false, vShow_Stock:false, vShow_isProvince:false, vShow_taxPoint:false, vShow_GoodsImages:false, vShow_detailInfoEditor:true, vShow_orderInfoEditor:true, vShow_attribute:false, }, computed: { }, methods: { getclass:function(val){ this.selectText.bigTypeID='请选择一级分类'; this.selectText.smallTypeID = '请选择二级分类'; this.releaseParams.bigTypeId =''; this.classificationTwoList=[]; this.classificationThreeList =[]; this.GetFistClassFn(val); }, GetEditReleaseProductInfo: function(productId){ var _this = this; SupplierApi.EditReleaseProductInfo({productId:productId},function(response){ if(response.code == 0){ console.log(response); var data = response.data; _this.releaseParams.brandId = data.brandId; _this.releaseParams.name = data.name; _this.releaseParams.aliasName = data.aliasName; _this.releaseParams.productType = data.productType; _this.releaseParams.machineType = data.machineType; _this.releaseParams.qualificationImg = data.qualificationImg; _this.releaseParams.unit = data.unit; _this.releaseParams.productCode = data.productCode; _this.releaseParams.normalPrice = data.normalPrice; _this.releaseParams.price = data.price; _this.releaseParams.includedTax = data.includedTax == '' ? 1 : data.includedTax; _this.releaseParams.invoiceType = data.invoiceType; _this.releaseParams.taxPoint = data.supplierTaxPoint; _this.releaseParams.costPrice = data.costPrice; _this.releaseParams.minBuyNumber = data.minBuyNumber; _this.releaseParams.stock = data.stock; _this.releaseParams.step = data.step; _this.releaseParams.byFlag = data.byFlag; _this.releaseParams.allAreaFlag = data.allAreaFlag; _this.releaseParams.detailInfo = data.productDetail.detailInfo; _this.releaseParams.serviceInfo = data.productDetail.serviceInfo; _this.releaseParams.orderInfo = data.productDetail.orderInfo; _this.productDetailInfoId = data.productDetail.productDetailInfoId; _this.tagsList = _this.setTagArray(data.tags); _this.EchoProductFn(data.productType); _this.EchoMachineTypeFn(data.machineType); _this.selectText.bigTypeID = data.bigTypeName; _this.selectText.smallTypeID = data.smallTypeName; _this.selectText.tinyTypeID = data.tinyTypeName; _this.releaseParams.bigTypeId = data.bigTypeId; _this.releaseParams.smallTypeId =data.smallTypeId; _this.releaseParams.tinyTypeId =data.tinyTypeId; _this.releaseParams.firstClassifyName = data.bigTypeName; _this.releaseParams.twoClassifyName = data.smallTypeName; _this.releaseParams.threeClassifyName = data.tinyTypeName; _this.releaseParams.commodityType =data.commodityType; _this.releaseParams.brandName = data.brandName; _this.GoodsImagesList = _this.EchoGoodsImagesListFn(data.imageList); _this.classificationTwoList = data.smallTypeName; _this.classificationThreeList = data.tinyTypeName; if(data.commodityType !=null||data.commodityType != ''){ _this.releaseParams.commodityType = data.commodityType; _this.GetFistClassFn(data.commodityType); } if(_this.classificationTwoList!=''){ _this.GetTwoClassFn(data.bigTypeID); } if (_this.classificationThreeList){ _this.GetThreeClassFn(data.smallTypeID); } if(data.searchKey != null){ _this.setSearchKeyArray(data.searchKey); } if(data.parametersList == ''){ _this.paramKeyList = [{paramsName:'',paramsContent:''}]; }else{ _this.paramKeyList = data.parametersList; } // 下拉列表初始化 setTimeout(function(){ _this.ChangeClassificationFirst({bigTypeId:data.bigTypeId, name:data.bigTypeName}); setTimeout(function(){ _this.ChangeClassificationTwo({smallTypeId:data.smallTypeId, name:data.smallTypeName}); setTimeout(function(){ _this.ChangeClassificationThree({tinyTypeId:data.tinyTypeId, name:data.tinyTypeName}); },500); },500); },500); }else{ CAIMEI.Alert(response.msg, '确定', false); } }) }, EchoProductFn : function(type) { switch (type) { case 0 && null: this.selectText.goodsType = '其他'; break; case 1: this.selectText.goodsType = '妆字号'; break; case 2: this.selectText.goodsType = '械字号'; break; } }, EchoMachineTypeFn : function(type) { switch (type) { case 1 && null: this.selectText.apparatusType = '一类医疗器械'; break; case 2: this.selectText.apparatusType = '二类医疗器械'; break; case 3: this.selectText.apparatusType = '三类医疗器械'; break; } }, EchoGoodsImagesListFn: function(arr){//处理商品主图回显 var newArray =[]; arr.forEach( function(el){ newArray.push(el.image) }); return newArray; }, touchmoveFn: function(){ this.isSelectActive =0; }, showOption: function(type){//显示option var _this = this; switch (type) { case 'first': _this.vShow_TinyTypeID = false; _this.isSelectActive=1; break; case 'two': _this.vShow_TinyTypeID = false; _this.isSelectActive=2; break; case 'three': _this.vShow_TinyTypeID = false; _this.isSelectActive=3; break; case 'type': _this.vShow_GoodsType = false; _this.isSelectActive=4; break; case 'ratus': _this.isSelectActive=5; break; } }, SelectChangeTypeFn: function(option){//选择商品类型 var _this = this; _this.releaseParams.productType = Number(option.value); _this.selectText.goodsType = option.name; _this.isSelectActive = 0; _this.vShow_GoodsType = false; }, SelectChangeApparatusFn: function(option){//选择器械类型 var _this = this; _this.releaseParams.machineType = Number(option.value); _this.selectText.apparatusType = option.name; _this.isSelectActive = 0; _this.vShow_GoodsType = false; }, bindBrandAssociationFn: function(e){//品牌输入联想 var _this = this; var name = e.target.value; if (name != ''){ SupplierApi.GetBrandAssociation({userId: _this.releaseParams.userId,name:name},function(response){ if(response.code ==0){ if(response.data&&response.data.length>0){ _this.brandAssociationList = response.data; _this.isBrandAssociation = true; }else{ _this.brandAssociationList = []; _this.isBrandAssociation = false; } } }); }else{ _this.isBrandAssociation = false; } }, brandAssociationFn: function(){//失去焦点判断是否存在品牌信息 var _this = this; if(_this.releaseParams.brandName == ''){ CAIMEI.dialog('请输入商品品牌名称'); }else{ SupplierApi.CheckSupplierBrandDetection({name:_this.releaseParams.brandName},function(response){ if(response.code ==0){ CAIMEI.dialog('您的品牌可以使用~'); _this.releaseParams.brandId = response.data.id; }else{ _this.releaseParams.brandId = ''; CAIMEI.Modal('您输入的品牌名称暂未被采美收录,请检查品牌名称是否输入正确或者向采美提交该品牌','确定','去提交',function () { setTimeout(function(){ _this.isAddBrand = true; },200); }); } }); } }, uploadBrandImagesFn: function(){//上传品牌LOGO var _this = this; var inputDOM = _this.$refs.brandImage; var formData = new FormData(); var file = inputDOM.files; formData.append('file', file[0]); SupplierApi.uploadimg(formData,function(response){ _this.brandImage = response.data; }); }, removeBrandImageFn: function(){//删除品牌LOGO var _this = this; _this.brandImage = ''; }, confimAddBrandPopup: function(){//确定提交新品牌 var _this = this; var params = { name:_this.releaseParams.brandName, userId:_this.releaseParams.userId, logo:_this.brandImage, description:_this.brandTextarea, source:1 }; SupplierApi.AddSupplierBrand(params,function(response){ if(response.code == 0){ CAIMEI.Alert('品牌提交成功,将在1-2个工作日内进行审核~','确定',true,function () { _this.releaseParams.brandId = response.data.id; _this.isBrandAssociation = false; _this.isAddBrand = false; }); }else{ CAIMEI.Alert(response.msg, '确定', false); } }); }, hideAddBrandPopup: function(){//取消提交新品牌 var _this = this; _this.isAddBrand = false; }, SelectChangeAssociationFn: function(option){//选择品牌 var _this = this; _this.releaseParams.brandName = option.name; _this.releaseParams.brandId = option.id; _this.isBrandAssociation = false; _this.vShow_BrandID = false; }, GetFistClassFn: function(val){//获取一级分类菜单 var _this = this; PublicApi.GetFirstClassFication({typeSort:val},function (response) { if(response.code == 0){ _this.classificationFirstList = response.data; }else{ CAIMEI.Alert(response.msg, '确定', false); } }) }, GetTwoClassFn: function(value){//获取二级分类菜单 var _this = this; PublicApi.GetTwoClassFication({bigTypeId:value},function (response) { if(response.code == 0){ if(response.data.length>0){ _this.classificationTwoList = response.data; }else { _this.classificationTwoList = []; _this.releaseParams.twoClassifyName = ''; _this.releaseParams.smallTypeId = '' } }else{ CAIMEI.Alert(response.msg, '确定', false); } }) }, GetThreeClassFn: function(value){//获取三级分类菜单 var _this = this; PublicApi.GetThreeClassFication({smallTypeId:value},function (response) { if(response.code == 0){ if(response.data.length>0){ _this.classificationThreeList = response.data; }else { _this.releaseParams.threeClassifyName = ''; _this.classificationThreeList = []; _this.releaseParams.tinyTypeId = '' } }else{ CAIMEI.Alert(response.msg, '确定', false); } }) }, ChangeClassificationFirst: function(option){//选择一级分类 var _this = this; _this.selectText.bigTypeID = option.name; _this.releaseParams.firstClassifyName = option.name; _this.releaseParams.bigTypeId = option.bigTypeId _this.selectText.smallTypeID='请选择二级分类'; _this.selectText.tinyTypeID = '请选择三级分类'; _this.releaseParams.smallTypeId =''; _this.releaseParams.tinyTypeId =''; _this.classificationTwoList=[]; _this.classificationThreeList =[]; _this.isSelectActive = 0; if(_this.releaseParams.bigTypeId!=''){ _this.GetTwoClassFn(option.bigTypeId); } }, ChangeClassificationTwo: function(option){//选择二级分类 var _this = this; if(!option.smallTypeId){_this.isSelectActive = 0; return;} _this.selectText.smallTypeID = option.name; _this.selectText.tinyTypeID = '请选择三级分类'; _this.releaseParams.smallTypeId = option.smallTypeId; _this.releaseParams.twoClassifyName = option.name; _this.isSelectActive = 0; _this.GetThreeClassFn(option.smallTypeId); }, ChangeClassificationThree: function(option){//选择三级分类 var _this = this; if(!option.tinyTypeId){_this.isSelectActive = 0; return;} _this.releaseParams.tinyTypeId = option.tinyTypeId; _this.selectText.tinyTypeID = option.name; _this.releaseParams.threeClassifyName = option.name; _this.isSelectActive = 0; _this.vShow_TinyTypeID = false; }, addTag:function(){//添加标签 var _this = this; if(_this.tagsText == ''){ _this.vShow_Tags = true; _this.fromMessage = '请输入商品标签!'; }else if(_this.in_array(_this.tagsText,_this.tagsList)){ _this.vShow_Tags = true; _this.fromMessage = '商品标签已存在!'; }else{ _this.tagsList.push({"tag":_this.tagsText}); _this.tagsText = ''; _this.vShow_Tags = false; _this.fromMessage = ''; } }, removeTags:function(index){//删除标签 this.tagsList.splice(index,1); }, in_array:function(search,array){//判断标签是否已存在 for(var i in array){ if(array[i].tag==search){ return true; } } return false; }, uploadQualificationsFn: function(el) {//上传资质证书 var _this = this; var inputDOM = _this.$refs.inputer; var file = inputDOM.files; _this.formData.append('file', file[0]); SupplierApi.uploadimg(_this.formData,function(response){ _this.releaseParams.qualificationImg = response.data; _this.vShow_QualificationImg = false; }); }, removeQualificationsFn: function(){//删除资质图片 var _this = this; _this.releaseParams.qualificationImg = ''; }, addParamsFn: function(){//添加参数 var _this = this; if(_this.paramKeyList.length>50){return;} var obj ={paramsName:'',paramsContent:''}; _this.paramKeyList.push(obj) }, removeParamsFn: function(index){//删除参数 var _this = this; _this.paramKeyList.splice(index,1); }, radioChangeInvoiceType: function(event) {//选择发票类型 var _this = this; _this.releaseParams.invoiceType= event.target.value; switch (_this.releaseParams.invoiceType) { case '1': _this.releaseParams.taxPoint = 13; _this.isTaxPonitEdit = true; break; case '2': _this.releaseParams.taxPoint = 6; _this.isTaxPonitEdit = true; break; case '3': _this.releaseParams.taxPoint = ''; _this.isTaxPonitEdit = false; break; } }, taxPonitEdit: function(){//修改税率 this.isTaxPonitEditPopup = true; }, hideTaxPonitEditPopup: function(){//取消修改税率弹窗 var _this = this; if(_this.releaseParams.taxPoint == ''){ _this.vShow_taxPoint = true; _this.fromMessage = '请输入税率'; return } if(_this.releaseParams.taxPoint == 0){ _this.vShow_taxPoint = true; _this.fromMessage = '税率不能为0'; return } this.isTaxPonitEditPopup = false; }, confimTaxPonitEditPopup: function(){//确定修改税率 var _this = this; if(_this.releaseParams.taxPoint == ''){ _this.vShow_taxPoint = true; _this.fromMessage = '请输入税率'; return } if(_this.releaseParams.taxPoint == 0){ _this.vShow_taxPoint = true; _this.fromMessage = '税率不能为0'; return } this.isTaxPonitEditPopup = false; }, radioChangeStep: function(event){//选择指定购买数量 this.releaseParams.step= event.target.value; }, radioChangeByFlag: function(event){//选择运费 this.releaseParams.byFlag= event.target.value; }, radioChangeAllAreaFlag: function(event){//选择指定区域 var _this = this; _this.releaseParams.areaFlag= event.target.value; if( _this.releaseParams.areaFlag == '0'){ _this.isProvince=true; _this.GetProvinceFn(); }else{ _this.vShow_isProvince = false; _this.isProvince=false; } }, addProvinceFn: function(item){//选择指定区域 item.isChecked = ! item.isChecked; }, GetProvinceFn: function(){//查询指定区域 var _this = this; PublicApi.GetProvince({},function(response){ if(response.code == 0){ var arr =[]; var data = response.data; data.forEach(function(el){ CAIMEI.returnedTarget(); arr.push(Object.assign({},el,{ isChecked : false })) }); _this.ProvinceList =arr; }else{ CAIMEI.Alert(response.msg, '确定', false); } }) }, uploadGoodsImagesFn: function(event){//上传商品图片 var _this = this; var inputDOM = _this.$refs.goodsImages; var file = inputDOM.files; var reader = new FileReader(); reader.readAsDataURL(file[0]); reader.onload = function(e) { var image = new Image(); image.src = e.target.result; image.onload = function() { var w = this.width; var h = this.height; if (w != h) { CAIMEI.dialog('请上传尺寸比例为1:1的图片'); return false; } if (w < 750 || h < 750) { CAIMEI.dialog('请上传分辨率大于750*750的图片'); return false; } _this.formData.append('file', file[0]); SupplierApi.uploadimg(_this.formData,function(response){ _this.GoodsImagesList.push(response.data); event.target.value = ''; }); } }; }, showViewerImageFn: function(index ){//预览上传图片 var _this = this; var DomEven = '#uploadGoodsImages'+index; var ViewerDom = document.querySelector(DomEven); _this.viewer = new Viewer(ViewerDom, {url:'data-image'}); }, removeGoodsImagesFn: function(index){//删除商品图片 var _this = this; _this.GoodsImagesList.splice(index,1); }, orderingTextConInput: function(event){//订购方案文字控制 var value = event.target.value; var len = parseInt(value.length); if (len > this.orderingMax) return; this.orderingMin = len; if(this.orderingMin == 500){ return; } }, severiTextConInput: function(event){//服务项目文字控制 var value = event.target.value; var len = parseInt(value.length); if (len > this.severiMax) return; this.severiMin = len; if(this.severiMin == 500){ return; } }, PrevStep: function(){//返回上一步 this.activeNum--; this.scrollIntoView(); }, NextStep: function(){//进入第二步 var _this = this; var KeyString = '',TagString=''; console.log(_this.releaseParams); if(_this.releaseParams.name == ''){ _this.vShow_Name = true; _this.fromMessage = '请输入商品显示名'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_Name = false; },2000); return } if(_this.releaseParams.aliasName == ''){ _this.vShow_AliasName = true; _this.fromMessage = '请输入内部商品名'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_AliasName = false; },2000); return; } if(_this.releaseParams.commodityType == ''){ _this.vShow_attribute=true; _this.fromMessage = '请选择商品属性'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_attribute = false; },2000); return; } if(_this.releaseParams.bigTypeId == ''){ _this.vShow_TinyTypeID = true; _this.fromMessage = '请选择商品分类'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_TinyTypeID = false; },2000); return; } if(_this.classificationTwoList!=''&& _this.classificationTwoList!=null){ if(_this.releaseParams.smallTypeId == ''){ _this.vShow_TinyTypeID = true; _this.fromMessage = '请选择二级分类'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_TinyTypeID = false; },2000); return; } } if(_this.classificationThreeList!='' && _this.classificationThreeList!=null){ if(_this.releaseParams.tinyTypeId == ''){ _this.vShow_TinyTypeID = true; _this.fromMessage = '请选择三级分类'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_TinyTypeID = false; },2000); return; } } if(_this.releaseParams.brandId == ''){ _this.vShow_BrandID = true; _this.fromMessage = '请选择商品品牌'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_BrandID = false; },2000); return; } if(_this.releaseParams.productType === ""){ _this.vShow_GoodsType = true; _this.fromMessage = '请选择商品类型'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_GoodsType = false; },2000); return; } if(_this.releaseParams.productType == 2){ if(_this.releaseParams.machineType == ''){ _this.vShow_GoodsType = true; _this.fromMessage = '请选择器械类型'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_GoodsType = false; },2000); return; } if(_this.releaseParams.qualificationImg == ''){ _this.vShow_QualificationImg = true; _this.fromMessage = '请上传资质图片'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_QualificationImg = false; },2000); return; } } //商品标签 if(_this.tagsList =='') { _this.vShow_Tags = true; _this.fromMessage = '请添加商品标签'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_Tags = false; },2000); return; }else{ _this.tagsList.forEach(function(el){ TagString += el.tag+','; }); _this.releaseParams.tags = TagString.substring(0, TagString.lastIndexOf(',')); } if(_this.releaseParams.unit == ''){ _this.vShow_Unit = true; _this.fromMessage = '请输入包装规格'; setTimeout(function(){ _this.vShow_Unit = false; },2000); _this.scrollIntoView(); return; } //搜索关键词 if(_this.searchKeyList!=''){ _this.searchKeyList.forEach(function(el){ KeyString+=el.value+','; }); _this.releaseParams.searchKey = KeyString.substring(0, KeyString.lastIndexOf(',')); } if( _this.paramKeyList[0].paramsName == ''){ _this.params.param = []; }else{ _this.params.param = _this.paramKeyList; } _this.activeNum++; _this.scrollIntoView(); }, NextStep1: function(){//进入第三步 var _this = this; if(_this.releaseParams.normalPrice == ''){ _this.vShow_NormalPrice = true; _this.fromMessage = '请输入市场价'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_NormalPrice = false; },2000); return } if(_this.releaseParams.normalPrice == 0){ _this.vShow_NormalPrice = true; _this.fromMessage = '市场价不能为0'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_NormalPrice = false; },2000); return } if(_this.releaseParams.price == ''){ _this.vShow_Price1 = true; _this.fromMessage = '请输入售价'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_Price1 = false; },2000); return; } if(_this.releaseParams.price1 == 0){ _this.vShow_Price1 = true; _this.fromMessage = '售价不能为0'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_Price1 = false; },2000); return; } if(_this.releaseParams.includedTax == 3){ _this.vShow_includedTax = true; _this.fromMessage = '请选择是否含税'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_includedTax = false; },2000); return; } if(_this.releaseParams.minBuyNumber === ''){ _this.vShow_MinBuyNumber = true; _this.fromMessage = '请输入起订量'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_MinBuyNumber = false; },2000); return; } if(_this.releaseParams.stock === ''){ _this.vShow_Stock = true; _this.fromMessage = '请输入库存'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_Stock = false; },2000); return; } if(_this.releaseParams.minBuyNumber > _this.releaseParams.stock){ _this.vShow_MinBuyNumber = true; _this.fromMessage = '起订量不能大于库存'; _this.scrollIntoView(); setTimeout(function(){ _this.vShow_MinBuyNumber = false; },2000); return; } if(_this.releaseParams.areaFlag == '0'){ _this.ProvinceList.forEach(function(el){ if(el.isChecked){ _this.releaseParams.provinceIds+=el.provinceID+','; } }); if(_this.releaseParams.provinceIds == ''){ _this.vShow_isProvince = true; _this.fromMessage = '请选择指定区域'; setTimeout(function(){ _this.vShow_isProvince = false; },2000); return; } } _this.activeNum++; _this.scrollIntoView(); if(_this.vShow_detailInfoEditor){ _this.initCKeditor(); } }, NextStep2: function() {//点击进入第四步 var _this = this; var detailInfo= detailInfoEditor.getData(); _this.releaseParams.detailInfo = detailInfo; if(_this.GoodsImagesList ==''){ CAIMEI.dialog('请上传商品图片'); return; } if( _this.releaseParams.detailInfo ==''){ CAIMEI.dialog('请填写商品详情'); return; } _this.params.image = []; _this.GoodsImagesList.forEach(function(el,index){ var imageObject = {}; if(index == 0 ){ imageObject = {productImageId:'',image:el,mainFlag:'1'}; }else{ imageObject = {productImageId:'',image:el,mainFlag:'0'}; } _this.params.image.push(imageObject); }); _this.activeNum++; _this.scrollIntoView(); if(_this.vShow_orderInfoEditor){ _this.initOrderCKeditor(); _this.initSeverCKeditor(); } }, initCKeditor: function(){//富文本 var _this = this; _this.vShow_detailInfoEditor = false; ClassicEditor.create(document.querySelector('#detailInfoEditor'), { ckfinder: { uploadUrl: _this.NODE_ENV_BASE_URL+'/formData/ckeditorImage' } }).then(function(editor) { window.detailInfoEditor = editor; var detailInfo= detailInfoEditor.getData(); ClassicEditor.instances.WORK_INTRODUCTION.setData(detailInfo); console.log(detailInfo); }).catch(function(error){ console.log(error); }); }, initOrderCKeditor: function(){//富文本 var _this = this; _this.vShow_orderInfoEditor = false; ClassicEditor.create(document.querySelector('#orderInfoEditor'), { ckfinder: { uploadUrl: _this.NODE_ENV_BASE_URL+'/formData/ckeditorImage' } }).then(function(editor) { window.orderInfoEditor = editor; var detailInfo= orderInfoEditor.getData(); ClassicEditor.instances.WORK_INTRODUCTION.setData(detailInfo); console.log(detailInfo); }).catch(function(error){ console.log(error); }); }, initSeverCKeditor: function(){//富文本 var _this = this; _this.vShow_orderInfoEditor = false; ClassicEditor.create(document.querySelector('#severInfoEditor'), { ckfinder: { uploadUrl: _this.NODE_ENV_BASE_URL+'/formData/ckeditorImage' } }).then(function(editor) { window.severInfoEditor = editor; var detailInfo= severInfoEditor.getData(); ClassicEditor.instances.WORK_INTRODUCTION.setData(detailInfo); }).catch(function(error){ console.log(error); }); }, addReleaseGoodSubmitFn: function(){//提交发布商品 var _this = this; _this.releaseParams.orderInfo = orderInfoEditor.getData(); _this.releaseParams.serviceInfo = severInfoEditor.getData(); if(_this.releaseType == 'edit'){ _this.releaseParams.productDetailInfoId = _this.productDetailInfoId; _this.releaseParams.productId = _this.productId; CAIMEI.returnedTarget(); _this.releaseParams = Object.assign(_this.releaseParams,{params:JSON.stringify(_this.params)}); delete _this.releaseParams.imageList; delete _this.releaseParams.parametersList; delete _this.releaseParams.productDetail; }else{ CAIMEI.returnedTarget(); _this.releaseParams = Object.assign(_this.releaseParams,{params:JSON.stringify(_this.params)}); } // console.log( _this.releaseParams); SupplierApi.AddSupplierReleaseProduct(_this.releaseParams,function(response){ if(response.code == 0){ CAIMEI.dialog('提交成功,等待审核',true,function () { if(_this.releaseType == 'edit'){ SupplierApi.UpdateSearchManageProduct({productId:_this.productId},function (res) { console.log('编辑商品更新搜索索引~~~成功'); }) } location.href = '/supplier/goods.html'; if(CAIMEI.Storage.getItem('adProductPeview')){ CAIMEI.Storage.removeItem('adProductPeview'); } }); }else{ CAIMEI.Alert(response.msg, '确定', false); } }); }, addReleasePeview: function(){//预览按钮 var _this = this; CAIMEI.returnedTarget(); _this.releaseParams.orderInfo = orderInfoEditor.getData(); _this.releaseParams.serviceInfo = severInfoEditor.getData(); _this.releaseParams = Object.assign(_this.releaseParams,{params:_this.params}); CAIMEI.Storage.setItem('adProductPeview', JSON.stringify(_this.releaseParams)); setTimeout(function(){ window.open('/supplier/goods/preview.html'); },1000) }, blur_name: function(e){//商品名失去焦点 var _this = this; _this.vShow_Name = false; if(e.target.value == ''){ _this.vShow_Name = true; _this.fromMessage = '请输入商品显示名'; setTimeout(function(){ _this.vShow_Name = false; },2000); }else{ _this.vShow_Name = false; } }, blur_aliasName: function(e){//内部商品名失去焦点 var _this = this; _this.vShow_AliasName = false; if(e.target.value == ''){ _this.vShow_AliasName = true; _this.fromMessage = '请输入内部商品名'; setTimeout(function(){ _this.vShow_AliasName = false; },2000); }else{ _this.vShow_AliasName = false; } }, blur_taxPoint: function(event){ var E_TaxPoint = event.target.value; if(E_TaxPoint!=''){ this.releaseParams.taxPoint = parseFloat(E_TaxPoint); }else{ this.releaseParams.taxPoint = ''; } this.vShow_taxPoint = false; }, blur_tags: function(e){ this.vShow_Tags = false; }, blur_aliasUnit: function(e){ this.vShow_Unit = false; }, input_normalPrice: function(e){ this.vShow_NormalPrice = false; }, input_price1: function(e){ this.vShow_Price1 = false; }, input_minBuyNumber: function(event){ this.vShow_MinBuyNumber = false; var E_Number = event.target.value; if(E_Number!=''){ this.releaseParams.minBuyNumber = parseInt(E_Number.replace(/[^0-9]/g,'')); }else{ this.releaseParams.minBuyNumber = ''; } }, input_stock: function(event){ this.vShow_Stock = false; var E_stock = event.target.value; if(E_stock!=''){ this.releaseParams.stock = parseInt(E_stock.replace(/[^0-9]/g,'')); }else{ this.releaseParams.stock = ''; } }, toFixedFn: function(text){ return Number(text).toFixed(2); }, scrollIntoView: function(){ document.getElementById('releaseContainer').scrollIntoView({block: 'start', behavior: 'smooth'}); }, setTagArray: function(arr){//回显处理商品标签 var arrSplit = arr.split(','); var _ARRAY = []; arrSplit.forEach(function(item){ var _OBJ = {tag:item}; _ARRAY.push(_OBJ) }); return _ARRAY }, setSearchKeyArray: function(arr){//回显处理商品搜索关键词 var _this = this; var arrSplit = arr.split(','); return _this.searchKeyList.map(function(el,index){ el.value = arrSplit[index] || ''; }) }, gernerateTitleId: function(index){ return "title_" +index }, dragstart: function(value) { // 记录初始信息 this.oldNum = value; }, dragend: function(value) { // 做最终操作 if (this.oldNum != this.newNum) { var oldIndex = this.GoodsImagesList.indexOf(this.oldNum); var newIndex = this.GoodsImagesList.indexOf(this.newNum); var newItems = this.GoodsImagesList; // 删除老的节点 newItems.splice(oldIndex, 1); // 在列表中目标位置增加新的节点 newItems.splice(newIndex, 0, this.oldNum); // this.items一改变,transition-group就起了作用 this.GoodsImagesList = newItems; } }, dragenter: function(value) {//记录移动过程中信息 this.newNum = value; }, }, created: function () { // 获取初始一级分类菜单 this.GetFistClassFn(this.releaseParams.commodityType); }, mounted: function () { var _this = this; // var NODE_ENV_BASE_URL = $('#spiServer').val(); var NODE_ENV_BASE_URL = 'https://spi-b.caimei365.com'; _this.NODE_ENV_BASE_URL = NODE_ENV_BASE_URL; if(globalUserData){ _this.releaseParams.shopId = globalUserData.shopId; _this.releaseParams.userId = globalUserData.userId; _this.releaseType = CAIMEI.getUrlParam('type'); if( _this.releaseType == 'edit'){ _this.productId = Number(CAIMEI.getUrlParam('productId')); _this.GetEditReleaseProductInfo(_this.productId); } } } });