Selaa lähdekoodia

feat: 固定项字段调整

lanjianrong 3 vuotta sitten
vanhempi
commit
9ba1315771

+ 3 - 37
src/pages/Institutions/Company/Detail/components/Staff.tsx

@@ -46,11 +46,6 @@ const Staff: React.FC<ListProps> = ({
     total: null
   })
   useEffect(() => {
-    if (!accountTypeList.length) {
-      dispatch({
-        type: 'institutions/queryAccountTypeList'
-      })
-    }
     dispatch({
       type: 'schemaBase/querySchema',
       payload: {
@@ -148,23 +143,6 @@ const Staff: React.FC<ListProps> = ({
       renderText: (_, record) => record?.created?.name
     },
     {
-      dataIndex: 'accountType',
-      key: 'accountType',
-      title: '账号类型',
-      filters: true,
-      width: 96,
-      align: 'center',
-      onHeaderCell: () => ({ style: { textAlign: 'center' } }),
-      filterMultiple: false,
-      valueEnum: accountTypeList.reduce((prev, curr) => {
-        const items = { ...prev }
-        items[curr.value] = {
-          text: curr.label
-        }
-        return items
-      }, {})
-    },
-    {
       title: '操作',
       dataIndex: 'operation',
       width: 61,
@@ -273,18 +251,6 @@ const Staff: React.FC<ListProps> = ({
   )
 }
 
-export default connect(
-  ({
-    institutions,
-    schemaBase
-  }: {
-    institutions: InstitutionsModelState
-    schemaBase: SchemaBaseModelState
-  }) => ({
-    accountTypeList: institutions.accountType.map(item => ({
-      label: item.name,
-      value: item.value
-    })),
-    schema: schemaBase.base[BaseMenuEnum.STAFF]?.schema
-  })
-)(Staff)
+export default connect(({ schemaBase }: { schemaBase: SchemaBaseModelState }) => ({
+  schema: schemaBase.base[BaseMenuEnum.STAFF]?.schema
+}))(Staff)

+ 1 - 1
src/pages/Institutions/Company/List/components/CompanyDrawer.tsx

@@ -104,7 +104,7 @@ const CompanyDrawer: React.FC<CompanyModalProps> = ({
   return (
     <div className="mt-6">
       <div className="max-w-800px">
-        <Form form={formInstance}>
+        <Form form={formInstance} labelCol={6} wrapperCol={8}>
           <SchemaField schema={SchemaEnum?.[BaseMenuEnum.COMPANY]} />
           <SchemaField schema={companySchema} />
           <FormButtonGroup.Sticky>

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

@@ -178,7 +178,7 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
   })
 
   return (
-    <Form form={normalForm} labelCol={5} className="max-w-500px mt-6">
+    <Form form={normalForm} labelCol={6} wrapperCol={8} className="max-w-500px mt-6">
       <SchemaField schema={SchemaEnum?.[BaseMenuEnum.STAFF]} />
       <SchemaField schema={staffSchema} />
       <FormButtonGroup.Sticky>

+ 37 - 48
src/pages/Institutions/Staff/index.tsx

@@ -2,11 +2,8 @@ import ProTable from '@ant-design/pro-table'
 import type { ProColumnType, ActionType } from '@ant-design/pro-table'
 import { PageContainer } from '@ant-design/pro-layout'
 import consts from '@/utils/consts'
-import { useRef, useState, useEffect } from 'react'
-import { connect } from 'umi'
+import { useRef, useState } from 'react'
 import type { ConnectProps } from 'umi'
-import type { InstitutionsModelState } from '../model'
-// import StaffModal, { ModalType } from './components/StaffModal'
 import { queryAccountList } from '@/services/api/institution'
 import dayjs from 'dayjs'
 import StaffDetail from './components/StaffDetail'
@@ -22,17 +19,8 @@ export const genderEum = {
   1: '女'
 }
 
-const CompanyList: React.FC<ListProps> = ({ dispatch, accountTypeList }) => {
-  // console.log(accountTypeList)
-
+const CompanyList: React.FC<ListProps> = () => {
   const tRef = useRef<ActionType>(null)
-  useEffect(() => {
-    if (!accountTypeList.length) {
-      dispatch({
-        type: 'institutions/queryAccountTypeList'
-      })
-    }
-  }, [])
   const [state, setState] = useState({
     params: {
       search: null,
@@ -88,17 +76,17 @@ const CompanyList: React.FC<ListProps> = ({ dispatch, accountTypeList }) => {
         false: { text: '禁用', status: 'Error' }
       }
     },
-    {
-      dataIndex: 'gender',
-      key: 'gender',
-      title: '性别',
-      width: 56,
-      align: 'center',
-      onHeaderCell: () => ({ style: { textAlign: 'center' } }),
-      render: (_, { gender }) => {
-        return <span>{genderEum[gender]}</span>
-      }
-    },
+    // {
+    //   dataIndex: 'gender',
+    //   key: 'gender',
+    //   title: '性别',
+    //   width: 56,
+    //   align: 'center',
+    //   onHeaderCell: () => ({ style: { textAlign: 'center' } }),
+    //   render: (_, { gender }) => {
+    //     return <span>{genderEum[gender]}</span>
+    //   }
+    // },
     {
       dataIndex: 'organizationalStructureID',
       key: 'organizationalStructureID',
@@ -133,23 +121,23 @@ const CompanyList: React.FC<ListProps> = ({ dispatch, accountTypeList }) => {
       onHeaderCell: () => ({ style: { textAlign: 'center' } }),
       renderText: (_, record) => record?.created?.name
     },
-    {
-      dataIndex: 'accountType',
-      key: 'accountType',
-      title: '账号类型',
-      width: 96,
-      align: 'center',
-      filters: true,
-      filterMultiple: false,
-      onHeaderCell: () => ({ style: { textAlign: 'center' } }),
-      valueEnum: accountTypeList.reduce((prev, curr) => {
-        const items = { ...prev }
-        items[curr.value] = {
-          text: curr.label
-        }
-        return items
-      }, {})
-    },
+    // {
+    //   dataIndex: 'accountType',
+    //   key: 'accountType',
+    //   title: '账号类型',
+    //   width: 96,
+    //   align: 'center',
+    //   filters: true,
+    //   filterMultiple: false,
+    //   onHeaderCell: () => ({ style: { textAlign: 'center' } }),
+    //   valueEnum: accountTypeList.reduce((prev, curr) => {
+    //     const items = { ...prev }
+    //     items[curr.value] = {
+    //       text: curr.label
+    //     }
+    //     return items
+    //   }, {})
+    // },
     {
       title: '操作',
       dataIndex: 'operation',
@@ -256,9 +244,10 @@ const CompanyList: React.FC<ListProps> = ({ dispatch, accountTypeList }) => {
   )
 }
 
-export default connect(({ institutions }: { institutions: InstitutionsModelState }) => ({
-  accountTypeList: institutions.accountType.map(item => ({
-    label: item.name,
-    value: item.value
-  }))
-}))(CompanyList)
+// export default connect(({ institutions }: { institutions: InstitutionsModelState }) => ({
+//   accountTypeList: institutions.accountType.map(item => ({
+//     label: item.name,
+//     value: item.value
+//   }))
+// }))(CompanyList)
+export default CompanyList

+ 30 - 38
src/pages/Project/Management/List/index.tsx

@@ -12,7 +12,6 @@ import { BaseMenuEnum } from '@/pages/Schema/Base'
 import AnimateContent from '@/components/AnimateContent'
 import type { ProColumnType, ActionType } from '@ant-design/pro-table'
 import type { ConnectProps } from 'umi'
-import type { ProjectModelState } from '../../model'
 import type { SchemaBaseModelState } from '@/pages/Schema/Base/model'
 
 type ListProps = ConnectProps & {
@@ -23,11 +22,11 @@ type ListProps = ConnectProps & {
 const List: React.FC<ListProps> = ({ schema, dispatch, pTypeList }) => {
   const tRef = useRef<ActionType>(null)
   useEffect(() => {
-    if (!pTypeList.length) {
-      dispatch({
-        type: 'project/queryProjectTypeList'
-      })
-    }
+    // if (!pTypeList.length) {
+    //   dispatch({
+    //     type: 'project/queryProjectTypeList'
+    //   })
+    // }
     if (!schema) {
       dispatch({
         type: 'schemaBase/querySchema',
@@ -78,8 +77,7 @@ const List: React.FC<ListProps> = ({ schema, dispatch, pTypeList }) => {
             //   title: record.name,
             //   defaultFormData: record
             // })
-          }}
-        >
+          }}>
           {text}
         </span>
       )
@@ -92,22 +90,22 @@ const List: React.FC<ListProps> = ({ schema, dispatch, pTypeList }) => {
       onHeaderCell: () => ({ style: { textAlign: 'center' } }),
       renderText: text => dayjs(text).format('YYYY-MM-DD')
     },
-    {
-      dataIndex: 'projectTypeID',
-      title: '项目类型',
-      width: 126,
-      align: 'center',
-      filters: true,
-      filterMultiple: false,
-      onHeaderCell: () => ({ style: { textAlign: 'center' } }),
-      valueEnum: pTypeList.reduce((prev, curr) => {
-        const items = { ...prev }
-        items[curr.value] = {
-          text: curr.label
-        }
-        return items
-      }, {})
-    },
+    // {
+    //   dataIndex: 'projectTypeID',
+    //   title: '项目类型',
+    //   width: 126,
+    //   align: 'center',
+    //   filters: true,
+    //   filterMultiple: false,
+    //   onHeaderCell: () => ({ style: { textAlign: 'center' } }),
+    //   valueEnum: pTypeList.reduce((prev, curr) => {
+    //     const items = { ...prev }
+    //     items[curr.value] = {
+    //       text: curr.label
+    //     }
+    //     return items
+    //   }, {})
+    // },
     {
       dataIndex: 'createdID',
       key: 'createdID',
@@ -157,16 +155,14 @@ const List: React.FC<ListProps> = ({ schema, dispatch, pTypeList }) => {
                 title: record.name,
                 defaultFormData: record
               })
-            }}
-          >
+            }}>
             编辑
           </div>
           <Popconfirm
             title="确认删除吗?"
             okText="确认"
             cancelText="取消"
-            onConfirm={() => tryDelProject({ ID: record.ID })}
-          >
+            onConfirm={() => tryDelProject({ ID: record.ID })}>
             <div className="pl-2 text-hex-fd3995 cursor-pointer hover:text-hex-e7026e">
               <DeleteOutlined />
             </div>
@@ -215,8 +211,7 @@ const List: React.FC<ListProps> = ({ schema, dispatch, pTypeList }) => {
                   title: null
                   // defaultFormData: transformToSchemaData(record, BaseMenuEnum.PROJECT, schema)
                 })
-              }
-            >
+              }>
               新建项目
             </Button>
           ]
@@ -233,8 +228,7 @@ const List: React.FC<ListProps> = ({ schema, dispatch, pTypeList }) => {
           </>
         }
         visible={state.visible}
-        onVisibleChange={onAnimateChange}
-      >
+        onVisibleChange={onAnimateChange}>
         <ProjectModal
           type={state.currentModalType}
           defaultFormData={state.defaultFormData}
@@ -248,9 +242,7 @@ const List: React.FC<ListProps> = ({ schema, dispatch, pTypeList }) => {
   )
 }
 
-export default connect(
-  ({ project, schemaBase }: { project: ProjectModelState; schemaBase: SchemaBaseModelState }) => ({
-    pTypeList: project.projectTypeList.map(item => ({ label: item.name, value: item.ID })),
-    schema: schemaBase.base[BaseMenuEnum.PROJECT]
-  })
-)(List)
+export default connect(({ schemaBase }: { schemaBase: SchemaBaseModelState }) => ({
+  // pTypeList: project.projectTypeList.map(item => ({ label: item.name, value: item.ID })),
+  schema: schemaBase.base[BaseMenuEnum.PROJECT]
+}))(List)

+ 1 - 1
src/pages/Schema/Base/components/Designable/widgets/ActionsWidget.tsx

@@ -36,7 +36,7 @@ export const ActionsWidget = observer(({ schema }) => {
   const saveSchema = () => {
     tryUpdateSchema({
       columnType,
-      schema: transformToSchema(designer.getCurrentTree()).schema
+      schema: JSON.stringify(transformToSchema(designer.getCurrentTree()).schema)
     })
   }
   return (

+ 7 - 3
src/pages/Schema/Base/model.ts

@@ -54,10 +54,14 @@ const SchemaBaseModel: SchemaBaseType = {
   },
   reducers: {
     save(state, action) {
-      return {
-        ...state,
-        base: { ...state?.base, [action.payload.columnType]: action.payload?.schema }
+      if (action.payload?.schema) {
+        const targetSchema = JSON.parse(action.payload?.schema)
+        return {
+          ...state,
+          base: { ...state?.base, [action.payload.columnType]: targetSchema }
+        }
       }
+      return state
     }
 
     // 启用 immer 之后

+ 0 - 1
src/services/api/schema.ts

@@ -11,7 +11,6 @@ export async function getSchemaByColmunType(params: API.SchemaParams) {
 export async function updateSchema(params) {
   return request('/BasicConfig/save', {
     method: 'POST',
-    requestType: 'form',
     data: params
   })
 }

+ 117 - 124
src/utils/schema.ts

@@ -21,19 +21,18 @@ export const projectSchema = {
     shortName: {
       type: 'string',
       title: '项目简称',
-      required: true,
       'x-decorator': 'FormItem',
       'x-component': 'Input',
       'x-index': 2
-    },
-    projectTypeID: {
-      type: 'string',
-      title: '项目类型',
-      required: true,
-      'x-decorator': 'FormItem',
-      'x-component': 'Select',
-      'x-index': 3
     }
+    // projectTypeID: {
+    //   type: 'string',
+    //   title: '项目类型',
+    //   required: true,
+    //   'x-decorator': 'FormItem',
+    //   'x-component': 'Select',
+    //   'x-index': 3
+    // }
   }
 }
 
@@ -46,95 +45,97 @@ export const institutionSchema = {
       title: '企事业单位名称',
       required: true,
       'x-decorator': 'FormItem',
-      'x-component': 'Input',
-      'x-decorator-props': {
-        // labelWidth: '131px'
-        labelCol: 4
-      }
+      'x-component': 'Input'
     },
-    layout: {
-      type: 'void',
-      'x-component': 'FormLayout',
-      'x-component-props': {
-        labelCol: 8,
-        layout: 'horizontal'
-      },
-      properties: {
-        gird: {
-          type: 'void',
-          'x-component': 'FormGrid',
-          'x-component-props': {
-            minColumns: 1,
-            maxColumns: 2,
-            columnGap: 0
-          },
-          properties: {
-            acronym: {
-              type: 'string',
-              title: '企事业单位简称',
-              required: true,
-              'x-decorator': 'FormItem',
-              'x-component': 'Input'
-            },
-            enterpriseCode: {
-              type: 'string',
-              title: '企业编码',
-              required: true,
-              'x-decorator': 'FormItem',
-              'x-component': 'Input'
-            },
-            phone: {
-              type: 'string',
-              title: '办公电话',
-              'x-decorator': 'FormItem',
-              'x-component': 'Input'
-            },
-            address: {
-              type: 'string',
-              title: '地址',
-              'x-decorator': 'FormItem',
-              'x-component': 'Input'
-            },
-            fax: {
-              type: 'string',
-              title: '传真号码',
-              'x-decorator': 'FormItem',
-              'x-component': 'Input'
-            },
-            organizationCode: {
-              type: 'string',
-              title: '组织架构代码',
-              'x-decorator': 'FormItem',
-              'x-component': 'Input'
-            },
-            bank: {
-              type: 'string',
-              title: '银行',
-              'x-decorator': 'FormItem',
-              'x-component': 'Input'
-            },
-            idCard: {
-              type: 'string',
-              title: '身份证号码',
-              'x-decorator': 'FormItem',
-              'x-component': 'Input'
-            },
-            bankAccount: {
-              type: 'string',
-              title: '银行账号',
-              'x-decorator': 'FormItem',
-              'x-component': 'Input'
-            },
-            legalPerson: {
-              type: 'string',
-              title: '法人代表',
-              'x-decorator': 'FormItem',
-              'x-component': 'Input'
-            }
-          }
-        }
-      }
+    acronym: {
+      type: 'string',
+      title: '企事业单位简称',
+      'x-decorator': 'FormItem',
+      'x-component': 'Input'
     }
+    // layout: {
+    //   type: 'void',
+    //   'x-component': 'FormLayout',
+    //   'x-component-props': {
+    //     labelCol: 8,
+    //     layout: 'horizontal'
+    //   },
+    //   properties: {
+    //     gird: {
+    //       type: 'void',
+    //       'x-component': 'FormGrid',
+    //       'x-component-props': {
+    //         minColumns: 1,
+    //         maxColumns: 2,
+    //         columnGap: 0
+    //       },
+    //       properties: {
+    //         acronym: {
+    //           type: 'string',
+    //           title: '企事业单位简称',
+    //           required: true,
+    //           'x-decorator': 'FormItem',
+    //           'x-component': 'Input'
+    //         },
+    //         enterpriseCode: {
+    //           type: 'string',
+    //           title: '企业编码',
+    //           required: true,
+    //           'x-decorator': 'FormItem',
+    //           'x-component': 'Input'
+    //         },
+    //         phone: {
+    //           type: 'string',
+    //           title: '办公电话',
+    //           'x-decorator': 'FormItem',
+    //           'x-component': 'Input'
+    //         },
+    //         address: {
+    //           type: 'string',
+    //           title: '地址',
+    //           'x-decorator': 'FormItem',
+    //           'x-component': 'Input'
+    //         },
+    //         fax: {
+    //           type: 'string',
+    //           title: '传真号码',
+    //           'x-decorator': 'FormItem',
+    //           'x-component': 'Input'
+    //         },
+    //         organizationCode: {
+    //           type: 'string',
+    //           title: '组织架构代码',
+    //           'x-decorator': 'FormItem',
+    //           'x-component': 'Input'
+    //         },
+    //         bank: {
+    //           type: 'string',
+    //           title: '银行',
+    //           'x-decorator': 'FormItem',
+    //           'x-component': 'Input'
+    //         },
+    //         idCard: {
+    //           type: 'string',
+    //           title: '身份证号码',
+    //           'x-decorator': 'FormItem',
+    //           'x-component': 'Input'
+    //         },
+    //         bankAccount: {
+    //           type: 'string',
+    //           title: '银行账号',
+    //           'x-decorator': 'FormItem',
+    //           'x-component': 'Input'
+    //         },
+    //         legalPerson: {
+    //           type: 'string',
+    //           title: '法人代表',
+    //           'x-decorator': 'FormItem',
+    //           'x-component': 'Input'
+    //         }
+    //       }
+    //     }
+    //   }
+    // }
   }
 }
 
@@ -191,41 +192,33 @@ export const staffSchema = {
       'x-component': 'Input',
       'x-index': 5
     },
-    accountType: {
-      type: 'string',
-      title: '账号类型',
-      required: true,
-      'x-decorator': 'FormItem',
-      'x-component': 'Select',
-      'x-index': 6
-    },
+    // accountType: {
+    //   type: 'string',
+    //   title: '账号类型',
+    //   required: true,
+    //   'x-decorator': 'FormItem',
+    //   'x-component': 'Select',
+    //   'x-index': 6
+    // },
     organizationalStructureID: {
       type: 'string',
       title: '组织架构',
       'x-decorator': 'FormItem',
       'x-component': 'TreeSelect',
       'x-index': 7
-    },
-    gender: {
-      type: 'string',
-      title: '性别',
-      required: true,
-      'x-decorator': 'FormItem',
-      'x-component': 'Select',
-      'x-index': 8,
-      enum: [
-        { label: '男', value: '0' },
-        { label: '女', value: '1' }
-      ]
-    },
-    phone: {
-      type: 'string',
-      title: '手机',
-      required: true,
-      'x-decorator': 'FormItem',
-      'x-component': 'Input',
-      'x-index': 9
     }
+    // gender: {
+    //   type: 'string',
+    //   title: '性别',
+    //   required: true,
+    //   'x-decorator': 'FormItem',
+    //   'x-component': 'Select',
+    //   'x-index': 8,
+    //   enum: [
+    //     { label: '男', value: '0' },
+    //     { label: '女', value: '1' }
+    //   ]
+    // },
   }
 }