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

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

Loading…
Cancel
Save