tangxilong
10 months ago
4 changed files with 122 additions and 122 deletions
@ -1,124 +1,124 @@ |
|||
import React, { useState, useEffect } from 'react' |
|||
import { connect } from 'react-redux' |
|||
import { getCarImages } from '../actions/carimages' |
|||
import ProTable from '@ant-design/pro-table' |
|||
import { Form, Space, DatePicker, Button, Select, Popconfirm, Image, Tooltip } from 'antd' |
|||
import moment from 'moment' |
|||
// import React, { useState, useEffect } from 'react'
|
|||
// import { connect } from 'react-redux'
|
|||
// import { getCarImages } from '../actions/carimages'
|
|||
// import ProTable from '@ant-design/pro-table'
|
|||
// import { Form, Space, DatePicker, Button, Select, Popconfirm, Image, Tooltip } from 'antd'
|
|||
// import moment from 'moment'
|
|||
|
|||
|
|||
function Carimages (props) { |
|||
const { dispatch, assess, user } = props |
|||
const [query, setQuery] = useState({ page: 1, pageSize: 10, }) |
|||
const [loading, setLoading] = useState(false) |
|||
const [datasource, setdatasource] = useState([]) |
|||
const [dateRange, setDateRange] = useState(['1970-1-1', '2099-12-31']) |
|||
const { RangePicker } = DatePicker |
|||
const [total, settotal] = useState(0) |
|||
const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.find(i => i.resourceId === 'ASSESSMANAGE')?.isshow === "true" ? true : '') |
|||
useEffect(() => { |
|||
// function Carimages (props) {
|
|||
// const { dispatch, assess, user } = props
|
|||
// const [query, setQuery] = useState({ page: 1, pageSize: 10, })
|
|||
// const [loading, setLoading] = useState(false)
|
|||
// const [datasource, setdatasource] = useState([])
|
|||
// const [dateRange, setDateRange] = useState(['1970-1-1', '2099-12-31'])
|
|||
// const { RangePicker } = DatePicker
|
|||
// const [total, settotal] = useState(0)
|
|||
// const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.find(i => i.resourceId === 'ASSESSMANAGE')?.isshow === "true" ? true : '')
|
|||
// useEffect(() => {
|
|||
|
|||
return () => { } |
|||
}, []) |
|||
// return () => { }
|
|||
// }, [])
|
|||
|
|||
useEffect(() => { |
|||
getData() |
|||
}, [query]) |
|||
// useEffect(() => {
|
|||
// getData()
|
|||
// }, [query])
|
|||
|
|||
|
|||
|
|||
|
|||
const getData = () => { |
|||
console.log(query, 'query') |
|||
dispatch(getCarImages({ ...query })).then(res => { |
|||
if (res?.success) { |
|||
setdatasource(res?.payload?.data?.rows) |
|||
settotal(res?.payload?.data?.count) |
|||
} |
|||
}) |
|||
} |
|||
// const getData = () => {
|
|||
// console.log(query, 'query')
|
|||
// dispatch(getCarImages({ ...query })).then(res => {
|
|||
// if (res?.success) {
|
|||
// setdatasource(res?.payload?.data?.rows)
|
|||
// settotal(res?.payload?.data?.count)
|
|||
// }
|
|||
// })
|
|||
// }
|
|||
|
|||
|
|||
return ( |
|||
<div> |
|||
<div style={{ marginBottom: '20px', display: 'flex', justifyContent: 'space-between' }}> |
|||
<Form layout="inline" onFinish={(v) => { |
|||
// return (
|
|||
// <div>
|
|||
// <div style={{ marginBottom: '20px', display: 'flex', justifyContent: 'space-between' }}>
|
|||
// <Form layout="inline" onFinish={(v) => {
|
|||
|
|||
setQuery({ |
|||
...query, page: 1, unit: v.unit, startTime: v?.time && moment(v?.time[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss'), |
|||
endTime: v?.time && moment(v?.time[1]).add(1, 'days').endOf('day').format('YYYY-MM-DD HH:mm:ss') |
|||
}) |
|||
}}> |
|||
// setQuery({
|
|||
// ...query, page: 1, unit: v.unit, startTime: v?.time && moment(v?.time[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
|||
// endTime: v?.time && moment(v?.time[1]).add(1, 'days').endOf('day').format('YYYY-MM-DD HH:mm:ss')
|
|||
// })
|
|||
// }}>
|
|||
|
|||
{/* <Form.Item> |
|||
<Button type="primary" htmlType="submit">搜索</Button> |
|||
</Form.Item> */} |
|||
</Form> |
|||
// {/* <Form.Item>
|
|||
// <Button type="primary" htmlType="submit">搜索</Button>
|
|||
// </Form.Item> */}
|
|||
// </Form>
|
|||
|
|||
{/* <Button type="primary" disabled={editAble} |
|||
onClick={() => { |
|||
setAssessModalVisible(true) |
|||
}}>新增</Button> */} |
|||
</div> |
|||
<ProTable |
|||
columns={[ |
|||
{ |
|||
title: '序号', |
|||
dataIndex: 'id', |
|||
key: 'id', |
|||
defaultSortOrder: 'ascend', |
|||
}, |
|||
{ |
|||
title: '抓拍图片', |
|||
dataIndex: 'url', |
|||
key: 'url', |
|||
render: (t, r) => { |
|||
if (r?.url && r?.id) { |
|||
return <span style={{ marginRight: 10 }}> |
|||
<Image src={r?.url} width={200} /> |
|||
</span> |
|||
} else { |
|||
return '--' |
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
title: '日期', |
|||
dataIndex: 'time', |
|||
key: 'time', |
|||
render: (t, r) => { |
|||
const localTime = moment.utc(r?.time).format('YYYY-MM-DD HH:mm:ss') |
|||
return r?.time ? localTime : '--' |
|||
} |
|||
}, |
|||
]} |
|||
dataSource={datasource || []} |
|||
loading={loading} |
|||
pagination={{ |
|||
total: total || 0, |
|||
pageSize: 10, |
|||
defaultPageSize: 10, |
|||
showSizeChanger: false, |
|||
onChange: (page, pageSize) => { |
|||
setQuery({ |
|||
...query, |
|||
page, |
|||
limit: pageSize |
|||
}) |
|||
} |
|||
}} |
|||
rowKey="key" |
|||
toolBarRender={false} |
|||
search={false} |
|||
/> |
|||
// {/* <Button type="primary" disabled={editAble}
|
|||
// onClick={() => {
|
|||
// setAssessModalVisible(true)
|
|||
// }}>新增</Button> */}
|
|||
// </div>
|
|||
// <ProTable
|
|||
// columns={[
|
|||
// {
|
|||
// title: '序号',
|
|||
// dataIndex: 'id',
|
|||
// key: 'id',
|
|||
// defaultSortOrder: 'ascend',
|
|||
// },
|
|||
// {
|
|||
// title: '抓拍图片',
|
|||
// dataIndex: 'url',
|
|||
// key: 'url',
|
|||
// render: (t, r) => {
|
|||
// if (r?.url && r?.id) {
|
|||
// return <span style={{ marginRight: 10 }}>
|
|||
// <Image src={r?.url} width={200} />
|
|||
// </span>
|
|||
// } else {
|
|||
// return '--'
|
|||
// }
|
|||
// }
|
|||
// },
|
|||
// {
|
|||
// title: '日期',
|
|||
// dataIndex: 'time',
|
|||
// key: 'time',
|
|||
// render: (t, r) => {
|
|||
// const localTime = moment.utc(r?.time).format('YYYY-MM-DD HH:mm:ss')
|
|||
// return r?.time ? localTime : '--'
|
|||
// }
|
|||
// },
|
|||
// ]}
|
|||
// dataSource={datasource || []}
|
|||
// loading={loading}
|
|||
// pagination={{
|
|||
// total: total || 0,
|
|||
// pageSize: 10,
|
|||
// defaultPageSize: 10,
|
|||
// showSizeChanger: false,
|
|||
// onChange: (page, pageSize) => {
|
|||
// setQuery({
|
|||
// ...query,
|
|||
// page,
|
|||
// limit: pageSize
|
|||
// })
|
|||
// }
|
|||
// }}
|
|||
// rowKey="key"
|
|||
// toolBarRender={false}
|
|||
// search={false}
|
|||
// />
|
|||
|
|||
</div> |
|||
) |
|||
} |
|||
function mapStateToProps (state) { |
|||
const { auth, assess } = state |
|||
return { |
|||
user: auth.user, |
|||
assess: assess.data || [], |
|||
} |
|||
} |
|||
export default connect(mapStateToProps)(Carimages) |
|||
// </div>
|
|||
// )
|
|||
// }
|
|||
// function mapStateToProps (state) {
|
|||
// const { auth, assess } = state
|
|||
// return {
|
|||
// user: auth.user,
|
|||
// assess: assess.data || [],
|
|||
// }
|
|||
// }
|
|||
// export default connect(mapStateToProps)(Carimages)
|
Loading…
Reference in new issue