更新商品图片关联
This commit is contained in:
parent
571342e252
commit
df27477349
|
@ -389,7 +389,7 @@ export default class adduserinfo extends React.Component{
|
|||
<ImageUpload
|
||||
className="zent-image-upload-demo"
|
||||
maxSize={5 * 1024 * 1024}
|
||||
tips="建议尺寸 30*30,图片不超过 500kb"
|
||||
tips="建议尺寸 30*30,图片不超过 20KB"
|
||||
maxAmount={1}
|
||||
onChange={(e)=>{this.onUploadChange(e)}}
|
||||
onUpload={this.onUpload}
|
||||
|
@ -404,7 +404,7 @@ export default class adduserinfo extends React.Component{
|
|||
<ImageUpload
|
||||
className="zent-image-upload-demo"
|
||||
maxSize={5 * 1024 * 1024}
|
||||
tips="建议尺寸 30*30,图片不超过 500kb"
|
||||
tips="建议尺寸 30*30,图片不超过 20KB"
|
||||
maxAmount={1}
|
||||
onChange={(e)=>{this.onUploadChange1(e)}}
|
||||
onUpload={this.onUpload}
|
||||
|
|
|
@ -119,6 +119,7 @@ export default class adduserinfo extends React.Component{
|
|||
onProductChange(e){
|
||||
this.setState({cur_product:e})
|
||||
let cur_product = this.state.products.find((item)=>{return item.id == e.key})
|
||||
let picItem = window.goods.find((item)=>{return item.id == cur_product.product_category_id})
|
||||
|
||||
let model2 = {
|
||||
product_id:cur_product.id,
|
||||
|
@ -128,11 +129,15 @@ export default class adduserinfo extends React.Component{
|
|||
cost_price:cur_product.cost_price,
|
||||
quantity:this.state.model.quantity,
|
||||
product_name:this.state.model.product_name,
|
||||
show_url:this.state.show_url ? this.state.show_url : "",
|
||||
describe_url:this.state.describe_url ? this.state.describe_url : "",
|
||||
show_url:picItem ? picItem.pic : "",
|
||||
describe_url:picItem ? picItem.pic : "",
|
||||
account_type:cur_product.account_type
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.setState({model:model2})
|
||||
}
|
||||
onTypeChange(e){
|
||||
|
@ -148,75 +153,110 @@ export default class adduserinfo extends React.Component{
|
|||
|
||||
|
||||
onUpload = (file, report) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let path = ""
|
||||
let formdata= new FormData();
|
||||
formdata.append("file",file)
|
||||
formdata.append("path","common_image")
|
||||
uploadImg(formdata).then((res)=>{
|
||||
handelResponse(res,(req,msg)=>{
|
||||
path = req.path;
|
||||
|
||||
|
||||
// return new Promise((resolve, reject) => {
|
||||
// let path = ""
|
||||
// let formdata= new FormData();
|
||||
// formdata.append("file",file)
|
||||
// formdata.append("path","common_image")
|
||||
// uploadImg(formdata).then((res)=>{
|
||||
// handelResponse(res,(req,msg)=>{
|
||||
// path = req.path;
|
||||
|
||||
},(err)=>{
|
||||
reject();
|
||||
})
|
||||
});
|
||||
// },(err)=>{
|
||||
// reject();
|
||||
// })
|
||||
// });
|
||||
|
||||
let count = 0;
|
||||
const update = () => {
|
||||
if(path)
|
||||
{
|
||||
// let count = 0;
|
||||
// const update = () => {
|
||||
// if(path)
|
||||
// {
|
||||
|
||||
resolve(
|
||||
path
|
||||
);
|
||||
// resolve(
|
||||
// path
|
||||
// );
|
||||
|
||||
}
|
||||
else{
|
||||
// }
|
||||
// else{
|
||||
|
||||
if (count < 100) {
|
||||
count += 2;
|
||||
report(count);
|
||||
setTimeout(update, 500);
|
||||
console.log("上传中")
|
||||
}
|
||||
else{
|
||||
// if (count < 100) {
|
||||
// count += 2;
|
||||
// report(count);
|
||||
// setTimeout(update, 500);
|
||||
// console.log("上传中")
|
||||
// }
|
||||
// else{
|
||||
|
||||
reject();
|
||||
}
|
||||
}
|
||||
// reject();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
};
|
||||
setTimeout(update, 500);
|
||||
});
|
||||
// };
|
||||
// setTimeout(update, 500);
|
||||
// });
|
||||
|
||||
};
|
||||
onUploadChange(files){
|
||||
|
||||
if(files.length > 0 && files[0].status == "success")
|
||||
console.log(files)
|
||||
if(files.length > 0 )
|
||||
{
|
||||
if(files[0].file.size > 20000)
|
||||
{
|
||||
Notify.error(`图片大小不能超过 20KB`);
|
||||
return;
|
||||
}
|
||||
let formdata= new FormData();
|
||||
formdata.append("file",files[0].file)
|
||||
formdata.append("path","common_image")
|
||||
uploadImg(formdata).then((res)=>{
|
||||
handelResponse(res,(req,msg)=>{
|
||||
let path = req.path;
|
||||
let model = this.state.model;
|
||||
model.show_url = path;
|
||||
this.setState({model:model})
|
||||
},(err)=>{
|
||||
|
||||
})
|
||||
});
|
||||
}
|
||||
else{
|
||||
let model = this.state.model;
|
||||
model.show_url = files[0].src;
|
||||
model.show_url = "";
|
||||
this.setState({model:model})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
onUploadChange1(files){
|
||||
|
||||
if(files.length > 0 && files[0].status == "success")
|
||||
if(files.length > 0 )
|
||||
{
|
||||
if(files[0].file.size > 20000)
|
||||
{
|
||||
Notify.error(`图片大小不能超过 20KB`);
|
||||
return;
|
||||
}
|
||||
let formdata= new FormData();
|
||||
formdata.append("file",files[0].file)
|
||||
formdata.append("path","common_image")
|
||||
uploadImg(formdata).then((res)=>{
|
||||
handelResponse(res,(req,msg)=>{
|
||||
let path = req.path;
|
||||
let model = this.state.model;
|
||||
model.describe_url = files[0].src;
|
||||
model.describe_url = path;
|
||||
this.setState({model:model})
|
||||
},(err)=>{
|
||||
|
||||
})
|
||||
});
|
||||
}
|
||||
else{
|
||||
let model = this.state.model;
|
||||
model.describe_url = "";
|
||||
this.setState({model:model})
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
onUploadError = (type, data) => {
|
||||
if (type === 'overMaxAmount') {
|
||||
Notify.error(`最多可上传 ${data.maxAmount} 张图片`);
|
||||
|
@ -325,10 +365,10 @@ export default class adduserinfo extends React.Component{
|
|||
<ImageUpload
|
||||
className="zent-image-upload-demo"
|
||||
maxSize={5 * 1024 * 1024}
|
||||
tips="建议尺寸 30*30,图片不超过 500kb"
|
||||
tips="建议尺寸 30*30,图片不超过 20KB"
|
||||
maxAmount={1}
|
||||
onChange={(e)=>{this.onUploadChange(e)}}
|
||||
onUpload={this.onUpload}
|
||||
fileList={this.state.model.show_url ? [{'src':this.state.model.show_url}] : null}
|
||||
value={this.state.model.show_url}
|
||||
/>
|
||||
</FormItem>
|
||||
|
@ -336,10 +376,10 @@ export default class adduserinfo extends React.Component{
|
|||
<ImageUpload
|
||||
className="zent-image-upload-demo"
|
||||
maxSize={5 * 1024 * 1024}
|
||||
tips="建议尺寸 30*30,图片不超过 500kb"
|
||||
tips="建议尺寸 30*30,图片不超过 20KB"
|
||||
maxAmount={1}
|
||||
onChange={(e)=>{this.onUploadChange1(e)}}
|
||||
onUpload={this.onUpload}
|
||||
fileList={this.state.model.describe_url ? [{'src':this.state.model.describe_url}] : null}
|
||||
value={this.state.model.describe_url}
|
||||
/>
|
||||
</FormItem>
|
||||
|
|
|
@ -311,7 +311,7 @@ export default class adduserinfo extends React.Component{
|
|||
<ImageUpload
|
||||
className="zent-image-upload-demo"
|
||||
maxSize={5 * 1024 * 1024}
|
||||
tips="建议尺寸 30*30,图片不超过 500kb"
|
||||
tips="建议尺寸 30*30,图片不超过 20KB"
|
||||
maxAmount={1}
|
||||
onChange={(e)=>{this.onUploadChange(e)}}
|
||||
onUpload={this.onUpload}
|
||||
|
@ -321,8 +321,8 @@ export default class adduserinfo extends React.Component{
|
|||
<FormItem prop="describe_url" labelname="商品描述" id="describe_url" >
|
||||
<ImageUpload
|
||||
className="zent-image-upload-demo"
|
||||
maxSize={5 * 1024 * 1024}
|
||||
tips="建议尺寸 30*30,图片不超过 500kb"
|
||||
maxSize={5 * 1024* 1024}
|
||||
tips="建议尺寸 30*30,图片不超过 20KB"
|
||||
maxAmount={1}
|
||||
onChange={(e)=>{this.onUploadChange1(e)}}
|
||||
onUpload={this.onUpload}
|
||||
|
|
|
@ -151,9 +151,6 @@ export default class adduserinfo extends React.Component{
|
|||
// }
|
||||
|
||||
this.setState({model:model2})
|
||||
|
||||
console.log(model2)
|
||||
console.log(this.state.show_url)
|
||||
}
|
||||
onTypeChange(e){
|
||||
let model2 = this.state.model;
|
||||
|
@ -189,7 +186,11 @@ export default class adduserinfo extends React.Component{
|
|||
console.log(files)
|
||||
if(files.length > 0 )
|
||||
{
|
||||
|
||||
if(files[0].file.size > 20000)
|
||||
{
|
||||
Notify.error(`图片大小不能超过 20KB`);
|
||||
return;
|
||||
}
|
||||
let formdata= new FormData();
|
||||
formdata.append("file",files[0].file)
|
||||
formdata.append("path","common_image")
|
||||
|
@ -214,6 +215,11 @@ export default class adduserinfo extends React.Component{
|
|||
|
||||
if(files.length > 0 )
|
||||
{
|
||||
if(files[0].file.size > 20000)
|
||||
{
|
||||
Notify.error(`图片大小不能超过 20KB`);
|
||||
return;
|
||||
}
|
||||
let formdata= new FormData();
|
||||
formdata.append("file",files[0].file)
|
||||
formdata.append("path","common_image")
|
||||
|
@ -343,8 +349,8 @@ export default class adduserinfo extends React.Component{
|
|||
<FormItem id="show_url" prop="show_url" labelname="商品展示">
|
||||
<ImageUpload
|
||||
className="zent-image-upload-demo"
|
||||
maxSize={5 * 1024 * 1024}
|
||||
tips="建议尺寸 30*30,图片不超过 500kb"
|
||||
maxSize={5 * 1024 * 1024}
|
||||
tips="建议尺寸 30*30,图片不超过 20KB"
|
||||
maxAmount={1}
|
||||
onChange={(e)=>{this.onUploadChange(e)}}
|
||||
|
||||
|
@ -359,7 +365,7 @@ export default class adduserinfo extends React.Component{
|
|||
<ImageUpload
|
||||
className="zent-image-upload-demo"
|
||||
maxSize={5 * 1024 * 1024}
|
||||
tips="建议尺寸 30*30,图片不超过 500kb"
|
||||
tips="建议尺寸 30*30,图片不超过 20KB"
|
||||
maxAmount={1}
|
||||
onChange={(e)=>{this.onUploadChange1(e)}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue