|
|
@@ -16,7 +16,8 @@ import {
|
|
|
Form,
|
|
|
Space,
|
|
|
Row,
|
|
|
- Col
|
|
|
+ Col,
|
|
|
+ Input
|
|
|
} from 'antd';
|
|
|
import {
|
|
|
PlusOutlined,
|
|
|
@@ -25,7 +26,10 @@ import {
|
|
|
DeleteOutlined,
|
|
|
StepForwardOutlined,
|
|
|
SearchOutlined,
|
|
|
- ReloadOutlined
|
|
|
+ ReloadOutlined,
|
|
|
+ BookOutlined,
|
|
|
+ TeamOutlined,
|
|
|
+ AppstoreOutlined
|
|
|
} from '@ant-design/icons';
|
|
|
import { apis } from '@/apis';
|
|
|
import './style.less';
|
|
|
@@ -124,7 +128,7 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
const [ projectList, setProjectList ] = React.useState<ProjectTypeList>( [] );
|
|
|
const [ appProjectList, setAppProjectList ] = React.useState<AppTypeList>( [] );
|
|
|
const [ showSubPanel, setShowSubPanel ] = React.useState( false );
|
|
|
- const [ selectedType, setSelectedType ] = React.useState<number | null>( null );
|
|
|
+ const [ selectedType, setSelectedType ] = React.useState<string | null>( '全部' );
|
|
|
const wrapperRef = React.useRef<HTMLDivElement>( null );
|
|
|
const selectRef = React.useRef<any>( null );
|
|
|
const [ levelTypeList, setLevelTypeList ] = React.useState<AppTypeList>( [] );
|
|
|
@@ -298,6 +302,9 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
await projectApi.fetchProject();
|
|
|
await appProTypeApi.fetchAppProType();
|
|
|
await levelTypeApi.fetchLevelAppType();
|
|
|
+
|
|
|
+ // 设置默认选择"全部"
|
|
|
+ form.setFieldsValue({ typeId: '全部' });
|
|
|
}
|
|
|
|
|
|
React.useEffect( () => {
|
|
|
@@ -347,6 +354,7 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
const handleClickReset = async () => {
|
|
|
form.resetFields();
|
|
|
setShowSubPanel( false );
|
|
|
+ setSelectedType( '全部' ); // 重置为"全部"
|
|
|
page.pageNumber = 1;
|
|
|
page.pageSize = 10;
|
|
|
await appApi.fetchList( null, null );
|
|
|
@@ -368,9 +376,8 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
}, [] );
|
|
|
|
|
|
|
|
|
- const handleAppTypeChange = ( value : number ) => {
|
|
|
- console.log( value, 'sssss' );
|
|
|
- if ( value === 41 ) {
|
|
|
+ const handleAppTypeChange = ( value : string ) => {
|
|
|
+ if ( value === '41' ) {
|
|
|
// 如果是项目级应用,切换面板状态
|
|
|
// setShowSubPanel(prev => !prev);
|
|
|
setShowSubPanel( true );
|
|
|
@@ -380,9 +387,20 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
}
|
|
|
setSelectedType( value );
|
|
|
form.setFieldsValue( { typeId: value } );
|
|
|
+
|
|
|
+ // 自动提交逻辑
|
|
|
+ if (value === '全部') {
|
|
|
+ // 全部选项,传递null给后端
|
|
|
+ appApi.fetchList( null, null );
|
|
|
+ indexApi.fetchIndex( null, null );
|
|
|
+ } else {
|
|
|
+ // 其他选项,传递对应的typeId
|
|
|
+ appApi.fetchList( value, null );
|
|
|
+ indexApi.fetchIndex( value, null );
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
- const handleAppProTypeChange = ( value : number ) => {
|
|
|
+ const handleAppProTypeChange = ( value : string ) => {
|
|
|
console.log( value, 'valuevalue' );
|
|
|
|
|
|
setSelectedType( value );
|
|
|
@@ -391,7 +409,6 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
|
|
|
return (
|
|
|
<div>
|
|
|
-
|
|
|
<div style={ { padding: '16px 20px' , display: 'flex' } }>
|
|
|
<Form
|
|
|
form={ form }
|
|
|
@@ -400,30 +417,52 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
style={{ flex: 1 }}
|
|
|
>
|
|
|
<div>
|
|
|
- {/* 主选择器 */ }
|
|
|
+ {/* 主选择器 - 修改为按钮组形式 */}
|
|
|
<FormItem
|
|
|
- // label="应用类型"
|
|
|
name="typeId"
|
|
|
style={ { marginBottom: 0 } }
|
|
|
>
|
|
|
- <Select
|
|
|
- ref={ selectRef }
|
|
|
- // style={ { width: 200 } }
|
|
|
- placeholder="请选择应用类型"
|
|
|
- onChange={ handleAppTypeChange }
|
|
|
- value={ selectedType }
|
|
|
- allowClear
|
|
|
- >
|
|
|
- { appTypeList.map( item => (
|
|
|
- <Option key={ item.value } value={ item.value }>
|
|
|
- { item.label }
|
|
|
- </Option>
|
|
|
- ) ) }
|
|
|
- </Select>
|
|
|
+ <div className="filter-button-group">
|
|
|
+ {/* 全部按钮 */}
|
|
|
+ <Button
|
|
|
+ key="全部"
|
|
|
+ type={selectedType === '全部' ? 'primary' : 'default'}
|
|
|
+ size="small"
|
|
|
+ onClick={() => handleAppTypeChange('全部')}
|
|
|
+ >
|
|
|
+ 全部
|
|
|
+ </Button>
|
|
|
+ {/* 动态应用类型按钮 */}
|
|
|
+ {appTypeList.map(item => {
|
|
|
+ // 根据label匹配对应的图标
|
|
|
+ let icon = null;
|
|
|
+ const isSelected = selectedType === item.value;
|
|
|
+
|
|
|
+ if (item.label === '专业知识') {
|
|
|
+ icon = <BookOutlined style={{ fontSize: '14px', marginRight: '0' }} />;
|
|
|
+ } else if (item.label === '职能管理') {
|
|
|
+ icon = <TeamOutlined style={{ fontSize: '14px', marginRight: '0' }} />;
|
|
|
+ } else if (item.label === '项目级应用') {
|
|
|
+ icon = <AppstoreOutlined style={{ fontSize: '14px', marginRight: '0' }} />;
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Button
|
|
|
+ key={item.value}
|
|
|
+ type={isSelected ? 'primary' : 'default'}
|
|
|
+ size="small"
|
|
|
+ onClick={() => handleAppTypeChange(item.value)}
|
|
|
+ >
|
|
|
+ {icon}
|
|
|
+ {item.label}
|
|
|
+ </Button>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
</FormItem>
|
|
|
|
|
|
{/* 子选项面板 */ }
|
|
|
- { showSubPanel && selectedType === 41 && (
|
|
|
+ { showSubPanel && selectedType === '41' && (
|
|
|
|
|
|
<FormItem
|
|
|
label='类型'
|
|
|
@@ -434,7 +473,12 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
placeholder='请选择'
|
|
|
allowClear
|
|
|
// style={ { width: 200 } }
|
|
|
- // onChange={handleAppProTypeChange}
|
|
|
+ onChange={(value) => {
|
|
|
+ // 项目类型选择器自动提交逻辑
|
|
|
+ const currentProjectId = form.getFieldValue('projectId');
|
|
|
+ appApi.fetchList(value, currentProjectId);
|
|
|
+ indexApi.fetchIndex(value, currentProjectId);
|
|
|
+ }}
|
|
|
>
|
|
|
{
|
|
|
appProjectList.map( ( item, index ) => {
|
|
|
@@ -464,6 +508,13 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
// style={ { width: '200px' } }
|
|
|
placeholder='请选择项目'
|
|
|
allowClear
|
|
|
+ onChange={(value) => {
|
|
|
+ // 项目选择器自动提交逻辑
|
|
|
+ const currentTypeId = form.getFieldValue('typeId');
|
|
|
+ const typeId = currentTypeId === '全部' ? null : currentTypeId;
|
|
|
+ appApi.fetchList(typeId, value);
|
|
|
+ indexApi.fetchIndex(typeId, value);
|
|
|
+ }}
|
|
|
>
|
|
|
{
|
|
|
projectList.map( ( item, index ) => {
|
|
|
@@ -478,21 +529,22 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
|
|
|
<FormItem>
|
|
|
<Space size={ 12 }>
|
|
|
- <Button
|
|
|
- // style={ { marginRight: 16 } }
|
|
|
+ <Tooltip title="重置">
|
|
|
+ <Button
|
|
|
+ shape="circle"
|
|
|
+ icon={ <ReloadOutlined /> }
|
|
|
+ onClick={ handleClickReset }
|
|
|
+ />
|
|
|
+ </Tooltip>
|
|
|
+ <Tooltip title="查询">
|
|
|
+ <Button
|
|
|
type='primary'
|
|
|
+ shape="circle"
|
|
|
onClick={ handleClickSearch }
|
|
|
icon={ <SearchOutlined /> }
|
|
|
- >
|
|
|
- 查询
|
|
|
- </Button>
|
|
|
- <Button
|
|
|
- icon={ <ReloadOutlined /> }
|
|
|
- onClick={ handleClickReset }>
|
|
|
- 重置
|
|
|
- </Button>
|
|
|
+ />
|
|
|
+ </Tooltip>
|
|
|
</Space>
|
|
|
-
|
|
|
</FormItem>
|
|
|
|
|
|
{/* {
|
|
|
@@ -745,14 +797,14 @@ const QuestionAnswerList : React.FC = () => {
|
|
|
</div>
|
|
|
:
|
|
|
<div>
|
|
|
- {
|
|
|
+ {/* {
|
|
|
createFlag &&
|
|
|
<Button type='primary'
|
|
|
icon={ <PlusOutlined /> }
|
|
|
onClick={ () => {
|
|
|
router.navigate( { pathname: '/deepseek/questionAnswer/create' } );
|
|
|
} }>创建问答应用</Button>
|
|
|
- }
|
|
|
+ } */}
|
|
|
<Empty image={ Empty.PRESENTED_IMAGE_SIMPLE } />
|
|
|
</div>
|
|
|
}
|