diff --git a/client/containers/ProjectGroups/ProjectList/UpDateModal.js b/client/containers/ProjectGroups/ProjectList/UpDateModal.js
index 277e94b0..8a02545e 100644
--- a/client/containers/ProjectGroups/ProjectList/UpDateModal.js
+++ b/client/containers/ProjectGroups/ProjectList/UpDateModal.js
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
-import { Modal, Form, Input, Icon, Tooltip, Select, message, Button } from 'antd';
+import { Modal, Form, Input, Icon, Tooltip, Select, message, Button, Row, Col } from 'antd';
import { updateProject, fetchProjectList, delProject, changeUpdateModal, changeTableLoading } from '../../../actions/project';
const { TextArea } = Input;
const FormItem = Form.Item;
@@ -23,7 +23,7 @@ const formItemLayout = {
const formItemLayoutWithOutLabel = {
wrapperCol: {
xs: { span: 24, offset: 0 },
- sm: { span: 20, offset: 4 }
+ sm: { span: 20, offset: 6 }
}
};
let uuid = 0;
@@ -87,14 +87,10 @@ class UpDateModal extends Component {
console.log(projectList[handleUpdateIndex]);
let assignValue = Object.assign(projectList[handleUpdateIndex], values);
values.protocol = this.state.protocol.split(':')[0];
- assignValue.env = assignValue.envs.map((item) => {
- console.log(assignValue);
- const arr = assignValue['envs-'+item].split(',');
- if (arr.length === 2) {
- return {
- host: arr[0],
- name: arr[1]
- }
+ assignValue.env = assignValue.envs.map((item, index) => {
+ return {
+ name: values['envs-name-'+index],
+ host: values['envs-host-'+index]
}
});
console.log(assignValue);
@@ -163,57 +159,78 @@ class UpDateModal extends Component {
// const that = this;
const { isUpdateModalShow, projectList, handleUpdateIndex } = this.props;
let initFormValues = {};
- let envMessage = [];
+ let envMessage = [{name:'name1',host:'host1'}, {name:'name2',host:'host2'}];
// 如果列表存在且用户点击修改按钮时,设置表单默认值
if (projectList.length !== 0 && handleUpdateIndex !== -1 ) {
// console.log(projectList[handleUpdateIndex]);
- const { name, basepath, desc, env } = projectList[handleUpdateIndex];
+ const { name, basepath, desc , env} = projectList[handleUpdateIndex];
initFormValues = { name, basepath, desc, env };
- if (env) {
- envMessage = env.map((item) => {
- return item.host + ',' + item.name;
- })
+ if (env.length !== 0) {
+ envMessage = env;
}
initFormValues.prd_host = projectList[handleUpdateIndex].prd_host;
initFormValues.prd_protocol = projectList[handleUpdateIndex].protocol + '\/\/';
- console.log(projectList);
+
}
getFieldDecorator('envs', { initialValue: envMessage });
const envs = getFieldValue('envs');
const formItems = envs.map((k, index) => {
+ // console.log(k);
+ const secondIndex = 'next' + index; // 为保证key的唯一性
return (
- 环境配置
-
-
-
- ) : ''}
- required={false}
- key={k}
- >
- {getFieldDecorator(`envs-${k}`, {
- validateTrigger: ['onChange', 'onBlur'],
- initialValue: envMessage.length !== 0 ? k : '',
- rules: [{
- required: false,
- whitespace: true,
- message: "请输入环境配置,放弃配置请清空输入框"
- }]
- })(
-
- )}
- {envs.length > 1 ? (
- this.remove(k)}
- />
- ) : null}
-
+
+
+ 环境名称) : ''}
+ required={false}
+ key={index}
+ >
+ {getFieldDecorator(`envs-name-${index}`, {
+ validateTrigger: ['onChange', 'onBlur'],
+ initialValue: envMessage.length !== 0 ? k.name : '',
+ rules: [{
+ required: false,
+ whitespace: true,
+ message: "请输入环境名称"
+ }]
+ })(
+
+ )}
+
+
+
+ 环境域名) : ''}
+ required={false}
+ key={secondIndex}
+ >
+ {getFieldDecorator(`envs-host-${index}`, {
+ validateTrigger: ['onChange', 'onBlur'],
+ initialValue: envMessage.length !== 0 ? k.host : '',
+ rules: [{
+ required: false,
+ whitespace: true,
+ message: "请输入环境域名"
+ }]
+ })(
+
+ )}
+
+
+
+ {envs.length > 1 ? (
+ this.remove(k)}
+ />
+ ) : null}
+
+
);
});
return (