; var logistics = new Vue({ el:'#logistics', data:{ userInfo:{}, orderList:[], GoodsImagesList:[], formData:new FormData(), txtVal: 0, desc:'', kdlist:[], logisticList:[ { value:'', name:'', numList:[ {number:''} ] } ], params:{ logistics:[],//物流 record:[], info:{ image:'', note:'',//备注 shopOrderId:'',//商品id }, }, select:'', electShow:false, }, methods:{ uploadGoodsImagesFn: function(event){//上传商品图片 var _this = this; var inputDOM = _this.$refs.goodsImages; var file = inputDOM.files; _this.formData.append('file', file[0]); SupplierApi.uploadimg(_this.formData,function(response){ _this.GoodsImagesList.push(response.data); _this.params.info.image =_this.GoodsImagesList.join('##').substring(); event.target.value = ''; }); }, removeGoodsImagesFn: function(index){//删除商品图片 var _this = this; _this.GoodsImagesList.splice(index,1); _this.params.info.image =_this.GoodsImagesList.join('##').substring(); }, selshow:function(event,index){ this.select = index; this.electShow = !this.electShow }, addBtn:function () { //添加物流 var _this = this; var obj = { value:'', name:'', numList:[ {number:''} ] }; _this.logisticList.push(obj); }, addNum:function(item,index){ var _this = this; var obj = {number:''}; item.numList.push(obj); }, subBtn:function (list) { var _this = this; _this.kdlist.splice(_this.kdlist.indexOf(list), 1); }, reduceBtn:function(item){ var _this = this; item.numList.splice(item.numList.indexOf(item.numList), 1); }, parameter:function(){//参数信息 var _this = this; var record=[]; $('.pro-information li').each(function(){//发货数 var productobj={}; productobj.orderProductId = $(this).attr('orderproductid'); productobj.num = $(this).find('.del-num').text(); record.push(productobj) }); _this.params.record=record _this.params.info.shopOrderId = $('.pro-information li').attr('shopOrderID'); _this.logisticList.forEach(function (pros) { var obj = {}; var Code = pros.value; var yName = pros.name; var numList = pros.numList; numList.forEach(function (item) { var logisNum = item.number; obj={ logisticsCompanyCode:Code, logisticsCompanyName:yName, number:logisNum }; if(obj.logisticsCompanyCode==""&&obj.logisticsCompanyName==""){ CAIMEI.Alert('请选择快递公司','确定') }else if(obj.number==""){ CAIMEI.Alert('请输入快递单号','确定') }else { _this.params.logistics.push(obj); } }) }) }, ChangeLogistics:function(event,item,index){ var donClass = '#logistics'+index; var domLogistics = document.querySelector(donClass); item.name = domLogistics.options[domLogistics.selectedIndex].text; item.value =event.target.value; }, turnBtn:function () {//提交发货 var _this = this; _this.parameter(); console.log(_this.params) var params = JSON.stringify(_this.params); SupplierApi.addLogistics({params:params},function (res) { if(res.code == 0) { setTimeout(function () { CAIMEI.dialog('发货成功') },1000) window.location.href = '/supplier/order/delivery_record.html?shopOrderID='+_this.params.info.shopOrderId; }else { } }) }, }, mounted:function () { var _self = this; SupplierApi.kdList(function (res) { if(res.code==0){ var data = res.data; data.forEach(function(item){ _self.kdlist.push(item); }); console.log(_self.kdlist.length); } }); _self.userInfo =JSON.parse(CAIMEI.Storage.getItem('userInfo_deliver')); _self.orderList = JSON.parse(CAIMEI.Storage.getItem('orderList')); } })