master
fanfan 6 months ago
parent 86c5d11a8a
commit 60dea96dc9
  1. 21
      src/views/goods/Create.vue

@ -38,7 +38,7 @@
</div>
</a-form-item>
<a-form-item label="商品图片" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸:750*750像素, 最多上传10张, 可拖拽图片调整顺序, 第1张将作为商品首图">
<SelectImage :defaultList="goods_images" :source='1' multiple :maxNum="10" v-decorator="['imagesIds', { rules: [{ required: true, message: '请至少上传1张商品图片' }] }]" />
<SelectImage ref="childComponent" :source='1' multiple :maxNum="10" v-decorator="['imagesIds', { rules: [{ required: true, message: '请至少上传1张商品图片' }] }]" />
</a-form-item>
<a-form-item label="商品来源" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-radio-group v-decorator="['goods_source', { initialValue: 'JD', rules: [{ required: true }] }]">
@ -408,7 +408,6 @@ export default {
],
//
citysCount: null,
goods_images: []
}
},
//
@ -420,16 +419,28 @@ export default {
})
},
methods: {
generateRandomDigits(length) {
let result = '';
for (let i = 0; i < length; i++) {
result += Math.floor(Math.random() * 10); // 0-9
}
return result;
},
handInfo() {
const { form } = this
const goods_no = form.getFieldValue('goods_no')
if(goods_no){
if (goods_no) {
let param = {
sku: goods_no
}
this.isLoading = true
GoodsApi.getCollector(param).then((result) => {
this.goods_images = result.data.goods_images
if (result.data.goods_images.length > 0) {
result.data.goods_images.forEach(item => {
item.id = Number(this.generateRandomDigits(7))
});
}
this.$refs.childComponent.selectedItems= result.data.goods_images
let obj = {
goods_name: result.data.name,
content: result.data.content,
@ -442,7 +453,7 @@ export default {
this.isLoading = false
})
.finally(() => (this.isLoading = false))
}else{
} else {
this.$message.warning('请输入商品SKU', 1.5)
}
},

Loading…
Cancel
Save