|
@@ -1,197 +1,17 @@
|
|
|
-import Header from '@/components/Header'
|
|
|
-import Slot from '@/components/Header/slot'
|
|
|
-import SvgIcon from '@/components/SvgIcon'
|
|
|
-import { iModalProps, iTenderFormValue, TenderTree } from '@/types/tender'
|
|
|
-import consts from '@/utils/consts'
|
|
|
-import { CaretDownOutlined, FolderAddFilled } from '@ant-design/icons'
|
|
|
-import { Button, Dropdown, Menu, Table, Tooltip } from 'antd'
|
|
|
-import { ColumnsType } from 'antd/lib/table'
|
|
|
-import React, { useEffect, useState } from 'react'
|
|
|
-import { Link } from 'react-router-dom'
|
|
|
-import { apiResfulTree, apiTree } from './api'
|
|
|
-import ModalForm from './components/ModalForm'
|
|
|
-import styles from './index.module.scss'
|
|
|
-import './index.scss'
|
|
|
-const Tender: React.FC<{}> = () =>{
|
|
|
- const [ tree, setTree ] = useState<TenderTree>({ ancounts: 0,
|
|
|
- attribution: '',
|
|
|
- bidsectionId: '',
|
|
|
- childsTotal: 0,
|
|
|
- createTime: '',
|
|
|
- csrf: '',
|
|
|
- depth: 0,
|
|
|
- children: [],
|
|
|
- hasFolder: false,
|
|
|
- id: '',
|
|
|
- isBid: false,
|
|
|
- leaf: false,
|
|
|
- isEnd: false,
|
|
|
- isfolder: 0,
|
|
|
- moveId: '',
|
|
|
- name: '',
|
|
|
- parentId: '',
|
|
|
- projectId: '',
|
|
|
- serial: '',
|
|
|
- updateTime: '' })
|
|
|
- const [ modal, setModal ] = useState<iModalProps>({
|
|
|
- type: 'folder',
|
|
|
- visible: false,
|
|
|
- confirmLoading: false,
|
|
|
- isFolder: false,
|
|
|
- id: ''
|
|
|
- })
|
|
|
- const treeBtnClick = (payload: any) => {
|
|
|
- setModal({
|
|
|
- ...modal,
|
|
|
- visible: true,
|
|
|
- ...payload
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- const columns: ColumnsType<TenderTree> = [
|
|
|
- {
|
|
|
- title: '名称',
|
|
|
- dataIndex: 'name',
|
|
|
- key: 'name',
|
|
|
- // eslint-disable-next-line react/display-name
|
|
|
- render: (text: string, record: TenderTree) => {
|
|
|
- if (record.isfolder) {
|
|
|
- return <div style={{ verticalAlign: "baseline" }}><SvgIcon type="xxh-folder-open" style={{ fontSize: 12 }} /><span className="pi-mg-left-2">{text}</span></div>
|
|
|
- } else {
|
|
|
- return <div><span style={{ color: '#6c757d', marginRight: '.5rem' }}>{record.isEnd ? '└' : '├'}</span><span>{text}</span></div>
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- title: '成员',
|
|
|
- dataIndex: 'member',
|
|
|
- key: 'member',
|
|
|
- width: 200,
|
|
|
- // eslint-disable-next-line react/display-name
|
|
|
- render: (text:string, record: TenderTree) => {
|
|
|
- if (record.leaf) {
|
|
|
- return <div><span className="pi-mg-right-5">{record.ancounts} 成员</span><Link className={styles.treeBtn} to="/">成员管理</Link></div>
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- title: '操作',
|
|
|
- dataIndex: 'opreate',
|
|
|
- key: 'opreate',
|
|
|
- width: 80,
|
|
|
- // eslint-disable-next-line react/display-name
|
|
|
- render: (text:string, record: TenderTree) => {
|
|
|
- return <Dropdown overlay={() => {
|
|
|
- return (
|
|
|
- <Menu>
|
|
|
- <Menu.Item key="0"><div className="menu-item" onClick={() => treeBtnClick({ type: 'rename', id: record.id })}><SvgIcon type="xxh-edit" style={{ fontSize: 12 }}></SvgIcon><span className="pi-mg-left-5">重命名</span></div></Menu.Item>
|
|
|
- <Menu.Item key="1"><div className="menu-item" onClick={() => treeBtnClick({ type: 'move', id: record.id, isFolder: Boolean(record.isfolder) })}><SvgIcon type="xxh-exchange-alt" style={{ fontSize: 12 }}></SvgIcon><span className="pi-mg-left-5">移动</span></div></Menu.Item>
|
|
|
- {
|
|
|
- record.children?.length ?
|
|
|
- <Menu.Item key="2">
|
|
|
- <Tooltip placement="left" title="请先移除所有数据">
|
|
|
- <div className="menu-item text-muted">
|
|
|
- <SvgIcon type="xxh-times" style={{ fontSize: 12 }}></SvgIcon><span className="pi-mg-left-5">删除</span>
|
|
|
- </div>
|
|
|
- </Tooltip>
|
|
|
- </Menu.Item>
|
|
|
- :
|
|
|
- <Menu.Item key="2"><div className="menu-item" onClick={() => treeBtnClick({ type : record.isfolder ? 'delFolder' : 'delTender', id: record.id, name: record.name })}><SvgIcon type="xxh-times" style={{ fontSize: 12 }}></SvgIcon><span className="pi-mg-left-5">删除</span></div></Menu.Item>
|
|
|
- }
|
|
|
- {
|
|
|
- record.isfolder ? <Menu.Divider /> : ''
|
|
|
- }
|
|
|
- {
|
|
|
- record.isfolder ? (!record.hasFolder) ?
|
|
|
- <Menu.Item key="3"><div className= "menu-item" onClick={() => treeBtnClick({ type: 'tender', id: record.id })}><SvgIcon type="xxh-plus" style={{ fontSize: 12 }}></SvgIcon><span className="pi-mg-left-5">新建标段</span></div></Menu.Item>
|
|
|
- :
|
|
|
- <Menu.Item key="3">
|
|
|
- <Tooltip placement="left" title="标段无法与文件夹同层">
|
|
|
- <div className= "menu-item text-muted"><SvgIcon type="xxh-plus" style={{ fontSize: 12 }}></SvgIcon><span className="pi-mg-left-5">新建标段</span></div>
|
|
|
- </Tooltip></Menu.Item>
|
|
|
- : ''
|
|
|
- }
|
|
|
- {
|
|
|
- record.isfolder ? !record.isBid ?
|
|
|
- <Menu.Item key="4"><div className="menu-item" onClick={() => treeBtnClick({ type : 'folder', id: record.id })}><SvgIcon type="xxh-folders" style={{ fontSize: 12 }}></SvgIcon><span className="pi-mg-left-5">新建子文件夹</span></div></Menu.Item>
|
|
|
- :
|
|
|
- <Menu.Item key="4">
|
|
|
- <Tooltip placement="left" title="文件夹无法与标段同层">
|
|
|
- <div className="menu-item text-muted"><SvgIcon type="xxh-folders" style={{ fontSize: 12 }}></SvgIcon><span className="pi-mg-left-5">新建子文件夹</span></div>
|
|
|
- </Tooltip>
|
|
|
- </Menu.Item>
|
|
|
- : ''
|
|
|
- }
|
|
|
-
|
|
|
- </Menu>
|
|
|
- )
|
|
|
- }} trigger={[ 'click' ]}>
|
|
|
- <span>
|
|
|
- <SvgIcon type="xxh-align-justify" style={{ fontSize: 12, color: "#007bff" }}></SvgIcon>
|
|
|
- <CaretDownOutlined style={{ fontSize: "12px", color: "#007bff" }}/>
|
|
|
- </span>
|
|
|
- </Dropdown>
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
-
|
|
|
- const onCreate = async (values: iTenderFormValue, type: string) => {
|
|
|
- console.log('Received values of form: ', values, type)
|
|
|
- setModal({
|
|
|
- ...modal,
|
|
|
- confirmLoading: true
|
|
|
- })
|
|
|
- const { code = -1 } = await apiResfulTree(type, values)
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- getTree()
|
|
|
- }
|
|
|
- setModal({
|
|
|
- ...modal,
|
|
|
- confirmLoading: false,
|
|
|
- visible: false,
|
|
|
- isFolder: false,
|
|
|
- id: ''
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
- useEffect(() => {
|
|
|
- getTree()
|
|
|
- }, [])
|
|
|
- const getTree = async () => {
|
|
|
- const { data = {}, code = -1 } = await apiTree()
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- setTree(data)
|
|
|
- }
|
|
|
- }
|
|
|
+import Guards from '@/components/Navigation'
|
|
|
+import { NavigationGuardsProps } from '@/types/router'
|
|
|
+import React from 'react'
|
|
|
+import { Switch } from 'react-router-dom'
|
|
|
+const Management:React.FC<NavigationGuardsProps> = props => {
|
|
|
+ const { routeConfig, match, location } = props
|
|
|
return (
|
|
|
- <div className="wrap-contaniner">
|
|
|
- <Header title="标段管理">
|
|
|
- <Slot position="right">
|
|
|
- <Button type="primary" size="small" icon={<FolderAddFilled />} onClick={() => treeBtnClick({ type: 'root', id: tree.id })}>新建文件夹</Button>
|
|
|
- </Slot>
|
|
|
- </Header>
|
|
|
- <div className="pi-flex-column">
|
|
|
- <div className="pi-mg-16 pi-pd-tb-64 pi-pd-lr-32 jumbotron">
|
|
|
- <h3>没有标段数据</h3>
|
|
|
- </div>
|
|
|
- <div className={styles.tableContent}>
|
|
|
- <Table<TenderTree>
|
|
|
- columns={columns}
|
|
|
- dataSource={tree.children}
|
|
|
- pagination={false}
|
|
|
- rowKey={record => record.id}
|
|
|
- indentSize={20}
|
|
|
- bordered
|
|
|
- ></Table>
|
|
|
- </div>
|
|
|
- <ModalForm modalObj={modal} treeObj={tree} onCreate={onCreate} onCancel={() => setModal({
|
|
|
- ...modal,
|
|
|
- visible: false
|
|
|
- })} ></ModalForm>
|
|
|
+ <>
|
|
|
+ <div className="panel-content">
|
|
|
+ <Switch>
|
|
|
+ <Guards routeConfig={routeConfig} match={match} location={location}></Guards>
|
|
|
+ </Switch>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </>
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-export default Tender
|
|
|
+export default Management
|