fix: 树修改后过滤失效

This commit is contained in:
chenjianxing 2021-01-21 12:13:01 +08:00
parent cf9e24f069
commit ca3a26a171
5 changed files with 71 additions and 3 deletions

View File

@ -119,6 +119,9 @@
buildNodePath(node, {path: ''}, moduleOptions); buildNodePath(node, {path: ''}, moduleOptions);
}); });
this.$emit('setModuleOptions', moduleOptions); this.$emit('setModuleOptions', moduleOptions);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);
}
} }
}); });
}, },
@ -142,6 +145,7 @@
}, (error) => { }, (error) => {
this.list(); this.list();
}); });
}, },
remove(nodeIds) { remove(nodeIds) {
this.$post("/api/automation/module/delete", nodeIds, () => { this.$post("/api/automation/module/delete", nodeIds, () => {

View File

@ -0,0 +1,45 @@
<template>
<el-form class="tcp" :model="config" :rules="rules" ref="config" label-width="120px" :disabled="isReadOnly"
size="small">
<el-row :gutter="10">
<el-col :span="16">
<el-form-item :label="$t('api_test.request.tcp.server')" prop="server">
<el-input v-model="config.server" maxlength="300" show-word-limit/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('api_test.request.tcp.port')" prop="port" label-width="60px">
<el-input-number v-model="config.port" controls-position="right" :min="0" :max="65535" :controls="false"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
export default {
name: "EnvironmentTcpConfig",
props: {
config: {},
isReadOnly: {
type: Boolean,
default: false
},
},
data() {
return {
rules: {}
}
},
}
</script>
<style scoped>
.tcp >>> .el-input-number {
width: 100%;
}
</style>

View File

@ -126,6 +126,9 @@
buildNodePath(node, {path: ''}, moduleOptions); buildNodePath(node, {path: ''}, moduleOptions);
}); });
this.$emit('setModuleOptions', moduleOptions); this.$emit('setModuleOptions', moduleOptions);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);
}
} }
}); });
}, },

View File

@ -137,7 +137,15 @@ export default {
return false; return false;
}, },
filter(val) { filter(val) {
if (!val) {
val = this.filterText;
} else {
// condition filterText
this.filterText = val;
}
this.$nextTick(() => {
this.$refs.tree.filter(val); this.$refs.tree.filter(val);
});
}, },
nodeExpand(data) { nodeExpand(data) {
if (data.id) { if (data.id) {
@ -149,10 +157,15 @@ export default {
this.expandedNode.splice(this.expandedNode.indexOf(data.id), 1); this.expandedNode.splice(this.expandedNode.indexOf(data.id), 1);
} }
}, },
edit(node, data) { edit(node, data, isAppend) {
this.$set(data, 'isEdit', true); this.$set(data, 'isEdit', true);
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.nameInput.focus(); this.$refs.nameInput.focus();
if (!isAppend) {
this.$nextTick(() => {
this.filter(this.filterText);
});
}
}); });
}, },
append(node, data) { append(node, data) {
@ -166,7 +179,7 @@ export default {
this.$set(data, 'children', []) this.$set(data, 'children', [])
} }
data.children.push(newChild); data.children.push(newChild);
this.edit(node, newChild); this.edit(node, newChild, true);
node.expanded = true; node.expanded = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.nameInput.focus(); this.$refs.nameInput.focus();

View File

@ -51,6 +51,9 @@
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;
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter();
}
}); });
} }
}, },