Commit ff1e2ff2 by zhaochengxiang

bug fix

parent 61b4ee30
import React from 'react'
import { Modal, Button, Spin, Tooltip, Typography } from "antd"
import { Modal, Button, Spin, Tooltip, Typography, Space, Input } from "antd"
import { dispatch } from '../../../../model'
import Table from '../../../../util/Component/Table'
import { checkMenuAdmit, isSzseEnv, showMessage } from '../../../../util'
import { checkMenuAdmit, inputWidth, isSzseEnv, showMessage } from '../../../../util'
import { useDebounceEffect } from 'ahooks'
const topN = 20
......@@ -15,17 +16,33 @@ const FC = (props) => {
const [havaMore, setMore] = React.useState(false)
const [offset, setOffset] = React.useState(1)
const [animating, setAnimating] = React.useState(false)
const [args, setArgs] = React.useState({
name: undefined,
cnName: undefined,
triggerType: undefined,
})
React.useEffect(() => {
if (visible) {
setAnimating(true)
setArgs({
name,
cnName,
triggerType
})
setTimeout(() => {
setAnimating(false)
getSuggests()
}, 300)
}
}, [visible])
useDebounceEffect(()=>{
if (args.name || args.cnName) {
getSuggests()
}
}, [args], { wait:300 })
const onSourceClick = (id, name) => {
const timestamp = new Date().getTime();
const tempArray = (id??'').split('=');
......@@ -145,8 +162,8 @@ const FC = (props) => {
type: 'datamodel.suggest',
payload: {
params: {
name,
cnName,
name: args.name,
cnName: args.cnName,
offset,
topN,
}
......@@ -154,17 +171,17 @@ const FC = (props) => {
callback: data => {
setLoading(false)
if (triggerType === 'cnName') {
if (args.triggerType === 'cnName') {
setSuggests(prevSuggests => {
const newSuggests = [...prevSuggests??[], ...data?.[0]?.suggestions??[]]
const newSuggests = (offset===1) ? data?.[0]?.suggestions : [...prevSuggests??[], ...data?.[0]?.suggestions??[]]
setOffset((data?.[0]?.suggestions??[]).length + offset)
setMore((data?.[0]?.suggestions??[]).length === topN)
return newSuggests
})
} else if (triggerType === 'name') {
} else if (args.triggerType === 'name') {
setSuggests(prevSuggests => {
const newSuggests = [...prevSuggests??[], ...data?.[1]?.suggestions??[]]
const newSuggests = (offset===1) ? data?.[1]?.suggestions : [...prevSuggests??[], ...data?.[1]?.suggestions??[]]
setOffset((data?.[1]?.suggestions??[]).length + offset)
setMore((data?.[1]?.suggestions??[]).length === topN)
......@@ -218,6 +235,32 @@ const FC = (props) => {
centered destroyOnClose
onCancel={() => { close() }}
>
<div className='mb-3'>
<Space>
<span>中文名称:</span>
<Input size="middle"
placeholder="请输入中文名称"
value={args.cnName}
bordered={true} allowClear
onChange={(e) => {
setOffset(1)
setArgs({...args, cnName: e.target.value, triggerType: 'cnName'})
}}
style={{ width: inputWidth }}
/>
<span>英文名称:</span>
<Input size="middle"
placeholder="请输入英文名称"
value={args.name}
bordered={true} allowClear
onChange={(e) => {
setOffset(1)
setArgs({...args, name: e.target.value, triggerType: 'name'})
}}
style={{ width: inputWidth }}
/>
</Space>
</div>
{
!animating && <Spin spinning={loading}>
<Table
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment