电脑知识|欧美黑人一区二区三区|软件|欧美黑人一级爽快片淫片高清|系统|欧美黑人狂野猛交老妇|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网

您的位置:首頁技術文章
文章詳情頁

vue 使用餓了么UI仿寫teambition的篩選功能

瀏覽:141日期:2022-06-10 17:57:29
問題描述

teambition軟件是企業辦公協同軟件,相信部分朋友的公司應該用過這款軟件。里面的篩選功能挺有意思,本篇文章,就是仿寫其功能。我們先看一下最終做出來的效果圖

vue 使用餓了么UI仿寫teambition的篩選功能

大致的功能效果有如下 需求一:常用篩選條件放在上面直接看到,不常用篩選條件放在添加篩選條件里面 需求二:篩選的方式有輸入框篩選、下拉框篩選、時間選擇器篩選等 需求三:如果覺得常用篩選條件比較多的話,可以鼠標移入點擊刪除,使之進入不常用的篩選條件里 需求四:也可以從不常用的篩選條件里面點擊對應篩選條件使之“蹦到”常用篩選條件里 需求五:點擊重置使之恢復到初試的篩選條件 需求六:用戶若是沒輸入內容點擊確認按鈕,就提示用戶要輸入篩選條件 思路分析

對于需求一和需求二,我們首先要搞兩個全屏幕彈框,然后在data中定義兩個數組,一個是放常用條件的數組,另外一個是放不常用條件的數組,常用條件v-for到第一個彈框里面,不常用條件v-for到第二個彈框里面。數組里面的每一項都要配置好對應內容,比如要有篩選字段名字,比如姓名、年齡什么的。有了篩選篩選字段名字以后,還有有一個類型type,在html中我們要寫三個類型的組件、比如input輸入框組件,select組件,時間選擇器組件。使用根據type類型通過v-show顯示對應字段,比如input的type為1,select的type為2,時間選擇器的type為3。是哪個type,就顯示哪個組件。

對應兩個數組如下:

