当前位置: 首页 > news >正文

Vue-easy-tree封装及使用

1.使用及安装

下载依赖
npm install @wchbrad/vue-easy-tree引入俩种方案
1.在main.js中引入
import VueEasyTree from "@wchbrad/vue-easy-tree";
import "@wchbrad/vue-easy-tree/src/assets/index.scss"
Vue.use(VueEasyTree)2.当前页面引入
import VueEasyTree from "@wchbrad/vue-easy-tree";
import "@wchbrad/vue-easy-tree/src/assets/index.scss"

2.封装vue-easy-tree

<template><div class='select-tree-container' ref="selectMutiple"><el-inputautocomplete="off":placeholder="loading?'正在加载数据···':placeholder":readonly="true":disabled="loading":value="checkedTreeData"><i v-show="loading" slot="suffix" class="el-input__icon el-icon-loading"></i></el-input><transition name="sub-comments"><divclass="scroll-container"v-show="selectTreeFlag"><el-inputplaceholder="输入关键字进行过滤"v-model="filterText"></el-input><VueEasyTree:data="treeData"show-checkboxheight="500px":node-key="treeProps.value":props="treeProps":default-checked-keys="newArr"ref="selectMutipleTree"@check="handleCheck":filter-node-method="filterNode":check-strictly="checkStrictly"></VueEasyTree></div></transition></div>
</template><script>
import VueEasyTree from "@wchbrad/vue-easy-tree";
// 样式文件,可以根据需要自定义样式或主题
import "@wchbrad/vue-easy-tree/src/assets/index.scss"
import {debounce} from '@/shared/debounceAndtThrottle.js'
export default {name: 'SelectMutipleTree',components: {VueEasyTree},props: {treeData: {type: Array,required: true,default:[],},treeProps: {type: Object,default: function () {return {value: 'id',label: 'orgName',checkStrictly: true}}},checkedTreeData: {type: String,required: true},placeholder: {type: String,default: '请输入'},checkStrictly: {type: Boolean,default: false},loading: {type: Boolean,default: true},defaultCheckedKeys:{type: Array,default:() => {return []},}},data () {return {selectTreeFlag: false,filterText: '',filterText_:null,newArr:[]}},watch: {checkedTreeData: function (newValue) {if (!newValue) {this.$nextTick(() => {this.$refs.selectMutipleTree.setCheckedKeys([])})}},filterText(val) {this.filterText_(val)},treeData(val){var num = 0this.chuli(val,num)},defaultCheckedKeys(val){if(val.length == 0) {this.newArr =[]}else{this.chuliCheckedKeys(this.treeData, val)}}},methods: {chuliCheckedKeys(list, val){list.forEach(item => {val.forEach(i => {if(item[this.treeProps.value].split('-')[0] === i){i= item[this.treeProps.value]this.newArr.push(i)}})if(item[this.treeProps.children]){this.chuliCheckedKeys(item[this.treeProps.children], val)}})},chuli(list,num){list.forEach(i=>{num++i[this.treeProps.value] = i[this.treeProps.value] + "-" + num;if(i[this.treeProps.children]){this.chuli(i[this.treeProps.children],num)}})},handleCheck (checkedNodes, checkedKeys) {checkedKeys.checkedNodes.forEach((f) => {f[this.treeProps.value] =  f[this.treeProps.value].split('-')[0]});this.$emit('handleCheckData', checkedKeys.checkedNodes)},filterNode(value, data) {if (!value) return true;return data[this.treeProps.label].includes(value);}},created () {},mounted () {if (!this.checkedTreeData) {this.$nextTick(() => {this.$refs.selectMutipleTree.setCheckedKeys([])})}this.$refs.selectMutiple && this.$refs.selectMutiple.addEventListener('click', (event) => {const ev = event || window.eventif (ev.stopPropagation) {ev.stopPropagation()} else {ev.cancelable = true}this.selectTreeFlag =  !this.loading && true})this.$root.$el.addEventListener('click', (event) => {this.selectTreeFlag = false})this.filterText_ = debounce((val)=>this.$refs.selectMutipleTree.filter(val), 1000)},destroyed () {}
}
</script>
<style lang="scss" scoped>
.scroll-container {max-height: 600px;overflow-y: auto;position: absolute;z-index: 10;width: 100%;border: 1px solid #eeeeee;border-top: none;background: #ffffff;::v-deep {.el-scrollbar__wrap {overflow-x: hidden;}}
}
.sub-comments-leave-active,.sub-comments-enter-active {transition: max-height 0.1s linear;
}
.sub-comments-enter,.sub-comments-leave-to {max-height:0 ;opacity: 0;
}
.sub-comments-enter-to,.sub-comments-leave {max-height: 136px ;
}
</style>

