From 4160326ccc141dfe8f10a609f051918c75c92e26 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 21 二月 2024 15:17:12 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/system/user/components/pwd.jsx | 74 ++++++++++++++++++++++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/system/controller/UserController.java | 15 +++++
zy-asrs-flow/src/pages/system/user/index.jsx | 60 +++++++++++++++++++
3 files changed, 147 insertions(+), 2 deletions(-)
diff --git a/zy-asrs-flow/src/pages/system/user/components/pwd.jsx b/zy-asrs-flow/src/pages/system/user/components/pwd.jsx
new file mode 100644
index 0000000..755e45b
--- /dev/null
+++ b/zy-asrs-flow/src/pages/system/user/components/pwd.jsx
@@ -0,0 +1,74 @@
+import React, { useState, useRef, useEffect } from 'react';
+import {
+ ProForm,
+ ProFormDigit,
+ ProFormText,
+} from '@ant-design/pro-components';
+import { Form, Modal } from 'antd';
+
+const Pwd = (props) => {
+ const [form] = Form.useForm();
+ const { } = props;
+
+ delete props.values.password
+
+ useEffect(() => {
+ form.resetFields();
+ form.setFieldsValue({
+ ...props.values
+ })
+ }, [form, props])
+
+ const handleCancel = () => {
+ props.onCancel();
+ };
+
+ const handleOk = () => {
+ form.submit();
+ }
+
+ const handleFinish = async (values) => {
+ props.onSubmit({ ...values });
+ }
+
+ return (
+ <>
+ <Modal
+ title="Reset Password"
+ width={400}
+ forceRender
+ destroyOnClose
+ open={props.open}
+ onCancel={handleCancel}
+ onOk={handleOk}
+ >
+ <ProForm
+ form={form}
+ submitter={false}
+ onFinish={handleFinish}
+ layout="horizontal"
+ grid={true}
+ >
+ <ProFormDigit
+ name="id"
+ disabled
+ hidden={true}
+ />
+ <ProFormText
+ name="password"
+ label="鏂板瘑鐮�"
+ colProps={{ md: 24, xl: 24 }}
+ placeholder="璇疯緭鍏�"
+ rules={[
+ { required: true, message: "瀵嗙爜涓嶈兘涓虹┖锛�" },
+ { min: 4, message: "瀵嗙爜涓嶈兘灏忎簬4浣�! " },
+ { max: 16, message: "瀵嗙爜涓嶈兘澶т簬16浣�! " },
+ ]}
+ />
+ </ProForm>
+ </Modal>
+ </>
+ )
+}
+
+export default Pwd;
diff --git a/zy-asrs-flow/src/pages/system/user/index.jsx b/zy-asrs-flow/src/pages/system/user/index.jsx
index 18fafb5..a967879 100644
--- a/zy-asrs-flow/src/pages/system/user/index.jsx
+++ b/zy-asrs-flow/src/pages/system/user/index.jsx
@@ -10,6 +10,7 @@
import { PlusOutlined, ExportOutlined, DownOutlined } 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'
@@ -88,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();
@@ -99,6 +119,7 @@
const [boxHeight, setBoxHeight] = useState();
const [deptTreeData, setDeptTreeData] = useState([]);
const [deptExpandedKeys, setDeptExpandedKeys] = useState([]);
+ const [pwdModalVisible, setPwdModalVisible] = useState(false);
useEffect(() => {
const handleResize = () => setBoxHeight(window.innerHeight - 368);
@@ -401,7 +422,7 @@
{
title: '鎿嶄綔',
dataIndex: 'option',
- width: 100,
+ width: 150,
valueType: 'option',
render: (_, record) => [
<Button
@@ -413,6 +434,16 @@
}}
>
缂栬緫
+ </Button>,
+ <Button
+ type="link"
+ key="pwd"
+ onClick={() => {
+ setPwdModalVisible(true);
+ setCurrentRow(record);
+ }}
+ >
+ 閲嶇疆瀵嗙爜
</Button>,
<Button
type="link"
@@ -482,7 +513,7 @@
formRef={formTableRef}
columns={columns}
cardBordered
- scroll={{y: boxHeight }}
+ scroll={{ y: boxHeight }}
dateFormatter="string"
pagination={{ pageSize: 20 }}
search={false}
@@ -610,6 +641,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>
);
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/system/controller/UserController.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/system/controller/UserController.java
index d16855d..bcaba13 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/system/controller/UserController.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/system/controller/UserController.java
@@ -113,4 +113,19 @@
ExcelUtil.build(ExcelUtil.create(userService.list(), User.class), response);
}
+ @PreAuthorize("hasAuthority('system:user:update')")
+ @OperationLog("閲嶇疆瀵嗙爜")
+ @PostMapping("/user/reset/pwd")
+ public R resetPwd(@RequestBody User user) {
+ if (!Cools.isEmpty(user.getPassword())) {
+ user.setPassword(userService.encodePassword(user.getPassword()));
+ }
+ user.setUpdateBy(getLoginUserId());
+ user.setUpdateTime(new Date());
+ if (!userService.updateById(user)) {
+ return R.error("閲嶇疆澶辫触");
+ }
+ return R.ok("閲嶇疆鎴愬姛");
+ }
+
}
--
Gitblit v1.9.1