|
|
|
@ -96,16 +96,11 @@
|
|
|
|
|
<view class="sku img-sku acea-row row-middle row-between"> |
|
|
|
|
<text>库存<text class="colR">*</text></text> |
|
|
|
|
<input type="number" v-model="attrs[0].stock" @input="changeStock" placeholder="请输入库存" /> |
|
|
|
|
<!-- <view class="acea-row row-middle"> |
|
|
|
|
<switch :checked="!infinite" @change="stockChange" style="transform: scale(0.8);" /> |
|
|
|
|
<view>{{infinite ? '不限' : '有限'}}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="colB">批量设置</view> --> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<!-- 批量操作 --> |
|
|
|
|
<view class="batch-set-box" v-if="batchData.titleStr"> |
|
|
|
|
<view class="batch-set-box" v-if="batchData.titleStr != ''"> |
|
|
|
|
<view class="box-top acea-row row-between-wrapper"> |
|
|
|
|
<view class="name">{{batchData.titleStr}}</view> |
|
|
|
|
<view class="attr-name w15">库存</view> |
|
|
|
@ -136,7 +131,7 @@
|
|
|
|
|
<radio :value="0" :checked="state == 0" /><text>上架</text> |
|
|
|
|
</label> |
|
|
|
|
<label> |
|
|
|
|
<radio :value="1" :checked="state == 1" /><text>下架</text> |
|
|
|
|
<radio :value="1" :checked="state == 1" /><text>不上架</text> |
|
|
|
|
</label> |
|
|
|
|
</radio-group> |
|
|
|
|
</view> |
|
|
|
@ -200,9 +195,9 @@
|
|
|
|
|
maskShow: false, |
|
|
|
|
addOptionsDialog: false, |
|
|
|
|
infinite: false, |
|
|
|
|
batchData: {}, |
|
|
|
|
batchData: {titleStr: '',priceArr: []}, |
|
|
|
|
editattr: false, |
|
|
|
|
priceArr: [], |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onLoad() { |
|
|
|
@ -332,10 +327,15 @@
|
|
|
|
|
getFormatAttr(data).then((res)=>{ |
|
|
|
|
if(res.success){ |
|
|
|
|
this.$set(this.batchData,'priceArr',res.data.value) |
|
|
|
|
let strArr = res.data.attr.map(item=>{ |
|
|
|
|
return item.value |
|
|
|
|
}) |
|
|
|
|
this.$set(this.batchData,'titleStr',strArr.join('/')) |
|
|
|
|
if(res.data.attr){ |
|
|
|
|
let strArr = res.data.attr.map(item=>{ |
|
|
|
|
return item.value |
|
|
|
|
}) |
|
|
|
|
this.$set(this.batchData,'titleStr',strArr.join('/')) |
|
|
|
|
} else{ |
|
|
|
|
this.$set(this.batchData,'titleStr','') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else{ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: res.msg, |
|
|
|
@ -344,32 +344,6 @@
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
//属性设置数据 |
|
|
|
|
setBatchData(arr){ |
|
|
|
|
var titleArr = [] |
|
|
|
|
for (var i in arr) { |
|
|
|
|
titleArr.push(arr[i].value) |
|
|
|
|
} |
|
|
|
|
var titleStr = titleArr.join('/') |
|
|
|
|
var attrArr = this.setData(arr) |
|
|
|
|
var branchList = [] |
|
|
|
|
var hash = {} |
|
|
|
|
attrArr.forEach((item,idx)=>{ |
|
|
|
|
branchList.push({ |
|
|
|
|
sku: item.join('/'), |
|
|
|
|
pic: '', //"规格图片 --可选", |
|
|
|
|
price: '', //"价格 元", |
|
|
|
|
ot_orice: '', //"市场价格 --可选", |
|
|
|
|
stock: '', //"库存", |
|
|
|
|
weight: '', //"重量 --可选", |
|
|
|
|
volume: '', //"体积 --可选" |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
console.log(attrArr,'attrArr') |
|
|
|
|
this.priceArr = branchList |
|
|
|
|
this.batchData.attrArr = attrArr |
|
|
|
|
console.log(this.batchData) |
|
|
|
|
}, |
|
|
|
|
//数组整合 |
|
|
|
|
setData(attrArr){ |
|
|
|
|
var tmp = [] |
|
|
|
@ -393,45 +367,23 @@
|
|
|
|
|
// 批量设置价格库存 |
|
|
|
|
changePrice(e){ |
|
|
|
|
const price = e.detail.value |
|
|
|
|
this.batchData.priceArr.forEach((item,i)=>{ |
|
|
|
|
item.price = price |
|
|
|
|
}) |
|
|
|
|
if(this.batchData.priceArr && this.batchData.priceArr.length > 0){ |
|
|
|
|
this.batchData.priceArr.forEach((item,i)=>{ |
|
|
|
|
item.price = price |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.attrs[0].price = price |
|
|
|
|
// console.log(this.batchData.priceArr,'this.batchData.priceArr') |
|
|
|
|
}, |
|
|
|
|
changeStock(e){ |
|
|
|
|
const stock = e.detail.value |
|
|
|
|
this.batchData.priceArr.forEach((item,i)=>{ |
|
|
|
|
item.stock = stock |
|
|
|
|
}) |
|
|
|
|
if(this.batchData.priceArr && this.batchData.priceArr.length > 0){ |
|
|
|
|
this.batchData.priceArr.forEach((item,i)=>{ |
|
|
|
|
item.stock = stock |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.attrs[0].stock = stock |
|
|
|
|
}, |
|
|
|
|
//单规格 |
|
|
|
|
addSku(){ |
|
|
|
|
let item = { |
|
|
|
|
pic: '', //"规格图片 --可选", |
|
|
|
|
price: '', //"价格 元", |
|
|
|
|
ot_orice: '', //"市场价格 --可选", |
|
|
|
|
stock: '', //"库存", |
|
|
|
|
weight: '', //"重量 --可选", |
|
|
|
|
volume: '', //"体积 --可选" |
|
|
|
|
} |
|
|
|
|
this.attrs.push(item) |
|
|
|
|
uni.pageScrollTo({ |
|
|
|
|
scrollTop: 999999 |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
delSku(idx){ |
|
|
|
|
this.attrs.splice(idx,1) |
|
|
|
|
}, |
|
|
|
|
//库存有限无限切换 |
|
|
|
|
stockChange(e){ |
|
|
|
|
// console.log(e) |
|
|
|
|
this.infinite = !e.detail.value |
|
|
|
|
}, |
|
|
|
|
radioChange(e){ |
|
|
|
|
this.state = e.detail.value |
|
|
|
|
}, |
|
|
|
|
submit(){ |
|
|
|
|
// console.log(this.batchData) |
|
|
|
|
var arrtsArr = [] |
|
|
|
@ -446,7 +398,7 @@
|
|
|
|
|
image: this.slider_image[0], //主图 |
|
|
|
|
slider_image: this.slider_image , // 轮播图 |
|
|
|
|
description: this.description, //商品详情富文本 |
|
|
|
|
tempId: 1, //运费方案 |
|
|
|
|
tempId: this.tempId, //运费方案 |
|
|
|
|
attrs: arrtsArr, |
|
|
|
|
state: this.state, |
|
|
|
|
items: this.items, |
|
|
|
@ -484,9 +436,9 @@
|
|
|
|
|
duration: 1500 |
|
|
|
|
}) |
|
|
|
|
setTimeout((res)=>{ |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/pages/user/goodsManage/index' |
|
|
|
|
}) |
|
|
|
|
uni.redirectTo({ |
|
|
|
|
url: '/pages/user/goodsManage/index' |
|
|
|
|
}); |
|
|
|
|
},1500) |
|
|
|
|
} else{ |
|
|
|
|
uni.showToast({ |
|
|
|
@ -503,9 +455,9 @@
|
|
|
|
|
duration: 1500 |
|
|
|
|
}) |
|
|
|
|
setTimeout((res)=>{ |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/pages/user/goodsManage/index' |
|
|
|
|
}) |
|
|
|
|
uni.redirectTo({ |
|
|
|
|
url: '/pages/user/goodsManage/index' |
|
|
|
|
}); |
|
|
|
|
},1500) |
|
|
|
|
} else{ |
|
|
|
|
uni.showToast({ |
|
|
|
@ -515,8 +467,6 @@
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log(form,'form') |
|
|
|
|
}, |
|
|
|
|
alertMessage(msg){ |
|
|
|
|
uni.showToast({ |
|
|
|
|