增加 postForm、分离订单列表

dev/mobile
Jimmy Liow 2 years ago
parent d938fe5df9
commit 4aa0b23932

@ -13,7 +13,7 @@ function checkStatus(response) {
} }
} }
export function useJson(url) { export function useGetJson(url) {
const [data, setData] = useState(null) const [data, setData] = useState(null)
useEffect(() => { useEffect(() => {
if (url) { if (url) {
@ -26,9 +26,34 @@ export function useJson(url) {
setData(json) setData(json)
} }
}) })
return () => {
ignore = true return () => { ignore = true }
} }
}, [url])
return data
}
export function usePostForm(url, formData) {
const [data, setData] = useState(null)
useEffect(() => {
if (url) {
let ignore = false
fetch(url, {
method: 'POST',
body: formData
}).then(checkStatus)
.then(response => response.json())
.then(json => {
if (!ignore) {
setData(json)
}
})
.catch(error => {
throw error
})
return () => { ignore = true }
} }
}, [url]) }, [url])

@ -60,7 +60,7 @@ ReactDOM.createRoot(document.getElementById('root')).render(
// <React.StrictMode> // <React.StrictMode>
<ThemeContext.Provider value={{colorPrimary: '#1ba784', borderRadius: 4}}> <ThemeContext.Provider value={{colorPrimary: '#1ba784', borderRadius: 4}}>
<AuthContext.Provider value={{loginUser: {userId: 1, openId: '123456789'}, permissionList: []}}> <AuthContext.Provider value={{loginUser: {userId: 1, openId: '123456789'}, permissionList: ['view_chat', 'send_msg']}}>
<RouterProvider <RouterProvider
router={router} router={router}
fallbackElement={() => <div>Loading...</div>} fallbackElement={() => <div>Loading...</div>}

@ -1,7 +1,7 @@
import { Outlet, Link, useHref, NavLink } from 'react-router-dom' import { Outlet, Link, useHref, NavLink } from 'react-router-dom'
import { useRef, useEffect, useState } from 'react' import { useRef, useEffect, useState } from 'react'
import { Layout, Menu, ConfigProvider, theme, Empty, Row, Col, Dropdown, Space, Typography, Result, Select, App as AntApp } from 'antd' import { Layout, Menu, ConfigProvider, theme, Empty, Row, Col, Dropdown, Space, Typography, Result, Select, App as AntApp } from 'antd'
import { DownOutlined } from "@ant-design/icons"; import { DownOutlined } from '@ant-design/icons';
import ErrorBoundary from '@/components/ErrorBoundary'; import ErrorBoundary from '@/components/ErrorBoundary';
import zhLocale from 'antd/locale/zh_CN'; import zhLocale from 'antd/locale/zh_CN';
import { useThemeContext } from '@/stores/ThemeContext' import { useThemeContext } from '@/stores/ThemeContext'
@ -50,7 +50,7 @@ function App() {
<Layout> <Layout>
<Header className='header' style={{ position: 'sticky', top: 0, zIndex: 2, width: '100%', background: 'white' }}> <Header className='header' style={{ position: 'sticky', top: 0, zIndex: 2, width: '100%', background: 'white' }}>
<Row gutter={{ md: 24 }} align='middle'> <Row gutter={{ md: 24 }} align='middle'>
<Col flex="300px"> <Col flex='300px'>
<NavLink to='/'> <NavLink to='/'>
<img src={AppLogo} className='logo' alt='App logo' /> <img src={AppLogo} className='logo' alt='App logo' />
</NavLink> </NavLink>
@ -70,26 +70,26 @@ function App() {
]} ]}
/> />
</Col> </Col>
<Col flex="auto" style={{ color: "white", marginBottom: "0", display: "flex", justifyContent: "end" }}> <Col flex='auto' style={{ color: 'white', marginBottom: '0', display: 'flex', justifyContent: 'end' }}>
<Dropdown <Dropdown
menu={{ menu={{
items: [ items: [
{ {
label: <Link to="/s/account/profile">个人资料</Link>, label: <Link to='/s/account/profile'>个人资料</Link>,
key: "1", key: '1',
}, },
{ {
type: "divider", type: 'divider',
}, },
{ {
label: <Link to="/login?out">退出</Link>, label: <Link to='/login?out'>退出</Link>,
key: "3", key: '3',
}, },
] ]
}} }}
trigger={['click']} trigger={['click']}
> >
<a onClick={(e) => e.preventDefault()}> <a onClick={(e) => e.preventDefault()} style={{color: colorPrimary}}>
<Space> <Space>
廖一军 廖一军
<DownOutlined /> <DownOutlined />

