CF2-60 DrillingProgram > DocumentsTemplate > UploadForm задавать фильтр допустимых форматов файлов

This commit is contained in:
Фролов 2021-09-01 10:32:47 +05:00
parent d7349afd6b
commit 0b18324a47
3 changed files with 7 additions and 4 deletions

View File

@ -3,7 +3,7 @@ import { UploadOutlined } from '@ant-design/icons'
import { useState } from 'react' import { useState } from 'react'
import { upload } from './factory' import { upload } from './factory'
export default function UploadForm({url, onUploadStart, onUploadComplete, onUploadError}) { export default function UploadForm({url, accept, onUploadStart, onUploadComplete, onUploadError}) {
const [fileList, setfileList] = useState([]) const [fileList, setfileList] = useState([])
const handleFileSend = async (values) => { const handleFileSend = async (values) => {
@ -31,6 +31,7 @@ export default function UploadForm({url, onUploadStart, onUploadComplete, onUplo
<Upload <Upload
name ="file" name ="file"
fileList={fileList} fileList={fileList}
accept={accept}
onChange={(props) => setfileList(props.fileList)}> onChange={(props) => setfileList(props.fileList)}>
<Button icon={<UploadOutlined/>}>Загрузить файл</Button> <Button icon={<UploadOutlined/>}>Загрузить файл</Button>
</Upload> </Upload>

View File

@ -17,7 +17,7 @@ const pageSize = 12
const { RangePicker } = DatePicker const { RangePicker } = DatePicker
const { Search } = Input const { Search } = Input
export default function DocumentsTemplate({ idCategory, idWell }) { export default function DocumentsTemplate({ idCategory, idWell, accept }) {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [filterDataRange, setFilterDataRange] = useState([]) const [filterDataRange, setFilterDataRange] = useState([])
const [filterCompanyName, setFilterCompanyName] = useState([]) const [filterCompanyName, setFilterCompanyName] = useState([])
@ -175,6 +175,7 @@ export default function DocumentsTemplate({ idCategory, idWell }) {
<span>Загрузка</span> <span>Загрузка</span>
<UploadForm <UploadForm
url={uploadUrl} url={uploadUrl}
accept={accept}
onUploadStart={() => setShowLoader(true)} onUploadStart={() => setShowLoader(true)}
onUploadComplete={handleUploadComplete}/> onUploadComplete={handleUploadComplete}/>
</div> </div>

View File

@ -9,7 +9,7 @@ const idFileCategoryDrillingProgramItems = 13;
export default function DrillingProgram({idWell}) { export default function DrillingProgram({idWell}) {
const [showLoader, setShowLoader] = useState(false) const [showLoader, setShowLoader] = useState(false)
const urlDownloadProgram =`api/well/${idWell}/drillingProgram` const urlDownloadProgram =`/api/well/${idWell}/drillingProgram`
const downloadProgram = () => invokeWebApiWrapperAsync(async()=>{ const downloadProgram = () => invokeWebApiWrapperAsync(async()=>{
await download(urlDownloadProgram) await download(urlDownloadProgram)
@ -21,6 +21,7 @@ export default function DrillingProgram({idWell}) {
<Button onClick={downloadProgram}>Сформировать программу бурения</Button> <Button onClick={downloadProgram}>Сформировать программу бурения</Button>
<DocumentsTemplate <DocumentsTemplate
idWell={idWell} idWell={idWell}
idCategory={idFileCategoryDrillingProgramItems}/> idCategory={idFileCategoryDrillingProgramItems}
accept='.xlsx'/>
</LoaderPortal>) </LoaderPortal>)
} }