You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 2.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import KFModal from '@/components/KFModal';
  2. import { createEditorMirrorReq } from '@/services/developmentEnvironment';
  3. import { to } from '@/utils/promise';
  4. import { Form, Input, message, type ModalProps } from 'antd';
  5. interface CreateMirrorModalProps extends Omit<ModalProps, 'onOk'> {
  6. envId: number; // 开发环境id
  7. onOk: () => void;
  8. }
  9. function CreateMirrorModal({ envId, onOk, ...rest }: CreateMirrorModalProps) {
  10. // 上传请求
  11. const createDatasetVersion = async (params: any) => {
  12. const [res] = await to(
  13. createEditorMirrorReq({
  14. ...params,
  15. dev_environment_id: envId,
  16. upload_type: 1,
  17. version: params['tagName'],
  18. }),
  19. );
  20. if (res) {
  21. message.success('创建成功,请到 “多形态资源库” - “个人镜像” 中查看');
  22. onOk?.();
  23. }
  24. };
  25. // 提交
  26. const onFinish = (formData: any) => {
  27. createDatasetVersion(formData);
  28. };
  29. return (
  30. <KFModal
  31. {...rest}
  32. title="制作镜像"
  33. image={require('@/assets/img/create-experiment.png')}
  34. width={825}
  35. okButtonProps={{
  36. htmlType: 'submit',
  37. form: 'form',
  38. }}
  39. >
  40. <Form name="form" layout="vertical" onFinish={onFinish} autoComplete="off">
  41. <Form.Item
  42. label="镜像名称"
  43. name="name"
  44. rules={[
  45. {
  46. required: true,
  47. message: '请输入镜像名称',
  48. },
  49. {
  50. pattern: /^[a-z0-9/._-]*$/,
  51. message: '只支持小写字母、数字、点(.)、下划线(_)、中横线(-)、斜杠(/)',
  52. },
  53. ]}
  54. >
  55. <Input placeholder="请输入镜像名称" maxLength={64} showCount allowClear />
  56. </Form.Item>
  57. <Form.Item
  58. label="镜像版本"
  59. name="tag_name"
  60. rules={[
  61. {
  62. required: true,
  63. message: '请输入镜像版本',
  64. },
  65. {
  66. pattern: /^[a-zA-Z0-9._-]+$/,
  67. message: '版本只支持字母、数字、点(.)、下划线(_)、中横线(-)',
  68. },
  69. ]}
  70. >
  71. <Input placeholder="请输入镜像版本" maxLength={64} showCount allowClear />
  72. </Form.Item>
  73. <Form.Item
  74. label="镜像描述"
  75. name="description"
  76. rules={[
  77. {
  78. required: true,
  79. message: '请输入镜像描述',
  80. },
  81. ]}
  82. >
  83. <Input.TextArea
  84. placeholder="请输入镜像描述"
  85. autoSize={{ minRows: 3, maxRows: 6 }}
  86. maxLength={128}
  87. showCount
  88. allowClear
  89. />
  90. </Form.Item>
  91. </Form>
  92. </KFModal>
  93. );
  94. }
  95. export default CreateMirrorModal;