topData: [ // 配置常用的篩選項 { wordTitle: '姓名', type: 1, // 1 為input 2為select 3為DatePicker content: '', // content為輸入框綁定的輸入數據 options: [], // options為所有的下拉框內容,可以發請求拿到存進來,這里是模擬 optionArr: [], // optionArr為選中的下拉框內容 timeArr: [], // timeArr為日期選擇區間 }, { wordTitle: '年齡', type: 1, content: '', options: [], optionArr: [], timeArr: [], }, { wordTitle: '授課班級', type: 2, content: '', options: [ // 發請求獲取下拉框選項 { id: 1, value: '一班', }, { id: 2, value: '二班', }, { id: 3, value: '三班', }, ], optionArr: [], timeArr: [], }, { wordTitle: '入職時間', type: 3, content: '', options: [], optionArr: [], timeArr: [], }, ], bottomData: [ // 配置不常用的篩選項 { wordTitle: '工號', type: 1, content: '', options: [], optionArr: [], timeArr: [], }, { wordTitle: '性別', type: 2, content: '', options: [ { id: 1, value: '男', }, { id: 2, value: '女', }, ], optionArr: [], timeArr: [], }, ],

對應html代碼如下:

<div class='rightright'> <el-input v-model.trim='item.content' clearable v-show='item.type == 1' placeholder='請輸入' size='small' :popper-append-to-body='false' ></el-input> <el-select v-model='item.optionArr' v-show='item.type == 2' multiple placeholder='請選擇' > <el-option v-for='whatItem in item.options' :key='whatItem.id' :label='whatItem.value' :value='whatItem.id' size='small' > </el-option> </el-select> <el-date-picker v-model='item.timeArr' v-show='item.type == 3' type='daterange' range-separator='至' start-placeholder='開始日期' end-placeholder='結束日期' format='yyyy-MM-dd' value-format='yyyy-MM-dd' > </el-date-picker></div>

完整代碼在最后,大家先順著思路看哦

對于需求三需求四,可描述為,刪除上面的掉到下面。點擊下面的蹦到上面。所以對應操作就是把上面數組某一項追加到下面數組,然后把上面數組的這一項刪掉;把下面數組的某一項追加到上面數組,然后把這一行刪掉。(注意還有一個索引)對應代碼如下:

/* 點擊某一項的刪除小圖標,把這一項添加到bottomData數組中 然后把這一項從topData數組中刪除掉(根據索引判別是哪一項) 最后刪除一個就把索引置為初始索引 -1 */ clickIcon(i) { this.bottomData.push(this.topData[i]); this.topData.splice(i, 1); this.whichIndex = -1; }, // 點擊底部的項的時候,通過事件對象,看看點擊的是底部的哪一項 // 然后把對應的那一項追加到topData中用于展示,同時把bottom數組 // 中的哪一項進行刪除 clickBottomItem(event) { this.bottomData.forEach((item, index) => { if (item.wordTitle == event.target.innerText) { this.topData.push(item); this.bottomData.splice(index, 1); } }); },

對于需求五需求六就簡單了,對應代碼如下,完整代碼注釋中已經寫好了

完整代碼

<template> <div id='app'> <div class='filterBtn'> <el-button type='primary' size='small' @click='filterMaskOne = true'> 數據篩選<i class='el-icon-s-operation el-icon--right'></i> </el-button> <transition name='fade'> <div v-show='filterMaskOne' @click='filterMaskOne = false' > <div @click.stop> <div class='filterHeader'> <span>數據篩選</span> </div> <div class='filterBody'> <div v-show='topData.length == 0'>暫無篩選條件,請添加篩選條件... </div> <div v-for='(item, index) in topData':key='index' ><div @mouseenter='mouseEnterItem(index)' @mouseleave='mouseLeaveItem(index)'> <span >{{ item.wordTitle }}: <i v-show='whichIndex == index' @click='clickIcon(index)' ></i> </span></div><div class='rightright'> <el-input v-model.trim='item.content' clearable v-show='item.type == 1' placeholder='請輸入' size='small' :popper-append-to-body='false' ></el-input> <el-select v-model='item.optionArr' v-show='item.type == 2' multiple placeholder='請選擇' > <el-option v-for='whatItem in item.options' :key='whatItem.id' :label='whatItem.value' :value='whatItem.id' size='small' > </el-option> </el-select> <el-date-picker v-model='item.timeArr' v-show='item.type == 3' type='daterange' range-separator='至' start-placeholder='開始日期' end-placeholder='結束日期' format='yyyy-MM-dd' value-format='yyyy-MM-dd' > </el-date-picker></div> </div> </div> <div class='filterFooter'> <div class='filterBtn'><el-button type='text' icon='el-icon-circle-plus-outline' @click='filterMaskTwo = true' >添加篩選條件</el-button><transition name='fade'> <div v-show='filterMaskTwo' @click='filterMaskTwo = false' > <div @click.stop> <div v-show='bottomData.length == 0'> 暫無內容... </div> <div @click='clickBottomItem' v-for='(item, index) in bottomData' :key='index' > <div class='mingzi'> {{ item.wordTitle }} </div> </div> </div> </div></transition> </div> <div class='resetAndConfirmBtns'><el-button size='small' @click='resetFilter'>重置</el-button><el-button type='primary' size='small' @click='confirmFilter' >確認</el-button> </div> </div> </div> </div> </transition> </div> </div></template><script>export default { name: 'app', data() { return { filterMaskOne: false, // 分別用于控制兩個彈框的顯示與隱藏 filterMaskTwo: false, whichIndex: -1, // 用于記錄點擊的索引 apiFilterArr:[], //存儲用戶填寫的篩選內容 topData: [ // 配置常用的篩選項 { wordTitle: '姓名', type: 1, // 1 為input 2為select 3為DatePicker content: '', // content為輸入框綁定的輸入數據 options: [], // options為所有的下拉框內容 optionArr: [], // optionArr為選中的下拉框內容 timeArr: [], // timeArr為日期選擇區間 }, { wordTitle: '年齡', type: 1, content: '', options: [], optionArr: [], timeArr: [], }, { wordTitle: '授課班級', type: 2, content: '', options: [ // 發請求獲取下拉框選項 { id: 1, value: '一班', }, { id: 2, value: '二班', }, { id: 3, value: '三班', }, ], optionArr: [], timeArr: [], }, { wordTitle: '入職時間', type: 3, content: '', options: [], optionArr: [], timeArr: [], }, ], bottomData: [ // 配置不常用的篩選項 { wordTitle: '工號', type: 1, content: '', options: [], optionArr: [], timeArr: [], }, { wordTitle: '性別', type: 2, content: '', options: [ { id: 1, value: '男', }, { id: 2, value: '女', }, ], optionArr: [], timeArr: [], }, ], }; }, mounted() { // 在初始化加載的時候,我們就把我們配置的常用和不常用的篩選項保存一份 // 當用戶點擊重置按鈕的時候,再取出來使其恢復到最初的篩選條件狀態 sessionStorage.setItem('topData',JSON.stringify(this.topData)) sessionStorage.setItem('bottomData',JSON.stringify(this.bottomData)) }, methods: { //鼠標移入顯示刪除小圖標 mouseEnterItem(index) { this.whichIndex = index; }, // 鼠標離開將索引回復到默認-1 mouseLeaveItem() { this.whichIndex = -1; }, /* 點擊某一項的刪除小圖標,把這一項添加到bottomData數組中 然后把這一項從topData數組中刪除掉(根據索引判別是哪一項) 最后刪除一個就把索引置為初始索引 -1 */ clickIcon(i) { this.bottomData.push(this.topData[i]); this.topData.splice(i, 1); this.whichIndex = -1; }, // 點擊底部的項的時候,通過事件對象,看看點擊的是底部的哪一項 // 然后把對應的那一項追加到topData中用于展示,同時把bottom數組 // 中的哪一項進行刪除 clickBottomItem(event) { this.bottomData.forEach((item, index) => { if (item.wordTitle == event.target.innerText) { this.topData.push(item); this.bottomData.splice(index, 1); } }); }, // 點擊確認篩選 async confirmFilter() { // 如果所有的輸入框的content內容為空,且選中的下拉框數組為空,且時間選擇器選中的數組為空 // 就說明用戶沒有輸入內容,那么我們就提示用戶要輸入內容以后再進行篩選 let isEmpty = this.topData.every((item)=>{ return (item.content == '') && (item.optionArr.length == 0) && (item.timeArr.length == 0) }) if(isEmpty == true){ this.$alert(’請輸入內容以后再進行篩選’, ’篩選提示’, { confirmButtonText: ’確定’ }); }else{ // 收集參數發篩選請求,這里要分類型,把不為空的既有用戶輸入內容的 // 存到存到數據篩選的數組中去,然后發請求給后端。 this.topData.forEach((item)=>{ if(item.type == 1){ if(item.content != ''){ let filterItem = {field:item.wordTitle,value:item.content } this.apiFilterArr.push(filterItem) } }else if(item.type == 2){ if(item.optionArr.length > 0){ let filterItem = {field:item.wordTitle,value:item.optionArr } this.apiFilterArr.push(filterItem) } }else if(item.type == 3){ if(item.timeArr.length > 0){ let filterItem = {field:item.wordTitle,value:item.timeArr } this.apiFilterArr.push(filterItem) } } }) // 把篩選的內容放到一個數組里面,傳遞給后端(當然不一定把參數放到數組里面) // 具體以怎樣的形式傳遞給后端,可以具體商量 console.log('帶著篩選內容發請求',this.apiFilterArr); } }, // 重置時,再把最初的配置篩選項取出來賦給對應的兩個數組 resetFilter() { this.topData = JSON.parse(sessionStorage.getItem('topData')) this.bottomData = JSON.parse(sessionStorage.getItem('bottomData')) }, },};</script><style lang='less' scoped>.filterBtn { width: 114px; height: 40px; .filterMaskOne { top: 0; left: 0; position: fixed; width: 100%; height: 100%; z-index: 999; background-color: rgba(0, 0, 0, 0.3); .filterMaskOneContent { position: absolute; top: 152px; right: 38px; width: 344px; height: 371px; background-color: #fff; box-shadow: 0px 0px 4px 3px rgba(194, 194, 194, 0.25); border-radius: 4px; .filterHeader { width: 344px; height: 48px; border-bottom: 1px solid #e9e9e9; span { display: inline-block; font-weight: 600; font-size: 16px; margin-left: 24px; margin-top: 16px; } } .filterBody { width: 344px; height: 275px; overflow-y: auto; overflow-x: hidden; box-sizing: border-box; padding: 12px 24px 0 24px; .outPrompt { color: #666; } .filterBodyCondition { width: 100%; min-height: 40px; display: flex; margin-bottom: 14px; .leftleft { width: 88px; height: 40px; display: flex; align-items: center; margin-right: 20px; span { position: relative; font-size: 14px; color: #333; i {color: #666;right: -8px;top: -8px;position: absolute;font-size: 15px;cursor: pointer; } i:hover {color: #5f95f7; } } } .rightright { width: calc(100% - 70px); height: 100%; /deep/ input::placeholder { color: rgba(0, 0, 0, 0.25); font-size: 13px; } /deep/ .el-input__inner { height: 40px; line-height: 40px; } /deep/ .el-select { .el-input--suffix {/deep/ input::placeholder { color: rgba(0, 0, 0, 0.25); font-size: 13px;}.el-input__inner { border: none;}.el-input__inner:hover { background: rgba(95, 149, 247, 0.05);} } } .el-date-editor { width: 100%; font-size: 12px; } .el-range-editor.el-input__inner { padding-left: 2px; padding-right: 0; } /deep/.el-range-input { font-size: 13px !important; } /deep/ .el-range-separator { padding: 0 !important; font-size: 12px !important; width: 8% !important; margin: 0; } /deep/ .el-range__close-icon { width: 16px; } } } } .filterFooter { width: 344px; height: 48px; display: flex; justify-content: space-between; align-items: center; box-sizing: border-box; padding-left: 24px; padding-right: 12px; border-top: 1px solid #e9e9e9; .filterBtn { .filterMaskTwo { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.3); z-index: 1000; .filterMaskContentTwo { width: 240px; height: 320px; background: #ffffff; box-shadow: 0px 0px 4px 3px rgba(194, 194, 194, 0.25); border-radius: 4px; position: absolute; top: 360px; right: 180px; overflow-y: auto; box-sizing: border-box; padding: 12px 0 18px 0; overflow-x: hidden; .innerPrompt {color: #666;width: 100%;padding-left: 20px;margin-top: 12px; } .contentTwoItem {width: 100%;height: 36px;line-height: 36px;font-size: 14px;color: #333333;cursor: pointer;.mingzi { width: 100%; height: 36px; box-sizing: border-box; padding-left: 18px;} } .contentTwoItem:hover {background: rgba(95, 149, 247, 0.05); } } } } } } }}// 控制淡入淡出效果.fade-enter-active,.fade-leave-active { transition: opacity 0.3s;}.fade-enter,.fade-leave-to { opacity: 0;}</style>總結

這里面需要注意的就是鼠標移入移出顯示對應的刪除小圖標。思路大致就這樣,敲代碼不易,咱們共同努力。

以上就是vue 使用餓了么UI仿寫teambition的篩選功能的詳細內容,更多關于vue 仿寫teambition的篩選功能的資料請關注好吧啦網其它相關文章!

標簽: 餓了么
相關文章:
主站蜘蛛池模板: 建筑消防设施检测系统检测箱-电梯**检测仪器箱-北京宇成伟业科技有限责任公司 | 深圳美安可自动化设备有限公司,喷码机,定制喷码机,二维码喷码机,深圳喷码机,纸箱喷码机,东莞喷码机 UV喷码机,日期喷码机,鸡蛋喷码机,管芯喷码机,管内壁喷码机,喷码机厂家 | ◆大型吹塑加工|吹塑加工|吹塑代加工|吹塑加工厂|吹塑设备|滚塑加工|滚塑代加工-莱力奇塑业有限公司 | 浙江建筑资质代办_二级房建_市政_电力_安许_劳务资质办理公司 | RO反渗透设备_厂家_价格_河南郑州江宇环保科技有限公司 | ★店家乐|服装销售管理软件|服装店收银系统|内衣店鞋店进销存软件|连锁店管理软件|收银软件手机版|会员管理系统-手机版,云版,App | 乐泰胶水_loctite_乐泰胶_汉高乐泰授权(中国)总代理-鑫华良供应链 | 胶水,胶粘剂,AB胶,环氧胶,UV胶水,高温胶,快干胶,密封胶,结构胶,电子胶,厌氧胶,高温胶水,电子胶水-东莞聚力-聚厉胶粘 | 金属回收_废铜废铁回收_边角料回收_废不锈钢回收_废旧电缆线回收-广东益夫金属回收公司 | 求是网 - 思想建党 理论强党| 砍排机-锯骨机-冻肉切丁机-熟肉切片机-预制菜生产线一站式服务厂商 - 广州市祥九瑞盈机械设备有限公司 | 青岛空压机,青岛空压机维修/保养,青岛空压机销售/出租公司,青岛空压机厂家电话 | 耳模扫描仪-定制耳机设计软件-DLP打印机-asiga打印机-fitshape「飞特西普」 | 高压包-点火器-高压发生器-点火变压器-江苏天网| 智能化的检漏仪_气密性测试仪_流量测试仪_流阻阻力测试仪_呼吸管快速检漏仪_连接器防水测试仪_车载镜头测试仪_奥图自动化科技 | 讲师宝经纪-专业培训机构师资供应商_培训机构找讲师、培训师、讲师经纪就上讲师宝经纪 | 电机修理_二手电机专家-河北豫通机电设备有限公司(原石家庄冀华高压电机维修中心) | 生物颗粒燃烧机-生物质燃烧机-热风炉-生物颗粒蒸汽发生器-丽水市久凯能源设备有限公司 | 撕碎机,撕破机,双轴破碎机-大件垃圾破碎机厂家 | 苏商学院官网 - 江苏地区唯一一家企业家自办的前瞻型、实操型商学院 | 样品瓶(色谱样品瓶)百科-浙江哈迈科技有限公司 | 分子精馏/精馏设备生产厂家-分子蒸馏工艺实验-新诺舜尧(天津)化工设备有限公司 | 臭氧发生器_臭氧消毒机 - 【同林品牌 实力厂家】 | 正压密封性测试仪-静态发色仪-导丝头柔软性测试仪-济南恒品机电技术有限公司 | 蓝米云-专注于高性价比香港/美国VPS云服务器及海外公益型免费虚拟主机 | 导电银胶_LED封装导电银胶_半导体封装导电胶厂家-上海腾烁 | 颚式破碎机,圆锥破碎机,制砂机-新乡市德诚机电制造有限公司 | 真空上料机(一种真空输送机)-百科 | PVC地板|PVC塑胶地板|PVC地板厂家|地板胶|防静电地板-无锡腾方装饰材料有限公司-咨询热线:4008-798-128 | 磁力加热搅拌器-多工位|大功率|数显恒温磁力搅拌器-司乐仪器官网 | cnc精密加工_数控机械加工_非标平键定制生产厂家_扬州沃佳机械有限公司 | 中国在职研究生招生信息网 | 钢木实验台-全钢实验台-化验室通风柜-实验室装修厂家-杭州博扬实验设备 | 聚合氯化铝厂家-聚合氯化铝铁价格-河南洁康环保科技 | 蜜蜂职场文库_职场求职面试实用的范文资料大全 | 临海涌泉蜜桔官网|涌泉蜜桔微商批发代理|涌泉蜜桔供应链|涌泉蜜桔一件代发 | 高温链条油|高温润滑脂|轴承润滑脂|机器人保养用油|干膜润滑剂-东莞卓越化学 | 高压微雾加湿器_工业加湿器_温室喷雾-昌润空气净化设备 | 翅片管散热器价格_钢制暖气片报价_钢制板式散热器厂家「河北冀春暖气片有限公司」 | 江苏全风,高压风机,全风环保风机,全风环形高压风机,防爆高压风机厂家-江苏全风环保科技有限公司(官网) | 全自动实验室洗瓶机,移液管|培养皿|进样瓶清洗机,清洗剂-广州摩特伟希尔机械设备有限责任公司 |