diff --git a/packages/select/src/select.tsx b/packages/select/src/select.tsx index 998483a9..4429f4d0 100644 --- a/packages/select/src/select.tsx +++ b/packages/select/src/select.tsx @@ -70,6 +70,7 @@ export default defineComponent({ scrollHeight: PropTypes.number.def(204), // 最大高度 minHeight: PropTypes.number, // 最小高度 showAll: PropTypes.bool.def(false), // 全部 + allOptionText: PropTypes.string.def(''), // 全部选项文本 allOptionId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), // 全部选项ID showSelectAll: PropTypes.bool.def(false), // 全选 popoverMinWidth: PropTypes.number.def(0), // popover最小宽度 @@ -165,6 +166,9 @@ export default defineComponent({ } = toRefs(props); const virtualRenderRef = ref(null); + const displayAllText = computed(() => { + return props.allOptionText; + }); const localNoDataText = computed(() => { if (props.noDataText === undefined) { return t.value.noData; @@ -850,6 +854,7 @@ export default defineComponent({ popoverConfig, isAllSelected, isAll, + displayAllText, focusInput, setHover, cancelHover, @@ -950,6 +955,14 @@ export default defineComponent({ ); }; + // 全部icon支持自定义 + const renderAllIcon = () => { + return this.$slots?.allOptionIcon?.() || ; + }; + // 全部选项文案支持自定义 + const renderAllText = () => { + return {this.displayAllText || this.t.all}; + }; // 全部 const renderAll = () => { if (!this.isShowAll) return; @@ -962,8 +975,8 @@ export default defineComponent({ ]} onClick={this.toggleAll} > - - {this.t.all} + {renderAllIcon()} + {renderAllText()} ); diff --git a/packages/upload/src/upload-list.tsx b/packages/upload/src/upload-list.tsx index 11033d78..7dd5973d 100644 --- a/packages/upload/src/upload-list.tsx +++ b/packages/upload/src/upload-list.tsx @@ -32,7 +32,7 @@ import Progress from '@bkui-vue/progress'; import { classes } from '@bkui-vue/shared'; import uploadProps from './props'; -import { CLASS_PREFIX, EThemes, UploadFile } from './upload.type'; +import { CLASS_PREFIX, EThemes, UploadFile, UploadFiles } from './upload.type'; export default defineComponent({ name: 'UploadList', @@ -70,8 +70,8 @@ export default defineComponent({ return `${size.toFixed(2)}${uints[index]}`; } - function handleReview(file: UploadFile, e: MouseEvent) { - emit('preview', file, e); + function handlePreview(file: UploadFile, files: UploadFiles, e: MouseEvent) { + emit('preview', file, files, e); } function handleRemove(file: UploadFile, e: MouseEvent) { @@ -128,7 +128,7 @@ export default defineComponent({ {isShowPreview.value && ( handleReview(file, e)} + onClick={e => handlePreview(file, props.files, e)} /> )} handleReview(file, e)} + onClick={e => handlePreview(file, e)} /> )} { + const handlePreview = async (file, fileList) => { if (!file.url) { file.url = await getBase64(file); } previewImage.value = file.url; - previewVisible.value = true; previewTitle.value = file.name || file.url.substring(file.url.lastIndexOf('/') + 1); + previewVisible.value = true; }; const getBase64 = file => { diff --git a/site/views/upload/index.tsx b/site/views/upload/index.tsx index 46d44295..42990cea 100644 --- a/site/views/upload/index.tsx +++ b/site/views/upload/index.tsx @@ -255,6 +255,13 @@ const uploadEvents: IPropsTableItem[] = [ desc: '文件上传成功后,点击删除文件触发的事件 ', optional: ['file(删除的哪个文件对象)', 'fileList(删除后的文件列表)'], }, + { + name: 'preview', + type: 'Function', + default: null, + desc: '文件上传成功后,点击预览文件触发的事件 ', + optional: ['file(预览的哪个文件对象)', 'fileList(预览的文件列表)'], + }, ]; const uploadSlots: IPropsTableItem[] = [