|
|
|
|
@ -38,7 +38,7 @@ const Option = Select.Option;
|
|
|
|
|
// 定义组件模式类型
|
|
|
|
|
type ComponentMode = 'create' | 'edit' | 'copy';
|
|
|
|
|
|
|
|
|
|
const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'create' }) => {
|
|
|
|
|
const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'create', permission = 'write' }) => {
|
|
|
|
|
const [selectedImage, setSelectedImage] = useState('');
|
|
|
|
|
const [description, setDescription] = useState('');
|
|
|
|
|
const [classifyList, setClassifyList] = useState([]);
|
|
|
|
|
@ -73,6 +73,8 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
const isEditMode = mode === 'edit';
|
|
|
|
|
// 判断是否为创建模式
|
|
|
|
|
const isCreateMode = mode === 'create';
|
|
|
|
|
// 判断是否为只读模式(read权限)
|
|
|
|
|
const isReadOnly = permission === 'read';
|
|
|
|
|
|
|
|
|
|
const columns: TableColumnProps[] = [
|
|
|
|
|
{
|
|
|
|
|
@ -112,14 +114,14 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
setSelectedApiData(record);
|
|
|
|
|
setShowApiModal(true);
|
|
|
|
|
}}
|
|
|
|
|
disabled={isCopyMode || (componentInfo && !['DEFAULT', 'DESIGN'].includes(componentInfo.componentStatus))}
|
|
|
|
|
disabled={isReadOnly || isCopyMode || (componentInfo && !['DEFAULT', 'DESIGN'].includes(componentInfo.componentStatus))}
|
|
|
|
|
>
|
|
|
|
|
编辑
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
type="text"
|
|
|
|
|
status="danger"
|
|
|
|
|
disabled={isCopyMode || (componentInfo && !['DEFAULT', 'DESIGN'].includes(componentInfo.componentStatus))}
|
|
|
|
|
disabled={isReadOnly || isCopyMode || (componentInfo && !['DEFAULT', 'DESIGN'].includes(componentInfo.componentStatus))}
|
|
|
|
|
onClick={async () => {
|
|
|
|
|
// 显示删除确认框
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
@ -463,34 +465,40 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
const modalFooter = () => {
|
|
|
|
|
return (
|
|
|
|
|
<Space size={30}>
|
|
|
|
|
<Button size="small" type="outline" style={{ borderRadius: 5 }} onClick={() => setVisible(false)}>取消</Button>
|
|
|
|
|
{isCopyMode ? (
|
|
|
|
|
<Button size="small" type="outline" style={{ borderRadius: 5 }} onClick={() => setVisible(false)}>
|
|
|
|
|
{isReadOnly ? '关闭' : '取消'}
|
|
|
|
|
</Button>
|
|
|
|
|
{!isReadOnly && (
|
|
|
|
|
<>
|
|
|
|
|
<Button
|
|
|
|
|
size="small"
|
|
|
|
|
type="primary"
|
|
|
|
|
style={{ borderRadius: 5 }}
|
|
|
|
|
onClick={handleCopyDesign}
|
|
|
|
|
>
|
|
|
|
|
仅复制设计
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
size="small"
|
|
|
|
|
type="primary"
|
|
|
|
|
style={{ borderRadius: 5 }}
|
|
|
|
|
onClick={handleCopyAll}
|
|
|
|
|
>
|
|
|
|
|
复制设计和代码
|
|
|
|
|
</Button>
|
|
|
|
|
{isCopyMode ? (
|
|
|
|
|
<>
|
|
|
|
|
<Button
|
|
|
|
|
size="small"
|
|
|
|
|
type="primary"
|
|
|
|
|
style={{ borderRadius: 5 }}
|
|
|
|
|
onClick={handleCopyDesign}
|
|
|
|
|
>
|
|
|
|
|
仅复制设计
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
size="small"
|
|
|
|
|
type="primary"
|
|
|
|
|
style={{ borderRadius: 5 }}
|
|
|
|
|
onClick={handleCopyAll}
|
|
|
|
|
>
|
|
|
|
|
复制设计和代码
|
|
|
|
|
</Button>
|
|
|
|
|
</>
|
|
|
|
|
) : showSaveBtn ? (
|
|
|
|
|
<Button size="small" type="primary" style={{ borderRadius: 5 }} onClick={() => onSubmit()}>
|
|
|
|
|
{isEditMode ? '更新' : '保存'}
|
|
|
|
|
</Button>
|
|
|
|
|
) : (
|
|
|
|
|
<Button size="small" type="primary" style={{ borderRadius: 5 }} onClick={() => onSubmit()}>
|
|
|
|
|
{isEditMode ? '更新组件信息' : '提交组件信息'}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
) : showSaveBtn ? (
|
|
|
|
|
<Button size="small" type="primary" style={{ borderRadius: 5 }} onClick={() => onSubmit()}>
|
|
|
|
|
{isEditMode ? '更新' : '保存'}
|
|
|
|
|
</Button>
|
|
|
|
|
) : (
|
|
|
|
|
<Button size="small" type="primary" style={{ borderRadius: 5 }} onClick={() => onSubmit()}>
|
|
|
|
|
{isEditMode ? '更新组件信息' : '提交组件信息'}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</Space>
|
|
|
|
|
);
|
|
|
|
|
@ -506,6 +514,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
headers={{ Authorization: getToken() }}
|
|
|
|
|
fileList={file ? [file] : initialImageUrl ? [{ url: initialImageUrl, status: 'done' }] : []}
|
|
|
|
|
showUploadList={false}
|
|
|
|
|
disabled={isReadOnly}
|
|
|
|
|
onChange={(_, currentFile: any) => {
|
|
|
|
|
setFile({
|
|
|
|
|
...currentFile,
|
|
|
|
|
@ -601,7 +610,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]}>
|
|
|
|
|
<Input style={{ width: '90%' }} allowClear placeholder="请输入名称" />
|
|
|
|
|
<Input style={{ width: '90%' }} allowClear placeholder="请输入名称" disabled={isReadOnly} />
|
|
|
|
|
</FormItem>
|
|
|
|
|
</Grid.Col>
|
|
|
|
|
<Grid.Col span={14}>
|
|
|
|
|
@ -620,7 +629,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
style={{ width: '90%' }}
|
|
|
|
|
allowClear
|
|
|
|
|
placeholder="请输入代码标识"
|
|
|
|
|
disabled={created || isEditMode}
|
|
|
|
|
disabled={isReadOnly || created || isEditMode}
|
|
|
|
|
onChange={(e) => debouncedValidateProjectId(e)}
|
|
|
|
|
/>
|
|
|
|
|
</FormItem>
|
|
|
|
|
@ -642,6 +651,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
<Select
|
|
|
|
|
placeholder="请选择分类"
|
|
|
|
|
style={{ width: '90%' }}
|
|
|
|
|
disabled={isReadOnly}
|
|
|
|
|
>
|
|
|
|
|
{classifyList.map((option, index) => (
|
|
|
|
|
<Option key={option.id} value={option.label}>
|
|
|
|
|
@ -666,7 +676,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
<Select
|
|
|
|
|
placeholder="请选择组件语言"
|
|
|
|
|
style={{ width: '90%' }}
|
|
|
|
|
disabled={created || isEditMode || isCopyMode}
|
|
|
|
|
disabled={isReadOnly || created || isEditMode || isCopyMode}
|
|
|
|
|
>
|
|
|
|
|
{codeLanguageOptions.map((option) => (
|
|
|
|
|
<Option key={option.value} value={option.value}>
|
|
|
|
|
@ -685,6 +695,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
allowCreate
|
|
|
|
|
mode="multiple"
|
|
|
|
|
style={{ width: '90%' }}
|
|
|
|
|
disabled={isReadOnly}
|
|
|
|
|
>
|
|
|
|
|
{tagsList.map((option, index) => (
|
|
|
|
|
<Option key={option.value} value={option.value}>
|
|
|
|
|
@ -709,7 +720,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
<Select
|
|
|
|
|
placeholder="请选择组件类型"
|
|
|
|
|
style={{ width: '90%' }}
|
|
|
|
|
disabled={created || isEditMode}
|
|
|
|
|
disabled={isReadOnly || created || isEditMode}
|
|
|
|
|
>
|
|
|
|
|
{componentTypeOptions.map((option) => (
|
|
|
|
|
<Option key={option.value} value={option.value}>
|
|
|
|
|
@ -726,6 +737,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
<EditorSection
|
|
|
|
|
visible={visible}
|
|
|
|
|
initialContent={description}
|
|
|
|
|
disabled={isReadOnly}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@ -740,7 +752,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
type="secondary"
|
|
|
|
|
style={{ borderRadius: 5 }}
|
|
|
|
|
loading={codeInitLoading}
|
|
|
|
|
disabled={(!componentDesignData || componentDesignData.length === 0) || componentInfo && !['DEFAULT', 'DESIGN'].includes(componentInfo.componentStatus)}
|
|
|
|
|
disabled={isReadOnly || (!componentDesignData || componentDesignData.length === 0) || componentInfo && !['DEFAULT', 'DESIGN'].includes(componentInfo.componentStatus)}
|
|
|
|
|
onClick={() => handleCodeInit()}
|
|
|
|
|
>
|
|
|
|
|
代码初始化
|
|
|
|
|
@ -753,7 +765,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c
|
|
|
|
|
setSelectedApiData(null); // 确保新增时清空选中的API数据
|
|
|
|
|
setShowApiModal(true);
|
|
|
|
|
}}
|
|
|
|
|
disabled={componentInfo && !['DEFAULT', 'DESIGN'].includes(componentInfo.componentStatus)}
|
|
|
|
|
disabled={isReadOnly || componentInfo && !['DEFAULT', 'DESIGN'].includes(componentInfo.componentStatus)}
|
|
|
|
|
>
|
|
|
|
|
+ 新增接口
|
|
|
|
|
</Button>
|
|
|
|
|
|