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

北京大型网站建设免费制作网站的软件

北京大型网站建设,免费制作网站的软件,企业网站的网页设计,银川360推广 网站建设前言 本文章是本人在开发过程中#xff0c;遇到使用树形数据#xff0c;动态单选或多选的需求#xff0c;element中没有这种组件#xff0c;故自己封装一个#xff0c;欢迎多多指教 开发环境#xff1a;element-UI、vue2 组件效果 单选 多选 组件引用 treeselec…前言 本文章是本人在开发过程中遇到使用树形数据动态单选或多选的需求element中没有这种组件故自己封装一个欢迎多多指教 开发环境element-UI、vue2 组件效果 单选 多选 组件引用 treeselect v-modelform.parentId:optionsdeptOptions:props{value:id,label:name,children: children}:placeholder选择上级部门/ 组件代码 templatedivel-selectreftreeSelectpopper-classcustom-select-popperstylewidth: 100%v-modelvalueLabel:clearableclearable:placeholderplaceholder:multiplemultipleclearhandleClearremove-taghandleRemoveTagel-input v-iffilterv-modelfilterText:placeholderfilterPlaceholder stylemargin-top: -6px;/el-option :valuevalue :labeloption.name classselect-optionsel-treeidtree-optionreftreeSelectTree:accordionaccordion:dataoptions:propsprops:node-keyprops.value:highlight-current!multiple:show-checkboxmultiple:check-strictlycheckStrictly:default-expand-allexpandAll:expand-on-click-nodemultiple:filter-node-methodfilterNodenode-clickhandleNodeClickcheckhandleNodeCheckboxspan slot-scope{ node, data } classtree_label{{ node.label }}/span/el-tree/el-option/el-select/div /template script export default {name: TreeSelect,model: {prop: value,event: change},props: {value: {type: [String, Number, Object, Array],default: () {return }},clearable: {type: Boolean,default: true},placeholder: {type: String,default: 请选择},multipleLimit: {type: Number,default: 2},//--------- filter props -----filter: {type: Boolean,default: true},filterPlaceholder: {type: String,default: 请输入关键字},//----- tree props -----accordion: {type: Boolean,default: false},options: {type: Array,default: () {return []}},props: {type: Object,default: () {return {value: id,label: label,children: children}}},expandAll: {type: Boolean,default: false},checkStrictly: {type: Boolean,default: false}},data() {return {tp: {value: id,label: label,children: children,prentId: parentId},multiple: false,valueLabel: [],option: {id: ,name: },filterText: undefined,valueId: [],treeIds: []}},watch: {valueId() {if (this.multiple) {let valueStr if (this.value instanceof Array) {valueStr this.value.join()} else {valueStr this.value}if (valueStr ! this.valueId.join()) {this.$emit(change, this.valueId)}} else {let id this.valueId.length 0 ? this.valueId[0] : undefinedif (id ! this.value) {this.$emit(change, id)}}},value: {handler(newVal, oldVal) {if (newVal ! oldVal) {this.init()}}},filterText: {handler(newVal, oldVal) {if (newVal ! oldVal) {this.$refs.treeSelectTree.filter(newVal)}}}},mounted() {for (let key in this.tp) {if (this.props[key] ! undefined) {this.tp[key] this.props[key]}}this.multiple this.multipleLimit 1this.init()this.$nextTick(() {if (this.multiple) {document.getElementsByClassName(el-select__tags)[0].style.maxHeight document.getElementsByClassName(el-select)[0].offsetHeight * 2 - 4 px}})},methods: {init() {if (this.value instanceof Array) {this.valueId this.value} else if (this.value undefined) {this.valueId []} else {this.valueId [this.value]}if (this.multiple) {for (let id of this.valueId) {this.$refs.treeSelectTree.setChecked(id, true, false)}} else {this.$refs.treeSelectTree.setCurrentKey(this.valueId.length 0 ? this.valueId[0] : undefined)}this.initValueLabel()this.initTreeIds()this.initScroll()},// 初始化滚动条initScroll() {this.$nextTick(() {let scrollWrap document.querySelectorAll(.el-scrollbar .el-select-dropdown__wrap)[0]scrollWrap.style.cssText margin: 0px; max-height: none; overflow: hidden;let scrollBar document.querySelectorAll(.el-scrollbar .el-scrollbar__bar)scrollBar.forEach((ele) (ele.style.width 0))})},initTreeIds() {let treeIds []let _this thisfunction traverse(nodes) {for (let node of nodes) {treeIds.push(node[_this.tp.value])if (node[_this.tp.children]) {traverse(node[_this.tp.children])}}}traverse(this.options)this.treeIds treeIds},initValueLabel() {let labels []let _this thisfor (let id of this.valueId) {let node this.traverse(this.options, node node[_this.tp.value] id)if (node) {labels.push(node[_this.tp.label])}}if (this.multiple) {this.valueLabel labelsthis.option.name labels.join()} else {this.valueLabel labels.length 0 ? labels[0] : undefinedthis.option.name this.valueLabel}},traverse(tree, func) {for (let node of tree) {if (func(node)) {return node}if (node[this.tp.children]) {let result this.traverse(node[this.tp.children], func)if (result ! undefined) {return result}}}return undefined},handleClear() {this.valueLabel []this.valueId []if (this.multiple) {for (let id of this.treeIds) {this.$refs.treeSelectTree.setChecked(id, false, false)}} else {this.$refs.treeSelectTree.setCurrentKey(null)}},/* 树filter方法 */filterNode(value, data) {if (!value) return truereturn data[this.props.label].indexOf(value) ! -1},/* 树节点点击事件 */handleNodeClick(data, node) {if (!this.multiple) {this.filterText this.valueId [data[this.tp.value]]}if(node.childNodes){node.expanded true}},handleNodeCheckbox(data, node) {if (this.multiple) {if (this.multipleLimit node.checkedKeys.length) {this.valueId node.checkedKeys} else {this.$refs.treeSelectTree.setChecked(data, false, !this.checkStrictly)this.$message.error(最多选择 this.multipleLimit 项)}}},handleRemoveTag(tag) {let n this.traverse(this.options, node node[this.tp.label] tag)if (n) {this.$refs.treeSelectTree.setChecked(n[this.tp.value], false, !this.checkStrictly)}this.valueId this.$refs.treeSelectTree.getCheckedKeys()}} }/scriptstyle scoped langscss ::v-deep .el-select__tags {overflow: auto; } .custom-select-popper{}.el-scrollbar {.el-scrollbar__view {.el-select-dropdown__item {height: auto;max-height: 300px;padding: 0;overflow: hidden;overflow-y: auto;}.el-select-dropdown__item.selected {font-weight: normal;}} }ul li {.el-tree {.el-tree-node__content {height: auto;padding: 0 20px;}.el-tree-node__label {font-weight: normal;}.is-current .el-tree-node__label{color: #409eff;font-weight: 700;}} }.tree_label {line-height: 23px;.label_index {background-color: rgb(0, 175, 255);width: 22px;height: 22px;display: inline-flex;border-radius: 4px;.label_index_font {color: #ffffff;width: 100%;text-align: center;}} } /style
http://www.dnsts.com.cn/news/1914.html

