124 lines
4.6 KiB
JavaScript
124 lines
4.6 KiB
JavaScript
import YuAnTable from './table'
|
|
import PreViewPdf from './preView'
|
|
import './index.less'
|
|
import React, { useEffect, useState } from 'react';
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import { Form, Input, Button, Select, DatePicker, Card,Modal } from 'antd';
|
|
import moment from 'moment'
|
|
import dayjs from 'dayjs'
|
|
import apiurl from '../../../models/apiurl.js'
|
|
import UploadFile from '../../../components/uploadFile/index'
|
|
import AdcdTree from '../../../components/FormZdy1/AdcdTree/index.js';
|
|
import { httpget, httpPostFile, httpGetFile } from '../../../utils/request.js';
|
|
import { exportFile } from '../../../utils/tools.js';
|
|
import { upload } from '@testing-library/user-event/dist/upload.js';
|
|
|
|
|
|
const YuanList = () => {
|
|
const [form] = Form.useForm();
|
|
const [info, serInfo] = useState({ year:dayjs().subtract(1,'year').format('YYYY') })
|
|
const [adInfo, setAdInfo] = useState('')
|
|
const [url,setUrl] = useState('')
|
|
const [open, setOpen] = useState(false)
|
|
|
|
|
|
const onFinish = (values) => {
|
|
serInfo({...values,
|
|
year:values.year?dayjs(values.year).format('YYYY'):undefined})
|
|
}
|
|
const getUrl = (w,name)=>{
|
|
setUrl({url:w,name:name})
|
|
|
|
}
|
|
const downtmp = ()=>{
|
|
httpGetFile(apiurl.service.yuan.template).then((res) => {
|
|
if (res) {
|
|
exportFile('预案模板.xlsx', res.data)
|
|
}
|
|
})
|
|
}
|
|
const down = ()=>{
|
|
let params={ ...info, adlevel: adInfo.adlevel, adcd: adInfo.adcd }
|
|
if(params.year){
|
|
downLoadYear(params)
|
|
}else{
|
|
downLoad(params)
|
|
}
|
|
}
|
|
const downLoad =(params)=>{
|
|
httpPostFile(apiurl.service.yuan.downLoad, params).then((res) => {
|
|
if (res) {
|
|
exportFile('预案.xlsx', res.data)
|
|
}
|
|
})
|
|
}
|
|
const downLoadYear =(params)=>{
|
|
httpPostFile(apiurl.service.yuan.downLoadYear, params).then((res) => {
|
|
if (res) {
|
|
exportFile('预案归档.xlsx', res.data)
|
|
}
|
|
})
|
|
}
|
|
const upload =()=>{
|
|
|
|
}
|
|
const handleCancel = () => {
|
|
setOpen(false)
|
|
}
|
|
useEffect(() => {
|
|
form.setFieldsValue({ year: dayjs().subtract(1,'year')})
|
|
}, [])
|
|
|
|
return (
|
|
<div className='yuanlist flex' style={{height: '100%'}}>
|
|
<Card>
|
|
<AdcdTree setAdInfo={v => setAdInfo(v)}/>
|
|
</Card>
|
|
<div style={{height: '100%',flex: 1}}>
|
|
|
|
<div style={{ padding: 5,margin:'0 5px', background: '#fff' }}>
|
|
<Form form={form} onFinish={onFinish} size='Default' layout="inline">
|
|
<Form.Item label="归档年份" name="year">
|
|
<DatePicker picker="year" maxDate={dayjs().subtract(1,'year')}/>
|
|
</Form.Item>
|
|
<Form.Item>
|
|
<Button type="primary" htmlType="submit" size='Default'>查询</Button>
|
|
</Form.Item>
|
|
<Form.Item>
|
|
<Button size='Default' onClick={() => form.setFieldsValue({year:'', yuanYear: dayjs()})}>重置</Button>
|
|
</Form.Item>
|
|
<Form.Item>
|
|
<Button onClick={()=>downtmp()}>下载模板</Button>
|
|
</Form.Item>
|
|
{adInfo.adlevel==2&&<Form.Item>
|
|
<Button size='Default' onClick={() => down()}>导出</Button>
|
|
</Form.Item>}
|
|
{/* <Form.Item>
|
|
<Button size='Default' onClick={() => upload()}>上传</Button>
|
|
</Form.Item> */}
|
|
</Form>
|
|
</div>
|
|
<div className='flex' style={{height: 'calc(100% - 42px)'}}>
|
|
<div style={{ background: '#fff', margin: '5px' }}>
|
|
|
|
<YuAnTable info={info} record={adInfo} getUrl={getUrl}/>
|
|
</div>
|
|
<div style={{ background: '#fff', margin: '5px', flex: 1 }}>
|
|
<PreViewPdf url={url}/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{/* <Modal
|
|
title='上传文件'
|
|
open={open}
|
|
onOk={handleCancel}
|
|
// confirmLoading={confirmLoading}
|
|
onCancel={handleCancel}
|
|
>
|
|
<UploadFile url={`${apiurl.service.yuan.upload}${recordData.adcd}/${new Date().getFullYear()}`} refresh={refresh}/>
|
|
</Modal> */}
|
|
</div>
|
|
)
|
|
}
|
|
export default YuanList |