| | |
| | | ProFormDigit, |
| | | ProFormText, |
| | | ProFormSelect, |
| | | ProFormDateTimePicker |
| | | ProFormDateTimePicker, |
| | | ProFormTreeSelect |
| | | } from '@ant-design/pro-components'; |
| | | import { Form, Modal } from 'antd'; |
| | | import moment from 'moment'; |
| | |
| | | hidden={true} |
| | | /> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="name" |
| | | label="名称" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | rules={[{ required: true, message: "名称不能为空!" }]} |
| | | /> |
| | | <ProFormDigit |
| | | <ProFormTreeSelect |
| | | name="parentId" |
| | | label="上级部门" |
| | | params={props.treeData} |
| | | request={async () => { |
| | | return props.treeData; |
| | | }} |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | placeholder="请选择" |
| | | rules={[{ required: true, message: "上级部门不能为空" }]} |
| | | fieldProps={{ |
| | | treeDefaultExpandedKeys: [0] |
| | | }} |
| | | /> |
| | | <ProFormText |
| | | name="name" |
| | | label="部门名称" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | rules={[{ required: true, message: "部门名称不能为空!" }]} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="parentName" |
| | | label="上级部门名" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | /> |
| | | <ProFormText |
| | | name="path" |
| | | label="关联路径" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="pathName" |
| | | label="关联路径名" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | /> |
| | | <ProFormText |
| | | name="fullName" |
| | | label="全称" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="brief" |
| | | label="简述" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | /> |
| | | <ProFormText |
| | | name="code" |
| | | label="标识" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormDigit |
| | | name="type" |
| | | label="类型" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | placeholder="请输入" |
| | | /> |
| | | <ProFormText |
| | | name="leader" |
| | | label="负责人" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormDigit |
| | | name="count" |
| | | label="数量" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | placeholder="请输入" |
| | | /> |
| | | <ProFormDigit |
| | |
| | | { label: '禁用', value: 0 }, |
| | | ]} |
| | | /> |
| | | <ProFormDateTimePicker |
| | | name="createTime" |
| | | label="添加时间" |
| | | <ProFormText |
| | | name="memo" |
| | | label=" 备注" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请选择" |
| | | transform={(value) => moment(value).toISOString()} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormSelect |
| | | name="createBy" |
| | | label="添加人员" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | placeholder="请选择" |
| | | showSearch |
| | | debounceTime={300} |
| | | request={async ({ keyWords }) => { |
| | | const resp = await Http.doPostForm('api/user/query', { condition: keyWords }); |
| | | return resp.data; |
| | | }} |
| | | /> |
| | | <ProFormDateTimePicker |
| | | name="updateTime" |
| | | label="修改时间" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请选择" |
| | | transform={(value) => moment(value).toISOString()} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormSelect |
| | | name="updateBy" |
| | | label="修改人员" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | placeholder="请选择" |
| | | showSearch |
| | | debounceTime={300} |
| | | request={async ({ keyWords }) => { |
| | | const resp = await Http.doPostForm('api/user/query', { condition: keyWords }); |
| | | return resp.data; |
| | | }} |
| | | placeholder="请输入" |
| | | /> |
| | | </ProForm.Group> |
| | | |
| | |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { Button, message, Modal } from 'antd'; |
| | | import { Button, message, Modal, Tag } from 'antd'; |
| | | import { |
| | | FooterToolbar, |
| | | PageContainer, |
| | |
| | | import Http from '@/utils/http'; |
| | | import Edit from './components/edit' |
| | | import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch' |
| | | import { transformTreeData } from '@/utils/tree-util' |
| | | |
| | | const statusMap = { |
| | | 1: { |
| | | color: 'green', |
| | | text: '正常', |
| | | }, |
| | | 0: { |
| | | color: 'red', |
| | | text: '禁用', |
| | | }, |
| | | }; |
| | | |
| | | const handleSave = async (val) => { |
| | | const hide = message.loading('正在添加'); |
| | |
| | | const [currentRow, setCurrentRow] = useState(); |
| | | const [searchParam, setSearchParam] = useState({}); |
| | | |
| | | const [treeData, setTreeData] = useState([]); |
| | | |
| | | useEffect(() => { |
| | | |
| | | }, []); |
| | |
| | | width: 48, |
| | | }, |
| | | { |
| | | title: '名称', |
| | | title: '部门名称', |
| | | dataIndex: 'name', |
| | | valueType: 'text', |
| | | hidden: false, |
| | |
| | | />, |
| | | }, |
| | | { |
| | | title: '上级部门', |
| | | dataIndex: 'parentId', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='parentId' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '上级部门名', |
| | | dataIndex: 'parentName', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | hidden: true, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='parentName' |
| | |
| | | />, |
| | | }, |
| | | { |
| | | title: '关联路径', |
| | | dataIndex: 'path', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='path' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '关联路径名', |
| | | dataIndex: 'pathName', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='pathName' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '全称', |
| | | dataIndex: 'fullName', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | hidden: true, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='fullName' |
| | |
| | | title: '简述', |
| | | dataIndex: 'brief', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | hidden: true, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='brief' |
| | |
| | | title: '标识', |
| | | dataIndex: 'code', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | hidden: true, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='code' |
| | |
| | | title: '类型', |
| | | dataIndex: 'type', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | hidden: true, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='type' |
| | |
| | | title: '数量', |
| | | dataIndex: 'count', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | hidden: true, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='count' |
| | |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | render: (_, record) => { |
| | | return <span style={{ fontWeight: "bold" }}>{_}</span> |
| | | } |
| | | }, |
| | | { |
| | | title: '状态', |
| | |
| | | { label: '禁用', value: 0 }, |
| | | ]} |
| | | />, |
| | | }, |
| | | { |
| | | title: '添加时间', |
| | | dataIndex: 'createTime$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <DatetimeRangeFilter |
| | | name='createTime' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '添加人员', |
| | | dataIndex: 'createBy$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='createBy' |
| | | major='user' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | render: (_, record) => { |
| | | const status = statusMap[record.status] |
| | | return <Tag color={status.color}>{status.text}</Tag> |
| | | }, |
| | | }, |
| | | { |
| | | title: '修改时间', |
| | |
| | | title: '备注', |
| | | dataIndex: 'memo', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | hidden: true, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='memo' |
| | |
| | | ], |
| | | }} |
| | | request={(params, sorter, filter) => |
| | | Http.doPostPromise('/api/dept/page', { ...params, ...searchParam }, (res) => { |
| | | Http.doPostPromise('/api/dept/tree', { ...params, ...searchParam }, (res) => { |
| | | const rootMenu = { id: 0, name: '根目录', value: 0, children: [] }; |
| | | rootMenu.children = res.data; |
| | | const treeData = transformTreeData([rootMenu]); |
| | | setTreeData(treeData); |
| | | |
| | | return { |
| | | data: res.data.records, |
| | | total: res.data.total, |
| | | data: res.data, |
| | | success: true, |
| | | } |
| | | }) |
| | |
| | | <Edit |
| | | open={modalVisible} |
| | | values={currentRow || {}} |
| | | treeData={treeData} |
| | | onCancel={ |
| | | () => { |
| | | setModalVisible(false); |
| | |
| | | /> |
| | | <ProFormText |
| | | name="name" |
| | | label="名称" |
| | | label="菜单名称" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | rules={[{ required: true, message: "名称不能为空!" }]} |
| | | rules={[{ required: true, message: "菜单名称不能为空!" }]} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |