import React, {useState} from 'react'; import {Form, Input, Modal, Select} from "antd/lib/index"; import {isEmpty} from "../../utils/utils"; const {TextArea} = Input; const accountTypes = [ {text: '密码', value: 'custom'}, {text: '密钥', value: 'private-key'}, ]; const CredentialModal = ({title, visible, handleOk, handleCancel, confirmLoading, model}) => { const [form] = Form.useForm(); const formItemLayout = { labelCol: {span: 6}, wrapperCol: {span: 14}, }; if (model === null || model === undefined) { model = {} } if (isEmpty(model.type)) { model.type = 'custom'; } for (let key in model) { if (model.hasOwnProperty(key)) { if (model[key] === '-') { model[key] = ''; } } } let [type, setType] = useState(model.type); const handleAccountTypeChange = v => { setType(v); model.type = v; } return ( { form .validateFields() .then(values => { form.resetFields(); handleOk(values); }) .catch(info => { }); }} onCancel={handleCancel} confirmLoading={confirmLoading} okText='确定' cancelText='取消' >
{ type === 'private-key' ? <>