{
+ tag.unshift(item);
+ });
+ }
+
+ return { tag };
+ }
+ componentDidMount() {
+ this.handleInit(this.props.tagMsg);
+ }
+
+ handleInit(data) {
+ // this.props.form.resetFields();
+ let newValue = this.initState(data);
+ // return newValue;
+ this.setState({ ...newValue });
+ }
+
+ addHeader = (val, index, name, label) => {
+ let newValue = {};
+ newValue[name] = [].concat(this.state[name]);
+ newValue[name][index][label] = val;
+ let nextData = this.state[name][index + 1];
+ if (!(nextData && typeof nextData === 'object')) {
+ let data = { name: '', desc: '' };
+ newValue[name] = [].concat(this.state[name], data);
+ }
+ this.setState(newValue);
+ };
+
+ delHeader = (key, name) => {
+ // let curValue = this.props.form.getFieldValue(name);
+ let curValue = this.state[name];
+ let newValue = {};
+ newValue[name] = curValue.filter((val, index) => {
+ return index !== key;
+ });
+ // this.props.form.setFieldsValue(newValue);
+ this.setState(newValue);
+ };
+
+ handleChange = (val, index, name, label) => {
+ let newValue = this.state;
+ newValue[name][index][label] = val;
+ this.setState(newValue);
+ };
+
+ render() {
+ const commonTpl = (item, index, name) => {
+ const length = this.state[name].length - 1;
+ return (
+
+
+ this.addHeader(e.target.value, index, name, 'name')}
+ />
+
+
+ this.handleChange(e.target.value, index, name, 'desc')}
+ value={item.desc || ''}
+ />
+
+
+ {/* 新增的项中,只有最后一项没有有删除按钮 */}
+ {
+ e.stopPropagation();
+ this.delHeader(index, name);
+ }}
+ />
+
+
+ );
+ };
+
+ return (
+
+ {this.state.tag.map((item, index) => {
+ return commonTpl(item, index, 'tag');
+ })}
+
+ );
+ }
+}
+
+export default ProjectTag;
diff --git a/client/containers/Project/Setting/ProjectMessage/ProjectTag.scss b/client/containers/Project/Setting/ProjectMessage/ProjectTag.scss
new file mode 100644
index 00000000..99b36819
--- /dev/null
+++ b/client/containers/Project/Setting/ProjectMessage/ProjectTag.scss
@@ -0,0 +1,18 @@
+
+.project-tag {
+ .item-name {
+ margin-right: 16px;
+ }
+
+ .delete {
+ font-size: 16px;
+ }
+
+ .tag-item {
+ margin-bottom: 8px;
+ }
+
+ .tag-last-row {
+ display: none;
+ }
+}
\ No newline at end of file
diff --git a/client/reducer/modules/project.js b/client/reducer/modules/project.js
index 7e937a89..582232a4 100755
--- a/client/reducer/modules/project.js
+++ b/client/reducer/modules/project.js
@@ -205,7 +205,7 @@ export function addProject(data) {
// 修改项目
export function updateProject(data) {
- const { name, project_type, basepath, desc, _id, env, group_id, switch_notice, strice, is_json5 } = data;
+ const { name, project_type, basepath, desc, _id, env, group_id, switch_notice, strice, is_json5, tag } = data;
const param = {
name,
project_type,
@@ -216,7 +216,8 @@ export function updateProject(data) {
env,
group_id,
strice,
- is_json5
+ is_json5,
+ tag
};
return {
type: PROJECT_UPDATE,
diff --git a/server/models/project.js b/server/models/project.js
index 32bf7963..e7e42276 100755
--- a/server/models/project.js
+++ b/server/models/project.js
@@ -34,7 +34,8 @@ class projectModel extends baseModel {
project_mock_script: String,
is_mock_open: { type: Boolean, default: false },
strice: { type: Boolean, default: false },
- is_json5: { type: Boolean, default: true }
+ is_json5: { type: Boolean, default: true },
+ tag: [{name: String, desc: String}]
};
}
@@ -84,7 +85,7 @@ class projectModel extends baseModel {
getBaseInfo(id, select) {
select =
select ||
- '_id uid name basepath switch_notice desc group_id project_type env icon color add_time up_time pre_script after_script project_mock_script is_mock_open strice is_json5';
+ '_id uid name basepath switch_notice desc group_id project_type env icon color add_time up_time pre_script after_script project_mock_script is_mock_open strice is_json5 tag';
return this.model
.findOne({
_id: id