|
|
|
|
@ -6,7 +6,15 @@ import { updateComponentDesign } from '@/api/componentDevelopProcess';
|
|
|
|
|
const FormItem = Form.Item;
|
|
|
|
|
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 [parametersData, setParametersData] = useState([]);
|
|
|
|
|
const [responsesData, setResponsesData] = useState([]);
|
|
|
|
|
@ -27,6 +35,9 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
|
...param
|
|
|
|
|
})));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
setParametersData([]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置响应表格数据
|
|
|
|
|
if (componentDesignProgress.responses && Array.isArray(componentDesignProgress.responses)) {
|
|
|
|
|
@ -35,6 +46,9 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
|
...response
|
|
|
|
|
})));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
setResponsesData([]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (visible) {
|
|
|
|
|
// 重置表单和表格数据
|
|
|
|
|
@ -71,7 +85,8 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
params['operates'] = updatedOperates;
|
|
|
|
|
} else if (componentDesignData && Array.isArray(componentDesignData)) {
|
|
|
|
|
}
|
|
|
|
|
else if (componentDesignData && Array.isArray(componentDesignData)) {
|
|
|
|
|
// 新增模式,将新记录添加到现有数据中
|
|
|
|
|
const newOperate = {
|
|
|
|
|
...formData,
|
|
|
|
|
@ -81,7 +96,8 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
params['operates'] = [...componentDesignData, newOperate];
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 没有现有数据时,创建包含单个元素的数组
|
|
|
|
|
params['operates'] = [{
|
|
|
|
|
...formData,
|
|
|
|
|
@ -137,10 +153,16 @@ const AddApiModal = ({ visible, baseInfo, componentDesignProgress, componentDesi
|
|
|
|
|
<TextArea placeholder="请输入描述" />
|
|
|
|
|
</FormItem>
|
|
|
|
|
<FormItem label="输入参数" field="parameters">
|
|
|
|
|
<EditableTable onDataUpdate={setParametersData} />
|
|
|
|
|
<EditableTable
|
|
|
|
|
onDataUpdate={setParametersData}
|
|
|
|
|
initialData={componentDesignProgress?.parameters || []}
|
|
|
|
|
/>
|
|
|
|
|
</FormItem>
|
|
|
|
|
<FormItem label="输出参数" field="responses">
|
|
|
|
|
<EditableTable onDataUpdate={setResponsesData} />
|
|
|
|
|
<EditableTable
|
|
|
|
|
onDataUpdate={setResponsesData}
|
|
|
|
|
initialData={componentDesignProgress?.responses || []}
|
|
|
|
|
/>
|
|
|
|
|
</FormItem>
|
|
|
|
|
</Form>
|
|
|
|
|
</Modal>
|
|
|
|
|
|