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的版本,实际上对于复杂的图像处理过程用cuda(特别是高分辨率的图像)可能会有加速效果。是否需要使用cuda需要思考: 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 数据库的兴起,JSON 作为一种轻量级的数据交换格式受到了广泛的关注。为了满足现代应用程序的需求,MySQL 8引入了原生的 JSON 数据类型,提供了一系列强大的 JSON 函数来处理和查询 JSON 数据。本文将深入探讨 MySQL 8 中JSON 类型的…...
学习Spring的第十三天
非自定义bean注解开发 设置非自定义bean : 用bean去修饰一个方法 , 最后去返回 , spring就把返回的这个对象,放到Spring容器 一 :名字 : 如果bean配置了参数 , 名字就是参数名 , 如果没有 , 就是方法名字 二 : 如果方法产生对象时 , 需要注入数据 , 在方法参数设置即可 , …...
jss/css/html 相关的技术栈有哪些?
js 的技术组件有哪些?比如 jQuery vue 等 常见的JavaScript技术组件: jQuery: jQuery是一个快速、小巧且功能丰富的JavaScript库,用于简化DOM操作、事件处理、动画效果等任务。 React: React是由Facebook开发的用于构…...
机器学习超参数优化算法(贝叶斯优化)
文章目录 贝叶斯优化算法原理贝叶斯优化的实现(三种方法均有代码实现)基于Bayes_opt实现GP优化基于HyperOpt实现TPE优化基于Optuna实现多种贝叶斯优化 贝叶斯优化算法原理 在贝叶斯优化的数学过程当中,我们主要执行以下几个步骤: …...
Sklearn、TensorFlow 与 Keras 机器学习实用指南第三版(六)
原文:Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow 译者:飞龙 协议:CC BY-NC-SA 4.0 第十四章:使用卷积神经网络进行深度计算机视觉 尽管 IBM 的 Deep Blue 超级计算机在 1996 年击败了国际象棋世界冠军…...
XGB-3: 模型IO
在XGBoost 1.0.0中,引入了对使用JSON保存/加载XGBoost模型和相关超参数的支持,旨在用一个可以轻松重用的开放格式取代旧的二进制内部格式。后来在XGBoost 1.6.0中,还添加了对通用二进制JSON的额外支持,作为更高效的模型IO的优化。…...
springboot(ssm船舶维保管理系统 船只报修管理系统Java系统
springboot(ssm船舶维保管理系统 船只报修管理系统Java系统 开发语言:Java 框架:springboot(可改ssm) vue JDK版本:JDK1.8(或11) 服务器:tomcat 数据库:mysql 5.7&a…...
机器学习本科课程 大作业 多元时间序列预测
1. 问题描述 1.1 阐述问题 对某电力部门的二氧化碳排放量进行回归预测,有如下要求 数据时间跨度从1973年1月到2021年12月,按月份记录。数据集包括“煤电”,“天然气”,“馏分燃料”等共9个指标的数据(其中早期的部分…...
[office] excel中weekday函数的使用方法 #学习方法#微信#媒体
excel中weekday函数的使用方法 在EXCEL中Weekday是一个日期函数,可以计算出特定日期所对应的星期数。下面给大家介绍下Weekday函数作用方法。 01、比如,我在A84单元格输入一个日期,2018/5/9;那么,我们利用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高压放大器用途是什么呢
高压放大器在电子领域中扮演着至关重要的角色,其主要作用是将低电压信号放大到更高的电压水平。这种类型的放大器广泛用于各种应用中,以下是高压放大器的用途以及其关键作用的详细介绍。 1、科学研究和实验室应用: 高压放大器在科学研究和实验…...
c++ STL less 的视角
c less 函数在不同的地方感觉所起的作用是不一样的, 这中间原因是 less 的视角不一样, 下面尝试给出解释下, 方便记忆 1、 左右视角 符合 排序sort less(value, element) less 表示一种 “符合关系“, 表示sort 后…...
MQ面试题整理(持续更新)
1. MQ的优缺点 优点:解耦,异步,削峰 缺点: 系统可用性降低 系统引入的外部依赖越多,越容易挂掉。万一 MQ 挂了,MQ 一挂,整套系统崩 溃,你不就完了?系统复杂度提高 硬生…...
2401cmake,学习cmake2
步4:安装与测试 现在开始给项目添加安装规则和支持测试. 安装规则 安装规则非常简单:对MathFunctions,想安装库和头文件,对应用,想安装可执行文件和配置头. 所以在MathFunctions/CMakeLists.txt尾添加: install(TARGETS MathFunctions DESTINATION lib) install(FILES Mat…...
理解Jetpack Compose中的`remember`和`mutableStateOf`
理解Jetpack Compose中的remember和mutableStateOf 在现代Android开发中,Jetpack Compose已经成为构建原生UI的首选工具。它引入了一种声明式的编程模式,极大地简化了UI开发。在Compose的世界里,remember和mutableStateOf是两个非常关键的函…...
深入浅出Asp.Net Core MVC应用开发系列-AspNetCore中的日志记录
ASP.NET Core 是一个跨平台的开源框架,用于在 Windows、macOS 或 Linux 上生成基于云的新式 Web 应用。 ASP.NET Core 中的日志记录 .NET 通过 ILogger API 支持高性能结构化日志记录,以帮助监视应用程序行为和诊断问题。 可以通过配置不同的记录提供程…...
3.3.1_1 检错编码(奇偶校验码)
从这节课开始,我们会探讨数据链路层的差错控制功能,差错控制功能的主要目标是要发现并且解决一个帧内部的位错误,我们需要使用特殊的编码技术去发现帧内部的位错误,当我们发现位错误之后,通常来说有两种解决方案。第一…...
理解 MCP 工作流:使用 Ollama 和 LangChain 构建本地 MCP 客户端
🌟 什么是 MCP? 模型控制协议 (MCP) 是一种创新的协议,旨在无缝连接 AI 模型与应用程序。 MCP 是一个开源协议,它标准化了我们的 LLM 应用程序连接所需工具和数据源并与之协作的方式。 可以把它想象成你的 AI 模型 和想要使用它…...
iPhone密码忘记了办?iPhoneUnlocker,iPhone解锁工具Aiseesoft iPhone Unlocker 高级注册版分享
平时用 iPhone 的时候,难免会碰到解锁的麻烦事。比如密码忘了、人脸识别 / 指纹识别突然不灵,或者买了二手 iPhone 却被原来的 iCloud 账号锁住,这时候就需要靠谱的解锁工具来帮忙了。Aiseesoft iPhone Unlocker 就是专门解决这些问题的软件&…...
大语言模型如何处理长文本?常用文本分割技术详解
为什么需要文本分割? 引言:为什么需要文本分割?一、基础文本分割方法1. 按段落分割(Paragraph Splitting)2. 按句子分割(Sentence Splitting)二、高级文本分割策略3. 重叠分割(Sliding Window)4. 递归分割(Recursive Splitting)三、生产级工具推荐5. 使用LangChain的…...
Frozen-Flask :将 Flask 应用“冻结”为静态文件
Frozen-Flask 是一个用于将 Flask 应用“冻结”为静态文件的 Python 扩展。它的核心用途是:将一个 Flask Web 应用生成成纯静态 HTML 文件,从而可以部署到静态网站托管服务上,如 GitHub Pages、Netlify 或任何支持静态文件的网站服务器。 &am…...
【android bluetooth 框架分析 04】【bt-framework 层详解 1】【BluetoothProperties介绍】
1. BluetoothProperties介绍 libsysprop/srcs/android/sysprop/BluetoothProperties.sysprop BluetoothProperties.sysprop 是 Android AOSP 中的一种 系统属性定义文件(System Property Definition File),用于声明和管理 Bluetooth 模块相…...
什么是Ansible Jinja2
理解 Ansible Jinja2 模板 Ansible 是一款功能强大的开源自动化工具,可让您无缝地管理和配置系统。Ansible 的一大亮点是它使用 Jinja2 模板,允许您根据变量数据动态生成文件、配置设置和脚本。本文将向您介绍 Ansible 中的 Jinja2 模板,并通…...
《C++ 模板》
目录 函数模板 类模板 非类型模板参数 模板特化 函数模板特化 类模板的特化 模板,就像一个模具,里面可以将不同类型的材料做成一个形状,其分为函数模板和类模板。 函数模板 函数模板可以简化函数重载的代码。格式:templa…...
根目录0xa0属性对应的Ntfs!_SCB中的FileObject是什么时候被建立的----NTFS源代码分析--重要
根目录0xa0属性对应的Ntfs!_SCB中的FileObject是什么时候被建立的 第一部分: 0: kd> g Breakpoint 9 hit Ntfs!ReadIndexBuffer: f7173886 55 push ebp 0: kd> kc # 00 Ntfs!ReadIndexBuffer 01 Ntfs!FindFirstIndexEntry 02 Ntfs!NtfsUpda…...
