import { Button, Divider, Dropdown, Space, Table, TableProps, Modal } from "antd"; import { CheckOutlined, LoadingOutlined, ReloadOutlined, RedoOutlined } from "@ant-design/icons"; import { useEffect, useState } from "react"; import { IProjMod } from "../../../interfaces/proj/IProj.ts"; import EditModal from '../../EditModal/EditModal.tsx' import ConfigModModal from '../../ConfigModModal/ConfigModModal.tsx' import { get } from "../../../util/AjaxUtils.ts"; import { useParams } from "react-router-dom"; import { SearchOutlined } from '@ant-design/icons'; import { message } from "antd"; type PropsType = { mods: IProjMod[]; newMods: ProjModType[], handleGenerate: () => void; handleSave: (index: number, mod: ProjModType) => void; handleResaveField: (index: number, projModId: string) => void; handleRemove: (index: number, projModId: string, item: IProjMod) => void; handleEdit: (index: number, projModId: string, item: IProjMod) => void; } type ProjModType = { name: string, desc: string, } export default function AiHelperMod(props: PropsType) { // 菜单状态是否可以编辑 const [messageApi, contextHolder] = message.useMessage(); const [modArray, setModArray] = useState([]); const [newModArray, setNewModArray] = useState([]); const [id, setId] = useState('') const[configModal,setConfigModal] = useState(false) const [editModal, setEditModal] = useState(false) const [updata, setUpdata] = useState([]) const [status, setStatus] = useState('') // const [items, setItems] = useState([]) const pathParams = useParams(); useEffect(() => { console.log('mods', props.mods); setModArray(props.mods); setNewModArray(props.newMods); }, [props.mods, props.newMods]); useEffect(() => { if (updata.length != 0) { console.log('更新数据', updata); setModArray(updata) } }, [updata]) useEffect(() => { get({ messageApi, url: `/api/proj/get/${pathParams.projId}`, onSuccess({ data }) { // console.log('其他页面状态判断', data); setStatus(data.generate.generateStatus) } }) }, []) const modColumnArray: TableProps['columns'] = [ { title: '序号', dataIndex: 'index', key: 'index', width: 60, align: 'center', render: (_value, _record, index) => { return index + 1 } }, { title: '模块名称', dataIndex: 'modName', key: 'name', width: 200, align: 'center' }, { title: '模块描述', dataIndex: 'modDesc', key: 'desc', align: 'center' }, { title: 'AI状态', dataIndex: 'aiFieldStatus', key: 'desc', width: 100, align: 'center', render: (value) => { if (value == 'GENERATING') { return '处理中' } if (value == 'FAILED') { return '失败' } if (value == 'SUCCESS') { return '成功' } } }, { title: '操作', dataIndex: 'option', key: 'option', width: 80, align: 'center', render: (_value, record, index) => { if (status == 'SUCCESS') { return ( ) } else if (status == 'GENERATING') { return ( ) } else { if (record.aiFieldStatus == 'GENERATING') { return } if (record.aiFieldStatus == 'FAILED') { return } return ( { // props.handleEdit(index, record.projModId, record); setId(record.projModId) setEditModal(true) } }, { key: 'remove', label: '删除', onClick: () => { props.handleRemove(index, record.projModId, record); } }, ] }} placement="bottom" arrow> ) } // if (record.aiFieldStatus == 'GENERATING') { // return // } // if (record.aiFieldStatus == 'FAILED') { // return // } // return ( // { // // props.handleEdit(index, record.projModId, record); // setId(record.projModId) // setEditModal(true) // } // }, { // key: 'remove', // label: '删除', // onClick: () => { // props.handleRemove(index, record.projModId, record); // } // }, // ] // }} placement="bottom" arrow> // // // ) // if (record.aiFieldStatus == 'SUCCESS' || status == 'GENERATING') { // return ( // // // // ) // }else{ // return( // { // // props.handleEdit(index, record.projModId, record); // setId(record.projModId) // setEditModal(true) // } // }, { // key: 'remove', // label: '删除', // onClick: () => { // props.handleRemove(index, record.projModId, record); // } // }, // ] // }} placement="bottom" arrow> // // // ) // } } }, ]; const newModColumnArray: TableProps['columns'] = [ { title: '序号', dataIndex: 'index', key: 'index', width: 60, align: 'center', render: (_value, _record, index) => { return index + 1 } }, { title: '模块名称', dataIndex: 'name', key: 'name', width: 200, align: 'center' }, { title: '模块描述', dataIndex: 'desc', key: 'desc', align: 'center' }, { title: '确认', dataIndex: 'option', key: 'option', width: 80, align: 'center', render: (_value, record, index) => { return ( ) } }, ]; return ( <>
模块管理
{newModArray.length > 0 ? 原模块 : <>} { newModArray.length > 0 ? ( <> 新模块
) : <> }
{ newModArray.length > 0 ? ( ) : }
{ setEditModal(false) }} width={1200} > < EditModal id={id} onConfirm={() => setEditModal(false)} setUpdata={setUpdata} /> { setConfigModal(false) }} width={1200} > setConfigModal(false)} > ) }