|
|
@@ -250,7 +250,7 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
- <el-form-item :label="'选择通道('+data.length+')'" prop="channelInfos">
|
|
|
+ <el-form-item :label="'选择通道('+filteredCount+')'" prop="channelInfos">
|
|
|
<el-col :span="10">
|
|
|
<el-input placeholder="输入关键字进行过滤" v-model="filterText"></el-input>
|
|
|
<div style="margin: 15px 0;"></div>
|
|
|
@@ -413,7 +413,48 @@ export default {
|
|
|
this.$refs.tree.filter(val);
|
|
|
}
|
|
|
},
|
|
|
+ // 新增的计算属性
|
|
|
+ computed: {
|
|
|
+ // 计算过滤后的节点数量
|
|
|
+ filteredCount() {
|
|
|
+ if (!this.filterText) {
|
|
|
+ // 没有过滤时,返回所有叶子节点的数量
|
|
|
+ return this.countLeafNodes(this.data);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 递归计算匹配的叶子节点数量
|
|
|
+ const countLeafMatches = (nodes) => {
|
|
|
+ let count = 0;
|
|
|
+ nodes.forEach(node => {
|
|
|
+ // 如果是叶子节点(没有子节点或子节点为空)且匹配过滤条件
|
|
|
+ if ((!node.children || node.children.length === 0) &&
|
|
|
+ this.filterNode(this.filterText, node)) {
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ // 递归处理子节点
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ count += countLeafMatches(node.children);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return count;
|
|
|
+ };
|
|
|
+
|
|
|
+ return countLeafMatches(this.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ // 新增方法:计算所有叶子节点数量
|
|
|
+ countLeafNodes(nodes) {
|
|
|
+ let count = 0;
|
|
|
+ nodes.forEach(node => {
|
|
|
+ if (!node.children || node.children.length === 0) {
|
|
|
+ count++; // 叶子节点
|
|
|
+ } else {
|
|
|
+ count += this.countLeafNodes(node.children); // 递归处理子节点
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return count;
|
|
|
+ },
|
|
|
/** 查询任务列表 */
|
|
|
getList() {
|
|
|
this.loading = true;
|