相关文章:

  • 网站使用的语言独立网站和平台网站
  • 手机运用网站篮网最新消息
  • 营销网站建设公司排名推广app赚佣金平台有哪些
  • 网站建设总体情况群发软件
  • 现在都不用dw做网站了吗百度pc端首页
  • 好的网站特点推广联盟平台
  • 电子商务网站管理内容seo招聘网
  • 有哪些做分析图用的网站网络推广宣传方式
  • 网站支付平台是怎么做的北京度seo排名
  • 如何用api做网站厦门seo报价
  • 淄博网站建设电话咨询百度pc版网页
  • 素材网站建设需要多少费用谷歌浏览器网页版在线
  • 网站建设方案案例seo整站优化新站快速排名
  • 学做网站设计需要多少钱百度关键词排名优化工具
  • 网站全新改版如何做成都私人网站制作
  • 做网站哪个行业比较有前景做营销策划的公司
  • 温州网站建设方案报价竞价推广培训课程
  • 上海网站建设与设计公司如何做互联网营销推广
  • 长城宽带seowhy论坛
  • 江门建站网站模板有什么引流客源的软件
  • 信阳做网站的公司官网排名优化方案
  • 外国做视频在线观看网站百度优化怎么做
  • 织梦网站源码下载学seo哪个培训好
  • 网站开发技术教程百度指数行业排行
  • 免费响应式模板网站模板申请域名
  • 中国建设银行招投标网站郑州企业网站seo
  • 可以做自己的单机网站种子搜索神器在线搜
  • 记事本做网站怎么调整图片间距希爱力的功效及副作用
  • 网络科技公司注册网站优化外包费用
  • 滕州网站搜索引擎优化网页开发公司