extrafile/upload removeitem后 过滤

This commit is contained in:
Wang Kejun 2023-10-12 10:28:43 +08:00
parent 761b11e1b3
commit 40bf1ed898
22 changed files with 91 additions and 74 deletions

View File

@ -6,7 +6,7 @@ export default function render(props) {
const disabled = oakExecuting || const disabled = oakExecuting ||
['uploading'].includes(state) || ['uploading'].includes(state) ||
(oakExecutable === false && ['uploaded'].includes(state)); (oakExecutable === false && ['uploaded'].includes(state));
let text = executeText || t('common::action.confirm'); let text = executeText || t('common:submit');
if (oakExecuting) { if (oakExecuting) {
text = t('executing', { text }); text = t('executing', { text });
} }

View File

@ -6,7 +6,7 @@ export default function render(props) {
const disabled = oakExecuting || const disabled = oakExecuting ||
['uploading'].includes(state) || ['uploading'].includes(state) ||
(oakExecutable !== true && ['uploaded'].includes(state)); (oakExecutable !== true && ['uploaded'].includes(state));
let text = executeText || t('common::action.confirm'); let text = executeText || t('common:submit');
if (oakExecuting) { if (oakExecuting) {
text = t('executing', { text }); text = t('executing', { text });
} }

View File

@ -10,9 +10,9 @@ export interface EnhancedExtraFile extends ExtraFile {
fileState?: FileState; fileState?: FileState;
percentage?: number; percentage?: number;
} }
type SourceType = 'album' | 'camera';
export type Theme = 'file' | 'image' | 'image-flow' | 'custom'; export type Theme = 'file' | 'image' | 'image-flow' | 'custom';
type ImgMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | "heightFix" | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right'; type SourceType = 'album' | 'camera';
type ImageMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, { declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
bucket: string; bucket: string;
removeLater: boolean; removeLater: boolean;
@ -22,7 +22,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
selectCount: number; selectCount: number;
sourceType: SourceType[]; sourceType: SourceType[];
mediaType: ('image' | 'video')[]; mediaType: ('image' | 'video')[];
mode: ImgMode; mode: ImageMode;
size: number; size: number;
showUploadList: boolean; showUploadList: boolean;
showUploadProgress: boolean; showUploadProgress: boolean;

View File

@ -97,7 +97,9 @@ export default OakComponent({
}, },
features: ['extraFile2'], features: ['extraFile2'],
formData({ data, features }) { formData({ data, features }) {
let files = data?.sort((ele1, ele2) => ele1.sort - ele2.sort); let files = data
?.filter((ele) => !ele.$$deleteAt$$)
.sort((ele1, ele2) => ele1.sort - ele2.sort);
if (this.props.tag1) { if (this.props.tag1) {
files = files?.filter((ele) => ele?.tag1 === this.props.tag1); files = files?.filter((ele) => ele?.tag1 === this.props.tag1);
} }

View File

@ -9,7 +9,6 @@ export default function render(props: WebComponentProps<EntityDict, 'extraFile',
multiple?: boolean; multiple?: boolean;
draggable?: boolean; draggable?: boolean;
theme?: Theme; theme?: Theme;
tips?: string;
beforeUpload?: (file: File) => Promise<boolean> | boolean; beforeUpload?: (file: File) => Promise<boolean> | boolean;
style?: Record<string, string>; style?: Record<string, string>;
className?: string; className?: string;

View File

@ -48,7 +48,7 @@ const DraggableUploadListItem = ({ originNode, moveRow, file, fileList, }) => {
return (_jsx("div", { ref: ref, className: `ant-upload-draggable-list-item ${isOver ? dropClassName : ""}`, style: { cursor: "move", height: "100%" }, children: originNode })); return (_jsx("div", { ref: ref, className: `ant-upload-draggable-list-item ${isOver ? dropClassName : ""}`, style: { cursor: "move", height: "100%" }, children: originNode }));
}; };
export default function render(props) { export default function render(props) {
const { accept = 'image/*', maxNumber = 20, multiple = maxNumber !== 1, draggable = false, theme = 'image', tips, beforeUpload, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files = [], disableInsert = false, disableDownload = false, disableDelete = false, disablePreview = false, } = props.data; const { accept = 'image/*', maxNumber = 20, multiple = maxNumber !== 1, draggable = false, theme = 'image', beforeUpload, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files = [], disableInsert = false, disableDownload = false, disableDelete = false, disablePreview = false, } = props.data;
const { t, updateItem, onRemove, addFileByWeb, checkSort } = props.methods; const { t, updateItem, onRemove, addFileByWeb, checkSort } = props.methods;
const listType = getListType(theme); const listType = getListType(theme);
const getUploadButton = () => { const getUploadButton = () => {
@ -146,27 +146,27 @@ export default function render(props) {
updateItem({ sort }, dragRow.id); updateItem({ sort }, dragRow.id);
} }
}, [files]); }, [files]);
return (_jsxs(Space, { direction: "vertical", className: Style['oak-upload'], style: { width: '100%' }, children: [_jsx(DndProvider, { backend: isPc ? HTML5Backend : TouchBackend, children: _jsx(Upload, { className: classNames(Style['oak-upload__upload'], className), style: style, directory: directory, showUploadList: showUploadList return (_jsx(Space, { direction: "vertical", className: Style['oak-upload'], style: { width: '100%' }, children: _jsx(DndProvider, { backend: isPc ? HTML5Backend : TouchBackend, children: _jsx(Upload, { className: classNames(Style['oak-upload__upload'], className), style: style, directory: directory, showUploadList: showUploadList
? { ? {
showPreviewIcon: !disablePreview, showPreviewIcon: !disablePreview,
showRemoveIcon: !disableDelete, showRemoveIcon: !disableDelete,
showDownloadIcon: !disableDownload, showDownloadIcon: !disableDownload,
}
: false, beforeUpload: async (file) => {
if (typeof beforeUpload === 'function') {
const result = await beforeUpload(file);
if (result) {
return false;
} }
: false, beforeUpload: async (file) => { }
if (typeof beforeUpload === 'function') { return false;
const result = await beforeUpload(file); }, multiple: multiple, accept: accept, listType: listType, fileList: transformToUploadFile(), onChange: ({ file, fileList, event }) => {
if (result) { if (file instanceof File) {
return false; addFileByWeb(file);
} }
} }, onRemove: onRemove, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => {
return false; return (_jsx(DraggableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow }));
}, multiple: multiple, accept: accept, listType: listType, fileList: transformToUploadFile(), onChange: ({ file, fileList, event }) => { }, children: !disableInsert && files.length < maxNumber
if (file instanceof File) { ? getUploadButton()
addFileByWeb(file); : null }) }) }));
}
}, onRemove: onRemove, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => {
return (_jsx(DraggableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow }));
}, children: !disableInsert && files.length < maxNumber
? getUploadButton()
: null }) }), tips && (_jsx("small", { className: Style['oak-upload__tips'], children: tips }))] }));
} }

