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 { 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 handleFileSend = async (values) => {
@ -31,6 +31,7 @@ export default function UploadForm({url, onUploadStart, onUploadComplete, onUplo
<Upload
name ="file"
fileList={fileList}
accept={accept}
onChange={(props) => setfileList(props.fileList)}>
<Button icon={<UploadOutlined/>}>Загрузить файл</Button>
</Upload>

View File

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

View File

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