lanjianrong преди 3 години
родител
ревизия
cf27491b27

+ 1 - 1
config/defaultSettings.ts

@@ -16,7 +16,7 @@ const Settings: LayoutSettings & {
   pwa: false,
   // logo: 'https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg',
   logo: '/logo.svg',
-  iconfontUrl: '//at.alicdn.com/t/font_2906856_nbx546tuh5.js'
+  iconfontUrl: '//at.alicdn.com/t/font_2906856_u986loe1g6.js'
 }
 
 export default Settings

+ 20 - 0
config/routes.ts

@@ -89,6 +89,26 @@
     ]
   },
   {
+    path: '/work-setting',
+    name: 'work-setting',
+    icon: 'icon-yewushezhi',
+    routes: [
+      {
+        path: 'schema',
+        name: 'schema',
+        icon: 'icon-schema',
+        component: './Schema/Base/index.tsx'
+      },
+      {
+        path: '/work-setting/schema/detail',
+        name: 'schema-detail',
+        hideInMenu: true,
+        component: './Schema/Base/detail.tsx'
+      }
+    ]
+  },
+
+  {
     component: './404'
   }
 ]

+ 28 - 0
src/global.less

@@ -55,3 +55,31 @@ ol {
     min-height: 100vh;
   }
 }
+
+.scale-up-center {
+  -webkit-animation: scale-up-center 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;
+  animation: scale-up-center 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;
+}
+
+@-webkit-keyframes scale-up-center {
+  0% {
+    -webkit-transform: scale(0.5);
+    transform: scale(0.5);
+  }
+  100% {
+    -webkit-transform: scale(1);
+    transform: scale(1);
+    @apply text-white bg-primary rounded-4px;
+  }
+}
+@keyframes scale-up-center {
+  0% {
+    -webkit-transform: scale(0.5);
+    transform: scale(0.5);
+  }
+  100% {
+    -webkit-transform: scale(1);
+    transform: scale(1);
+    @apply text-white bg-primary rounded-4px;
+  }
+}

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

@@ -22,5 +22,10 @@ export default {
   'menu.institutions.company': '单位管理',
   'menu.institutions.staff': '人员管理',
   'menu.institutions.company.list': '单位列表',
-  'menu.institutions.company.detail': '单位详情'
+  'menu.institutions.company.detail': '单位详情',
+  'menu.work-setting': '业务设置',
+  'menu.work-setting.schema': '基础数据设置',
+  'menu.work-setting.schema-detail': '编辑数据模型'
+  // 'menu.work-setting.schema.base': '基础数据设置',
+  // 'menu.work-setting.schema.detail': '基础数据设置',
 }

+ 4 - 1
src/pages/Institutions/Company/Detail/components/Organization.tsx

@@ -1,4 +1,5 @@
 import { Breadcrumb, Button } from 'antd'
+import type { ActionType } from '@ant-design/pro-table'
 import ProTable from '@ant-design/pro-table'
 import React, { useState, useEffect, useRef } from 'react'
 import { useRequest } from 'umi'
@@ -115,7 +116,9 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
         type={state.currentModalType}
         visible={state.visible}
         setVisible={(visible: boolean) => setState({ ...state, visible })}
-        reloadTable={() => tRef.current?.reload()}
+        reload={() => {
+          tryOrganizationList()
+        }}
         defaultFormData={state.defaultFormData}
       />
     </div>

+ 10 - 11
src/pages/Institutions/Company/Detail/components/OrganizationModal.tsx

