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 | 217 ++++++++++++++++++++++++++++++++++++------------------
1 files changed, 144 insertions(+), 73 deletions(-)
diff --git a/zy-asrs-flow/src/pages/system/user/index.jsx b/zy-asrs-flow/src/pages/system/user/index.jsx
index 5734465..dae8e2a 100644
--- a/zy-asrs-flow/src/pages/system/user/index.jsx
+++ b/zy-asrs-flow/src/pages/system/user/index.jsx
@@ -1,17 +1,19 @@
import React, { useState, useRef, useEffect } from 'react';
-import { Button, message, Modal, Row, Col, Card, Tree, Input } 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, DownOutlined } 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湪娣诲姞');
@@ -87,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();
@@ -98,20 +119,26 @@
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();
- Http.doPostPromise('/api/dept/tree', {}, (res) => {
- const rootMenu = { id: 0, name: '鍏ㄩ儴', value: 0, children: [] };
- rootMenu.children = res.data;
- const treeData = transformTreeData([rootMenu]);
- setDeptTreeData(treeData);
- const treeAllKeys = getTreeAllKeys(treeData);
- setDeptExpandedKeys(treeAllKeys);
- })
+ loadDeptTreeData();
return () => window.removeEventListener('resize', handleResize);
}, []);
@@ -124,12 +151,11 @@
width: 30,
},
{
- title: '鏄电О',
+ title: '鍚嶇О',
dataIndex: 'nickname',
valueType: 'text',
hidden: false,
width: 100,
- copyable: true,
filterDropdown: (props) => <TextFilter
name='nickname'
{...props}
@@ -138,7 +164,7 @@
/>,
},
{
- title: '璐﹀彿',
+ title: '鐧诲綍璐﹀彿',
dataIndex: 'username',
valueType: 'text',
hidden: false,
@@ -256,13 +282,20 @@
valueType: 'text',
hidden: false,
width: 100,
- filterDropdown: (props) => <LinkFilter
- name='deptId'
- major='dept'
- {...props}
- actionRef={actionRef}
- setSearchParam={setSearchParam}
- />,
+ render: (_, record) => {
+ if (_ && _ !== '-') {
+ return <Tag color={""}>{_}</Tag>
+ } else {
+ return '-'
+ }
+ },
+ // filterDropdown: (props) => <LinkFilter
+ // name='deptId'
+ // major='dept'
+ // {...props}
+ // actionRef={actionRef}
+ // setSearchParam={setSearchParam}
+ // />,
},
{
title: '鐪熷疄濮撳悕',
@@ -322,6 +355,10 @@
valueType: 'text',
hidden: false,
width: 80,
+ render: (_, record) => {
+ const status = statusMap[record.status]
+ return <Tag color={status.color}>{status.text}</Tag>
+ },
filterDropdown: (props) => <SelectFilter
name='status'
{...props}
@@ -390,7 +427,7 @@
{
title: '鎿嶄綔',
dataIndex: 'option',
- width: 100,
+ width: 150,
valueType: 'option',
render: (_, record) => [
<Button
@@ -405,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: '鍒犻櫎',
@@ -442,25 +489,30 @@
placeholder="Search"
onChange={(e) => {
const { value } = e.target;
- console.log(value);
+ loadDeptTreeData({
+ condition: value
+ })
}}
/>
- <Tree
- showLine
- blockNode
- defaultExpandAll // 寮傛鍔犺浇澶辨晥
- expandedKeys={deptExpandedKeys}
- treeData={deptTreeData}
- switcherIcon={<DownOutlined />}
- onSelect={(selectedKeys, info) => {
- const deptId = selectedKeys[0];
- setSearchParam(prevState => ({
- ...prevState,
- deptId: deptId
- }));
- actionRef.current?.reload();
- }}
- />
+ <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}>
@@ -471,7 +523,7 @@
formRef={formTableRef}
columns={columns}
cardBordered
- scroll={{y: boxHeight }}
+ scroll={{ y: boxHeight }}
dateFormatter="string"
pagination={{ pageSize: 20 }}
search={false}
@@ -495,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)
@@ -515,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,
@@ -523,6 +599,7 @@
}
})
}
+ tableAlertRender={false}
rowSelection={{
onChange: (ids, rows) => {
setSelectedRows(rows);
@@ -540,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);
@@ -598,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