@ -1,9 +1,8 @@
import { useNavigate } from 'react-router-dom' import { useNavigate } from 'react-router-dom'
import { useRef, useEffect, useState } from 'react' import { useRef, useEffect, useState } from 'react'
import { observer } from 'mobx-react'
import { import {
Row, Col, Divider, Table, Card, Button, Input, Row, Col, Divider, Table, Card, Button, Input,
Space, Segmented, Radio, Select, AutoComplete, Spin, Typography, Flex, DatePicker, List, Avatar Space, Segmented, Radio, Select, AutoComplete, Spin, Typography, Switch, DatePicker, List, Avatar
} from 'antd' } from 'antd'
import { import {
StarFilled, ZoomInOutlined, StarOutlined, BarsOutlined, AppstoreOutlined, SearchOutlined StarFilled, ZoomInOutlined, StarOutlined, BarsOutlined, AppstoreOutlined, SearchOutlined
@ -184,93 +183,16 @@ const columns = [
function OrderFollow() { function OrderFollow() {
const [taskCategory, setTaskCategory] = useState('today') const [taskCategory, setTaskCategory] = useState('today')
const [advanceChecked, toggleAdvance] = useState(false)
useEffect(() => { useEffect(() => {
}, []) }, [])
function AdvanceCriteria() {
return (
<Space direction='vertical' style={{ width: '100%' }}>
<Row gutter={[16, 16]} justify='start' align='middle'>
<Col span={2}>
<Select
defaultValue='全部'
style={{
width: 100,
}}
options={[
{
value: '潜力',
label: '潜力',
},
{
value: '重点',
label: '重点',
},
{
value: '休眠',
label: '休眠',
}
]}
/>
</Col>
<Col span={2}>
<Select
defaultValue='全部'
style={{
width: 100,
}}
options={[
{
value: '新订单',
label: '新订单',
},
{
value: '报价中',
label: '报价中',
},
{
value: '丢失',
label: '丢失',
},
{
value: '一催',
label: '一催',
},
{
value: '二催',
label: '二催',
},
{
value: '三催',
label: '三催',
},
]}
/>
</Col>
<Col span={6}>
<Input placeholder="订单号" allowClear />
</Col>
<Col span={4}>
<RangePicker />
</Col>
<Col span={2}>
<Button icon={<SearchOutlined />} onClick={() => {
search()
}}>搜索</Button>
</Col>
</Row>
</Space>
)
}
return ( return (
<Spin spinning={false} delay={500}> <Spin spinning={false} delay={500}>
<Space direction='vertical' style={{ width: '100%' }}> <Space direction='vertical' style={{ width: '100%' }}>
<Row gutter={[16, 16]} justify='start' align='middle'> <Row gutter={[16, 16]} justify='start' align='middle'>
<Col span={24}> <Col span={10}>
<Radio.Group <Radio.Group
options={[ options={[
{ label: '今日任务', value: 'today' }, { label: '今日任务', value: 'today' },
@ -278,8 +200,7 @@ function OrderFollow() {
{ label: '重点订单', value: 'important' }, { label: '重点订单', value: 'important' },
{ label: '成行', value: 'myfavorites' }, { label: '成行', value: 'myfavorites' },
{ label: '走团中', value: 'ing' }, { label: '走团中', value: 'ing' },
{ label: '走团后一月', value: 'lastMonth' }, { label: '走团后一月', value: 'lastMonth' }
{ label: '高级查询', value: 'advance' }
]} ]}
value={taskCategory} value={taskCategory}
onChange={({ target: { value } }) => { onChange={({ target: { value } }) => {
@ -289,8 +210,13 @@ function OrderFollow() {
buttonStyle='solid' buttonStyle='solid'
/> />
</Col> </Col>
<Col span={4}>
<Switch checkedChildren='高级查询' unCheckedChildren='高级查询'
defaultChecked={false}
onChange={() => {toggleAdvance(!advanceChecked)}} />
</Col>
</Row> </Row>
<Conditional condition={taskCategory==='advance'} whenTrue={<AdvanceCriteria />} /> <Conditional condition={advanceChecked} whenTrue={<AdvanceCriteria />} />
</Space> </Space>
<Divider plain orientation='left'></Divider> <Divider plain orientation='left'></Divider>
<Space <Space
@ -300,10 +226,96 @@ function OrderFollow() {
display: 'flex', display: 'flex',
}} }}
> >
<Table dataSource={dataSource} columns={columns} /> <OrderList taskCategory={taskCategory} />
</Space> </Space>
</Spin> </Spin>
) )
function OrderList({ taskCategory }) {
console.info('taskCategory: ' + taskCategory)
return (
<>
<Table dataSource={dataSource} columns={columns} />
</>
)
}
function AdvanceCriteria() {
return (
<Space direction='vertical' style={{ width: '100%' }}>
<Row gutter={[16, 16]} justify='start' align='middle'>
<Col span={2}>
<Select
defaultValue='全部'
style={{
width: 100,
}}
options={[
{
value: '潜力',
label: '潜力',
},
{
value: '重点',
label: '重点',
},
{
value: '休眠',
label: '休眠',
}
]}
/>
</Col>
<Col span={2}>
<Select
defaultValue='全部'
style={{
width: 100,
}}
options={[
{
value: '新订单',
label: '新订单',
},
{
value: '报价中',
label: '报价中',
},
{
value: '丢失',
label: '丢失',
},
{
value: '一催',
label: '一催',
},
{
value: '二催',
label: '二催',
},
{
value: '三催',
label: '三催',
},
]}
/>
</Col>
<Col span={6}>
<Input placeholder='订单号' allowClear />
</Col>
<Col span={4}>
<RangePicker />
</Col>
<Col span={2}>
<Button icon={<SearchOutlined />} onClick={() => {
search()
}}>搜索</Button>
</Col>
</Row>
</Space>
)
}
} }
export default observer(OrderFollow) export default OrderFollow

@ -9,7 +9,7 @@ import {
} from '@ant-design/icons' } from '@ant-design/icons'
import {useFormInput} from '@/hooks/useFormInput' import {useFormInput} from '@/hooks/useFormInput'
import {useJson} from '@/hooks/userFetch' import {useGetJson} from '@/hooks/userFetch'
const { Search } = Input; const { Search } = Input;
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
@ -104,7 +104,7 @@ const columns = [
function SalesManagement() { function SalesManagement() {
const keywordProps = useFormInput('') const keywordProps = useFormInput('')
const countryList = useJson(`https://p9axztuwd7x8a7.mycht.cn/service-InfoSys/InfoSys/GetCountryList`) const countryList = useGetJson(`https://p9axztuwd7x8a7.mycht.cn/service-InfoSys/InfoSys/GetCountryList`)
console.info(countryList) console.info(countryList)
useEffect(() => { useEffect(() => {

Loading…
Cancel
Save