雪忆
2024-07-29 ecfe66a0199606241c73a52519bbe800c9aa31f8
src/components/Upload/src/props.ts
@@ -1,9 +1,11 @@
import type { PropType } from 'vue';
import { FileBasicColumn } from './types/typing';
import { BaseFileItem, FileBasicColumn } from './types/typing';
import type { Options } from 'sortablejs';
import { Merge } from '@/utils/types';
import { propTypes } from '@/utils/propTypes';
import { BasicColumn } from '@/components/Table';
type SortableOptions = Merge<
  Omit<Options, 'onEnd'>,
@@ -12,10 +14,29 @@
    // ...可扩展
  }
>;
export type handleFnKey = 'record' | 'valueKey' | 'uidKey';
export type previewColumnsFnType = {
  handleRemove: (record: Record<handleFnKey, any>) => any;
  handleAdd: (record: Record<handleFnKey, any>) => any;
};
export const previewType = {
  previewColumns: {
    type: [Array, Function] as PropType<
      BasicColumn[] | ((arg: previewColumnsFnType) => BasicColumn[])
    >,
    required: false,
  },
  beforePreviewData: {
    type: Function as PropType<(arg: BaseFileItem[] | any) => Recordable<any>>,
    default: null,
    required: false,
  },
};
type ListType = 'text' | 'picture' | 'picture-card';
export const basicProps = {
  disabled: { type: Boolean, default: false },
  listType: {
    type: String as PropType<ListType>,
    default: 'picture-card',
@@ -69,6 +90,8 @@
    type: Object as PropType<SortableOptions>,
    default: () => ({}),
  },
  // support xxx.xxx.xx
  resultField: propTypes.string.def(''),
};
export const uploadContainerProps = {
@@ -85,18 +108,24 @@
    type: Boolean as PropType<boolean>,
    default: false,
  },
  ...previewType,
};
export const previewProps = {
  value: {
    type: Array as PropType<string[]>,
    type: Array as PropType<BaseFileItem[] | any[]>,
    default: () => [],
  },
  maxNumber: {
    type: Number as PropType<number>,
    default: 1,
  },
  ...previewType,
};
export const fileListProps = {
  columns: {
    type: Array as PropType<FileBasicColumn[]>,
    type: Array as PropType<BasicColumn[] | FileBasicColumn[]>,
    default: null,
  },
  actionColumn: {