123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- var addlogistics = new Vue({
- el:'#qualifications',
- data:{
- open:false,
- pageType:'',
- shopOrderId:0,
- logisticsBatchId:0,
- selectGoods:false,
- productActions:[],
- qualificationsList:[
- {
- productName:'请选择商品',
- recordId:'',
- sn:'',
- fileList:[],
- imageList:[]
- }
- ]
- },
- methods:{
- GetSupplierQualificationData:function(logisticsBatchId){//编辑回显商品资质信息
- var _this = this;
- SupplierApi.GetSupplierQualificationData({logisticsBatchId:logisticsBatchId},function(response){
- if(response.code == 0 ){
- var data = response.data;
- if(data && data.length > 0) {
- _this.qualificationsList = data;
- _this.isEmpty = false
- }else{
- _this.isEmpty = true
- }
- }else{
- CAIMEI.Alert(response.msg, '确定', false);
- }
- })
- },
- GetSupplierLogisticsRecord:function(logisticsBatchId){//添加商品资质初始化查询商品信息
- var _this = this;
- SupplierApi.GetSupplierLogisticsRecord({ logisticsBatchId : logisticsBatchId },function(response){
- if(response.code == 0 ){
- var data = response.data;
- data.forEach(function(el,index){
- var obj = {
- id : el.id,
- productName : el.productName
- };
- _this.productActions.push(obj)
- });
- }else{
- CAIMEI.Alert(response.msg, '确定', false);
- }
- })
- },
- editButtonConfim:function(){//确定添加商品资质信息
- var _this = this;
- var params = [];
- var isRecordId = false;
- var isSnCode = false;
- var isFileList = false;
- var isImageList = false;
- _this.qualificationsList.forEach(function(el){
- if( el.recordId == '' ){ isRecordId = true }
- if( el.sn == '' ){ isSnCode = true }
- if( el.fileList == '' ){ isFileList = true }
- if( el.imageList == '' ){ isImageList = true }
- var obj = {
- recordId : el.recordId,
- sn : el.sn,
- files : el.fileList,
- images : el.imageList
- };
- params.push(obj)
- });
- if(isRecordId){
- CAIMEI.dialog('请选择商品');
- return
- }
- if(isSnCode){
- CAIMEI.dialog('请输入商品SN码');
- return
- }
- if(isFileList && isImageList){
- CAIMEI.dialog('请上传商品资质文件');
- return
- }
- console.log('params========>',params);
- SupplierApi.GetSupplierQualificationUpdata({ params:JSON.stringify(params) },function(response){
- if(response.code == 0 ){
- CAIMEI.dialog('保存资质成功');
- setTimeout(function(){
- window.location.href = '/supplier/order/delivery_record.html?shopOrderID='+_this.shopOrderId;
- },2000);
- }else{
- CAIMEI.Alert(response.msg, '确定', false);
- }
- })
- },
- hanldSnCodeChecked: function(e){//校验SN码格式错误
- if(!this.$reg.isNoChinese(e.detail.value)){
- this.$util.msg('SN码格式错误',2000);
- return
- }
- },
- showViewerImageFn: function(index,imageIndex ){//预览图片
- var _this = this;
- var DomEven = '#listViewImage'+index+''+imageIndex;
- var ViewerDom = document.querySelector(DomEven);
- _this.viewer = new Viewer(ViewerDom, {url:'data-image'});
- },
- showGoodSelect:function(){//显示选择商品下拉框
- var _this = this;
- _this.selectGoods = !_this.selectGoods;
- },
- changeGoodsFn:function(item,good){ //品牌列表
- var _this = this;
- item.recordId = good.id;
- item.productName = good.productName;
- },
- uploadImagesFn: function(index,array,event){//上传商品资质图片
- var _this = this;
- var inputDOM = _this.$refs['Qualificationsimage'+index];
- var file = inputDOM[0].files;
- var formData = new FormData();
- formData.append('file', file[0]);
- PublicApi.uploadimg(formData,function(response){
- array.push(response.data);
- event.target.value = '';
- });
- },
- uploadFileFn : function(index,array,event){//上传承诺函文件
- var _this = this;
- var inputDOM = _this.$refs['QualificationsFile'+index];
- var file = inputDOM[0].files[0];
- console.log('file========>',file);
- var formData = new FormData();
- var size = file.size;
- var newfilename = file.name;
- //截取
- var fixFile = newfilename.substr(newfilename.lastIndexOf('.'));
- console.log(fixFile);
- //统一转成小写
- var lowFixFile = fixFile.toLowerCase();
- if ( lowFixFile != '.pdf' && lowFixFile != '.doc' && lowFixFile != '.docx' ){ //限制了文件类型
- CAIMEI.dialog('文件格式不正确!');
- event.target.value = '';
- return;
- }
- if(size > 52428800){//限制了文件的大小20MB
- CAIMEI.dialog('文件大小不能超过50M');
- event.target.value = '';
- return;
- }
- formData.append('file', file);
- PublicApi.uploadFile(formData,function(response){
- var obj = {
- fileName:response.data.fileName,
- ossName:response.data.ossName
- };
- array.push(obj);
- console.log('array',array);
- event.target.value = '';
- });
- },
- removeGoodsImagesFn: function(index){//删除商品图片
- var _this = this;
- _this.GoodsImagesList.splice(index,1);
- _this.secondParams.image =_this.GoodsImagesList.toString()+',';
- },
- deleteImageFileFn: function(array,index){//删除图片
- array.splice(index, 1);
- },
- deleteFileFn:function(array,index){//删除商品资质文件
- var _this = this;
- PublicApi.deleteOssFile({ ossName : array[index].ossName },function (response) {
- if (response.code==0){
- array.splice(index, 1);
- }else{
- console.log('删除文件异常提示===>',response.msg)
- }
- })
- },
- addListFn : function(){//添加商品
- var _this = this;
- var obj ={
- productName:'',
- recordId:'',
- sn:'',
- fileList:[],
- imageList:[]
- };
- _this.qualificationsList.push(obj)
- },
- deleteLogistItemFn: function(item,index){
- var _this = this;
- CAIMEI.Modal('确认删除商品吗?','取消','确定',function () {
- _this.qualificationsList.splice(index, 1);
- });
- },
- editButtonCanel:function(){//暂不填写
- var _this = this;
- window.location.href = '/supplier/order/delivery_record.html?shopOrderID='+_this.shopOrderId;
- }
- },
- mounted:function () {
- var _self = this;
- _self.shopOrderId=CAIMEI.getUrlParam('shopOrderId');
- _self.logisticsBatchId = CAIMEI.getUrlParam('logisticsBatchId');
- _self.pageType = CAIMEI.getUrlParam('type');
- if( _self.pageType == 'edit'){
- _self.GetSupplierLogisticsRecord( _self.logisticsBatchId);
- _self.GetSupplierQualificationData( _self.logisticsBatchId);
- }else{
- _self.GetSupplierLogisticsRecord(_self.logisticsBatchId);
- }
- _self.open=true;
- }
- });
|