feat(component): 实现组件下架功能

master
钟良源 2 months ago
parent 9b0569cbaa
commit 7f38dda156

@ -26,6 +26,7 @@ import {
import dayjs from 'dayjs';
import { updateComponentCodingPath } from '@/store/ideContainer';
import { useDispatch } from 'react-redux';
import { componentOffSale } from '@/api/componentDeploy';
const Group = Radio.Group;
@ -49,6 +50,8 @@ const GlobalVarContainer = () => {
const [importModalVisible, setImportModalVisible] = useState(false); // 导入弹窗
const [importComponentInfo, setImportComponentInfo] = useState(null); // 导入组件信息
const [importLoading, setImportLoading] = useState(false); // 导入加载状态
const [showOffSaleModal, setShowOffSaleModal] = useState(false);
const [offSaleComponent, setOffSaleComponent] = useState(null);
const dispatch = useDispatch();
const menuItems = [
@ -207,8 +210,8 @@ const GlobalVarContainer = () => {
onExportComponent(row);
}}
onStopComponentShow={(row) => {
// TODO: 实现下架组件逻辑
console.log('Stop component show', row);
setOffSaleComponent(row);
setShowOffSaleModal(true);
}}
onRowDel={(row) => {
// 显示确认框
@ -272,6 +275,22 @@ const GlobalVarContainer = () => {
};
}, []);
// 下架组件
const componentOffSaleHandler = async (stopInstance: boolean) => {
const res: any = await componentOffSale({ identifier: offSaleComponent.identifier, stopInstance });
if (res.code === 200) {
setShowOffSaleModal(false);
setOffSaleComponent(null);
fetchComponentReview();
}
else {
Modal.error({
title: '下架失败',
content: res.message
});
}
};
// 处理导入组件 - 文件选择后获取组件信息
const handleImportFileSelect = async (file: File) => {
try {
@ -627,6 +646,34 @@ const GlobalVarContainer = () => {
componentInfo={importComponentInfo}
loading={importLoading}
/>
<Modal
title={'下架组件'}
visible={showOffSaleModal}
style={{ width: '45%' }}
onCancel={() => {
setSelectedItem(null);
setShowOffSaleModal(false);
}}
footer={[
<Button key="cancel" onClick={() => setShowOffSaleModal(false)}>
</Button>,
<Button key="offshelf" type="primary" onClick={() => {
componentOffSaleHandler(false);
}}>
</Button>,
<Button key="stopAndOffshelf" type="primary" status="danger" onClick={() => {
componentOffSaleHandler(true);
}}>
线
</Button>
]}
>
<p></p>
<p> 线使线</p>
</Modal>
</>
);
};

Loading…
Cancel
Save