@@ -17,12 +17,12 @@ type OrganizationModalProps = {
   visible: boolean
   setVisible: (visible: boolean) => void
   type: ModalType
-  reloadTable: () => void
+  reload: () => void
   defaultFormData?: {
-    structureType: string
-    dataID: string
-    name: string
-    parentID: string
+    structureType?: string
+    dataID?: string
+    name?: string
+    parentID?: string
   }
 }
 const OrganizationModal: React.FC<OrganizationModalProps> = ({
@@ -30,14 +30,12 @@ const OrganizationModal: React.FC<OrganizationModalProps> = ({
   type,
   setVisible,
   defaultFormData,
-  reloadTable
+  reload
 }) => {
-  console.log(defaultFormData)
-
   const ref = useRef<FormInstance>(null)
   useEffect(() => {
-    defaultFormData && ref.current?.setFieldsValue({ ...defaultFormData })
-  }, [defaultFormData])
+    visible && defaultFormData && ref.current?.setFieldsValue({ ...defaultFormData })
+  }, [defaultFormData, visible])
   const { run: tryUpdateOrganization } = useRequest(updateOrganizationalStructure, {
     manual: true,
     onSuccess: () => {
@@ -60,8 +58,9 @@ const OrganizationModal: React.FC<OrganizationModalProps> = ({
           await tryUpdateOrganization(values)
         }
         setVisible(false)
-        reloadTable()
+
         ref.current?.resetFields()
+        reload()
       } catch (error) {
         message.error(error)
       }

+ 35 - 0
src/pages/Schema/Base/components/LeftMenu.tsx

@@ -0,0 +1,35 @@
+import React from 'react'
+
+type LeftMenuProps = {
+  title?: string
+  options: { label: string; value: string }[]
+  onChange: (key: string) => void
+  value: string
+}
+
+const LeftMenu: React.FC<LeftMenuProps> = ({ title = '栏目/功能', options, onChange, value }) => {
+  return (
+    <div className="h-full w-max-234px rounded-4px shadow-card">
+      <div className="p-4 border-b-1 border-solid border-black border-opacity-10 bg-[#f7f9fa] text-left">
+        <span>{title}</span>
+      </div>
+      <div className="p-4 bg-white" style={{ height: 'calc(100vh - 201px)' }}>
+        <ul className="p-0 m-0 list-none text-primary flex flex-col flex-1">
+          {options.map(item => (
+            <li
+              key={item.value}
+              className={[
+                'flex justify-between items-center py-2 px-5 cursor-pointer',
+                item.value === value ? 'scale-up-center' : ''
+              ].join(' ')}
+              onClick={() => onChange(item.value)}>
+              {item.label}
+            </li>
+          ))}
+        </ul>
+      </div>
+    </div>
+  )
+}
+
+export default LeftMenu

+ 44 - 0
src/pages/Schema/Base/detail.tsx

@@ -0,0 +1,44 @@
+import { querySchemas } from '@/services/api/schema'
+import { useRequest } from 'umi'
+import Generator from 'fr-generator'
+import React, { useState } from 'react'
+import type { RouteComponentProps } from 'react-router'
+import { PageContainer } from '@ant-design/pro-layout'
+type DetailProps = RouteComponentProps
+const Detail: React.FC<DetailProps> = ({ location }) => {
+  const { columnType } = location.query
+  const [schema, setSchema] = useState(null)
+  useRequest(() => querySchemas({ columnType }), {
+    onSuccess: result => {
+      if (result?.[0]) {
+        setSchema(JSON.parse(result?.[0]))
+      }
+    }
+  })
+  return (
+    <PageContainer title={false}>
+      <div className="bg-white shadow-card p-4" style={{ height: 'calc(100vh - 146px)' }}>
+        <Generator
+          defaultValue={schema}
+          onSchemaChange={target => setSchema(target)}
+          controlButtons={[false, true]}
+          extraButtons={[
+            false,
+            false,
+            false,
+            false,
+            {
+              text: '提交',
+              type: 'primary',
+              onClick: e => {
+                console.log(schema)
+              }
+            }
+          ]}
+        />
+      </div>
+    </PageContainer>
+  )
+}
+
+export default Detail

+ 72 - 0
src/pages/Schema/Base/index.tsx

@@ -0,0 +1,72 @@
+import { PageContainer } from '@ant-design/pro-layout'
+import LeftMenu from './components/LeftMenu'
+import { useState } from 'react'
+import FormRender, { useForm } from 'form-render'
+import { Button } from 'antd'
+import { history } from 'umi'
+export enum BaseMenuEnum {
+  PROJECT = 1,
+  COMPANY = 2,
+  STAFF = 3
+}
+
+const schema = {
+  type: 'object',
+  properties: {
+    input1: {
+      title: '简单输入框',
+      type: 'string',
+      required: true
+    },
+    select1: {
+      title: '单选',
+      type: 'string',
+      enum: ['a', 'b', 'c'],
+      enumNames: ['早', '中', '晚']
+    }
+  }
+}
+
+const Index = () => {
+  const form = useForm()
+  const [state, setState] = useState({
+    activeKey: BaseMenuEnum.PROJECT,
+    schema: {}
+  })
+  const menuOptions = [
+    { label: '项目信息', value: BaseMenuEnum.PROJECT },
+    { label: '企事业单位信息', value: BaseMenuEnum.COMPANY },
+    { label: '人员信息', value: BaseMenuEnum.STAFF }
+  ]
+
+  const gotoDetail = key => {
+    history.push({
+      pathname: '/work-setting/schema/detail',
+      query: {
+        columnType: key
+      }
+    })
+  }
+  return (
+    <PageContainer title={false}>
+      <div className="h-full w-full flex flex-row">
+        <LeftMenu
+          title="基础数据类别"
+          options={menuOptions}
+          value={state.activeKey}
+          onChange={key => setState({ ...state, activeKey: key })}
+        />
+        <div className="w-max-3/4 ml-8 bg-white p-4 shadow-card relative ">
+          <div className="text-right">
+            <Button onClick={() => gotoDetail(state.activeKey)}>编辑</Button>
+          </div>
+          <div>
+            <FormRender form={form} schema={schema} />
+          </div>
+        </div>
+      </div>
+    </PageContainer>
+  )
+}
+
+export default Index

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

@@ -0,0 +1,9 @@
+import { request } from 'umi'
+
+/** 获取所有的基础schema */
+export async function querySchemas(params: API.SchemasParams) {
+  return request('/BasicConfig/list', {
+    method: 'GET',
+    params
+  })
+}

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

@@ -167,5 +167,13 @@ declare namespace API {
 
   type OrganizationalStructureDelParams = {
     ID: string
+  type Schema = {
+    ID: string
+    columnType: number
+    schema: string
+  }
+
+  type SchemasParams = {
+    columnType: number
   }
 }