ソースを参照

feat: 数据源列表url的显示

outaozhen 3 年 前
コミット
b18bb58245
1 ファイル変更19 行追加2 行削除
  1. 19 2
      src/pages/Schema/Option/index.tsx

+ 19 - 2
src/pages/Schema/Option/index.tsx

@@ -4,7 +4,7 @@ import { SortableContainer, SortableElement, SortableHandle } from 'react-sortab
 import { arrayMoveImmutable } from 'array-move'
 import type { ColumnsType } from 'antd/lib/table'
 import type { SortableContainerProps, SortEnd } from 'react-sortable-hoc'
-import { useRef, useState } from 'react'
+import { useEffect, useRef, useState } from 'react'
 import { useRequest } from 'umi'
 import type { ProFormInstance } from '@ant-design/pro-form'
 import { addDataSourceItem, queryDataSource, updateDataSourceItem } from '@/services/api/schema'
@@ -32,6 +32,7 @@ const SortableBody = SortableContainer((props: React.HTMLAttributes<HTMLTableSec
 type iState = {
   menuData: API.DataSourceMenuItem[]
   activeID: Nullable<string>
+  menuDataTitle: Nullable<string>
   current: NonNullable<API.DataSourceItem>
   modalType: ModalType
   menuDataItems?: API.DataSourceItem[]
@@ -44,7 +45,8 @@ const Option = () => {
     modalVisible: false,
     modalType: OptionModalType.ADD,
     menuDataItems: [],
-    current: null
+    current: null,
+    menuDataTitle: null
   })
 
   const { run: tryFetchList } = useRequest(queryDataSource, {
@@ -52,6 +54,9 @@ const Option = () => {
       setState({
         ...state,
         menuData: result,
+        menuDataTitle:
+          result.find(i => i.ID === state.activeID)?.name +
+          `(/api/form/v1/ds/items?ID=${result.find(i => i.ID === state.activeID)?.ID})`,
         menuDataItems: result.find(i => i.ID === state.activeID)?.items
       })
     }
@@ -164,6 +169,17 @@ const Option = () => {
     />
   )
 
+  useEffect(() => {
+    if (state.activeID) {
+      setState({
+        ...state,
+        menuDataTitle:
+          state.menuData.find(i => i.ID === state.activeID)?.name +
+          `(/api/form/v1/ds/items?ID=${state.menuData.find(i => i.ID === state.activeID)?.ID})`
+      })
+    }
+  }, [state.activeID])
+
   const DraggableBodyRow = ({ ...restProps }) => {
     if (state.menuDataItems?.length) {
       const index = state.menuDataItems?.findIndex(x => x.index === restProps['data-row-key'])
@@ -189,6 +205,7 @@ const Option = () => {
             search={false}
             dataSource={state.menuDataItems || []}
             rowKey="index"
+            headerTitle={state.activeID ? state.menuDataTitle : null}
             toolbar={{
               actions: [
                 <Button