From b93137dc9ede2895af9f64e95e301fb075641541 Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Fri, 5 Jun 2020 22:01:44 +0800 Subject: [PATCH] update apolloTable upload --- .../apolloTable/component/base/detail/link/index.tsx | 7 ++++++- .../apolloTable/component/base/edit/upload/index.tsx | 3 +++ .../apolloTable/component/base/extra/upload/index.tsx | 5 ++++- .../apolloTable/component/filter-condition/index.tsx | 10 ++++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/components/apolloTable/component/base/detail/link/index.tsx b/components/apolloTable/component/base/detail/link/index.tsx index 68e4906..944c2dd 100644 --- a/components/apolloTable/component/base/detail/link/index.tsx +++ b/components/apolloTable/component/base/detail/link/index.tsx @@ -11,7 +11,12 @@ export const ApolloLinkDetail = (props: LinkProps) => { {value.map((item, i) => { return (
- + {item.text || item.value}
diff --git a/components/apolloTable/component/base/edit/upload/index.tsx b/components/apolloTable/component/base/edit/upload/index.tsx index 920dd20..a63911d 100644 --- a/components/apolloTable/component/base/edit/upload/index.tsx +++ b/components/apolloTable/component/base/edit/upload/index.tsx @@ -11,6 +11,9 @@ export const ApolloUpload = (props: ApolloUploadProps) => { const selfProps = antiAssign(props, ['onChange', 'value']); if (isMultiple) { selfProps.multiple = true; + } else { + selfProps.multiple = false; + selfProps.maxLength = 1; } const [value, setValue] = useState(props.value || []); const changeValue = (value) => { diff --git a/components/apolloTable/component/base/extra/upload/index.tsx b/components/apolloTable/component/base/extra/upload/index.tsx index 31b9fde..1b2d59a 100644 --- a/components/apolloTable/component/base/extra/upload/index.tsx +++ b/components/apolloTable/component/base/extra/upload/index.tsx @@ -12,7 +12,7 @@ message.config({ }); const UploadCom = (props) => { - const { onChange, CDN_HOST, getFormat, setFormat, data, domain } = props; + const { onChange, CDN_HOST, getFormat, setFormat, data, domain, maxLength } = props; const selfProps = antiAssign(props, ['onChange', 'CDN_HOST', 'data']); const getFormatFileList = (fileList = []) => { if (!fileList) { @@ -88,6 +88,9 @@ const UploadCom = (props) => { const changeFileList = ({ file, fileList }) => { let newList = fileList; + if (maxLength) { + newList = fileList.slice(-maxLength); + } if (file.status === 'done' && file.response) { const itemObj = setFormatFile(file); newList = fileList.map((item) => { diff --git a/components/apolloTable/component/filter-condition/index.tsx b/components/apolloTable/component/filter-condition/index.tsx index 5720fa8..c75b2e1 100644 --- a/components/apolloTable/component/filter-condition/index.tsx +++ b/components/apolloTable/component/filter-condition/index.tsx @@ -18,18 +18,24 @@ const formatTags = (columns: ColumnProps[], tags: any[]) => { return item.columnName === tag.colName; }); if (!colConfig) return; - const { componentAttr } = config[colConfig.columnType]; const { operator = [], columnType } = colConfig; + const { componentAttr, getFormatter } = config[columnType]; const newProps = { ...(componentAttr || {}), ...(colConfig.columnAttrObj || {}), }; const transferColumn = transferAttr(columnType, newProps); - const value = tag.colValues + let value = tag.colValues .map((item: any) => { return item.text; }) .join(','); + if (Number(columnType) === 11 && getFormatter) { + value = getFormatter(tag.colValues, transferColumn); + if (value.format) { + value = value.format(transferColumn.format); + } + } const op = operator.find((item: any) => { return item.id === tag.operationCode; -- 2.21.0