|
|
@@ -1,9 +1,227 @@
|
|
|
-import React from 'react'
|
|
|
+import React, { useState, useEffect } from 'react'
|
|
|
+import ProTable from '@ant-design/pro-table'
|
|
|
+import useAutoTable from '@/hooks/useAutoTable'
|
|
|
+import SvgIcon from '@/components/SvgIcon'
|
|
|
+import { Button } from 'antd'
|
|
|
+import consts from '@/consts'
|
|
|
+import { queryCompany } from '@/services/company'
|
|
|
+import LazyCascader from '@/components/LazyCascader'
|
|
|
+import Companys from '@/components/PopContent/Companys'
|
|
|
+import AddCompany from '@/pages/Customer/Company/AddCompany'
|
|
|
+
|
|
|
+const Company = props => {
|
|
|
+ const { collapsed } = props
|
|
|
+ const needSubtractHeight = 48 + 48 + 48 + 64 + 24 + 32 // 需要被裁掉的高度
|
|
|
+ const needSubtractWidth = (collapsed ? 208 : 48) + 48 + 48 + 48 // 需要被裁掉的高度
|
|
|
+
|
|
|
+ const [x, y] = useAutoTable(collapsed, needSubtractHeight, needSubtractWidth)
|
|
|
+
|
|
|
+ const [state, setState] = useState({
|
|
|
+ data: [],
|
|
|
+ total: 0,
|
|
|
+ id: '',
|
|
|
+ visible: false
|
|
|
+ })
|
|
|
+ const [addClient, setAddClient] = useState({
|
|
|
+ visible: false,
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ // const handleAddCompany = async values => {
|
|
|
+ // setAddCompany({ ...addCompany, loading: true })
|
|
|
+ // const { code = -1 } = await apiAddCompany(values)
|
|
|
+ // if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ // message.success('新增成功')
|
|
|
+ // setState({ ...state, data: values })
|
|
|
+ // }
|
|
|
+ // // 请求完了
|
|
|
+ // setAddCompany({ ...addCompany, loading: false, visible: false })
|
|
|
+ // await initData()
|
|
|
+ // }
|
|
|
+ const initData = async payload => {
|
|
|
+ const {
|
|
|
+ code = -1,
|
|
|
+ data: { customer = [], total = 0 } = { customer: [], total: 0 }
|
|
|
+ } = await queryCompany(payload)
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ setState({ ...state, data: customer, total })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ useEffect(() => {
|
|
|
+ // props.getlist();
|
|
|
+ initData()
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ const handleSearch = value => {
|
|
|
+ initData({ search: value })
|
|
|
+ }
|
|
|
+ const handleOnselect = payload => {
|
|
|
+ initData({ ...payload })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 展示drawer
|
|
|
+ const showDrawer = id => {
|
|
|
+ // console.log(id);
|
|
|
+ setState({ ...state, id, visible: true })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 隐藏drawer
|
|
|
+ const hideDrawer = () => {
|
|
|
+ setState({ ...state, visible: false, id: '' })
|
|
|
+ }
|
|
|
+
|
|
|
+ const onCreate = values => {
|
|
|
+ console.log(values)
|
|
|
+ }
|
|
|
+ const columns = [
|
|
|
+ {
|
|
|
+ title: '客户名称',
|
|
|
+ dataIndex: 'companyName',
|
|
|
+ key: 'companyName',
|
|
|
+ width: 320,
|
|
|
+ render: (companyName, record) => <a onClick={() => showDrawer(record.id)}>{companyName}</a>
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '地区',
|
|
|
+ dataIndex: 'local',
|
|
|
+ key: 'local',
|
|
|
+ width: 150
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '个人标签',
|
|
|
+ dataIndex: 'biaoqian',
|
|
|
+ key: 'biaoqian',
|
|
|
+ width: 80
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '协作标签',
|
|
|
+ dataIndex: 'biaoqian1',
|
|
|
+ key: 'biaoqian1',
|
|
|
+ width: 80
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '联系人',
|
|
|
+ dataIndex: 'clientTotal',
|
|
|
+ key: 'clientTotal',
|
|
|
+ width: 80
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '公司性质',
|
|
|
+ dataIndex: 'nature',
|
|
|
+ key: 'nature',
|
|
|
+ width: 80
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '公司地址',
|
|
|
+ dataIndex: 'address',
|
|
|
+ key: 'address',
|
|
|
+ width: 80
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '公司传真',
|
|
|
+ dataIndex: 'fax',
|
|
|
+ key: 'fax',
|
|
|
+ width: 80
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '网址',
|
|
|
+ dataIndex: 'webservice',
|
|
|
+ key: 'webservice',
|
|
|
+ width: 80
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '乘车路线',
|
|
|
+ dataIndex: 'ride',
|
|
|
+ key: 'ride',
|
|
|
+ width: 80
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '地标建筑',
|
|
|
+ dataIndex: 'landmarks',
|
|
|
+ key: 'landmarks',
|
|
|
+ width: 80
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '参考住宿',
|
|
|
+ dataIndex: 'stay',
|
|
|
+ key: 'stay',
|
|
|
+ width: 80
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '备注',
|
|
|
+ dataIndex: 'remarks',
|
|
|
+ key: 'remarks',
|
|
|
+ width: 80
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ const [columnsStateMap, setColumnsStateMap] = useState({
|
|
|
+ address: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ nature: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ fax: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ webservice: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ ride: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ stay: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ landmarks: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ remarks: {
|
|
|
+ show: false
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
|
|
|
-const Company = () => {
|
|
|
return (
|
|
|
<div>
|
|
|
- casda
|
|
|
+ <ProTable
|
|
|
+ rowKey={record => record.id}
|
|
|
+ search={false}
|
|
|
+ headerTitle="客户"
|
|
|
+ bordered
|
|
|
+ toolbar={{
|
|
|
+ search: {
|
|
|
+ onSearch: handleSearch
|
|
|
+ },
|
|
|
+ actions: [
|
|
|
+ <LazyCascader onSelect={handleOnselect} key="LazyCascader" />,
|
|
|
+ <Button
|
|
|
+ key="button"
|
|
|
+ type="primary"
|
|
|
+ onClick={() => setAddClient({ ...addClient, visible: true })}
|
|
|
+ >
|
|
|
+ <SvgIcon type="icon-plus" />
|
|
|
+ 客户
|
|
|
+ </Button>
|
|
|
+ ]
|
|
|
+ }}
|
|
|
+ scroll={{ x, y }}
|
|
|
+ columnsStateMap={columnsStateMap}
|
|
|
+ onColumnsStateChange={map => setColumnsStateMap(map)}
|
|
|
+ columns={columns}
|
|
|
+ dataSource={state.data}
|
|
|
+ pagination={{
|
|
|
+ pageSize: consts.PAGE_SIZE,
|
|
|
+ total: state.total,
|
|
|
+ onChange: (page, size) => initData({ page, size })
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <AddCompany
|
|
|
+ // onConfirm={handleAddCompany}
|
|
|
+ loading={addClient.loading}
|
|
|
+ visible={addClient.visible}
|
|
|
+ onCancel={() => setAddClient({ ...addClient, visible: false })}
|
|
|
+ />
|
|
|
+ <Companys onClose={hideDrawer} visible={state.visible} onCreate={onCreate} id={state.id} />
|
|
|
</div>
|
|
|
)
|
|
|
}
|