From 074513acdfed38c8537a046801ee5dbc8f01e2eb Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 22 二月 2024 10:06:42 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/system/user/index.jsx | 231 ++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 168 insertions(+), 63 deletions(-)
diff --git a/zy-asrs-flow/src/pages/system/user/index.jsx b/zy-asrs-flow/src/pages/system/user/index.jsx
index ef79296..dae8e2a 100644
--- a/zy-asrs-flow/src/pages/system/user/index.jsx
+++ b/zy-asrs-flow/src/pages/system/user/index.jsx
@@ -1,16 +1,19 @@
import React, { useState, useRef, useEffect } from 'react';
-import { Button, message, Modal, Row, Col, Card } from 'antd';
+import { Button, message, Modal, Row, Col, Card, Tree, Input, Tag } from 'antd';
import {
FooterToolbar,
PageContainer,
ProTable,
LightFilter,
} from '@ant-design/pro-components';
-import { PlusOutlined, ExportOutlined } from '@ant-design/icons';
+import { PlusOutlined, ExportOutlined, DownOutlined, DeleteOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
import Http from '@/utils/http';
import Edit from './components/edit'
+import Pwd from './components/pwd'
import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch'
+import { transformTreeData, getTreeAllKeys } from '@/utils/tree-util'
+import { statusMap } from '@/utils/enum-util'
const handleSave = async (val) => {
const hide = message.loading('姝e湪娣诲姞');
@@ -86,6 +89,25 @@
}
};
+const handlePwd = async (val) => {
+ const hide = message.loading('姝e湪閲嶇疆');
+ try {
+ const resp = await Http.doPost('api/user/reset/pwd', val);
+ if (resp.code === 200) {
+ message.success('閲嶇疆鎴愬姛');
+ return true;
+ } else {
+ message.error(resp.msg);
+ return false;
+ }
+ } catch (error) {
+ message.error('閲嶇疆澶辫触璇烽噸璇曪紒');
+ return false;
+ } finally {
+ hide();
+ }
+};
+
const Main = () => {
const formTableRef = useRef();
@@ -95,28 +117,45 @@
const [currentRow, setCurrentRow] = useState();
const [searchParam, setSearchParam] = useState({});
const [boxHeight, setBoxHeight] = useState();
+ const [deptTreeData, setDeptTreeData] = useState([]);
+ const [deptExpandedKeys, setDeptExpandedKeys] = useState([]);
+ const [pwdModalVisible, setPwdModalVisible] = useState(false);
+
+ const loadDeptTreeData = (param) => {
+ Http.doPostPromise('/api/dept/tree', param, (res) => {
+ const rootMenu = { id: 0, name: '鍏ㄩ儴', value: 0, children: [] };
+ rootMenu.children = res.data;
+ // const treeData = transformTreeData([rootMenu]);
+ const treeData = transformTreeData(res.data);
+ setDeptTreeData(treeData);
+ const treeAllKeys = getTreeAllKeys(treeData);
+ setDeptExpandedKeys(treeAllKeys);
+ })
+ }
useEffect(() => {
const handleResize = () => setBoxHeight(window.innerHeight - 368);
window.addEventListener('resize', handleResize);
handleResize();
+
+ loadDeptTreeData();
+
return () => window.removeEventListener('resize', handleResize);
- }, [boxHeight]);
+ }, []);
const columns = [
{
title: 'No',
dataIndex: 'index',
valueType: 'indexBorder',
- width: 48,
+ width: 30,
},
{
- title: '鏄电О',
+ title: '鍚嶇О',
dataIndex: 'nickname',
valueType: 'text',
hidden: false,
- width: 140,
- copyable: true,
+ width: 100,
filterDropdown: (props) => <TextFilter
name='nickname'
{...props}
@@ -125,11 +164,11 @@
/>,
},
{
- title: '璐﹀彿',
+ title: '鐧诲綍璐﹀彿',
dataIndex: 'username',
valueType: 'text',
hidden: false,
- width: 140,
+ width: 100,
filterDropdown: (props) => <TextFilter
name='username'
{...props}
@@ -142,7 +181,7 @@
dataIndex: 'password',
valueType: 'password',
hidden: true,
- width: 140,
+ width: 100,
filterDropdown: (props) => <TextFilter
name='password'
{...props}
@@ -154,7 +193,7 @@
title: '澶村儚',
dataIndex: 'avatar',
valueType: 'text',
- hidden: false,
+ hidden: true,
width: 140,
filterDropdown: (props) => <TextFilter
name='avatar'
@@ -181,7 +220,7 @@
dataIndex: 'sex$',
valueType: 'text',
hidden: false,
- width: 140,
+ width: 80,
filterDropdown: (props) => <SelectFilter
name='sex'
{...props}
@@ -199,7 +238,7 @@
dataIndex: 'phone',
valueType: 'text',
hidden: false,
- width: 140,
+ width: 100,
filterDropdown: (props) => <TextFilter
name='phone'
{...props}
@@ -211,7 +250,7 @@
title: '閭',
dataIndex: 'email',
valueType: 'text',
- hidden: false,
+ hidden: true,
width: 140,
filterDropdown: (props) => <TextFilter
name='email'
@@ -242,14 +281,21 @@
dataIndex: 'deptId$',
valueType: 'text',
hidden: false,
- width: 140,
- filterDropdown: (props) => <LinkFilter
- name='deptId'
- major='dept'
- {...props}
- actionRef={actionRef}
- setSearchParam={setSearchParam}
- />,
+ width: 100,
+ render: (_, record) => {
+ if (_ && _ !== '-') {
+ return <Tag color={""}>{_}</Tag>
+ } else {
+ return '-'
+ }
+ },
+ // filterDropdown: (props) => <LinkFilter
+ // name='deptId'
+ // major='dept'
+ // {...props}
+ // actionRef={actionRef}
+ // setSearchParam={setSearchParam}
+ // />,
},
{
title: '鐪熷疄濮撳悕',
@@ -308,7 +354,11 @@
dataIndex: 'status$',
valueType: 'text',
hidden: false,
- width: 140,
+ width: 80,
+ render: (_, record) => {
+ const status = statusMap[record.status]
+ return <Tag color={status.color}>{status.text}</Tag>
+ },
filterDropdown: (props) => <SelectFilter
name='status'
{...props}
@@ -377,7 +427,7 @@
{
title: '鎿嶄綔',
dataIndex: 'option',
- width: 140,
+ width: 150,
valueType: 'option',
render: (_, record) => [
<Button
@@ -392,8 +442,18 @@
</Button>,
<Button
type="link"
+ key="pwd"
+ onClick={() => {
+ setPwdModalVisible(true);
+ setCurrentRow(record);
+ }}
+ >
+ 閲嶇疆瀵嗙爜
+ </Button>,
+ <Button
+ type="link"
danger
- key="batchRemove"
+ key="remove"
onClick={async () => {
Modal.confirm({
title: '鍒犻櫎',
@@ -423,10 +483,36 @@
>
<Row gutter={[16, 24]}>
<Col lg={6} md={24}>
- <Card title="閮ㄩ棬" extra={<a href="#">More</a>} style={{ width: '100%', height: 'calc(100vh - 200px)' }}>
- <p>Card content</p>
- <p>Card content</p>
- <p>Card content</p>
+ <Card title="閮ㄩ棬" style={{ width: '100%', height: 'calc(100vh - 200px)' }}>
+ <Input
+ style={{ marginBottom: 10 }}
+ placeholder="Search"
+ onChange={(e) => {
+ const { value } = e.target;
+ loadDeptTreeData({
+ condition: value
+ })
+ }}
+ />
+ <div style={{height: 'calc(100vh - 350px)', overflowY: 'auto' }}>
+ <Tree
+ showLine
+ blockNode
+ defaultExpandAll // 寮傛鍔犺浇澶辨晥
+ expandedKeys={deptExpandedKeys}
+ onExpand={setDeptExpandedKeys}
+ treeData={deptTreeData}
+ switcherIcon={<DownOutlined />}
+ onSelect={(selectedKeys, info) => {
+ const deptId = selectedKeys[0];
+ setSearchParam(prevState => ({
+ ...prevState,
+ deptId: deptId
+ }));
+ actionRef.current?.reload();
+ }}
+ />
+ </div>
</Card>
</Col>
<Col lg={18} md={24}>
@@ -437,7 +523,7 @@
formRef={formTableRef}
columns={columns}
cardBordered
- scroll={{ x: 1300, y: boxHeight }}
+ scroll={{ y: boxHeight }}
dateFormatter="string"
pagination={{ pageSize: 20 }}
search={false}
@@ -461,6 +547,30 @@
actions: [
<Button
type="primary"
+ danger
+ key="removeBatch"
+ hidden={selectedRows?.length === 0}
+ onClick={async () => {
+ Modal.confirm({
+ title: '鏄惁纭鍒犻櫎鎵�閫夋暟鎹」?',
+ icon: <ExclamationCircleOutlined />,
+ content: '璇疯皑鎱庢搷浣�',
+ async onOk() {
+ const success = await handleRemove(selectedRows);
+ if (success) {
+ setSelectedRows([]);
+ actionRef.current.reload();
+ }
+ },
+ onCancel() { },
+ });
+ }}
+ >
+ <DeleteOutlined />
+ 鍒犻櫎
+ </Button>,
+ <Button
+ type="primary"
key="save"
onClick={async () => {
setModalVisible(true)
@@ -481,7 +591,7 @@
],
}}
request={(params, sorter, filter) =>
- Http.doPostPromise('/api/user/page', { ...params, ...searchParam }, (res) => {
+ Http.doPostPromise('/api/user/page1', { ...params, ...searchParam }, (res) => {
return {
data: res.data.records,
total: res.data.total,
@@ -489,6 +599,7 @@
}
})
}
+ tableAlertRender={false}
rowSelection={{
onChange: (ids, rows) => {
setSelectedRows(rows);
@@ -506,41 +617,10 @@
/>
</Col>
- {selectedRows?.length > 0 && (
- <FooterToolbar
- extra={
- <div>
- 宸查�夋嫨
- <a style={{ fontWeight: 600 }}>{selectedRows.length}</a>
- 椤�
- </div>
- }
- >
- <Button
- key="remove"
- danger
- onClick={async () => {
- Modal.confirm({
- title: '鍒犻櫎',
- content: '纭畾鍒犻櫎璇ラ」鍚楋紵',
- onOk: async () => {
- const success = await handleRemove(selectedRows);
- if (success) {
- setSelectedRows([]);
- actionRef.current?.reloadAndRest?.();
- }
- },
- });
- }}
- >
- 鎵归噺鍒犻櫎
- </Button>
- </FooterToolbar>
- )}
-
<Edit
open={modalVisible}
values={currentRow || {}}
+ treeData={deptTreeData}
onCancel={
() => {
setModalVisible(false);
@@ -564,6 +644,31 @@
}
}
/>
+
+ <Pwd
+ open={pwdModalVisible}
+ values={currentRow || {}}
+ onCancel={
+ () => {
+ setPwdModalVisible(false);
+ setCurrentRow(undefined);
+ }
+ }
+ onSubmit={async (values) => {
+ let ok = false;
+ if (values.id) {
+ ok = await handlePwd({ ...values })
+ }
+ if (ok) {
+ setPwdModalVisible(false);
+ setCurrentRow(undefined);
+ if (actionRef.current) {
+ actionRef.current.reload();
+ }
+ }
+ }
+ }
+ />
</Row>
</PageContainer>
);
--
Gitblit v1.9.1