vue實現(xiàn)二級彈框案例_第1頁
vue實現(xiàn)二級彈框案例_第2頁
vue實現(xiàn)二級彈框案例_第3頁
vue實現(xiàn)二級彈框案例_第4頁
vue實現(xiàn)二級彈框案例_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

第vue實現(xiàn)二級彈框案例本文實例為大家分享了vue實現(xiàn)二級彈框的具體代碼,供大家參考,具體內(nèi)容如下

二級彈框案例,如下圖所示

template

div

div

p請選擇職位/p

div

!--inputv-model="jobKeyWord"placeholder="請輸入職位關(guān)鍵詞"/--

el-input

v-model="jobKeyWord"

@click.native="clickSearchInput"

clearable

@blur="blurSearch"

placeholder="請輸入職位關(guān)鍵詞"/el-input

divv-show="searchFlag"

ul

!--liv-for="(item,i)insearchList":key="i"{{Zh}}/li--

liv-for="(item,i)insearchList"

:key="i"@click="clickTwoCatFun(item)"

@mousedown=downDrag($event)

v-html="Val"/li

/ul

/div

/div

/div

div

spanv-for="(item,i)inclickTwoNameArr":key="i"

{{Zh}}

i@click="delChoolseTwoItem(item)"/i

/span

span最多選擇1個職位類別/span

span@click="jobSure"確認(rèn)/span

/div

div

div

ul

!--li產(chǎn)品/運營/新媒體span1/span/li--

!--templatev-for="(item,i)injobClassList":key="i"

/template

--

li

:class="[clickOneJobNameArr.includes(item.id)'li-active':'']"

v-for="(item,i)injobClassList"

@click="clickJobItem(item)"

:key="i"{{Zh}}

spanv-if="countObj[item.id]"{{countObj[item.id]}}/span

/li

/ul

/div

div

div

!--span互聯(lián)網(wǎng)/移動互聯(lián)網(wǎng)/電子商務(wù)/span--

span

:class="[clickTwoIdArr.includes(twoObj.id)'job-active':'']"

v-for="(twoObj,i)inclickCateObj.list"

:key="i"@click="clickTwoCatFun(twoObj)"{{twoOZh}}

/span

/div

/div

/div

/div

/template

script