View File

@ -394,6 +394,7 @@ const i18ns = [
"newAdd": "新增", "newAdd": "新增",
"add": "添加" "add": "添加"
}, },
"submit": "提交",
"reset": "重置", "reset": "重置",
"select": "查询", "select": "查询",
"expand": "展开", "expand": "展开",

View File

@ -16,6 +16,7 @@
"newAdd": "新增", "newAdd": "新增",
"add": "添加" "add": "添加"
}, },
"submit": "提交",
"reset": "重置", "reset": "重置",
"select": "查询", "select": "查询",
"expand": "展开", "expand": "展开",

View File

@ -8,7 +8,7 @@ function render(props) {
const disabled = oakExecuting || const disabled = oakExecuting ||
['uploading'].includes(state) || ['uploading'].includes(state) ||
(oakExecutable === false && ['uploaded'].includes(state)); (oakExecutable === false && ['uploaded'].includes(state));
let text = executeText || t('common::action.confirm'); let text = executeText || t('common:submit');
if (oakExecuting) { if (oakExecuting) {
text = t('executing', { text }); text = t('executing', { text });
} }

View File

@ -8,7 +8,7 @@ function render(props) {
const disabled = oakExecuting || const disabled = oakExecuting ||
['uploading'].includes(state) || ['uploading'].includes(state) ||
(oakExecutable !== true && ['uploaded'].includes(state)); (oakExecutable !== true && ['uploaded'].includes(state));
let text = executeText || t('common::action.confirm'); let text = executeText || t('common:submit');
if (oakExecuting) { if (oakExecuting) {
text = t('executing', { text }); text = t('executing', { text });
} }

View File

@ -10,9 +10,9 @@ export interface EnhancedExtraFile extends ExtraFile {
fileState?: FileState; fileState?: FileState;
percentage?: number; percentage?: number;
} }
type SourceType = 'album' | 'camera';
export type Theme = 'file' | 'image' | 'image-flow' | 'custom'; export type Theme = 'file' | 'image' | 'image-flow' | 'custom';
type ImgMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | "heightFix" | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right'; type SourceType = 'album' | 'camera';
type ImageMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, { declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
bucket: string; bucket: string;
removeLater: boolean; removeLater: boolean;
@ -22,7 +22,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
selectCount: number; selectCount: number;
sourceType: SourceType[]; sourceType: SourceType[];
mediaType: ('image' | 'video')[]; mediaType: ('image' | 'video')[];
mode: ImgMode; mode: ImageMode;
size: number; size: number;
showUploadList: boolean; showUploadList: boolean;
showUploadProgress: boolean; showUploadProgress: boolean;

View File

@ -99,7 +99,9 @@ exports.default = OakComponent({
}, },
features: ['extraFile2'], features: ['extraFile2'],
formData({ data, features }) { formData({ data, features }) {
let files = data?.sort((ele1, ele2) => ele1.sort - ele2.sort); let files = data
?.filter((ele) => !ele.$$deleteAt$$)
.sort((ele1, ele2) => ele1.sort - ele2.sort);
if (this.props.tag1) { if (this.props.tag1) {
files = files?.filter((ele) => ele?.tag1 === this.props.tag1); files = files?.filter((ele) => ele?.tag1 === this.props.tag1);
} }

View File

@ -9,7 +9,6 @@ export default function render(props: WebComponentProps<EntityDict, 'extraFile',
multiple?: boolean; multiple?: boolean;
draggable?: boolean; draggable?: boolean;
theme?: Theme; theme?: Theme;
tips?: string;
beforeUpload?: (file: File) => Promise<boolean> | boolean; beforeUpload?: (file: File) => Promise<boolean> | boolean;
style?: Record<string, string>; style?: Record<string, string>;
className?: string; className?: string;

View File

@ -51,7 +51,7 @@ const DraggableUploadListItem = ({ originNode, moveRow, file, fileList, }) => {
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: `ant-upload-draggable-list-item ${isOver ? dropClassName : ""}`, style: { cursor: "move", height: "100%" }, children: originNode })); return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: `ant-upload-draggable-list-item ${isOver ? dropClassName : ""}`, style: { cursor: "move", height: "100%" }, children: originNode }));
}; };
function render(props) { function render(props) {
const { accept = 'image/*', maxNumber = 20, multiple = maxNumber !== 1, draggable = false, theme = 'image', tips, beforeUpload, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files = [], disableInsert = false, disableDownload = false, disableDelete = false, disablePreview = false, } = props.data; const { accept = 'image/*', maxNumber = 20, multiple = maxNumber !== 1, draggable = false, theme = 'image', beforeUpload, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files = [], disableInsert = false, disableDownload = false, disableDelete = false, disablePreview = false, } = props.data;
const { t, updateItem, onRemove, addFileByWeb, checkSort } = props.methods; const { t, updateItem, onRemove, addFileByWeb, checkSort } = props.methods;
const listType = getListType(theme); const listType = getListType(theme);
const getUploadButton = () => { const getUploadButton = () => {
@ -149,28 +149,28 @@ function render(props) {
updateItem({ sort }, dragRow.id); updateItem({ sort }, dragRow.id);
} }
}, [files]); }, [files]);
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, { direction: "vertical", className: web_module_less_1.default['oak-upload'], style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(react_dnd_1.DndProvider, { backend: utils_1.isPc ? react_dnd_html5_backend_1.HTML5Backend : react_dnd_touch_backend_1.TouchBackend, children: (0, jsx_runtime_1.jsx)(antd_1.Upload, { className: (0, classnames_1.default)(web_module_less_1.default['oak-upload__upload'], className), style: style, directory: directory, showUploadList: showUploadList return ((0, jsx_runtime_1.jsx)(antd_1.Space, { direction: "vertical", className: web_module_less_1.default['oak-upload'], style: { width: '100%' }, children: (0, jsx_runtime_1.jsx)(react_dnd_1.DndProvider, { backend: utils_1.isPc ? react_dnd_html5_backend_1.HTML5Backend : react_dnd_touch_backend_1.TouchBackend, children: (0, jsx_runtime_1.jsx)(antd_1.Upload, { className: (0, classnames_1.default)(web_module_less_1.default['oak-upload__upload'], className), style: style, directory: directory, showUploadList: showUploadList
? { ? {
showPreviewIcon: !disablePreview, showPreviewIcon: !disablePreview,
showRemoveIcon: !disableDelete, showRemoveIcon: !disableDelete,
showDownloadIcon: !disableDownload, showDownloadIcon: !disableDownload,
}
: false, beforeUpload: async (file) => {
if (typeof beforeUpload === 'function') {
const result = await beforeUpload(file);
if (result) {
return false;
} }
: false, beforeUpload: async (file) => { }
if (typeof beforeUpload === 'function') { return false;
const result = await beforeUpload(file); }, multiple: multiple, accept: accept, listType: listType, fileList: transformToUploadFile(), onChange: ({ file, fileList, event }) => {
if (result) { if (file instanceof File) {
return false; addFileByWeb(file);
} }
} }, onRemove: onRemove, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => {
return false; return ((0, jsx_runtime_1.jsx)(DraggableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow }));
}, multiple: multiple, accept: accept, listType: listType, fileList: transformToUploadFile(), onChange: ({ file, fileList, event }) => { }, children: !disableInsert && files.length < maxNumber
if (file instanceof File) { ? getUploadButton()
addFileByWeb(file); : null }) }) }));
}
}, onRemove: onRemove, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => {
return ((0, jsx_runtime_1.jsx)(DraggableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow }));
}, children: !disableInsert && files.length < maxNumber
? getUploadButton()
: null }) }), tips && ((0, jsx_runtime_1.jsx)("small", { className: web_module_less_1.default['oak-upload__tips'], children: tips }))] }));
} }
exports.default = render; exports.default = render;

