add FilterFileName

This commit is contained in:
Фролов 2021-08-17 17:01:19 +05:00
parent 2418d13e75
commit 7bfd446913

View File

@ -17,8 +17,9 @@ const { Search } = Input
export default function DocumentsTemplate({ idCategory, idWell }) { export default function DocumentsTemplate({ idCategory, idWell }) {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [dataRange, setDataRange] = useState([]) const [filterDataRange, setFilterDataRange] = useState([])
const [company, setCompany] = useState([]) const [filterCompany, setFilterCompany] = useState([])
const [filterFileName, setFilterFileName] = useState('')
const [pagination, setPagination] = useState(null) const [pagination, setPagination] = useState(null)
const [files, setFiles] = useState([]) const [files, setFiles] = useState([])
const [showLoader, setShowLoader] = useState(false) const [showLoader, setShowLoader] = useState(false)
@ -45,7 +46,11 @@ export default function DocumentsTemplate({ idCategory, idWell }) {
} }
const hanleCompanySearch = (value, _) => { const hanleCompanySearch = (value, _) => {
setCompany(value) setFilterCompany(value)
}
const hanleFileNameSearch = (value, _) => {
setFilterFileName(value)
} }
const columns = [ const columns = [
@ -89,9 +94,9 @@ export default function DocumentsTemplate({ idCategory, idWell }) {
const update = () => { const update = () => {
let begin = null let begin = null
let end = null let end = null
if (dataRange?.length > 1) { if (filterDataRange?.length > 1) {
begin = dataRange[0].toISOString() begin = filterDataRange[0].toISOString()
end = dataRange[1].toISOString() end = filterDataRange[1].toISOString()
} }
updateFromWebApiWrapperAsync( updateFromWebApiWrapperAsync(
@ -115,13 +120,20 @@ export default function DocumentsTemplate({ idCategory, idWell }) {
) )
} }
useEffect(update, [idWell, dataRange, page, idCategory, company]) useEffect(update, [idWell, idCategory, page, filterDataRange, filterCompany, filterFileName])
const companies = [...new Set(files.map(file=>file.company))] const companies = [...new Set(files.map(file=>file.company))]
.filter(company=>company) .filter(company=>company)
const DataListCompanies = <datalist id="listCompanies"> const DataListCompanies = <datalist id="listCompanies">
{companies.map((company, i)=><option key={company} value={company}>{company}</option>)} {companies.map((company)=><option key={company} value={company}>{company}</option>)}
</datalist>
const filenames = [...new Set(files.map(file=>file.name))]
.filter(name=>name)
const DataListFileNames = <datalist id="listFileNames">
{filenames.map((name)=><option key={name} value={name}>{name}</option>)}
</datalist> </datalist>
return ( return (
@ -130,7 +142,7 @@ export default function DocumentsTemplate({ idCategory, idWell }) {
<div> <div>
<span>Фильтр по дате</span> <span>Фильтр по дате</span>
<div> <div>
<RangePicker showTime onChange={setDataRange} /> <RangePicker showTime onChange={setFilterDataRange} />
</div> </div>
</div> </div>
&nbsp; &nbsp;
@ -142,6 +154,15 @@ export default function DocumentsTemplate({ idCategory, idWell }) {
onSearch={hanleCompanySearch}/> onSearch={hanleCompanySearch}/>
{DataListCompanies} {DataListCompanies}
</div> </div>
&nbsp;
<div>
<span>Фильтр по имени файла</span>
<Search
list='listFileNames'
placeholder="Фильтр по имени файла"
onSearch={hanleFileNameSearch}/>
{DataListFileNames}
</div>
&nbsp;&nbsp; &nbsp;&nbsp;
<div> <div>
<span>Загрузка</span> <span>Загрузка</span>