Commit 91e004e21148c38e572cfbb6b75f0a6f353c15b6

Authored by vben
1 parent 22088e82

fix(upload): fix maxNumber not work #240

CHANGELOG.zh_CN.md
... ... @@ -3,6 +3,7 @@
3 3 ### 🐛 Bug Fixes
4 4  
5 5 - 修复菜单在 hmr 时数据被置空
  6 +- 修复 Upload 组件 maxNumber 失效问题
6 7  
7 8 ## 2.0.0-rc.18 (2021-02-05)
8 9  
... ...
build/config/themeConfig.ts
1 1 import { generate } from '@ant-design/colors';
  2 +
2 3 export const primaryColor = '#0084f4';
3 4  
4 5 export const themeMode = 'light';
... ...
src/components/Upload/src/BasicUpload.vue
... ... @@ -20,7 +20,12 @@
20 20 </Tooltip>
21 21 </a-button-group>
22 22  
23   - <UploadModal v-bind="bindValue" @register="registerUploadModal" @change="handleChange" />
  23 + <UploadModal
  24 + v-bind="bindValue"
  25 + :previewFileList="fileListRef"
  26 + @register="registerUploadModal"
  27 + @change="handleChange"
  28 + />
24 29  
25 30 <UploadPreviewModal
26 31 :value="fileListRef"
... ...
src/components/Upload/src/UploadModal.vue
... ... @@ -42,7 +42,7 @@
42 42 </BasicModal>
43 43 </template>
44 44 <script lang="ts">
45   - import { defineComponent, reactive, ref, toRefs, unref, computed } from 'vue';
  45 + import { defineComponent, reactive, ref, toRefs, unref, computed, PropType } from 'vue';
46 46 import { Upload, Alert } from 'ant-design-vue';
47 47 import { BasicModal, useModalInner } from '/@/components/Modal';
48 48 // import { BasicTable, useTable } from '/@/components/Table';
... ... @@ -63,7 +63,13 @@
63 63 import { useI18n } from '/@/hooks/web/useI18n';
64 64 export default defineComponent({
65 65 components: { BasicModal, Upload, Alert, FileList },
66   - props: basicProps,
  66 + props: {
  67 + ...basicProps,
  68 + previewFileList: {
  69 + type: Array as PropType<string[]>,
  70 + default: () => [],
  71 + },
  72 + },
67 73 emits: ['change', 'register'],
68 74 setup(props, { emit }) {
69 75 const { t } = useI18n();
... ... @@ -206,7 +212,7 @@
206 212 // 点击开始上传
207 213 async function handleStartUpload() {
208 214 const { maxNumber } = props;
209   - if (fileListRef.value.length > maxNumber) {
  215 + if ((fileListRef.value.length + props.previewFileList?.length ?? 0) > maxNumber) {
210 216 return createMessage.warning(t('component.upload.maxNumber', [maxNumber]));
211 217 }
212 218 try {
... ...
src/components/Upload/src/data.tsx
... ... @@ -156,7 +156,7 @@ export function createPreviewActionColumn({
156 156 // onClick: handlePreview.bind(null, record),
157 157 // });
158 158 // }
159   - return <TableAction actions={actions} />;
  159 + return <TableAction actions={actions} outside={true} />;
160 160 },
161 161 };
162 162 }
... ...