Browse Source

feat: 后台密码错误被禁用列表相关

outaozhen 3 years atrás
parent
commit
341179f50c

+ 5 - 0
config/routes.ts

@@ -95,6 +95,11 @@
         path: 'staff',
         name: 'staff',
         component: './Institutions/Staff'
+      },
+      {
+        path: 'restrict',
+        name: 'restrict',
+        component: './Institutions/Restrict'
       }
     ]
   },

+ 1 - 0
src/locales/zh-CN/menu.ts

@@ -24,6 +24,7 @@ export default {
   'menu.institutions': '企事业单位',
   'menu.institutions.company': '单位管理',
   'menu.institutions.staff': '人员管理',
+  'menu.institutions.restrict': '限制登录',
   'menu.business': '业务审批设置',
   'menu.business.inventory': '资料签收清单模板',
   'menu.business.process': '流程用户设置',

+ 188 - 0
src/pages/Institutions/Restrict/index.tsx

@@ -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

+ 8 - 0
src/services/api/institution.ts

@@ -70,6 +70,14 @@ export async function queryAccountDetail(params: { ID: string }) {
   })
 }
 
+/** 账号重置登录 */
+export async function ResetAccountLogin(params: API.AcountUpdateParams) {
+  return request('/account/reset/login', {
+    method: 'POST',
+    data: params
+  })
+}
+
 /** 获取账号类型 */
 export async function getAccountTypeList() {
   return request('/account/type', {

+ 6 - 0
src/services/api/typings.d.ts

@@ -369,4 +369,10 @@ declare namespace API {
     name?: string
     accountIDs?: AccountListItem[]
   }
+
+  type ApprovalAccountDetail = {
+    name: string
+    institutionID: string
+    accountIDs: []
+  }
 }