import AliyunOSSUpload from '@/components/OssUpload/AliyunOssUploader';
import { queryOSSData } from '@/services/boom';
import { useParams, useRequest } from '@umijs/max';

function DDAttachment(props) {
  const { disabled, onChange } = props;
  const { oaId } = useParams();

  const { data: OSSData } = useRequest(queryOSSData, {
    defaultParams: [{ ids: oaId }],
    cacheKey: `ossData-${oaId}`,
  });

  const OnModelFileDone = (file) => {
    onChange(OSSData.host + '/' + file.url);
  };

  if (!OSSData) return;
  return (
    <AliyunOSSUpload
      OSSData={OSSData}
      onDone={OnModelFileDone}
      directory={false}
      noStyle={false}
      label="上传文件"
      disabled={disabled}
    />
  );
}

export default DDAttachment;
