Bladeren bron

feat: 111

lanjianrong 3 jaren geleden
bovenliggende
commit
0435a3e467

+ 2 - 1
src/pages/Institutions/Company/Detail/components/Staff.tsx

@@ -6,13 +6,14 @@ import consts from '@/utils/consts'
 import { connect } from 'umi'
 import dayjs from 'dayjs'
 import { queryAcountList } from '@/services/api/institution'
-import StaffDetail, { ModalType } from '@/pages/Institutions/Staff/components/StaffDetail'
+import StaffDetail from '@/pages/Institutions/Staff/components/StaffDetail'
 import type { SchemaBaseModelState } from '@/pages/Schema/Base/model'
 import { BaseMenuEnum } from '@/pages/Schema/Base'
 import type { InstitutionsModelState } from '@/pages/Institutions/model'
 import { generateColumns } from '@/utils/util'
 import { genderEum } from '@/pages/Institutions/Staff'
 import AnimateContent from '@/components/AnimateContent'
+import { ModalType } from '@/utils/enum'
 
 type ListProps = ConnectProps & {
   accountType: API.AccountType[]

+ 13 - 14
src/pages/Institutions/Staff/components/StaffDetail.tsx

@@ -17,10 +17,7 @@ import type { ConnectProps } from 'umi'
 import type { InstitutionsModelState } from '../../model'
 
 import 'antd/lib/tree-select/style/index'
-export enum ModalType {
-  ADD = 0,
-  UPDATE = 1
-}
+import { ModalType } from '@/utils/enum'
 
 type StaffModalProps = ConnectProps & {
   visible: boolean
@@ -123,16 +120,16 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
   }
 
   const onMount = () => {
-    form.setValues({ ...defaultFormData })
+    form.setValues(type === ModalType.ADD ? {} : { ...defaultFormData })
     delay(80).then(() => {
       form.setSchemaByPath('accountType', {
         type: 'string',
         widget: 'select',
-        props: {
-          options: accountTypeList
-        }
-        // enum: accountTypeList.map(item => item.value),
-        // enumNames: accountTypeList.map(item => item.label)
+        // props: {
+        //   options: accountTypeList
+        // }
+        enum: accountTypeList.map(item => item.value),
+        enumNames: accountTypeList.map(item => item.label)
       })
       form.setSchemaByPath('institutionID', {
         type: 'string',
@@ -222,7 +219,7 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
       <div className="text-xl mb-6">
         {type === ModalType.ADD ? '新增账号' : null}
         {type === ModalType.UPDATE ? '编辑账号' : null}
-        {type === ModalType.DETAIL ? '员工详情' : null}
+        {type === ModalType.PREVIEW ? '员工详情' : null}
       </div>
       <Form>
         {schema && (
@@ -236,9 +233,11 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
           />
         )}
         <div className="ml-120px">
-          <Button type="primary" onClick={form.submit}>
-            提交
-          </Button>
+          {type !== ModalType.PREVIEW && (
+            <Button type="primary" onClick={form.submit}>
+              提交
+            </Button>
+          )}
         </div>
       </Form>
     </div>

+ 3 - 3
src/pages/Institutions/Staff/index.tsx

@@ -10,11 +10,12 @@ import type { InstitutionsModelState } from '../model'
 // import StaffModal, { ModalType } from './components/StaffModal'
 import { queryAcountList } from '@/services/api/institution'
 import dayjs from 'dayjs'
-import StaffDetail, { ModalType } from './components/StaffDetail'
+import StaffDetail from './components/StaffDetail'
 import type { SchemaBaseModelState } from '@/pages/Schema/Base/model'
 import { BaseMenuEnum } from '@/pages/Schema/Base'
 import { generateColumns } from '@/utils/util'
 import AnimateContent from '@/components/AnimateContent'
+import { ModalType } from '@/utils/enum'
 
 type ListProps = ConnectProps & {
   accountTypeList: { label: string; value: string }[]
@@ -78,8 +79,7 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
             setState({
               ...state,
               visible: true,
-              readOnly: true,
-              currentModalType: ModalType.DETAIL,
+              currentModalType: ModalType.PREVIEW,
               defaultFormData: {
                 // ...record,
                 institution: null,

+ 2 - 1
src/utils/enum.ts

@@ -1,5 +1,6 @@
 // 适用于抽屉/弹窗表单
 export enum ModalType {
   ADD = 0,
-  UPDATE = 1
+  UPDATE = 1,
+  PREVIEW = 2
 }