|  |  |  | 
|---|
|  |  |  | 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' | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handlePwd = async (val) => { | 
|---|
|  |  |  | const hide = message.loading('正在重置'); | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | 
|---|
|  |  |  | const [boxHeight, setBoxHeight] = useState(); | 
|---|
|  |  |  | const [deptTreeData, setDeptTreeData] = useState([]); | 
|---|
|  |  |  | const [deptExpandedKeys, setDeptExpandedKeys] = useState([]); | 
|---|
|  |  |  | const [pwdModalVisible, setPwdModalVisible] = useState(false); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | useEffect(() => { | 
|---|
|  |  |  | const handleResize = () => setBoxHeight(window.innerHeight - 368); | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | title: '操作', | 
|---|
|  |  |  | dataIndex: 'option', | 
|---|
|  |  |  | width: 100, | 
|---|
|  |  |  | width: 150, | 
|---|
|  |  |  | valueType: 'option', | 
|---|
|  |  |  | render: (_, record) => [ | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | 编辑 | 
|---|
|  |  |  | </Button>, | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | type="link" | 
|---|
|  |  |  | key="pwd" | 
|---|
|  |  |  | onClick={() => { | 
|---|
|  |  |  | setPwdModalVisible(true); | 
|---|
|  |  |  | setCurrentRow(record); | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | 重置密码 | 
|---|
|  |  |  | </Button>, | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | type="link" | 
|---|
|  |  |  | 
|---|
|  |  |  | formRef={formTableRef} | 
|---|
|  |  |  | columns={columns} | 
|---|
|  |  |  | cardBordered | 
|---|
|  |  |  | scroll={{y: boxHeight }} | 
|---|
|  |  |  | scroll={{ y: boxHeight }} | 
|---|
|  |  |  | dateFormatter="string" | 
|---|
|  |  |  | pagination={{ pageSize: 20 }} | 
|---|
|  |  |  | search={false} | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <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> | 
|---|
|  |  |  | ); | 
|---|