vue + elementUI 实现下拉树形结构选择部门,支持多选,支持检索
vue + elementUI 实现下拉树形结构选择部门,支持多选,支持检索
<template><div><el-select v-model="multiple?choosedValue:choosedValue[0]" element-loading-background="rgba(0,0,0,0.8)":disabled="disableFlag" @visible-change="visibleChange"filterable clearable collapse-tags :filter-method="filterMethod" @clear="clear" @remove-tag="removeTag":multiple="multiple" ref="selectRef" v-loading="loading" style="width: 100%"><el-option :label="option.name" :value="option.id" v-for="option in options" :key="option.id"class="optionClass"/><template v-slot:empty><div/></template><el-tree :props="treeProps" :load="loadNode" :data="treeData" :show-checkbox="multiple" @check="handleCheck":expand-on-click-node="false" @node-click="chooseNode" :filter-node-method="filterNodeMethod"class="treeClass" ref="treeRef" :node-key="'id'" :default-checked-keys="choosedValue"/></el-select></div>
</template><script>
import {getDwxxOfTree} from "@/api/commentTable/api";export default {name: "chooseUnitTree",props: {disableFlag: {Type: Boolean,required: false,default: false},value: {Type: Object,required: true},multiple: {Type: Boolean,required: false,default: false}},data() {return {treeProps: {label: 'name',value: 'id',children: 'children'},deptMap: {},treeData: [],options: [],loading: false,choosedValue: [],choosedOptions: [],}},computed: {},watch: {// choosedValue: {// handler(n, o) {// if (this.$refs.treeRef) {// this.$refs.treeRef.filter()// }// },// immediate: true,// deep: true// }},mounted() {this.choosedValue = []this.getNodeData()},methods: {visibleChange(visible) {if (!visible) {this.$refs.treeRef.filter()}},removeTag(nodeId) {this.choosedValue = this.choosedValue.filter(item => item !== nodeId)this.choosedOptions = this.choosedOptions.filter(item => item.id !== nodeId)this.$refs.treeRef.setCheckedKeys(this.choosedValue, false)this.$emit('input', this.multiple ? this.choosedValue : this.choosedValue[0])},clear() {this.choosedValue = []this.choosedOptions = []this.$refs.treeRef.setCheckedKeys([], false)this.$emit('input', '')},filterMethod(keyWord) {this.$refs.treeRef.filter(keyWord)},filterNodeMethod(keyWord, node) {if (!keyWord) {return true}return (node.name + node.id).includes(keyWord)},init() {this.choosedValue = []if (typeof this.value === 'string') {this.choosedOptions.push(this.deptMap[this.value])this.choosedValue.push(this.value)} else {this.value.forEach(item => {this.choosedOptions.push(this.deptMap[item.id])this.choosedValue = this.value})}},getNodeData(resolve) {this.loading = truegetDwxxOfTree().then(dwxxResult => {// dwxxResult.data :// [{// id : "123456"// name : "xx集团"// pid : "000000"// }]this.loading = falseif (dwxxResult.data) {this.options = dwxxResult.dataconst rootDept = []this.deptMap = {}for (let deptInfo of dwxxResult.data) {this.deptMap[deptInfo.id] = deptInfo}for (let deptInfo of dwxxResult.data) {if (!this.deptMap[deptInfo.pid]) {rootDept.push(deptInfo)}}if (resolve) {resolve(rootDept)}} else {if (resolve) {resolve([])}}this.init()this.createTree(dwxxResult.data)})},createNodeChildren(node) {let children = []for (let deptId in this.deptMap) {let tmpNode = this.deptMap[deptId]if (tmpNode.pid === node.id) {children.push(this.createNodeChildren(tmpNode))}}node.children = childrenreturn node},createTree() {this.treeData = []for (let deptId in this.deptMap) {let node = this.deptMap[deptId]if (!this.deptMap[node.pid]) {this.treeData.push(this.createNodeChildren(node))}}},loadNode(node, resolve) {if (node.level === 0) {this.getNodeData(resolve)} else {const children = []for (let deptId in this.deptMap) {if (this.deptMap[deptId].pid === node.data.id) {children.push(this.deptMap[deptId])}resolve(children)}}},handleCheck(data, currentData) {this.choosedOptions = this.multiple ? [data] : currentData.checkedNodes // this.$refs.treeRef.getCheckedNodes(false, false)if (this.choosedOptions.length > 0) {const tempMap = {}this.choosedOptions.forEach(op => {tempMap[op.id] = op})let tmpOps = []this.choosedOptions.forEach(op => {if (!tempMap[op.pid]) {tmpOps.push(op)}})this.choosedOptions = tmpOpsthis.choosedValue = this.choosedOptions.map(item => item.id)} else {this.choosedValue = []}this.$emit('input', this.multiple ? this.choosedValue : this.choosedValue[0])},chooseNode(data) {this.choosedOptions = [data]this.choosedValue = [data.id]this.$emit('input', data.id)this.$refs.selectRef.visible = false}}
}
</script><style scoped lang="scss">
.optionClass {display: none;
}.treeClass {background: transparent;margin: 10px;
}
</style>
相关文章:
![](https://www.ngui.cc/images/no-images.jpg)
vue + elementUI 实现下拉树形结构选择部门,支持多选,支持检索
vue elementUI 实现下拉树形结构选择部门,支持多选,支持检索 <template><div><el-select v-model"multiple?choosedValue:choosedValue[0]" element-loading-background"rgba(0,0,0,0.8)":disabled"disableFl…...
![](https://img-blog.csdnimg.cn/63ab09c6c488472a821254b19e8631db.png)
招投标系统简介 企业电子招投标采购系统源码之电子招投标系统 —降低企业采购成本 tbms
功能模块: 待办消息,招标公告,中标公告,信息发布 描述: 全过程数字化采购管理,打造从供应商管理到采购招投标、采购合同、采购执行的全过程数字化管理。通供应商门户具备内外协同的能力,为外…...
![](https://img-blog.csdnimg.cn/6905e351a3da44b086f19b78b8b04fa6.png)
半监督学习(主要伪标签方法)
半监督学习 1. 引言 应用场景:存在少量的有标签样本和大量的无标签样本的场景。在此应用场景下,通常标注数据是匮乏的,成本高的,难以获取的,与之相对应的是却存在大量的无标注数据。半监督学习的假设:决策…...
![](https://www.ngui.cc/images/no-images.jpg)
datePicker一个或多个日期组件,如何快捷选择多个日期(时间段)
elementUI的组件文档中没有详细说明type"dates"如何快捷选择一个时间段的日期,我们可以通过picker-options参数来设置快捷选择: <div class"block"><span class"demonstration">多个日期</span><el…...
![](https://www.ngui.cc/images/no-images.jpg)
【语音合成】微软 edge-tts
目录 1. edge-tts 介绍 2. 代码示例 1. edge-tts 介绍 https://github.com/rany2/edge-tts 在Python代码中使用Microsoft Edge的在线文本到语音服务 2. 代码示例 import asyncio # pip install edge_tts import edge_tts TEXT """给我放首我喜欢听的歌曲…...
![](https://img-blog.csdnimg.cn/4f5d27b0927b443989cf8d37c16be30d.png#pic_center)
elevation mapping学习笔记3之使用D435i相机离线或在线订阅点云和tf关系生成高程图
文章目录 0 引言1 数据1.1 D435i相机配置1.2 协方差位姿1.3 tf 关系2 离线demo2.1 yaml配置文件2.2 launch启动文件2.3 数据录制2.4 离线加载点云生成高程图3 在线demo3.1 launch启动文件3.2 CMakeLists.txt3.3 在线加载点云生成高程图0 引言 elevation mapping学习笔记1已经成…...
![](https://img-blog.csdnimg.cn/img_convert/c7a211ff5d3a07afec59cb0e25a3328c.png)
ESP32 Max30102 (3)修复心率误差
1. 运行效果 2. 新建修复心率误差.py 代码如下: from machine import sleep, SoftI2C, Pin, Timer from utime import ticks_diff, ticks_us from max30102 import MAX30102, MAX30105_PULSE_AMP_MEDIUM from hrcalc import calc_hr_and_spo2BEATS = 0 # 存储心率 FINGER_F…...
![](https://www.ngui.cc/images/no-images.jpg)
16-4_Qt 5.9 C++开发指南_Qt 应用程序的发布
文章目录 1. 应用程序发布方式2. Windows 平台上的应用程序发布 1. 应用程序发布方式 用 Qt 开发一个应用程序后,将应用程序提供给用户在其他计算机上使用就是应用程序的发布。应用程序发布一般会提供一个安装程序,将应用程序的可执行文件及需要的运行库…...
![](https://img-blog.csdnimg.cn/img_convert/48ed9f2cade376cc8fb04565ff0dca9a.jpeg)
oracle容灾备份怎么样Oracle容灾备份
随着科学技术的发展和业务的增长,数据安全问题越来越突出。为了保证数据的完整性、易用性和保密性,公司需要采取一系列措施来防止内容丢失的风险。 Oracle是一个关系数据库管理系统(RDBMS),OracleCorporation是由美国软件公司开发和维护的。该系统功能…...
![](https://www.ngui.cc/images/no-images.jpg)
AcWing 4957:飞机降落
【题目来源】https://www.acwing.com/problem/content/4960/【题目描述】 有 N 架飞机准备降落到某个只有一条跑道的机场。 其中第 i 架飞机在 Ti 时刻到达机场上空,到达时它的剩余油料还可以继续盘旋 Di 个单位时间,即它最早可以于 Ti 时刻开始降落&…...
![](https://img-blog.csdnimg.cn/07a1b057bfd642db936d3f8ad0d424f8.png)
强化学习研究 PG
由于一些原因, 需要学习一下强化学习。用这篇博客来学习吧, 用的资料是李宏毅老师的强化学习课程。 深度强化学习(DRL)-李宏毅1-8课(全)_哔哩哔哩_bilibili 这篇文章的目的是看懂公式, 毕竟这是我的弱中弱。 强化…...
![](https://img-blog.csdnimg.cn/5f658cbbf90947c8ad5c4f22bf088dd4.png)
uniapp微信小程序 401时重复弹出登录弹框问题
APP.vue 登陆成功后,保存登陆信息 if (res.code 200) {uni.setStorageSync(loginResult, res)uni.setStorageSync(token, res.token);uni.setStorageSync(login,false);uni.navigateTo({url: "/pages/learning/learning"}) }退出登录 toLogout: func…...
![](https://img-blog.csdnimg.cn/49778db4f54542b08bb549a8fcde26ec.png)
Cloud Studio实战——热门视频Top100爬虫应用开发
最近Cloud Studio非常火,我也去试了一下,感觉真的非常方便!我就以Python爬取B站各区排名前一百的视频,并作可视化来给大家分享一下Cloud Studio!应用链接:Cloud Studio实战——B站热门视频Top100爬虫应用开…...
![](https://www.ngui.cc/images/no-images.jpg)
php 去除二维数组重复
在 PHP 中,我们常常需要对数组进行处理和操作。有时候,我们需要去除数组中的重复元素,这里介绍一种针对二维数组的去重方法。 以下是列举一些常见的方法: 方法一:使用 array_map 和 serialize 函数 array_map 函数可以…...
![](https://img-blog.csdnimg.cn/img_convert/f6e974c205db0a29f17de74ab4fe5ee9.png)
玩转graphQL
转载至酒仙桥的玩转graphQL - SecPulse.COM | 安全脉搏 前言 在测试中我发现了很多网站开始使用GraphQL技术,并且在测试中发现了其使用过程中存在的问题,那么,到底GraphQL是什么呢?了解了GraphQL后能帮助我们在渗透测试中发现哪些…...
![](https://www.ngui.cc/images/no-images.jpg)
神经网络super(XXX, self).__init__()的含义
学习龙良曲老师的课程,在77节有这样一段代码 import torch from torch import nnclass Lenet5(nn.Module):def __init__(self):super(Lenet5,self).__init__()那么,super(XXX, self).init()的含义是什么? Python中的super(Net, self).init()…...
![](https://img-blog.csdnimg.cn/6e01905b672e485284ded1c7f620eae5.png)
45.杜芬方程解仿真解曲线(matlab程序)
1.简述 Dufing方程是一种重要的动力系统山,是反映工程物理系统中非线性现象和混沌动力学行为的极其重要的方程式。通过Duffing方程可以探讨铁磁谐振电路中的分岔、拟周期运动、子谐波振荡。而在非线性与混沌系统的研究中,Duffing方程展示了丰富的混沌动力…...
![](https://img-blog.csdnimg.cn/fb4ebec082b341188f621c8e2663b55d.png)
服务器数据恢复-EXT3分区误删除邮件的数据恢复案例
服务器数据恢复环境: 一台服务器有一组由8块盘组建的RAID5阵列,EXT3文件系统。 服务器故障: 由于工作人员的误操作导致文件系统中的邮件丢失。用户需要恢复丢失的邮件数据。 服务器数据恢复过程: 1、将故障服务器中所有磁盘以只…...
![](https://www.ngui.cc/images/no-images.jpg)
C 语言的逗号运算符
逗号运算符 comma operator 逗号运算符最常用在 for 循环的循环头中. 程序示例: #include<stdio.h> #define FIRST_OZ 46 #define NEXT_OZ 20int main(void) {int ounces;float cost;printf("ounces cost\n");for (ounces 1, cost FIRST_OZ…...
![](https://img-blog.csdnimg.cn/ba64b2b782ed4ff495a8147ba0c20ad4.png)
无人车沿着指定线路自动驾驶与远程控制的实践应用
有了前面颜色识别跟踪的基础之后,我们就可以设定颜色路径,让无人车沿着指定线路做自动驾驶了,视频:PID控制无人车自动驾驶 有了前几章的知识铺垫,就比较简单了,也是属于颜色识别的一种应用,主要…...
![](https://img-blog.csdnimg.cn/54288d9825ef4833b1b0c4d9fed66a8e.png)
C++ 多态性——纯虚函数与抽象类
抽象类是一种特殊的类,它为一个类族提供统一的操作界面。抽象类是为了抽象和设计的目的而建立的。可以说,建立抽象类,就是为了通过它多态地使用其中的成员函数。抽象类处于类层次的上层,一个抽象类自身无法实例化,也就…...
![](https://www.ngui.cc/images/no-images.jpg)
小程序如何使用防抖和节流?
防抖(Debounce)和节流(Throttle)都是用来优化函数执行频率的技术,特别在处理用户输入、滚动等频繁触发的情况下,它们可以有效减少函数的执行次数,从而提升性能和用户体验。但它们的工作方式和应…...
![](https://img-blog.csdnimg.cn/c1e648bb548f47e49c9e219a77cde4e7.png)
计算机三级网络技术(持续更新)
BGP考点 A S:自治系统 BGP: Border Gateway Protocol(当前使用的版本是 BGP-4)外部网关协议 动态路由协议可以按照工作范围分为IGP以及EGP。IGP工作在同一个AS内,主要用来发现和计算路由,为AS内提供路由信息的交换&…...
![](https://img-blog.csdnimg.cn/68c422e9811d488083b933bcb831e5a3.png)
Django Rest_Framework(二)
文章目录 1. http请求响应1.1. 请求与响应1.1.1 Request1.1.1.1 常用属性1).data2).query_params3)request._request 基本使用 1.1.2 Response1.1.2.1 构造方式1.1.2.2 response对象的属性1).data2).status_code3&…...
![](https://img-blog.csdnimg.cn/deeb7203da4e416a8e3a020aff24440d.png#pic_center)
Kotlin~Visitor访问者模式
概念 将数据结构和操作分离,使操作集合可以独立于数据结构变化。 角色介绍 Visitor:抽象访问者,为对象结构每个具体元素类声明一个访问操作。Element:抽象元素,定义一个accept方法ConcreteElement:具体元…...
![](https://img-blog.csdnimg.cn/08bcd1238b1543fea1c0712d7ccba4ba.png)
LVS-DR模式集群构建过程演示
一、工作原理 LVS的工作原理 1.当用户向负载均衡调度器(Director Server)发起请求,调度器将请求发往至内核空间 2.PREROUTING链首先会接收到用户请求,判断目标IP确定是本机IP,将数据包发往INPUT链 3.IPVS是工作在IN…...
![](https://img-blog.csdnimg.cn/76a200fa976b4244bece380dbad891d5.png)
UML-A 卷-知识考卷
UML-A 卷-知识考卷 UML有多少种图,请列出每种图的名字: 常用的几种UML图: 类图(Class Diagram):类图是描述类、接口、关联关系和继承关系的图形化表示。它展示了系统中各个类之间的静态结构和关系。时序…...
![](https://img-blog.csdnimg.cn/img_convert/33a37cd4ee72f932d69782e633397bd4.png)
BpBinder与PPBinder调用过程——Android开发Binder IPC通信技术
在Android系统中,进程间通信(IPC)是一个非常重要的话题。Android系统通过Binder IPC机制实现进程间通信,而Binder IPC通信技术则是Android系统中最为重要的进程间通信技术之一。本文将介绍Binder IPC通信技术的原理,并…...
![](https://www.ngui.cc/images/no-images.jpg)
篇十五:模板方法模式:固定算法的步骤
篇十五:"模板方法模式:固定算法的步骤" 设计模式是软件开发中的重要知识,模板方法模式(Template Method Pattern)是一种行为型设计模式,用于定义一个算法的骨架,将算法中一些步骤的具…...
![](https://img-blog.csdnimg.cn/5dd49808096c41e2abe3c329b127ae91.png)
web-ssrf
目录 ssrf介绍 以pikachu靶场为例 curl 访问外网链接 利用file协议查看本地文件 利用dict协议扫描内网主机开放端口 file_get_content 利用file协议查看本地文件: fsockopen() 防御方式: ssrf介绍 服务器端请求伪造,是一种由攻击者构造形成…...
![](https://i.stack.imgur.com/ZsXlK.png)
如何做免费电影网站/关键词优化seo公司
我有2x JComboBox:showingsCb和timesCbshowingsCb包含从我的数据库中提取的电影放映列表.timesCb包含一个电影列表,根据showingsCb中的选择显示时间,这也是从我的数据库中提取的.现在我已经设法用正确的数据填充它们并且逻辑工作正常,但这是我的问题:我在…...
![](https://img-blog.csdnimg.cn/20200610174351500.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzQyODI4Mw==,size_16,color_FFFFFF,t_70)
科技网站 石家庄/苏州关键词优化排名推广
推荐教材 1、《R语言编程基础》,林智章、张良均 主编,人民邮电出版社。 2、《R语言与数据挖掘》,张良均、谢佳标、杨坦等著,机械工业出版社。 3、 《R语言基础与数据科技应用》,沈刚主编,人民邮电出版社。 4、《R语言商务数据分析实战》,韩宝国、张良均主编,人民邮电出…...
衡阳做网站优化/免费的个人网页
序言从Elasticsearch 到大名鼎鼎的ELK三件套,从ELK到Elastic Stack生态,ES的生态发展越来越完善,应用领域也越来越宽广。下面就以我个人视角谈谈 “为什么你会需要Elastic Stack?”,仅代表本人观点,如有异议…...
![](/images/no-images.jpg)
河南郑州网站建设哪家公司好/建站推广网站
(linux操作系统下)#一 Django框架的安装与配置##1 环境配置步骤:1 安装python32 pip3.6 install pytz文件 --时间模块3 pip3.6 install Django文件4 pip3.6 install PyMySQL文件 --操作mysql模块5 pip3.6 install pillow文件 --图像处理库,项目中用到了验证码模块,所以需要导…...
![](https://img-blog.csdnimg.cn/20210107171125712.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0FsaWVOZW55,size_16,color_FFFFFF,t_70)
做网站需要懂什么技术/广州优化seo
这里将自己学习java及其应用的一些笔记、积累分享一下,如果涉及到了文章、文字侵权,请联系我删除或调整。 一、二进制 2.1 概述 计算机表示任何数据,都是二进制数字 电容高电位,1 电容低电位,0 一个电位,…...
![](/images/no-images.jpg)
赤壁网站建设公司/南平网站seo
ngx_http_sub_module模块是一个过滤器,它修改网站响应内容中的字符串,比如你想把响应内容中的‘iuwai’全部替换成‘aaaaa‘,这个模块已经内置在nginx中,但是默认未安装,需要安装需要加上配置参数:–with-h…...