图片选择器增加裁剪配置

This commit is contained in:
zhangxulong 2022-08-09 14:13:49 +08:00
parent e389050762
commit 2eba390dad
2 changed files with 20 additions and 3 deletions

View File

@ -386,6 +386,8 @@ app.listen(8080, function () {});
| fixedSize | `boolean` | | 是否开启固定尺寸,若开启,需同时设置 fixedSizeClassName |
| fixedSizeClassName | `string` | | 开启固定尺寸时,根据此值控制展示尺寸。例如`h-30`,即图片框高为 h-30,AMIS 将自动缩放比率设置默认图所占位置的宽度,最终上传图片根据此尺寸对应缩放。 |
| initAutoFill | `boolean` | `false` | 表单反显时是否执行 autoFill |
| dropCrop | `boolean` | `true` | 图片上传后是否进入裁剪模式 |
| initCrop | `boolean` | `false` | 图片选择器初始化后是否立即进入裁剪模式 |
### Limit 属性表

View File

@ -242,6 +242,16 @@ export interface ImageControlSchema extends FormBaseControlSchema {
*/
initAutoFill?: boolean;
/**
*
*/
initCrop?: boolean;
/**
*
*/
dropCrop?: boolean;
/**
*
*/
@ -327,7 +337,8 @@ export default class ImageControl extends React.Component<
extractValue: false,
delimiter: ',',
autoUpload: true,
multiple: false
multiple: false,
dropCrop: true
};
static formatFileSize(
@ -454,6 +465,10 @@ export default class ImageControl extends React.Component<
? this.syncAutoFill()
: addHook(this.syncAutoFill, 'init');
}
if (this.props.initCrop && this.files.length){
this.editImage(0);
}
}
componentDidUpdate(prevProps: ImageProps) {
@ -873,9 +888,9 @@ export default class ImageControl extends React.Component<
}
handleDrop(files: Array<FileX>) {
const {multiple, crop} = this.props;
const {multiple, crop, dropCrop} = this.props;
if (crop && !multiple) {
if (crop && !multiple && dropCrop) {
const file = files[0] as any;
if (!file.preview || !file.url) {
file.preview = window.URL.createObjectURL(file);