View File

@ -396,6 +396,7 @@ const i18ns = [
"newAdd": "新增", "newAdd": "新增",
"add": "添加" "add": "添加"
}, },
"submit": "提交",
"reset": "重置", "reset": "重置",
"select": "查询", "select": "查询",
"expand": "展开", "expand": "展开",

View File

@ -16,6 +16,7 @@
"newAdd": "新增", "newAdd": "新增",
"add": "添加" "add": "添加"
}, },
"submit": "提交",
"reset": "重置", "reset": "重置",
"select": "查询", "select": "查询",
"expand": "展开", "expand": "展开",

View File

@ -42,7 +42,7 @@ export default function render(
oakExecuting || oakExecuting ||
['uploading'].includes(state) || ['uploading'].includes(state) ||
(oakExecutable !== true && ['uploaded'].includes(state)); (oakExecutable !== true && ['uploaded'].includes(state));
let text = executeText || t('common::action.confirm'); let text = executeText || t('common:submit');
if (oakExecuting) { if (oakExecuting) {
text = t('executing', { text }); text = t('executing', { text });
} else if (oakExecutable === false) { } else if (oakExecutable === false) {

View File

@ -43,7 +43,7 @@ export default function render(
oakExecuting || oakExecuting ||
['uploading'].includes(state) || ['uploading'].includes(state) ||
(oakExecutable === false && ['uploaded'].includes(state)); (oakExecutable === false && ['uploaded'].includes(state));
let text = executeText || t('common::action.confirm'); let text = executeText || t('common:submit');
if (oakExecuting) { if (oakExecuting) {
text = t('executing', { text }); text = t('executing', { text });
} else if (oakExecutable === false) { } else if (oakExecutable === false) {

View File

@ -14,11 +14,24 @@ export interface EnhancedExtraFile extends ExtraFile {
fileState?: FileState; fileState?: FileState;
percentage?: number; percentage?: number;
}; };
export type Theme = 'file' | 'image' | 'image-flow' | 'custom';
type SourceType = 'album' | 'camera'; type SourceType = 'album' | 'camera';
export type Theme = 'file' | 'image' | 'image-flow' | 'custom'; type ImageMode =
type ImgMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | "heightFix" | 'top' | 'bottom' | 'left' | 'scaleToFill'
| 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right'; | 'aspectFit'
| 'aspectFill'
| 'widthFix'
| 'heightFix'
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'center'
| 'top left'
| 'top right'
| 'bottom left'
| 'bottom right';
export default OakComponent({ export default OakComponent({
entity: 'extraFile', entity: 'extraFile',
@ -72,7 +85,7 @@ export default OakComponent({
selectCount: 1, // 每次打开图片时,可选中的数量 小程序独有 selectCount: 1, // 每次打开图片时,可选中的数量 小程序独有
sourceType: ['album', 'camera'] as SourceType[], // 小程序独有 chooseMedia sourceType: ['album', 'camera'] as SourceType[], // 小程序独有 chooseMedia
mediaType: ['image'] as ('image' | 'video')[], // 小程序独有 chooseMedia mediaType: ['image'] as ('image' | 'video')[], // 小程序独有 chooseMedia
mode: 'aspectFit' as ImgMode, // 图片显示模式 mode: 'aspectFit' as ImageMode, // 图片显示模式
size: 3, // 每行可显示的个数 小程序独有 size: 3, // 每行可显示的个数 小程序独有
showUploadList: true, //web独有 showUploadList: true, //web独有
showUploadProgress: false, // web独有 showUploadProgress: false, // web独有
@ -123,7 +136,9 @@ export default OakComponent({
}, },
features: ['extraFile2'], features: ['extraFile2'],
formData({ data, features }) { formData({ data, features }) {
let files = data?.sort((ele1, ele2) => ele1.sort! - ele2.sort!); let files = data
?.filter((ele) => !ele.$$deleteAt$$)
.sort((ele1, ele2) => ele1.sort! - ele2.sort!);
if (this.props.tag1) { if (this.props.tag1) {
files = files?.filter((ele) => ele?.tag1 === this.props.tag1); files = files?.filter((ele) => ele?.tag1 === this.props.tag1);
} }
@ -363,7 +378,7 @@ export default OakComponent({
sourceType: SourceType[]; sourceType: SourceType[];
mediaType: ('image' | 'video')[]; mediaType: ('image' | 'video')[];
// 图片显示模式 // 图片显示模式
mode: ImgMode; mode: ImageMode;
// 每行可显示的个数 // 每行可显示的个数
size: number; size: number;
showUploadList: boolean; showUploadList: boolean;

View File

@ -80,7 +80,6 @@ export default function render(
multiple?: boolean; multiple?: boolean;
draggable?: boolean; draggable?: boolean;
theme?: Theme; theme?: Theme;
tips?: string;
beforeUpload?: (file: File) => Promise<boolean> | boolean; beforeUpload?: (file: File) => Promise<boolean> | boolean;
style?: Record<string, string>; style?: Record<string, string>;
className?: string; className?: string;
@ -107,7 +106,6 @@ export default function render(
multiple = maxNumber !== 1, multiple = maxNumber !== 1,
draggable = false, draggable = false,
theme = 'image', theme = 'image',
tips,
beforeUpload, beforeUpload,
style, style,
className, className,
@ -287,10 +285,6 @@ export default function render(
: null} : null}
</Upload> </Upload>
</DndProvider> </DndProvider>
{tips && (
<small className={Style['oak-upload__tips']}>{tips}</small>
)}
</Space> </Space>
); );
} }

View File

@ -396,6 +396,7 @@ const i18ns: I18n[] = [
"newAdd": "新增", "newAdd": "新增",
"add": "添加" "add": "添加"
}, },
"submit": "提交",
"reset": "重置", "reset": "重置",
"select": "查询", "select": "查询",
"expand": "展开", "expand": "展开",

View File

@ -16,6 +16,7 @@
"newAdd": "新增", "newAdd": "新增",
"add": "添加" "add": "添加"
}, },
"submit": "提交",
"reset": "重置", "reset": "重置",
"select": "查询", "select": "查询",
"expand": "展开", "expand": "展开",