exportdefault{

name:"JobClassComp",

data(){

return{

jobKeyWord:'',//職位關(guān)鍵詞

searchFlag:false,//是否展示搜索框

searchList:[],//搜索數(shù)據(jù)

clickOneJobNameArr:[],//存儲點擊時一級分類

clickTwoNameArr:[],//選中的二級分類

clickTwoIdArr:[],//選中的二級分類

clickCateObj:{},//點擊選中的一級分類

countObj:{},//二級職位被選中時一級顯示數(shù)量

searchDataList:[],//搜索數(shù)據(jù)

allTwoClassList:[],//所有二級分類

}

},

props:{

form:Object,

isEndDateNow:Boolean,

jobClassList:{

type:Array,

default(){

return[];

}

}

},

computed:{

listLength(){

returnthis.jobClassList.length

}

},

watch:{

jobKeyWord(val){

if(val.length0){

this.searchList=this.searchDataList.filter(item={

val=val.toUpperCase();

letreg=newRegExp("("+val+")","g");

letnameVal=Zh.replace(reg,"span$1/span

Val=nameVal;

//

returnnewstr;

returnZh.includes(val)

})

this.searchFlag=true

}else{

this.searchList=[];

this.searchFlag=false

}

},

listLength(val,oldValue){

/*

console.log("val==",val)

console.log("oldValue==",oldValue)*/

if(oldValue===0val0){

//console.log("--22--",this.jobClassList)

this.clickOneJobNameArr.length===0this.clickOneJobNameArr.push(this.jobClassList[0].id):'';

Object.keys(this.clickCateObj).length===0this.clickCateObj=this.jobClassList[0]:'';

this.dealSearchData();//處理搜索職位數(shù)據(jù)

//

this.doAllTwoClassData()lzs

}

}

},

created(){

if(this.jobClassListthis.jobClassList.length0){

this.clickOneJobNameArr.length===0this.clickOneJobNameArr.push(this.jobClassList[0].id):'';

Object.keys(this.clickCateObj).length===0this.clickCateObj=this.jobClassList[0]:'';

this.dealSearchData();//處理搜索職位數(shù)據(jù)

}

},

methods:{

clickSearchInput(){

this.jobKeyWord.length0this.searchFlag=true:this.searchFlag=false;

},

//input失去焦點

blurSearch(){

this.searchFlag=false;

},

downDrag(el){

el.preventDefault();//阻止input失去焦點事件時的影響

},

//職位確認(rèn)

jobSure(){

//this.dialogVisible=false;//addlzs

if(this.clickTwoNameArr.length0){

this.form.jobIntensionName='';

this.clickTwoNameArr.forEach(item={

this.form.jobIntensionName=this.form.jobIntensionName+','+Zh;

})

this.form.jobIntensionName.length0this.form.jobIntensionName=this.form.jobIntensionName.substring(1,this.form.jobIntensionName.length):'';

}else{

this.form.jobIntensionName='';

}

this.$emit('sureJobMethod',this.clickTwoNameArr)

},

clickJobItem(item){//點擊職位類別

//console.log("item----",item)

this.clickCateObj=item;

//處理選中顏色變化

if(this.clickOneJobNameArr.length0){

this.clickOneJobNameArr.splice(0,1);

this.clickOneJobNameArr.push(item.id)

}else{

this.clickOneJobNameArr.push(item.id)

}

},

//點擊二級職位名稱

clickTwoCatFun(obj){

//type:searchtwo;=search是點擊的搜索框出現(xiàn),否則就是點擊的二級

//type==='search'this.jobKeyWord=Zh:'';

if(!this.clickTwoIdArr.includes(obj.id)this.clickTwoIdArr.length===1){

this.$message({

message:'最多選擇1個職位類別哦',

type:'warning'

});

return

}

if(!this.clickTwoIdArr.includes(obj.id)this.clickTwoIdArr.length3){

this.clickTwoNameArr.push(obj)

this.clickTwoIdArr.push(obj.id)

this.form.jobIntensionNameSel.push(obj.id)

if(!this.countObj[obj.parentId]){

this.countObj[obj.parentId]=1

}else{

this.countObj[obj.parentId]++;

}

}

},

//要刪除的二級分類,改變選中顏色,改變一級分類統(tǒng)計數(shù)量

delChoolseTwoItem(delObj){

//varfiltered=someArray.filter(function(el){returnel.Name!="Kristian";});

letindex=this.clickTwoNameArr.findIndex(item={

returnitem.id===delObj.id

})

letformIndex=this.form.jobIntensionNameSel.findIndex(idVal={

returnidVal===delObj.id

})

this.form.jobIntensionNameSel.splice(formIndex,1)//刪除

this.clickTwoNameArr.splice(index,1)

this.clickTwoIdArr.splice(index,1)

if(!this.countObj[delObj.parentId]){

this.countObj[delObj.parentId]=0

}else{

this.countObj[delObj.parentId]--;

}

},

//處理搜索的數(shù)據(jù)

dealSearchData(){

this.jobClassList.forEach(item={

this.searchDataList=this.searchDataList.concat(item.list)

})

},

}

}

/script

stylescopedlang="less"

.zw-dialog{

/*

border:1pxsolidred;*/

width:880px;

height:550px;

background:rgba(255,255,255,1);

.zw-top{

height:52px;

width:100%;

display:flex;

/*border:1pxsolidgreen;*/

border-bottom:1pxsolid#EFEFEF;

.zw-word{

width:200px;

/*text-align:center;*/

margin-left:30px;

line-height:52px;

font-size:16px;

color:#333333;

}

.zw-in{

/*border:1pxsolidblue;*/

width:calc(100%-200px);

line-height:52px;

.zw-put{

border-radius:15px;

border:1pxsolidrgba(224,224,224,1);

width:200px;

height:30px;

margin-left:32px;

font-size:12px;

padding-left:20px;

}

.in-put{

width:200px;

height:30px;

/deep/.el-input__inner{

border-radius:15px;

color:#999999;

font-size:12px;

}

/deep/input::-webkit-input-placeholder{

/*WebKitbrowsers*/

font-size:12px;

color:#999999;

}

/deep/input:-moz-placeholder{

/*MozillaFirefox4to18*/

font-size:12px;

color:#999999;

}

/deep/input::-moz-placeholder{

溫馨提示

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

評論

0/150

提交評論