Skip to content

Commit

Permalink
Merge branch 'bqx-dev' into lay-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
NJUPTlay committed Apr 5, 2024
2 parents 9904547 + 8d35969 commit d3b30e0
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions src/pages/workDetail/component/Uploader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UploadOutlined } from '@ant-design/icons'
import { Button, message, Upload } from 'antd'
import React from 'react'
import { uploadWork } from '../../../../api/user'
import { getLicense, uploadWork } from '../../../../api/user'

function Uploader(props: any) {
const localProps: any = {
Expand All @@ -10,19 +10,36 @@ function Uploader(props: any) {
onChange(info: any) {
console.log('onChange', info)
},
// customRequest(options: any) {
// console.log('options', options)
// const { onSuccess, onError, file, onProgress } = options
// uploadWork(Number(props.competitionId), props.inputName, file, onProgress).then((res) => {
// console.log(res)
// if (res.data.errCode === null) {
// onSuccess(res, file)
// message.success({
// content: file.name + ' 上传成功',
// })
// }
// })
// },
customRequest(options: any) {
// console.log('options', options)
// const { onSuccess, onError, file, onProgress } = options
// uploadWork(Number(props.competitionId), props.inputName, file, onProgress).then((res) => {
// console.log(res)
// if (res.data.errCode === null) {
// onSuccess(res, file)
// message.success({
// content: file.name + ' 上传成功',
// })
// }
// })
const temp = options.file as File
getLicense(temp.name, props.inputName, props.competitionId as unknown as number).then(res => {
console.log(res);
const { onSuccess, file } = options
console.log(res.data.data.url);
fetch(res.data.data.url, {
method: "put",
body: temp
}).then(_ => {
onSuccess && onSuccess(res)
message.success({
content: (file as File).name + ' 上传成功',
})
})
}).catch(err => {
console.log(err);
})
},
headers: { Token: localStorage.getItem('approval-system-token') },
}
return (
Expand Down

0 comments on commit d3b30e0

Please sign in to comment.