|
@@ -0,0 +1,188 @@
|
|
|
+import AnimateContent from '@/components/AnimateContent'
|
|
|
+import { queryAccountList, ResetAccountLogin } from '@/services/api/institution'
|
|
|
+import consts from '@/utils/consts'
|
|
|
+import { ModalType } from '@/utils/enum'
|
|
|
+import { PageContainer } from '@ant-design/pro-layout'
|
|
|
+import ProTable from '@ant-design/pro-table'
|
|
|
+import { useRequest } from '@umijs/max'
|
|
|
+import { Modal } from 'antd'
|
|
|
+import React, { useRef, useState } from 'react'
|
|
|
+import StaffDetail from '../Staff/components/StaffDetail'
|
|
|
+
|
|
|
+const Restrict = () => {
|
|
|
+ const tRef = useRef<ActionType>(null)
|
|
|
+ const [state, setState] = useState({
|
|
|
+ params: {
|
|
|
+ search: null,
|
|
|
+ accountType: '1',
|
|
|
+ failLogin: true
|
|
|
+ },
|
|
|
+ title: '',
|
|
|
+ visible: false,
|
|
|
+ currentModalType: ModalType.ADD,
|
|
|
+ defaultFormData: {},
|
|
|
+ account: null,
|
|
|
+ name: null
|
|
|
+ })
|
|
|
+
|
|
|
+ const { run: tryResetAccount } = useRequest(ResetAccountLogin, {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: () => tRef.current?.reload()
|
|
|
+ })
|
|
|
+ const handleResetAccount = (ID: string) => {
|
|
|
+ Modal.confirm({
|
|
|
+ title: '解除限制',
|
|
|
+ content: (
|
|
|
+ <div>
|
|
|
+ <div>
|
|
|
+ {state.account} / {state.name}
|
|
|
+ </div>
|
|
|
+ <div>确认移除该账号的登录限制</div>
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ okButtonProps: {
|
|
|
+ danger: true
|
|
|
+ },
|
|
|
+ onOk: () => tryResetAccount({ ID })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ const columns: ProColumnType = [
|
|
|
+ {
|
|
|
+ dataIndex: 'account',
|
|
|
+ key: 'account',
|
|
|
+ title: '账号',
|
|
|
+ width: 116,
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } }),
|
|
|
+ render: (name, record) => (
|
|
|
+ <div
|
|
|
+ className="text-primary cursor-pointer hover:text-hex-967bbd"
|
|
|
+ onClick={() => {
|
|
|
+ setState({
|
|
|
+ ...state,
|
|
|
+ visible: true,
|
|
|
+ currentModalType: ModalType.PREVIEW,
|
|
|
+ title: record.name,
|
|
|
+ defaultFormData: record
|
|
|
+ })
|
|
|
+ }}>
|
|
|
+ {name}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'name',
|
|
|
+ key: 'name',
|
|
|
+ title: '名称',
|
|
|
+ width: 86,
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'institutionID',
|
|
|
+ key: 'institutionID',
|
|
|
+ title: '所属企事业单位',
|
|
|
+ width: 286,
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } }),
|
|
|
+ renderText: (_, record) => record.institution.name
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'contactMobile',
|
|
|
+ key: 'contactMobile',
|
|
|
+ title: '联系手机',
|
|
|
+ width: 116,
|
|
|
+ align: 'center',
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'officePhone',
|
|
|
+ key: 'officePhone',
|
|
|
+ title: '办公电话',
|
|
|
+ width: 136,
|
|
|
+ align: 'center',
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ dataIndex: 'createdTime',
|
|
|
+ key: 'createdTime',
|
|
|
+ width: 106,
|
|
|
+ align: 'center',
|
|
|
+ title: '创建时间',
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'operate',
|
|
|
+ width: 61,
|
|
|
+ align: 'center',
|
|
|
+ onHeaderCell: () => ({ style: { textAlign: 'center' } }),
|
|
|
+ render: (_, record) => (
|
|
|
+ <div className="divide-x divide-bg-gray-400 flex flex-row justify-center">
|
|
|
+ <div
|
|
|
+ className="text-red cursor-pointer hover:text-hex-967bbd"
|
|
|
+ onClick={() => {
|
|
|
+ setState({
|
|
|
+ ...state,
|
|
|
+ account: record.account,
|
|
|
+ name: record.name
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ handleResetAccount(record.ID)
|
|
|
+ }, 80)
|
|
|
+ }}>
|
|
|
+ 解除限制
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ return (
|
|
|
+ <PageContainer title={false}>
|
|
|
+ <ProTable
|
|
|
+ rowKey="ID"
|
|
|
+ actionRef={tRef}
|
|
|
+ params={state.params}
|
|
|
+ columns={columns}
|
|
|
+ search={false}
|
|
|
+ request={async (params, filter, sorter) => {
|
|
|
+ const { code = -1, data: { items = [], total = 0, iCount = 0 } = {} } = await queryAccountList({
|
|
|
+ ...params,
|
|
|
+ ...filter,
|
|
|
+ ...sorter
|
|
|
+ })
|
|
|
+
|
|
|
+ setState({ ...state, total: iCount })
|
|
|
+ return {
|
|
|
+ data: items,
|
|
|
+ success: code === consts.RET_CODE.SUCCESS,
|
|
|
+ total
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ toolbar={{
|
|
|
+ search: {
|
|
|
+ // onSearch: val => setState({ ...state, params: { ...state.params, search: val } }),
|
|
|
+ style: { width: '250px' },
|
|
|
+ placeholder: '请输入账号、姓名、企事业单位'
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <AnimateContent
|
|
|
+ title={
|
|
|
+ <>
|
|
|
+ {state.currentModalType === ModalType.UPDATE ? `编辑账号(${state.title})` : null}
|
|
|
+ {state.currentModalType === ModalType.PREVIEW ? `员工详情(${state.title})` : null}
|
|
|
+ </>
|
|
|
+ }
|
|
|
+ visible={state.visible}
|
|
|
+ onVisibleChange={visible => setState({ ...state, visible })}>
|
|
|
+ <StaffDetail
|
|
|
+ type={state.currentModalType}
|
|
|
+ defaultFormData={state.defaultFormData}
|
|
|
+ visible={state.visible}
|
|
|
+ reload={() => tRef.current?.reload()}
|
|
|
+ onVisibleChange={(visible: boolean) => setState({ ...state, visible })}
|
|
|
+ />
|
|
|
+ </AnimateContent>
|
|
|
+ </PageContainer>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+export default Restrict
|