浏览代码

fix: 详情只读的代码优化

outaozhen 3 年之前
父节点
当前提交
2109ae5041

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

@@ -44,7 +44,6 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
   schema,
   dispatch,
   type,
-  readOnly,
   defaultFormData,
   accountTypeList,
   reload
@@ -253,7 +252,7 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
             schema={schema}
             onFinish={onFinish}
             onMount={onMount}
-            readOnly={readOnly}
+            readOnly={type === ModalType.PREVIEW ? true : null}
             widgets={{ site: SiteInput }}
             watch={watch}
           />

+ 0 - 4
src/pages/Institutions/Staff/index.tsx

@@ -80,7 +80,6 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
             setState({
               ...state,
               visible: true,
-              readOnly: true,
               currentModalType: ModalType.PREVIEW,
               defaultFormData: {
                 // ...record,
@@ -166,7 +165,6 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
               setState({
                 ...state,
                 visible: true,
-                readOnly: false,
                 currentModalType: ModalType.UPDATE,
                 defaultFormData: {
                   // ...record,
@@ -229,7 +227,6 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
                 setState({
                   ...state,
                   visible: true,
-                  readOnly: false,
                   currentModalType: ModalType.ADD
                 })
               }>
@@ -246,7 +243,6 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
           type={state.currentModalType}
           defaultFormData={state.defaultFormData}
           visible={state.visible}
-          readOnly={state.readOnly}
           institutionDisable={state.institutionDisable}
           reload={() => tRef.current?.reload()}
           onVisibleChange={(visible: boolean) => setState({ ...state, visible })}

+ 10 - 2
src/pages/Project/Management/components/Detail.tsx

@@ -10,7 +10,7 @@ import type { ConnectProps } from 'umi'
 import type { ProjectModelState } from '../../model'
 import ProForm, { ProFormSelect } from '@ant-design/pro-form'
 import TreeNodeSelect from './TreeNodeSelect'
-import type { ModalType } from '@/utils/enum'
+import { ModalType } from '@/utils/enum'
 
 type ProjectModalProps = ConnectProps & {
   visible: boolean
@@ -28,6 +28,7 @@ const DetailModal: React.FC<ProjectModalProps> = ({
   onVisibleChange,
   dispatch,
   schema,
+  type,
   defaultFormData,
   pTypeList,
   reload
@@ -119,7 +120,14 @@ const DetailModal: React.FC<ProjectModalProps> = ({
   return (
     <Tabs onChange={onChange}>
       <TabPane tab="项目信息" key="1">
-        {schema && <FormRender form={form} schema={schema} onMount={onMount} readOnly={true} />}
+        {schema && (
+          <FormRender
+            form={form}
+            schema={schema}
+            onMount={onMount}
+            readOnly={type === ModalType.PREVIEW ? true : null}
+          />
+        )}
       </TabPane>
       <TabPane tab="审批流程" key="2">
         <ProForm