2019-12-18 17:00:44 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<transition name="right-box">
|
2019-12-20 17:18:30 +08:00
|
|
|
|
<div class="right-box right-box-module" v-if="rightBox.show">
|
2019-12-19 17:22:18 +08:00
|
|
|
|
<!-- begin--顶部按钮-->
|
|
|
|
|
|
<div class="right-box-top-btns">
|
2020-01-17 09:54:01 +08:00
|
|
|
|
<button id="module-del" type="button" v-if="module.id != '' && rightBox.isEdit" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82">
|
|
|
|
|
|
<span class="right-box-top-btn-icon"><i class="el-icon-delete"></i></span>
|
|
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</button>
|
2020-01-17 09:54:01 +08:00
|
|
|
|
<button v-if="!rightBox.isEdit" id="module-save" type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82">
|
|
|
|
|
|
<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-edit"></i></span>
|
|
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.edit')}}</span>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</button>
|
2019-12-19 17:22:18 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end--顶部按钮-->
|
2019-12-18 17:00:44 +08:00
|
|
|
|
|
2019-12-19 17:22:18 +08:00
|
|
|
|
<!-- begin--标题-->
|
|
|
|
|
|
<div class="right-box-title">{{rightBox.title}}</div>
|
|
|
|
|
|
<!-- end--标题-->
|
2019-12-18 17:00:44 +08:00
|
|
|
|
|
2019-12-19 17:22:18 +08:00
|
|
|
|
<!-- begin--表单-->
|
2019-12-27 17:53:17 +08:00
|
|
|
|
<el-scrollbar class="right-box-form-box">
|
|
|
|
|
|
<el-form class="right-box-form" :model="module" label-position="top" :rules="rules" ref="moduleForm">
|
2020-01-02 18:13:01 +08:00
|
|
|
|
<el-form-item :label='$t("project.project.project")' prop="project">
|
2020-01-06 19:03:38 +08:00
|
|
|
|
<el-select v-if="rightBox.isEdit" value-key="id" popper-class="config-dropdown" v-model="module.project" placeholder="" size="small">
|
2020-01-13 18:48:25 +08:00
|
|
|
|
<el-option :id="'module-project-'+item.id" v-for="item in projectList" :key="item.id" :label="item.name" :value="item"></el-option>
|
2019-12-19 17:22:18 +08:00
|
|
|
|
</el-select>
|
2020-01-06 19:03:38 +08:00
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{module.project.name}}</div>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label='$t("project.module.moduleName")' prop="name">
|
2020-01-06 19:03:38 +08:00
|
|
|
|
<el-input v-if="rightBox.isEdit" placeholder="" maxlength="64" show-word-limit v-model="module.name" size="small"></el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{module.name}}</div>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label='$t("project.module.description")' prop="remark">
|
2020-01-06 19:03:38 +08:00
|
|
|
|
<el-input v-if="rightBox.isEdit" type="textarea" placeholder="" maxlength="1024" show-word-limit v-model="module.remark" size="small"></el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{module.remark}}</div>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</el-form-item>
|
2020-01-06 19:03:38 +08:00
|
|
|
|
<div class="right-box-form-tip" v-if="rightBox.isEdit">
|
2019-12-27 17:53:17 +08:00
|
|
|
|
{{$t('project.module.tip.defaultEndpointSet')}}
|
|
|
|
|
|
<div class="line-100"></div>
|
|
|
|
|
|
{{$t('project.module.tip.relation')}}
|
2019-12-18 17:00:44 +08:00
|
|
|
|
</div>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
<el-form-item :label='$t("project.endpoint.port")' prop="port">
|
2020-01-06 19:03:38 +08:00
|
|
|
|
<el-input v-if="rightBox.isEdit" placeholder="" v-model.number="module.port" size="small"></el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{module.port}}</div>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label='$t("project.endpoint.path")' prop="path">
|
2020-01-06 19:03:38 +08:00
|
|
|
|
<el-input v-if="rightBox.isEdit" placeholder="" v-model="module.path" size="small"></el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{module.path}}</div>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item class="right-box-form-param">
|
|
|
|
|
|
<template slot="label">
|
2019-12-31 19:02:58 +08:00
|
|
|
|
<span>{{$t('project.endpoint.param')}}</span>
|
2020-01-06 19:03:38 +08:00
|
|
|
|
<div class="right-box-form-btns" v-if="rightBox.isEdit">
|
2019-12-27 17:53:17 +08:00
|
|
|
|
<button style="display: none;">第一个button会出现意料之外的hover样式,找不到原因,只好加个不可见的button规避问题</button>
|
2020-01-16 18:11:15 +08:00
|
|
|
|
<button id="module-clear-all" type="button" @click="clearAllParam" class="nz-btn nz-btn-size-normal nz-btn-style-light">
|
2019-12-27 17:53:17 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.clearAll')}}</span>
|
|
|
|
|
|
</button>
|
2020-01-16 18:11:15 +08:00
|
|
|
|
<button id="module-add-param" type="button" @click="addParam" class="nz-btn nz-btn-size-normal nz-btn-style-normal">
|
2019-12-27 17:53:17 +08:00
|
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.add')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2020-01-19 19:34:38 +08:00
|
|
|
|
<div v-if="rightBox.isEdit" class="param-box param-box-module">
|
|
|
|
|
|
<div class="param-box-row" v-for="(item, index) in module.paramObj">
|
2019-12-27 17:53:17 +08:00
|
|
|
|
<el-form-item class="param-box-row-key" :rules="{required: true, message: $t('validate.required'), trigger: 'blur'}" :prop="'paramObj.' + index + '.key'">
|
|
|
|
|
|
<el-input placeholder="key" size="mini" v-model="item.key"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2019-12-19 17:22:18 +08:00
|
|
|
|
<span class="param-box-row-eq">=</span>
|
2019-12-27 17:53:17 +08:00
|
|
|
|
<el-form-item class="param-box-row-value" :rules="{required: true, message: $t('validate.required'), trigger: 'blur'}" :prop="'paramObj.' + index + '.value'">
|
|
|
|
|
|
<el-input placeholder="value" size="mini" v-model="item.value"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2020-01-13 18:48:25 +08:00
|
|
|
|
<span class="param-box-row-symbol" :id="'moduel-remove-param-'+index" @click="removeParam(index)"><i class="nz-icon nz-icon-minus-square"></i></span>
|
2019-12-18 17:00:44 +08:00
|
|
|
|
</div>
|
2020-01-19 19:34:38 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div v-for="(item, index) in module.paramObj" v-if="!rightBox.isEdit">
|
|
|
|
|
|
<div class="right-box-form-content-txt">{{item.key}}={{item.value}}</div>
|
2019-12-18 17:00:44 +08:00
|
|
|
|
</div>
|
2020-01-06 19:03:38 +08:00
|
|
|
|
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-scrollbar>
|
2020-01-16 18:11:15 +08:00
|
|
|
|
|
|
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
|
<div class="right-box-bottom-btns">
|
2020-02-17 17:29:15 +08:00
|
|
|
|
<button @click="esc" id="module-box-esc" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-min-width-100">
|
2020-01-16 18:11:15 +08:00
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
2020-02-17 17:29:15 +08:00
|
|
|
|
<button v-if="rightBox.isEdit" @click="saveOrToEdit" id="module-box-save" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-100">
|
2020-01-16 18:11:15 +08:00
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2019-12-18 17:00:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2020-01-17 10:35:09 +08:00
|
|
|
|
import {noSpecialChar} from "../js/validate";
|
|
|
|
|
|
import {port} from "../js/validate";
|
|
|
|
|
|
|
2019-12-18 17:00:44 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: "moduleBox",
|
|
|
|
|
|
props: {
|
|
|
|
|
|
module: Object,
|
|
|
|
|
|
currentProject: Object
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
rightBox: {
|
|
|
|
|
|
show: false,
|
2020-01-06 19:03:38 +08:00
|
|
|
|
title: '',
|
|
|
|
|
|
isEdit:false
|
2019-12-18 17:00:44 +08:00
|
|
|
|
},
|
2019-12-27 17:53:17 +08:00
|
|
|
|
rules: {
|
|
|
|
|
|
name: [
|
2020-01-17 10:35:09 +08:00
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'},
|
|
|
|
|
|
{validator:noSpecialChar,trigger: "change"}
|
2019-12-27 17:53:17 +08:00
|
|
|
|
],
|
|
|
|
|
|
project: [
|
2020-01-02 18:13:01 +08:00
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'change'}
|
2019-12-27 17:53:17 +08:00
|
|
|
|
],
|
|
|
|
|
|
port: [
|
2020-01-19 19:50:12 +08:00
|
|
|
|
{validator:port, trigger: 'blur'},
|
2019-12-27 17:53:17 +08:00
|
|
|
|
],
|
2020-01-19 19:50:12 +08:00
|
|
|
|
path: [
|
|
|
|
|
|
]
|
2019-12-27 17:53:17 +08:00
|
|
|
|
},
|
2019-12-18 17:00:44 +08:00
|
|
|
|
projectList: [],
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2020-01-06 20:57:49 +08:00
|
|
|
|
show(show, isEdit) {
|
2019-12-18 17:00:44 +08:00
|
|
|
|
this.rightBox.show = show;
|
2020-01-06 20:57:49 +08:00
|
|
|
|
this.rightBox.isEdit = isEdit;
|
2019-12-18 17:00:44 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/*关闭弹框*/
|
|
|
|
|
|
esc() {
|
|
|
|
|
|
this.rightBox.show = false;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/*保存*/
|
|
|
|
|
|
save() {
|
|
|
|
|
|
this.module.param = this.paramToJson(this.module.paramObj);
|
2019-12-27 17:53:17 +08:00
|
|
|
|
this.$refs.moduleForm.validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
2019-12-31 19:02:58 +08:00
|
|
|
|
this.module.projectId = this.module.project.id;
|
2019-12-27 17:53:17 +08:00
|
|
|
|
if (this.module.id) {
|
|
|
|
|
|
this.$put('module', this.module).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2019-12-31 19:02:58 +08:00
|
|
|
|
this.$store.commit('moduleListChange');
|
2019-12-27 17:53:17 +08:00
|
|
|
|
this.rightBox.show = false;
|
2020-01-06 20:57:49 +08:00
|
|
|
|
this.$emit('reload');
|
2019-12-27 17:53:17 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
} else {
|
2019-12-27 17:53:17 +08:00
|
|
|
|
this.$post('module', this.module).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2019-12-31 19:02:58 +08:00
|
|
|
|
this.$store.commit('moduleListChange');
|
2019-12-27 17:53:17 +08:00
|
|
|
|
this.rightBox.show = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
2019-12-27 17:53:17 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
},
|
2020-01-06 19:03:38 +08:00
|
|
|
|
saveOrToEdit: function() {
|
|
|
|
|
|
if (!this.rightBox.isEdit) {
|
|
|
|
|
|
this.rightBox.isEdit = true;
|
|
|
|
|
|
this.rightBox.title = this.$t("project.module.editModule") + " ID:" + this.module.id;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.save();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2019-12-18 17:00:44 +08:00
|
|
|
|
/*删除*/
|
|
|
|
|
|
del() {
|
|
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2019-12-19 17:22:18 +08:00
|
|
|
|
this.$delete("module?ids=" + this.module.id).then(response => {
|
2019-12-18 17:00:44 +08:00
|
|
|
|
if (response.code === 200) {
|
2019-12-19 17:22:18 +08:00
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
this.rightBox.show = false;
|
2019-12-31 19:02:58 +08:00
|
|
|
|
this.$store.commit('moduleListChange');
|
2019-12-18 17:00:44 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
2019-12-19 17:22:18 +08:00
|
|
|
|
});
|
2019-12-18 17:00:44 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/*获取project列表*/
|
|
|
|
|
|
getProjectList: function() {
|
|
|
|
|
|
this.$get('project', {pageSize: 999, pageNo: 1}).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.projectList = response.data.list;
|
|
|
|
|
|
if (this.currentProject && this.currentProject.id) {
|
2019-12-19 17:22:18 +08:00
|
|
|
|
/*for (let i = 0; i < this.projectList.length; i++) {
|
2019-12-18 17:00:44 +08:00
|
|
|
|
if (this.projectList[i].id == this.currentProject.id) {
|
|
|
|
|
|
this.currentProject = this.projectList[i];
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-12-19 17:22:18 +08:00
|
|
|
|
}*/
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 清除param
|
|
|
|
|
|
clearAllParam: function() {
|
|
|
|
|
|
this.module.paramObj = [];
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 新增param
|
|
|
|
|
|
addParam: function() {
|
|
|
|
|
|
this.module.paramObj.push({key: '', value: ''});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 移除单个param
|
|
|
|
|
|
removeParam: function(index) {
|
|
|
|
|
|
this.module.paramObj.splice(index, 1);
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
//将param转为json字符串格式
|
|
|
|
|
|
paramToJson: function(param) {
|
|
|
|
|
|
let tempParam = {};
|
|
|
|
|
|
for (let i = 0; i < param.length; i++) {
|
2019-12-27 17:53:17 +08:00
|
|
|
|
eval('tempParam["' + param[i].key + '"]="' + param[i].value + '"');
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
let jsonString = JSON.stringify(tempParam);
|
|
|
|
|
|
if (jsonString == '{}') {
|
|
|
|
|
|
return "";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return jsonString;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
created() {
|
|
|
|
|
|
this.getProjectList();
|
|
|
|
|
|
},
|
2019-12-31 19:02:58 +08:00
|
|
|
|
computed: {
|
|
|
|
|
|
projectListReloadWatch() {
|
|
|
|
|
|
return this.$store.state.projectListChange;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2019-12-18 17:00:44 +08:00
|
|
|
|
watch: {
|
|
|
|
|
|
module: {
|
|
|
|
|
|
immediate: true,
|
2020-01-06 19:03:38 +08:00
|
|
|
|
deep:true,
|
2019-12-18 17:00:44 +08:00
|
|
|
|
handler(n, o) {
|
|
|
|
|
|
if (n && n.id) {
|
2020-01-06 19:03:38 +08:00
|
|
|
|
this.rightBox.title =this.rightBox.isEdit? this.$t("project.module.editModule") + " ID:" + n.id : this.$t("project.module.module") + " ID:" + n.id ;
|
2019-12-18 17:00:44 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.rightBox.title = this.$t("project.module.createModule");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-12-31 19:02:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
projectListReloadWatch(n, o) {
|
|
|
|
|
|
this.getProjectList();
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
</style>
|