| | |
| | | LightFilter, |
| | | TableDropdown |
| | | } from '@ant-design/pro-components'; |
| | | import { FormattedMessage, useIntl } from '@umijs/max'; |
| | | import { PlusOutlined, ExportOutlined, DownOutlined, DeleteOutlined, ExclamationCircleOutlined } from '@ant-design/icons'; |
| | | import Http from '@/utils/http'; |
| | | import Edit from './components/edit' |
| | |
| | | |
| | | const TABLE_KEY = "pro-table-user"; |
| | | |
| | | const handleSave = async (val) => { |
| | | const hide = message.loading('正在添加'); |
| | | const handleSave = async (val, intl) => { |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.adding', defaultMessage: '正在添加' })); |
| | | try { |
| | | const resp = await Http.doPost('api/user/save', val); |
| | | if (resp.code === 200) { |
| | | message.success('添加成功'); |
| | | message.success(intl.formatMessage({ id: 'page.add.success', defaultMessage: '添加成功' })); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.error('添加失败请重试!'); |
| | | message.error(intl.formatMessage({ id: 'page.add.fail', defaultMessage: '添加失败请重试!' })); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | const handleUpdate = async (val) => { |
| | | const hide = message.loading('正在更新'); |
| | | const handleUpdate = async (val, intl) => { |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.updating', defaultMessage: '正在更新' })); |
| | | try { |
| | | const resp = await Http.doPost('api/user/update', val); |
| | | if (resp.code === 200) { |
| | | message.success('更新成功'); |
| | | message.success(intl.formatMessage({ id: 'page.update.success', defaultMessage: '更新成功' })); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.error('配置失败请重试!'); |
| | | message.error(intl.formatMessage({ id: 'page.update.fail', defaultMessage: '更新失败请重试!' })); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | const handleRemove = async (rows) => { |
| | | const handleRemove = async (rows, intl) => { |
| | | if (!rows) return true; |
| | | const hide = message.loading('正在删除'); |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.deleting', defaultMessage: '正在删除' })); |
| | | try { |
| | | const resp = await Http.doPost('api/user/remove/' + rows.map((row) => row.id).join(',')); |
| | | if (resp.code === 200) { |
| | | message.success('删除成功'); |
| | | message.success(intl.formatMessage({ id: 'page.delete.success', defaultMessage: '删除成功' })); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.error('删除失败,请重试'); |
| | | message.error(intl.formatMessage({ id: 'page.delete.fail', defaultMessage: '删除失败,请重试!' })); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | const handleExport = async () => { |
| | | const hide = message.loading('正在导出'); |
| | | const handleExport = async (intl) => { |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.exporting', defaultMessage: '正在导出' })); |
| | | try { |
| | | const resp = await Http.doPostBlob('api/user/export'); |
| | | const blob = new Blob([resp], { type: 'application/vnd.ms-excel' }); |
| | | window.location.href = window.URL.createObjectURL(blob); |
| | | message.success('导出成功'); |
| | | message.success(intl.formatMessage({ id: 'page.export.success', defaultMessage: '导出成功' })); |
| | | return true; |
| | | } catch (error) { |
| | | message.error('导出失败,请重试'); |
| | | message.error(intl.formatMessage({ id: 'page.export.fail', defaultMessage: '导出失败,请重试' })); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | const handlePwd = async (val) => { |
| | | const hide = message.loading('正在重置'); |
| | | const handlePwd = async (val, intl) => { |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.resetting', defaultMessage: '正在重置' })); |
| | | try { |
| | | const resp = await Http.doPost('api/user/reset/pwd', val); |
| | | if (resp.code === 200) { |
| | | message.success('重置成功'); |
| | | message.success(intl.formatMessage({ id: 'page.reset.success', defaultMessage: '重置成功' })); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.error('重置失败请重试!'); |
| | | message.error(intl.formatMessage({ id: 'page.reset.fail', defaultMessage: '重置失败请重试!' })); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | |
| | | |
| | | |
| | | const Main = () => { |
| | | const intl = useIntl(); |
| | | const formTableRef = useRef(); |
| | | const actionRef = useRef(); |
| | | const [selectedRows, setSelectedRows] = useState([]); |
| | |
| | | const treeAllKeys = getTreeAllKeys(treeData); |
| | | setDeptExpandedKeys(treeAllKeys); |
| | | }).catch((err) => { |
| | | console.error(err); |
| | | setDeptTreeLoading(false); |
| | | }) |
| | | } |
| | |
| | | |
| | | const columns = [ |
| | | { |
| | | title: 'No', |
| | | title: intl.formatMessage({ |
| | | id: 'page.table.no', |
| | | defaultMessage: 'No' |
| | | }), |
| | | dataIndex: 'index', |
| | | valueType: 'indexBorder', |
| | | width: 30, |
| | | width: 48, |
| | | }, |
| | | { |
| | | title: '部门', |
| | | dataIndex: 'deptId$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 100, |
| | | render: (_, record) => { |
| | | if (_ && _ !== '-') { |
| | | return <Tag color={""}>{_}</Tag> |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | copyable: true, |
| | | width: 100, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='username' |
| | | {...props} |
| | |
| | | dataIndex: 'nickname', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 100, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='nickname' |
| | | {...props} |
| | |
| | | dataIndex: 'password', |
| | | valueType: 'password', |
| | | hidden: false, |
| | | width: 100, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='password' |
| | | {...props} |
| | |
| | | dataIndex: 'avatar', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='avatar' |
| | | {...props} |
| | |
| | | dataIndex: 'code', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='code' |
| | | {...props} |
| | |
| | | dataIndex: 'sex$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 80, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='sex' |
| | | {...props} |
| | |
| | | dataIndex: 'phone', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 100, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='phone' |
| | | {...props} |
| | |
| | | dataIndex: 'email', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='email' |
| | | {...props} |
| | |
| | | dataIndex: 'emailVerified$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='emailVerified' |
| | | {...props} |
| | |
| | | ]} |
| | | />, |
| | | }, |
| | | // { |
| | | // title: '角色', |
| | | // valueType: 'text', |
| | | // hidden: false, |
| | | // width: 100, |
| | | // render: (_, record) => { |
| | | // if (record.roleIds && record.roleIds.length > 0) { |
| | | // Http.doGetPromise('api/role/list/name/' + record.roleIds.join(','), null, (res) => { |
| | | // return '-' |
| | | // }); |
| | | // } else { |
| | | // return '-' |
| | | // } |
| | | // }, |
| | | // }, |
| | | { |
| | | title: '真实姓名', |
| | | dataIndex: 'realName', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='realName' |
| | | {...props} |
| | |
| | | dataIndex: 'idCard', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='idCard' |
| | | {...props} |
| | |
| | | dataIndex: 'birthday', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='birthday' |
| | | {...props} |
| | |
| | | dataIndex: 'introduction', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='introduction' |
| | | {...props} |
| | |
| | | dataIndex: 'status$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 80, |
| | | render: (_, record) => { |
| | | const status = statusMap[record.status] |
| | | return <Tag color={status.color}>{status.text}</Tag> |
| | |
| | | dataIndex: 'createTime$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <DatetimeRangeFilter |
| | | name='createTime' |
| | | {...props} |
| | |
| | | dataIndex: 'updateTime$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <DatetimeRangeFilter |
| | | name='updateTime' |
| | | {...props} |
| | |
| | | dataIndex: 'updateBy$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='updateBy' |
| | | major='user' |
| | |
| | | dataIndex: 'memo', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='memo' |
| | | {...props} |
| | |
| | | { |
| | | title: '操作', |
| | | dataIndex: 'option', |
| | | width: 120, |
| | | valueType: 'option', |
| | | width: 180, |
| | | render: (_, record) => [ |
| | | <Button |
| | | type="link" |
| | |
| | | setCurrentRow(record); |
| | | }} |
| | | > |
| | | 编辑 |
| | | <FormattedMessage id='page.edit' defaultMessage='编辑' /> |
| | | </Button>, |
| | | <Button |
| | | type="link" |
| | |
| | | setCurrentRow(record); |
| | | }} |
| | | > |
| | | 重置密码 |
| | | <FormattedMessage id='page.reset.pwd' defaultMessage='重置密码' /> |
| | | </Button>, |
| | | <Button |
| | | type="link" |
| | |
| | | key="remove" |
| | | onClick={async () => { |
| | | Modal.confirm({ |
| | | title: '删除', |
| | | content: '确定删除该项吗?', |
| | | title: intl.formatMessage({ id: 'page.delete', defaultMessage: '删除' }), |
| | | content: intl.formatMessage({ id: 'page.delete.confirm', defaultMessage: '确定删除该项吗?' }), |
| | | onOk: async () => { |
| | | const success = await handleRemove([record]); |
| | | const success = await handleRemove([record], intl); |
| | | if (success) { |
| | | if (actionRef.current) { |
| | | actionRef.current.reload(); |
| | |
| | | }); |
| | | }} |
| | | > |
| | | 删除 |
| | | <FormattedMessage id='page.delete' defaultMessage='删除' /> |
| | | </Button>, |
| | | <TableDropdown |
| | | key="actionGroup" |
| | |
| | | } |
| | | }} |
| | | menus={[ |
| | | { key: 'assign', name: '分配角色' }, |
| | | { key: 'assign', name: intl.formatMessage({ id: 'page.assign.role', defaultMessage: '分配角色' }) }, |
| | | ]} |
| | | />, |
| | | ], |
| | |
| | | > |
| | | <Row gutter={[16, 24]}> |
| | | <Col lg={6} md={24}> |
| | | <Card title="部门" style={{ width: '100%', height: 'calc(100vh - 160px)' }}> |
| | | <Card |
| | | title={intl.formatMessage({ id: 'system.dept', defaultMessage: '部门' })} |
| | | style={{ width: '100%', height: 'calc(100vh - 160px)' }} |
| | | > |
| | | <Input |
| | | style={{ marginBottom: 10 }} |
| | | placeholder="请输入" |
| | | placeholder={intl.formatMessage({ id: 'commont.enter', defaultMessage: '请输入' })} |
| | | onChange={(e) => { |
| | | const { value } = e.target; |
| | | loadDeptTreeData({ |
| | |
| | | columns={columns} |
| | | cardBordered |
| | | size='small' |
| | | scroll={{ y: boxHeight }} |
| | | // scroll={{ y: boxHeight }} |
| | | dateFormatter="string" |
| | | pagination={{ pageSize: 20 }} |
| | | pagination={{ pageSize: 12 }} |
| | | search={false} |
| | | toolbar={{ |
| | | search: { |
| | |
| | | hidden={selectedRows?.length === 0} |
| | | onClick={async () => { |
| | | Modal.confirm({ |
| | | title: '是否确认删除所选数据项?', |
| | | title: intl.formatMessage({ id: 'page.delete', defaultMessage: '删除' }), |
| | | content: intl.formatMessage({ id: 'page.delete.confirm', defaultMessage: '确定删除该项吗?' }), |
| | | icon: <ExclamationCircleOutlined />, |
| | | content: '请谨慎操作', |
| | | async onOk() { |
| | | const success = await handleRemove(selectedRows); |
| | | const success = await handleRemove(selectedRows, intl); |
| | | if (success) { |
| | | setSelectedRows([]); |
| | | actionRef.current.reload(); |
| | |
| | | }} |
| | | > |
| | | <DeleteOutlined /> |
| | | 删除 |
| | | <FormattedMessage id='page.delete' defaultMessage='删除' /> |
| | | </Button>, |
| | | <Button |
| | | type="primary" |
| | |
| | | }} |
| | | > |
| | | <PlusOutlined /> |
| | | 添加 |
| | | <FormattedMessage id='page.add' defaultMessage='添加' /> |
| | | </Button>, |
| | | <Button |
| | | key="export" |
| | | onClick={async () => { |
| | | handleExport(); |
| | | handleExport(intl); |
| | | }} |
| | | > |
| | | <ExportOutlined /> |
| | | 导出 |
| | | <FormattedMessage id='page.export' defaultMessage='导出' /> |
| | | </Button>, |
| | | ], |
| | | }} |
| | |
| | | onSubmit={async (values) => { |
| | | let ok = false; |
| | | if (values.id) { |
| | | ok = await handleUpdate({ ...values }) |
| | | ok = await handleUpdate({ ...values }, intl) |
| | | } else { |
| | | ok = await handleSave({ ...values }) |
| | | ok = await handleSave({ ...values }, intl) |
| | | } |
| | | if (ok) { |
| | | setModalVisible(false); |
| | |
| | | onSubmit={async (values) => { |
| | | let ok = false; |
| | | if (values.id) { |
| | | ok = await handlePwd({ ...values }) |
| | | ok = await handlePwd({ ...values }, intl) |
| | | } |
| | | if (ok) { |
| | | setPwdModalVisible(false); |
| | |
| | | onSubmit={async (values) => { |
| | | let ok = false; |
| | | if (values.id) { |
| | | ok = await handleUpdate({ ...values }) |
| | | ok = await handleUpdate({ ...values }, intl) |
| | | } |
| | | if (ok) { |
| | | setAssignModalVisible(false); |