|
|
|
@ -6,7 +6,15 @@ import { updateComponentDesign } from '@/api/componentDevelopProcess';
|
|
|
|
const FormItem = Form.Item;
|
|
|
|
const FormItem = Form.Item;
|
|
|
|
const TextArea = Input.TextArea;
|
|
|
|
const TextArea = Input.TextArea;
|
|
|
|
|
|
|
|
|
|
|
|
const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesignData, onUpdateComponentDesign, onCancel, onOk }) => {
|
|
|
|
const AddApiModal = ({
|
|
|
|
|
|
|
|
visible,
|
|
|
|
|
|
|
|
baseInfo,
|
|
|
|
|
|
|
|
componentDesignProgress,
|
|
|
|
|
|
|
|
componentDesignData,
|
|
|
|
|
|
|
|
onUpdateComponentDesign,
|
|
|
|
|
|
|
|
onCancel,
|
|
|
|
|
|
|
|
onOk
|
|
|
|
|
|
|
|
}) => {
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
const [parametersData, setParametersData] = useState([]);
|
|
|
|
const [parametersData, setParametersData] = useState([]);
|
|
|
|
const [responsesData, setResponsesData] = useState([]);
|
|
|
|
const [responsesData, setResponsesData] = useState([]);
|
|
|
|
@ -27,6 +35,9 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
...param
|
|
|
|
...param
|
|
|
|
})));
|
|
|
|
})));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
setParametersData([]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 设置响应表格数据
|
|
|
|
// 设置响应表格数据
|
|
|
|
if (componentDesignProgress.responses && Array.isArray(componentDesignProgress.responses)) {
|
|
|
|
if (componentDesignProgress.responses && Array.isArray(componentDesignProgress.responses)) {
|
|
|
|
@ -35,6 +46,9 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
...response
|
|
|
|
...response
|
|
|
|
})));
|
|
|
|
})));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
setResponsesData([]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (visible) {
|
|
|
|
else if (visible) {
|
|
|
|
// 重置表单和表格数据
|
|
|
|
// 重置表单和表格数据
|
|
|
|
@ -48,7 +62,7 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await form.validate();
|
|
|
|
await form.validate();
|
|
|
|
const formData = form.getFields();
|
|
|
|
const formData = form.getFields();
|
|
|
|
|
|
|
|
|
|
|
|
// 构造要提交的数据
|
|
|
|
// 构造要提交的数据
|
|
|
|
const params = {
|
|
|
|
const params = {
|
|
|
|
baseInfo
|
|
|
|
baseInfo
|
|
|
|
@ -69,9 +83,10 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return item;
|
|
|
|
return item;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
params['operates'] = updatedOperates;
|
|
|
|
params['operates'] = updatedOperates;
|
|
|
|
} else if (componentDesignData && Array.isArray(componentDesignData)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (componentDesignData && Array.isArray(componentDesignData)) {
|
|
|
|
// 新增模式,将新记录添加到现有数据中
|
|
|
|
// 新增模式,将新记录添加到现有数据中
|
|
|
|
const newOperate = {
|
|
|
|
const newOperate = {
|
|
|
|
...formData,
|
|
|
|
...formData,
|
|
|
|
@ -79,9 +94,10 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
parameters: parametersData,
|
|
|
|
parameters: parametersData,
|
|
|
|
responses: responsesData
|
|
|
|
responses: responsesData
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
params['operates'] = [...componentDesignData, newOperate];
|
|
|
|
params['operates'] = [...componentDesignData, newOperate];
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// 没有现有数据时,创建包含单个元素的数组
|
|
|
|
// 没有现有数据时,创建包含单个元素的数组
|
|
|
|
params['operates'] = [{
|
|
|
|
params['operates'] = [{
|
|
|
|
...formData,
|
|
|
|
...formData,
|
|
|
|
@ -90,7 +106,7 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
responses: responsesData
|
|
|
|
responses: responsesData
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const res: any = await updateComponentDesign(params);
|
|
|
|
const res: any = await updateComponentDesign(params);
|
|
|
|
|
|
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
if (res.code === 200) {
|
|
|
|
@ -137,10 +153,16 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
<TextArea placeholder="请输入描述" />
|
|
|
|
<TextArea placeholder="请输入描述" />
|
|
|
|
</FormItem>
|
|
|
|
</FormItem>
|
|
|
|
<FormItem label="输入参数" field="parameters">
|
|
|
|
<FormItem label="输入参数" field="parameters">
|
|
|
|
<EditableTable onDataUpdate={setParametersData} />
|
|
|
|
<EditableTable
|
|
|
|
|
|
|
|
onDataUpdate={setParametersData}
|
|
|
|
|
|
|
|
initialData={componentDesignProgress?.parameters || []}
|
|
|
|
|
|
|
|
/>
|
|
|
|
</FormItem>
|
|
|
|
</FormItem>
|
|
|
|
<FormItem label="输出参数" field="responses">
|
|
|
|
<FormItem label="输出参数" field="responses">
|
|
|
|
<EditableTable onDataUpdate={setResponsesData} />
|
|
|
|
<EditableTable
|
|
|
|
|
|
|
|
onDataUpdate={setResponsesData}
|
|
|
|
|
|
|
|
initialData={componentDesignProgress?.responses || []}
|
|
|
|
|
|
|
|
/>
|
|
|
|
</FormItem>
|
|
|
|
</FormItem>
|
|
|
|
</Form>
|
|
|
|
</Form>
|
|
|
|
</Modal>
|
|
|
|
</Modal>
|
|
|
|
|