3.具体页面该如何使用

<select-mutiple-tree  size="mini" style="display: inline-block" :treeData="organizationTree" :treeProps="releaseTreeProps" :loading="treeLoading" :checkedTreeData="addCaseForm.copyToUserListName" 
placeholder="请选择"  @handleCheckData="handleCheck" :checkStrictly="releaseTreeProps.checkStrictly">
</select-mutiple-tree>1.data中定义organizationTree: [],treeLoading: true, //控制人员树加载状态releaseTreeProps: {value: "nodeIdAndType",label: "nodeName",children: "organizationTreeUserSingeNodeList",checkStrictly: false,},addCaseForm: {copyToUserListName:'',copyToUserList:[], //抄送人}
2.引入及注册import SelectMutipleTree from "@/components/selectMutipleTree";components:{SelectMutipleTree }
3.接口中写接口名字().then((response) => {const { data, success } = response;if (success) {this.organizationTree = data;this.treeLoading = false;} else {this.organizationTree = [];this.treeLoading = false;}}).catch((error) => {this.organizationTree = [];this.treeLoading = false;});
4.方法handleCheck(checkedData) {if (checkedData.length > 0) {// 集合var namesArr = [];var idsArr = [];var userName = [];checkedData.forEach((f) => {if (f.nodeType !== 0) {namesArr.push(f.nodeName);idsArr.push(f.nodeId)userName.push({id: f.nodeId,name: f.nodeName,});}});this.addCaseForm.copyToUserListName = namesArr.join(";");this.addCaseForm.copyToUserList = idsArr;} else {this.addCaseForm.copyToUserListName = '';this.addCaseForm.copyToUserList = [];}},

 5.具体返回的后台格式

相关文章:

Vue-easy-tree封装及使用

1.使用及安装 下载依赖 npm install wchbrad/vue-easy-tree引入俩种方案 1.在main.js中引入 import VueEasyTree from "wchbrad/vue-easy-tree"; import "wchbrad/vue-easy-tree/src/assets/index.scss" Vue.use(VueEasyTree)2.当前页面引入 import VueEa…...

opencv中使用cuda加速图像处理

opencv大多数只使用到了cpu的版本&#xff0c;实际上对于复杂的图像处理过程用cuda&#xff08;特别是高分辨率的图像&#xff09;可能会有加速效果。是否需要使用cuda需要思考&#xff1a; 1、opencv的cuda库是否提供了想要的算子。在CUDA-accelerated Computer Vision你可以…...

FPGA高端项目:IMX327 MIPI 视频解码 USB3.0 UVC 输出,提供FPGA开发板+2套工程源码+技术支持

目录 1、前言免责声明 2、相关方案推荐我这里已有的 MIPI 编解码方案 3、本 MIPI CSI-RX IP 介绍4、个人 FPGA高端图像处理开发板简介5、详细设计方案设计原理框图IMX327 及其配置MIPI CSI RX图像 ISP 处理图像缓存UVC 时序USB3.0输出架构 6、vivado工程详解FPGA逻辑设计 7、工…...

深入探索 MySQL 8 中的 JSON 类型:功能与应用

随着 NoSQL 数据库的兴起&#xff0c;JSON 作为一种轻量级的数据交换格式受到了广泛的关注。为了满足现代应用程序的需求&#xff0c;MySQL 8引入了原生的 JSON 数据类型&#xff0c;提供了一系列强大的 JSON 函数来处理和查询 JSON 数据。本文将深入探讨 MySQL 8 中JSON 类型的…...

学习Spring的第十三天

非自定义bean注解开发 设置非自定义bean : 用bean去修饰一个方法 , 最后去返回 , spring就把返回的这个对象,放到Spring容器 一 :名字 : 如果bean配置了参数 , 名字就是参数名 , 如果没有 , 就是方法名字 二 : 如果方法产生对象时 , 需要注入数据 , 在方法参数设置即可 , …...

jss/css/html 相关的技术栈有哪些?

js 的技术组件有哪些&#xff1f;比如 jQuery vue 等 常见的JavaScript技术组件&#xff1a; jQuery&#xff1a; jQuery是一个快速、小巧且功能丰富的JavaScript库&#xff0c;用于简化DOM操作、事件处理、动画效果等任务。 React&#xff1a; React是由Facebook开发的用于构…...

机器学习超参数优化算法(贝叶斯优化)

文章目录 贝叶斯优化算法原理贝叶斯优化的实现&#xff08;三种方法均有代码实现&#xff09;基于Bayes_opt实现GP优化基于HyperOpt实现TPE优化基于Optuna实现多种贝叶斯优化 贝叶斯优化算法原理 在贝叶斯优化的数学过程当中&#xff0c;我们主要执行以下几个步骤&#xff1a; …...

Sklearn、TensorFlow 与 Keras 机器学习实用指南第三版(六)

原文&#xff1a;Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow 译者&#xff1a;飞龙 协议&#xff1a;CC BY-NC-SA 4.0 第十四章&#xff1a;使用卷积神经网络进行深度计算机视觉 尽管 IBM 的 Deep Blue 超级计算机在 1996 年击败了国际象棋世界冠军…...

XGB-3: 模型IO

在XGBoost 1.0.0中&#xff0c;引入了对使用JSON保存/加载XGBoost模型和相关超参数的支持&#xff0c;旨在用一个可以轻松重用的开放格式取代旧的二进制内部格式。后来在XGBoost 1.6.0中&#xff0c;还添加了对通用二进制JSON的额外支持&#xff0c;作为更高效的模型IO的优化。…...

springboot(ssm船舶维保管理系统 船只报修管理系统Java系统

springboot(ssm船舶维保管理系统 船只报修管理系统Java系统 开发语言&#xff1a;Java 框架&#xff1a;springboot&#xff08;可改ssm&#xff09; vue JDK版本&#xff1a;JDK1.8&#xff08;或11&#xff09; 服务器&#xff1a;tomcat 数据库&#xff1a;mysql 5.7&a…...

机器学习本科课程 大作业 多元时间序列预测

1. 问题描述 1.1 阐述问题 对某电力部门的二氧化碳排放量进行回归预测&#xff0c;有如下要求 数据时间跨度从1973年1月到2021年12月&#xff0c;按月份记录。数据集包括“煤电”&#xff0c;“天然气”&#xff0c;“馏分燃料”等共9个指标的数据&#xff08;其中早期的部分…...

[office] excel中weekday函数的使用方法 #学习方法#微信#媒体

excel中weekday函数的使用方法 在EXCEL中Weekday是一个日期函数&#xff0c;可以计算出特定日期所对应的星期数。下面给大家介绍下Weekday函数作用方法。 01、比如&#xff0c;我在A84单元格输入一个日期&#xff0c;2018/5/9&#xff1b;那么&#xff0c;我们利用weekday计算…...

PAT-Apat甲级题1007(python和c++实现)

PTA | 1007 Maximum Subsequence Sum 1007 Maximum Subsequence Sum 作者 CHEN, Yue 单位 浙江大学 Given a sequence of K integers { N1​, N2​, ..., NK​ }. A continuous subsequence is defined to be { Ni​, Ni1​, ..., Nj​ } where 1≤i≤j≤K. The Maximum Su…...

洛谷:P2957 [USACO09OCT] Barn Echoes G

题目描述 The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has been recording the exact wording of the moo as it goes out and returns. She is curious as to just how mu…...

flinksqlbug : AggregateFunction udf Could not extract a data type from

org.apache.flink.table.api.ValidationException: SQL validation failed. An error occurred in the type inference logic of function ‘default_catalog.default_database.CollectSetSort’. org.apache.flink.table.api.ValidationException: An error occurred in the t…...

Aigtek高压放大器用途是什么呢

高压放大器在电子领域中扮演着至关重要的角色&#xff0c;其主要作用是将低电压信号放大到更高的电压水平。这种类型的放大器广泛用于各种应用中&#xff0c;以下是高压放大器的用途以及其关键作用的详细介绍。 1、科学研究和实验室应用&#xff1a; 高压放大器在科学研究和实验…...

c++ STL less 的视角

c less 函数在不同的地方感觉所起的作用是不一样的&#xff0c; 这中间原因是 less 的视角不一样&#xff0c; 下面尝试给出解释下&#xff0c; 方便记忆 1、 左右视角 符合 排序sort less(value, element&#xff09; less 表示一种 “符合关系“&#xff0c; 表示sort 后…...

MQ面试题整理(持续更新)

1. MQ的优缺点 优点&#xff1a;解耦&#xff0c;异步&#xff0c;削峰 缺点&#xff1a; 系统可用性降低 系统引入的外部依赖越多&#xff0c;越容易挂掉。万一 MQ 挂了&#xff0c;MQ 一挂&#xff0c;整套系统崩 溃&#xff0c;你不就完了&#xff1f;系统复杂度提高 硬生…...

2401cmake,学习cmake2

步4:安装与测试 现在开始给项目添加安装规则和支持测试. 安装规则 安装规则非常简单:对MathFunctions,想安装库和头文件,对应用,想安装可执行文件和配置头. 所以在MathFunctions/CMakeLists.txt尾添加: install(TARGETS MathFunctions DESTINATION lib) install(FILES Mat…...

理解Jetpack Compose中的`remember`和`mutableStateOf`

理解Jetpack Compose中的remember和mutableStateOf 在现代Android开发中&#xff0c;Jetpack Compose已经成为构建原生UI的首选工具。它引入了一种声明式的编程模式&#xff0c;极大地简化了UI开发。在Compose的世界里&#xff0c;remember和mutableStateOf是两个非常关键的函…...

Java 语言特性(面试系列2)

一、SQL 基础 1. 复杂查询 &#xff08;1&#xff09;连接查询&#xff08;JOIN&#xff09; 内连接&#xff08;INNER JOIN&#xff09;&#xff1a;返回两表匹配的记录。 SELECT e.name, d.dept_name FROM employees e INNER JOIN departments d ON e.dept_id d.dept_id; 左…...

Java 语言特性(面试系列1)

一、面向对象编程 1. 封装&#xff08;Encapsulation&#xff09; 定义&#xff1a;将数据&#xff08;属性&#xff09;和操作数据的方法绑定在一起&#xff0c;通过访问控制符&#xff08;private、protected、public&#xff09;隐藏内部实现细节。示例&#xff1a; public …...

Linux相关概念和易错知识点(42)(TCP的连接管理、可靠性、面临复杂网络的处理)

目录 1.TCP的连接管理机制&#xff08;1&#xff09;三次握手①握手过程②对握手过程的理解 &#xff08;2&#xff09;四次挥手&#xff08;3&#xff09;握手和挥手的触发&#xff08;4&#xff09;状态切换①挥手过程中状态的切换②握手过程中状态的切换 2.TCP的可靠性&…...

学习STC51单片机31(芯片为STC89C52RCRC)OLED显示屏1

每日一言 生活的美好&#xff0c;总是藏在那些你咬牙坚持的日子里。 硬件&#xff1a;OLED 以后要用到OLED的时候找到这个文件 OLED的设备地址 SSD1306"SSD" 是品牌缩写&#xff0c;"1306" 是产品编号。 驱动 OLED 屏幕的 IIC 总线数据传输格式 示意图 …...

Psychopy音频的使用

Psychopy音频的使用 本文主要解决以下问题&#xff1a; 指定音频引擎与设备&#xff1b;播放音频文件 本文所使用的环境&#xff1a; Python3.10 numpy2.2.6 psychopy2025.1.1 psychtoolbox3.0.19.14 一、音频配置 Psychopy文档链接为Sound - for audio playback — Psy…...

Mac下Android Studio扫描根目录卡死问题记录

环境信息 操作系统: macOS 15.5 (Apple M2芯片)Android Studio版本: Meerkat Feature Drop | 2024.3.2 Patch 1 (Build #AI-243.26053.27.2432.13536105, 2025年5月22日构建) 问题现象 在项目开发过程中&#xff0c;提示一个依赖外部头文件的cpp源文件需要同步&#xff0c;点…...

DeepSeek 技术赋能无人农场协同作业:用 AI 重构农田管理 “神经网”

目录 一、引言二、DeepSeek 技术大揭秘2.1 核心架构解析2.2 关键技术剖析 三、智能农业无人农场协同作业现状3.1 发展现状概述3.2 协同作业模式介绍 四、DeepSeek 的 “农场奇妙游”4.1 数据处理与分析4.2 作物生长监测与预测4.3 病虫害防治4.4 农机协同作业调度 五、实际案例大…...

学校时钟系统,标准考场时钟系统,AI亮相2025高考,赛思时钟系统为教育公平筑起“精准防线”

2025年#高考 将在近日拉开帷幕&#xff0c;#AI 监考一度冲上热搜。当AI深度融入高考&#xff0c;#时间同步 不再是辅助功能&#xff0c;而是决定AI监考系统成败的“生命线”。 AI亮相2025高考&#xff0c;40种异常行为0.5秒精准识别 2025年高考即将拉开帷幕&#xff0c;江西、…...

算法:模拟

1.替换所有的问号 1576. 替换所有的问号 - 力扣&#xff08;LeetCode&#xff09; ​遍历字符串​&#xff1a;通过外层循环逐一检查每个字符。​遇到 ? 时处理​&#xff1a; 内层循环遍历小写字母&#xff08;a 到 z&#xff09;。对每个字母检查是否满足&#xff1a; ​与…...

SQL慢可能是触发了ring buffer

简介 最近在进行 postgresql 性能排查的时候,发现 PG 在某一个时间并行执行的 SQL 变得特别慢。最后通过监控监观察到并行发起得时间 buffers_alloc 就急速上升,且低水位伴随在整个慢 SQL,一直是 buferIO 的等待事件,此时也没有其他会话的争抢。SQL 虽然不是高效 SQL ,但…...