Commit a1dd8442 authored by XieZhiXiong's avatar XieZhiXiong

fix: 编辑添加图片修改、完善图片展示相关

parent 807a81e5
......@@ -111,10 +111,10 @@ const normalizeFileList = fileList => {
status: file.status,
name: file.name,
url: file.downloadURL || file.imgURL || file.url,
...file.response,
...file.response.data,
thumbUrl: file.imgURL || getImageByUrl(file.downloadURL || file.url, {
exclude: ['.png', '.jpg', '.jpeg', '.gif']
})
}),
} : file;
})
}
......@@ -242,6 +242,8 @@ export const Upload = connect({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { listType, locale, onChange, value, ...others } = this.props
console.log('this.state.value', this.state.value)
if (listType.indexOf('card') > -1) {
return (
<AntdUpload
......@@ -251,7 +253,9 @@ export const Upload = connect({
onRemove={this.onRemoveHandler}
listType={'picture-card'}
>
<UploadPlaceholder />
{!others.readOnly ? (
<UploadPlaceholder />
) : null}
</AntdUpload>
)
}
......
......@@ -18,7 +18,9 @@ export const useBusinessEffects = (context, actions) => {
return `comments.${$1}.picture`
}),
state => {
state.props['x-component-props'].disabled = value.length >= 4;
// 禁用掉 或者 editable 设置成 false,删除按钮也会禁用掉的
// 所以目前先用过 rules 去限制最多可上传多少张
// state.props['x-component-props'].disabled = value.length >= 4;
}
);
});
......
......@@ -117,6 +117,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
id,
star,
comment,
pics: picture.map(item => item.status === 'done' && item.data.url).filter(Boolean),
};
});
......@@ -130,9 +131,11 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
setTimeout(() => {
history.goBack();
}, 800);
} else {
setSubmitLoading(false);
}
})
.finally(() => {
.catch(() => {
setSubmitLoading(false);
});
};
......@@ -228,17 +231,6 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
}}
effects={($, actions) => {
createEffects($, actions);
onFormInit$().subscribe(() => {
if (isEdit) {
actions.setFieldState(
'comments.*.picture',
state => {
state.visible = false;
}
);
}
});
}}
schema={evaluateSchema}
/>
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-09-23 17:00:24
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-10-19 16:23:24
* @LastEditTime: 2021-01-07 15:04:44
* @Description:
*/
import { ISchema } from '@formily/antd';
......@@ -76,6 +76,12 @@ export const evaluateSchema: ISchema = {
beforeUpload: '{{beforeUpload}}',
accept: '.png, .jpg, .jpeg',
},
'x-rules': [
{
len: 4,
message: '最多可上传4张图片',
},
],
'x-mega-props': {
addonAfter: '{{UploadTip}}',
},
......
......@@ -116,8 +116,10 @@ const EvaluateOrder: React.FC = () => {
setTimeout(() => {
history.goBack();
}, 800);
} else {
setSubmitLoading(false);
}
}).finally(() => {
}).catch(() => {
setSubmitLoading(false);
});
};
......
......@@ -18,7 +18,9 @@ export const useBusinessEffects = (context, actions) => {
return `comments.${$1}.picture`
}),
state => {
state.props['x-component-props'].disabled = value.length >= 4;
// 禁用掉 或者 editable 设置成 false,删除按钮也会禁用掉的
// 所以目前先用过 rules 去限制最多可上传多少张
// state.props['x-component-props'].disabled = value.length >= 4;
}
);
});
......
......@@ -116,6 +116,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
id,
star,
comment,
pics: picture.map(item => item.status === 'done' && item.data.url).filter(Boolean),
};
});
......@@ -129,9 +130,11 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
setTimeout(() => {
history.goBack();
}, 800);
} else {
setSubmitLoading(false);
}
})
.finally(() => {
.catch(() => {
setSubmitLoading(false);
});
};
......@@ -229,17 +232,6 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
}}
effects={($, actions) => {
createEffects($, actions);
onFormInit$().subscribe(() => {
if (isEdit) {
actions.setFieldState(
'comments.*.picture',
state => {
state.visible = false;
}
);
}
});
}}
schema={evaluateSchema}
/>
......
......@@ -76,6 +76,12 @@ export const evaluateSchema: ISchema = {
beforeUpload: '{{beforeUpload}}',
accept: '.png, .jpg, .jpeg',
},
'x-rules': [
{
len: 4,
message: '最多可上传4张图片',
},
],
'x-mega-props': {
addonAfter: '{{UploadTip}}',
},
......
......@@ -116,8 +116,10 @@ const EvaluateOrder: React.FC = () => {
setTimeout(() => {
history.goBack();
}, 800);
} else {
setSubmitLoading(false);
}
}).finally(() => {
}).catch(() => {
setSubmitLoading(false);
});
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment