Merge remote-tracking branch 'origin/v1.8' into v1.8

This commit is contained in:
Captain.B 2021-03-30 14:11:05 +08:00
commit b54ed5c92e
10 changed files with 68 additions and 45 deletions

View File

@ -190,7 +190,7 @@
this.activeName = name; this.activeName = name;
let currentScenario = { let currentScenario = {
status: "Underway", principal: getCurrentUser().id, status: "Underway", principal: getCurrentUser().id,
apiScenarioModuleId: "root", id: getUUID(), apiScenarioModuleId: "default-module", id: getUUID(),
modulePath: "/" + this.$t("commons.module_title") modulePath: "/" + this.$t("commons.module_title")
}; };
if (this.nodeTree && this.nodeTree.length > 0) { if (this.nodeTree && this.nodeTree.length > 0) {

View File

@ -117,6 +117,9 @@
if (this.currentModule && this.currentModule.id != "root") { if (this.currentModule && this.currentModule.id != "root") {
this.scenarioForm.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null; this.scenarioForm.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null;
this.scenarioForm.apiScenarioModuleId = this.currentModule.id; this.scenarioForm.apiScenarioModuleId = this.currentModule.id;
}else{
this.scenarioForm.modulePath = this.$t("commons.module_title");
this.scenarioForm.apiScenarioModuleId = "default-module";
} }
}, },
getMaintainerOptions() { getMaintainerOptions() {

View File

@ -29,7 +29,7 @@
@refresh="refresh" @refresh="refresh"
ref="basisScenario"/> ref="basisScenario"/>
<api-import ref="apiImport" :moduleOptions="extendTreeNodes" @refreshAll="$emit('refreshAll')"/> <api-import ref="apiImport" :moduleOptions="data" @refreshAll="$emit('refreshAll')"/>
</div> </div>
</template> </template>
@ -82,9 +82,7 @@
trashEnable: false trashEnable: false
}, },
data: [], data: [],
extendTreeNodes: [],
currentModule: undefined, currentModule: undefined,
moduleOptions: [],
operators: [ operators: [
{ {
label: this.$t('api_test.automation.add_scenario'), label: this.$t('api_test.automation.add_scenario'),
@ -141,11 +139,16 @@
this.result = this.$get("/api/automation/module/list/" + this.projectId, response => { this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
if (response.data != undefined && response.data != null) { if (response.data != undefined && response.data != null) {
this.data = response.data; this.data = response.data;
let moduleOptions = []; this.data.unshift({
this.data.forEach(node => { "id": "default-module",
buildNodePath(node, {path: ''}, moduleOptions); "name": this.$t('commons.module_title'),
"level": 0,
"path": "/" + this.$t('commons.module_title'),
"children": [],
});
this.data.forEach(node => {
buildTree(node, {path: ''});
}); });
this.moduleOptions = moduleOptions
} }
}); });
this.$refs.apiImport.open(this.currentModule); this.$refs.apiImport.open(this.currentModule);
@ -163,11 +166,16 @@
this.result = this.$get("/api/automation/module/list/" + this.projectId, response => { this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
if (response.data != undefined && response.data != null) { if (response.data != undefined && response.data != null) {
this.data = response.data; this.data = response.data;
let moduleOptions = []; this.data.unshift({
this.data.forEach(node => { "id": "default-module",
buildNodePath(node, {path: ''}, moduleOptions); "name": this.$t('commons.module_title'),
"level": 0,
"path": "/" + this.$t('commons.module_title'),
"children": [],
});
this.data.forEach(node => {
buildTree(node, {path: ''});
}); });
this.moduleOptions = moduleOptions
} }
}); });
this.$refs.apiImport.open(this.currentModule); this.$refs.apiImport.open(this.currentModule);
@ -188,17 +196,17 @@
this.result = this.$get(url, response => { this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) { if (response.data != undefined && response.data != null) {
this.data = response.data; this.data = response.data;
this.extendTreeNodes = []; this.data.unshift({
this.extendTreeNodes.unshift({ "id": "default-module",
"id": "root",
"name": this.$t('commons.module_title'), "name": this.$t('commons.module_title'),
"level": 0, "level": 0,
"children": this.data, "path": "/" + this.$t('commons.module_title'),
"children": [],
}); });
this.extendTreeNodes.forEach(node => { this.data.forEach(node => {
buildTree(node, {path: ''}); buildTree(node, {path: ''});
}); });
this.$emit('setModuleOptions', this.extendTreeNodes); this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data); this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) { if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText); this.$refs.nodeTree.filter(this.condition.filterText);

View File

@ -84,7 +84,7 @@
callback(); callback();
}; };
return { return {
httpForm: {environmentId: "", moduleId: "root"}, httpForm: {environmentId: "", moduleId: "default-module"},
moduleOptions: [], moduleOptions: [],
httpVisible: false, httpVisible: false,
currentModule: {}, currentModule: {},
@ -251,13 +251,13 @@
let url = "/api/module/list/" + getCurrentProjectID() + "/" + data.protocol; let url = "/api/module/list/" + getCurrentProjectID() + "/" + data.protocol;
this.result = this.$get(url, response => { this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) { if (response.data != undefined && response.data != null) {
let data = response.data; this.moduleOptions = response.data;
this.moduleOptions = [];
this.moduleOptions.unshift({ this.moduleOptions.unshift({
"id": "root", "id": "default-module",
"name": this.$t('commons.module_title'), "name": this.$t('commons.module_title'),
"level": 0, "level": 0,
"children": data, "path": "/" + this.$t('commons.module_title'),
"children": [],
}); });
this.moduleOptions.forEach(node => { this.moduleOptions.forEach(node => {
buildTree(node, {path: ''}); buildTree(node, {path: ''});
@ -282,7 +282,7 @@
data.protocol = "DUBBO"; data.protocol = "DUBBO";
} }
data.id = getUUID(); data.id = getUUID();
this.httpForm = {id: data.id, name: data.name, protocol: data.protocol, path: data.path, method: api.method, userId: getCurrentUser().id, request: data, moduleId: "root"}; this.httpForm = {id: data.id, name: data.name, protocol: data.protocol, path: data.path, method: api.method, userId: getCurrentUser().id, request: data, moduleId: "default-module"};
this.getMaintainerOptions(); this.getMaintainerOptions();
this.list(data); this.list(data);
this.httpVisible = true; this.httpVisible = true;

View File

@ -32,7 +32,7 @@
</el-tooltip> </el-tooltip>
<slot name="button"></slot> <slot name="button"></slot>
<el-tooltip content="Copy" placement="top"> <el-tooltip content="Copy" placement="top">
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="padding: 5px"/> <el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="padding: 5px" :disabled="data.disabled && !data.root"/>
</el-tooltip> </el-tooltip>
<step-extend-btns style="display: contents" :data="data" @copy="copyRow" @remove="remove" @openScenario="openScenario" v-if="showBtn && (!data.disabled || data.root)"/> <step-extend-btns style="display: contents" :data="data" @copy="copyRow" @remove="remove" @openScenario="openScenario" v-if="showBtn && (!data.disabled || data.root)"/>
</div> </div>

View File

@ -154,6 +154,9 @@
if (this.currentModule != null) { if (this.currentModule != null) {
this.httpForm.modulePath = this.currentModule.method != undefined ? this.currentModule.method : null; this.httpForm.modulePath = this.currentModule.method != undefined ? this.currentModule.method : null;
this.httpForm.moduleId = this.currentModule.id; this.httpForm.moduleId = this.currentModule.id;
} else {
this.httpForm.modulePath = this.$t("commons.module_title");
this.httpForm.moduleId = "default-module";
} }
}, },

View File

@ -114,8 +114,8 @@ export default {
this.testCaseForm.nodePath = this.currentModule.path; this.testCaseForm.nodePath = this.currentModule.path;
this.testCaseForm.nodeId = this.currentModule.id; this.testCaseForm.nodeId = this.currentModule.id;
} else { } else {
this.testCaseForm.nodePath = "/全部用例" this.testCaseForm.nodePath = "/默认模块"
this.testCaseForm.nodeId = "root" this.testCaseForm.nodeId = "default-module"
} }
this.result = this.$post(path, this.testCaseForm, response => { this.result = this.$post(path, this.testCaseForm, response => {
this.testCaseForm.id = response.data.id this.testCaseForm.id = response.data.id

View File

@ -35,7 +35,7 @@
<el-col :span="7"> <el-col :span="7">
<el-form-item :label="$t('test_track.case.module')" :label-width="formLabelWidth" prop="module"> <el-form-item :label="$t('test_track.case.module')" :label-width="formLabelWidth" prop="module">
<ms-select-tree :disabled="readOnly" :data="moduleOptions" :defaultKey="form.module" :obj="moduleObj" <ms-select-tree :disabled="readOnly" :data="treeNodes" :defaultKey="form.module" :obj="moduleObj"
@getValue="setModule" clearable checkStrictly size="small" /> @getValue="setModule" clearable checkStrictly size="small" />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -314,7 +314,7 @@ export default {
dialogFormVisible: false, dialogFormVisible: false,
form: { form: {
name: '', name: '',
module: 'root', module: 'default-module',
nodePath:'', nodePath:'',
maintainer: getCurrentUser().id, maintainer: getCurrentUser().id,
priority: 'P0', priority: 'P0',
@ -416,10 +416,6 @@ export default {
}; };
}); });
}, 1000); }, 1000);
if(this.selectNode && this.selectNode.data){
this.form.module = this.selectNode.data.id;
this.form.nodePath = this.selectNode.data.path;
}
}, },
watch: { watch: {
treeNodes() { treeNodes() {
@ -432,7 +428,14 @@ export default {
created() { created() {
this.loadOptions(); this.loadOptions();
this.addListener(); // ctrl s this.addListener(); // ctrl s
if(this.selectNode && this.selectNode.data && this.form.id){
this.form.module = this.selectNode.data.id;
this.form.nodePath = this.selectNode.data.path;
}
if (this.type === 'edit' || this.type === 'copy') {
this.form.module = this.currentTestCaseInfo.nodeId;
this.form.nodePath = this.currentTestCaseInfo.nodePath;
}
}, },
methods: { methods: {
setModule(id,data) { setModule(id,data) {
@ -836,16 +839,11 @@ export default {
this.getTestOptions() this.getTestOptions()
}, },
getModuleOptions() { getModuleOptions() {
this.moduleOptions = []; let moduleOptions = [];
this.moduleOptions.unshift({ this.treeNodes.forEach(node => {
"id": "root", buildNodePath(node, {path: ''}, moduleOptions);
"name": this.$t('commons.module_title'),
"level": 0,
"children": this.treeNodes,
});
this.moduleOptions.forEach(node => {
buildTree(node, {path: ''});
}); });
this.moduleOptions = moduleOptions;
}, },
getMaintainerOptions() { getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID); let workspaceId = localStorage.getItem(WORKSPACE_ID);

View File

@ -32,7 +32,7 @@
<span v-if="!disabled" class="node-operate child"> <span v-if="!disabled" class="node-operate child">
<el-tooltip <el-tooltip
v-if="data.id != 'root'" v-if="data.id != 'root' && data.id !='default-module'"
class="item" class="item"
effect="dark" effect="dark"
:open-delay="200" :open-delay="200"
@ -49,7 +49,7 @@
<i @click.stop="append(node, data)" class="el-icon-circle-plus-outline"></i> <i @click.stop="append(node, data)" class="el-icon-circle-plus-outline"></i>
</el-tooltip> </el-tooltip>
<el-tooltip <el-tooltip
v-if="data.id != 'root'" v-if="data.id != 'root' && data.id !='default-module'"
class="item" effect="dark" class="item" effect="dark"
:open-delay="200" :open-delay="200"
:content="$t('commons.delete')" :content="$t('commons.delete')"

View File

@ -37,6 +37,7 @@ import MsNodeTree from "./NodeTree";
import TestCaseCreate from "@/business/components/track/case/components/TestCaseCreate"; import TestCaseCreate from "@/business/components/track/case/components/TestCaseCreate";
import TestCaseImport from "@/business/components/track/case/components/TestCaseImport"; import TestCaseImport from "@/business/components/track/case/components/TestCaseImport";
import MsSearchBar from "@/business/components/common/components/search/MsSearchBar"; import MsSearchBar from "@/business/components/common/components/search/MsSearchBar";
import {buildTree} from "../../api/definition/model/NodeTree";
export default { export default {
name: "TestCaseNodeTree", name: "TestCaseNodeTree",
@ -115,6 +116,16 @@ export default {
if (this.projectId) { if (this.projectId) {
this.result = this.$get("/case/node/list/" + this.projectId, response => { this.result = this.$get("/case/node/list/" + this.projectId, response => {
this.treeNodes = response.data; this.treeNodes = response.data;
this.treeNodes.unshift({
"id": "default-module",
"name": this.$t('commons.module_title'),
"level": 0,
"path": "/" + this.$t('commons.module_title'),
"children": [],
});
this.treeNodes.forEach(node => {
buildTree(node, {path: ''});
});
if (this.$refs.nodeTree) { if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(); this.$refs.nodeTree.filter();
} }