Element樹形控件整合帶圖標的下拉菜單(tree+dropdown+input)_第1頁
Element樹形控件整合帶圖標的下拉菜單(tree+dropdown+input)_第2頁
Element樹形控件整合帶圖標的下拉菜單(tree+dropdown+input)_第3頁
Element樹形控件整合帶圖標的下拉菜單(tree+dropdown+input)_第4頁
Element樹形控件整合帶圖標的下拉菜單(tree+dropdown+input)_第5頁
已閱讀5頁,還剩1頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領

文檔簡介

第Element樹形控件整合帶圖標的下拉菜單(tree+dropdown+input)目錄需求說明:實現(xiàn)步驟:本文主要講述:自定義樹形控件el-tree

需求說明:

ElementUI官網(wǎng)提供的樹形控件包含基礎的、可選擇的、自定義節(jié)點內(nèi)容的、帶節(jié)點過濾的以及可拖拽節(jié)點的樹形結(jié)構(gòu)如下:

我想要的效果是支持搜索效果的樹,將鼠標懸浮后顯示添加修改圖標,點擊圖標后彈出對應頁面;并且在每個文件夾前添加自定義圖標。

實現(xiàn)效果:

實現(xiàn)步驟:

1、使用插槽(slot)

el-col:span="4":xs="24"

!--目錄搜索功能--

div

el-input

v-model="dirNameCn"

placeholder="請輸入目錄名稱"

clearable

size="small"

prefix-icon="el-icon-search"

/div

!--樹的展示--

div

el-tree

:data="dirTreeOptions"

:props="defaultProps"

:expand-on-click-node="false"

:filter-node-method="filterNode"

ref="tree"

default-expand-all

@node-click="handleNodeClick"

icon-node-key="id"

:check-on-click-node="true"

!--隱藏的新增等圖標--

spanslot-scope="{node,data}"@mouseenter="mouseenter(data)"@mouseleave="mouseleave(data)"

span{{node.label}}/span

div

iv-show="data.show"@click="addDial(node,data)"/

!--隱藏的下拉選--

el-dropdowntrigger="click"placement="right"@command="(command)={handleCommand(command)}"

iv-show="data.show"/

el-dropdown-menuslot="dropdown"

el-dropdown-itemcommand="a"重命名/el-dropdown-item

el-dropdown-itemcommand="b"刪除/el-dropdown-item

/el-dropdown-menu

/el-dropdown

/div

/span

/el-tree

/div

/el-col

2、組件對應的JS

注意:樹的數(shù)據(jù)是從后端查詢回來的,保存在dirTreeOptions里面

script

exportdefault{

name:'reqmdoctree',

data(){

return{

//左側(cè)搜索框內(nèi)容

dirNameCn:'',

//目錄樹選項

dirTreeOptions:undefined,

defaultProps:{

children:"children",

label:"label"

//樹形菜單中有無子節(jié)點

yesChild:undefined,

//控制左側(cè)新增提示信息框

show:0,

//查詢需求文檔信息參數(shù)

queryParams:{

docNo:undefined,//文檔編號

docNameEn:undefined,//文檔英文名稱

dirNo:undefined,//目錄編號

current:1,//當前頁數(shù)

size:20//每頁顯示多少條

treeId:undefined,

methods:{

/**查詢需求目錄下拉樹結(jié)構(gòu)*/

getTreeselect(){

treeselect().then(response={

this.dirTreeOptions=response.data

//搜索值為過濾函數(shù)

filterNode(value,data){

if(!value)returntrue

returndata.label.indexOf(value)!==-1

//節(jié)點被點擊時的回調(diào)函數(shù)

handleNodeClick(data){

//console.log(data)

this.treeId=data.id

this.yesChild=data.children

this.queryParams.dirNo=data.id

this.getList()

//樹中三個點的事件

handleCommand(command){

if(command=='a'){

selectReqNo(this.treeId).then(response={

this.uuid=response.msg

getObjTree(response.msg).then(response={

this.form=response.data

this.open=true

this.title='修改需求文檔目錄配置表'

if(command=='b'){

if(this.yesChild!=undefined){

this.$notify.error({

title:'警告',

message:'此目錄下還有別的文件夾'

}else{

selectReqNo(this.treeId).then(response={

this.uuid=response.msg

this.$confirm('是否確認刪除ID為'+this.uuid+'的數(shù)據(jù)項?','警告',{

confirmButtonText:'確定',

cancelButtonText:'取消',

type:'warning'

}).then(()={

returndelObjTree(this.uuid)

}).then(data={

this.getTreeselect()

this.msgSuccess('刪除成功')

}).catch(function(){

//左側(cè)新建目錄/文件

addDial(node,data){

//console.log(node,'---',data)

this.reset()

this.form.dirParentId=data.id

this.open=true

this.title='添加需求文檔目錄配置表'

//左側(cè)鼠標懸浮展示圖標

mouseenter(data){

this.

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論