最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue3+Element Plus實(shí)現(xiàn)自定義穿梭框的詳細(xì)代碼

 更新時(shí)間:2024年01月30日 09:26:11   作者:左小白  
找到一個(gè)好用的vue樹形穿梭框組件都很難,又不想僅僅因?yàn)橐粋€(gè)穿梭框在element-ui之外其他重量級(jí)插件,本文給大家分享vue3+Element Plus實(shí)現(xiàn)自定義穿梭框的示例代碼,感興趣的朋友一起看看吧

先上效果圖:具體細(xì)節(jié)可以自己調(diào)整這里主要說(shuō)明 派單,取消這兩個(gè)按鈕的實(shí)現(xiàn)

DOM部分代碼:

    <el-row style="min-height: 7.5rem">
        <el-col :span="10" style="border: 1px solid #E1E1E1;border-radius: 5px">
            <div>
                <div style="border-radius: 5px 5px 0px 0px;
                                                                    border-bottom: 1px solid #42A4ED;display: flex;
                                                                    justify-content: space-around;background: #42A4ED">
                    <div id="rec" style="
                                 font-weight: bolder;
                                                                         cursor: pointer;/*鼠標(biāo)變成手指樣式*/
                                                                         transition: all 0.3s;
                                                                         color: #fff;">
                        <p style="padding: 10px 10px;height: 40px;"></p>
                    </div>
                </div>
                <div style="padding-bottom: 20px;margin: auto;
                                                                    min-height: 15%;width:80%;font-size: .2rem;
                                                                    color:#0c1a24;background-color: #fff;">
                    <el-row>
                        <el-col :span="20" style="margin-left: 40px; margin-top: 10px;">
                            <el-input :style="{ margin: 'auto', height: '30px'}" v-model.trim="formData.orgName"
                                v-show="flag == 'REC'" placeholder="請(qǐng)輸入組織名稱">
                                <template #append>
                                    <img @click="getUserData()" src="@/assets/images/icon/search.png"
                                        style="position:relative;top:0px;right: 0px;cursor: pointer">
                                </template>
                            </el-input>
                        </el-col>
                    </el-row>
                </div>
                <el-table v-loading="flagTbale" ref="selectedLeft"  align='center' :row-style="{ height: '30px', padding: '0 0' }"
                    highlight-current-row :data="tableData" @selection-change="handleLeftSelectionChange"
                    :cell-style="{ padding: '3px', background: '#fff', paddingLeft: '0', color: '#666' }"
                    :header-cell-style="{ background: '#42A4ED', color: '#FFFFFF', height: '20px', fontSize: '0.2rem', fontWeight: 'bold' }"
                    :header-row-style="{ padding: '10px' }">
                    <el-table-column type="selection" width="50" prop="select"></el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="center" v-for="col in cols" :key="col.id"
                        :label="col.label" :prop="col.prop" :width="col.width">
                    </el-table-column>
                </el-table>
                <div style="height: 1rem;margin-bottom:0.2rem;display: flex; justify-content: center;">
                    <el-pagination class="pagination"  small layout="prev, pager, next" @size-change="handleSizeChange"
                        :pager-count="3" @current-change="handleCurrentChange" v-model:current-page="pageNum"
                        v-model:page-size="pageSize" :total="total"  />
                </div>
            </div>
        </el-col>
        <!-- 中間按鈕 -->
        <!--中間按鈕開始-->
        <el-col :span="2" class="layui-transfer-active" style="margin: 230px 3% 0 5%;">
            <div>
                <el-button class="setting-btn" style="width: 70%;" @click="buttonRight" type="primary"
                    :disabled="fxDisabled">
                    派單
                </el-button>
            </div>
            <div>
                <el-button class="setting-btn mt20" style="width: 70%;" @click="buttonLeft" type="primary"
                    :disabled="qxfxDisabled">取消
                </el-button>
            </div>
        </el-col>
        <el-col :span="10" style="border: 1px solid #E1E1E1;border-radius: 5px">
            <div>
                <div style="border-radius: 5px 5px 0px 0px;
                                                            border-bottom: 0px solid #42A4ED;display: flex;
                                                            justify-content: space-around;background: #42A4ED">
                    <div id="reced" style="font-family: SourceHanSansCN-Medium;
                                                                 font-weight: bolder;
                                                                 cursor: pointer;/*鼠標(biāo)變成手指樣式*/
                                                                 transition: all 0.3s;
                                                                 color: #fff;">
                        <p style="padding: 1px 0px;height: 4px;"></p>
                    </div>
                </div>
                <el-table ref="selectedRight"  align='center' max-height="470px" :row-style="{ height: '30px', padding: '0 0' }"
                    highlight-current-row :data="sharedData" @selection-change="handleRightSelectionChange"
                    :cell-style="{ padding: '3px', background: '#fff', paddingLeft: '0', color: '#666' }"
                    :header-cell-style="{ background: '#42A4ED', color: '#FFFFFF', height: '20px', fontSize: '0.2rem', fontWeight: 'bold' }"
                    :header-row-style="{ padding: '10px' }"
                    >
                    <el-table-column type="selection" width="55" prop="select"></el-table-column>
                    <el-table-column :show-overflow-tooltip="true" align="center" v-for="col in cols" :key="col.id"
                        :label="col.label" :prop="col.prop" :width="col.width">
                    </el-table-column>
                </el-table>
            </div>
        </el-col>
    </el-row>

穿梭框的table表頭是動(dòng)態(tài)的html中無(wú)需修改,使用這個(gè)組件首先需要在scripe中創(chuàng)建如下變量

const tableData = ref([]) //左側(cè)數(shù)據(jù)
const selectedLeft = ref([])// 左側(cè)選中數(shù)據(jù)
const sharedData = ref([])//右側(cè)數(shù)據(jù)
const selectedRight = ref([])// 右側(cè)選中數(shù)據(jù)
//表格loading
const flagTbale = ref(false) //可以去除所有的flagTbale 變量即可去除loading功能
//兩個(gè)table表頭
const cols = ref([
    { id: 1, prop: 'latnName', label: '本地網(wǎng)' },
    { id: 2, prop: 'orgId', label: '組織編碼' },
    { id: 3, prop: 'orgName', label: '組織' },
])

然后就是最重要的按鈕功能

// 取消按鈕
const buttonLeft = async () => {
    if (!selectedRight.value || !Array.isArray(selectedRight.value)) {
        selectedRight.value = [];
    }
    // 將右側(cè)選中的數(shù)據(jù)移動(dòng)到左側(cè)
    tableData.value = tableData.value.concat(selectedRight.value);
    // 從右側(cè)數(shù)據(jù)中移除已經(jīng)移動(dòng)的數(shù)據(jù)
    sharedData.value = sharedData.value.filter(item => !selectedRight.value.includes(item));
    // 清空右側(cè)選中的數(shù)據(jù)
    selectedRight.value = [];
}
// 分享按鈕
const buttonRight = async () => {
    if (!selectedLeft.value || !Array.isArray(selectedLeft.value)) {
        selectedLeft.value = [];
    }
    // 將左側(cè)選中的數(shù)據(jù)移動(dòng)到右側(cè)
    sharedData.value = sharedData.value.concat(selectedLeft.value);
    // 從左側(cè)數(shù)據(jù)中移除已經(jīng)移動(dòng)的數(shù)據(jù)
    tableData.value = tableData.value.filter(item => !selectedLeft.value.includes(item));
    // 清空左側(cè)選中的數(shù)據(jù)
    selectedLeft.value = [];
}

按鈕禁用邏輯實(shí)現(xiàn)

// 按鈕是否禁用
const qxfxDisabled = ref(true)
const fxDisabled = ref(true)
// 左側(cè)表格選中事件
const handleLeftSelectionChange = (selection) => {
    if (selection.length !== 0) {
        fxDisabled.value = false
    }
    if (selection.length === 0) {
        fxDisabled.value = true
    }
};
// 右側(cè)表格選中事件
const handleRightSelectionChange = (selection) => {
    selectedRight.value = selection;
    if (selection.length !== 0) {
        qxfxDisabled.value = false
    }
    if (selection.length === 0) {
        qxfxDisabled.value = true
    }
};

到這里你就可以使用在這個(gè)組件了。這是經(jīng)過(guò)插分的代碼原本還擁有表頭切換的邏輯如有需要可留言.我后續(xù)可以在做整理

到此這篇關(guān)于vue3+Element Plus實(shí)現(xiàn)自定義穿梭框的文章就介紹到這了,更多相關(guān)vue3 Element Plus穿梭框內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Vue2單一事件管理組件通信

    Vue2單一事件管理組件通信

    這篇文章主要為大家詳細(xì)介紹了Vue2單一事件管理組件通信的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Vue按照順序?qū)崿F(xiàn)多級(jí)彈窗效果 附Demo

    Vue按照順序?qū)崿F(xiàn)多級(jí)彈窗效果 附Demo

    這篇文章主要介紹了Vue按照順序?qū)崿F(xiàn)多級(jí)彈窗效果 附Demo,通過(guò)實(shí)例代碼介紹了單個(gè)彈窗和多級(jí)彈窗的實(shí)現(xiàn)方法,感興趣的朋友跟隨小編一起看看吧
    2024-05-05
  • Vue使用antd中input組件去驗(yàn)證輸入框輸入內(nèi)容(rules?案例)

    Vue使用antd中input組件去驗(yàn)證輸入框輸入內(nèi)容(rules?案例)

    這篇文章主要介紹了Vue使用antd中input組件去驗(yàn)證輸入框輸入內(nèi)容-rules-案例,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • vue-cli腳手架初始化項(xiàng)目各個(gè)文件夾用途

    vue-cli腳手架初始化項(xiàng)目各個(gè)文件夾用途

    這篇文章主要介紹了vue-cli腳手架初始化項(xiàng)目各個(gè)文件夾用途,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-01-01
  • 在vue.config.js中優(yōu)化webpack配置的方法

    在vue.config.js中優(yōu)化webpack配置的方法

    在日常開發(fā)中我們離不開打包工具webpack,但是不同的配置會(huì)影響我們項(xiàng)目的運(yùn)行構(gòu)建時(shí)間,也會(huì)影響打包之后項(xiàng)目包的大小,這篇文章記錄一下我使用過(guò)的可以優(yōu)化webpack的配置,需要的朋友可以參考下
    2024-05-05
  • Ant Design moment對(duì)象和字符串之間的相互轉(zhuǎn)化教程

    Ant Design moment對(duì)象和字符串之間的相互轉(zhuǎn)化教程

    這篇文章主要介紹了Ant Design moment對(duì)象和字符串之間的相互轉(zhuǎn)化教程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-10-10
  • 淺談Vue父子組件和非父子組件傳值問(wèn)題

    淺談Vue父子組件和非父子組件傳值問(wèn)題

    本篇文章主要介紹了淺談Vue父子組件和非父子組件傳值問(wèn)題,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2017-08-08
  • Vue計(jì)時(shí)器的用法詳解

    Vue計(jì)時(shí)器的用法詳解

    這篇文章主要為大家詳細(xì)介紹了Vue計(jì)時(shí)器的用法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-06-06
  • Vue 用Vant實(shí)現(xiàn)時(shí)間選擇器的示例代碼

    Vue 用Vant實(shí)現(xiàn)時(shí)間選擇器的示例代碼

    這篇文章主要介紹了Vue 用Vant實(shí)現(xiàn)時(shí)間選擇器的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-10-10
  • Vue指令之 v-cloak、v-text、v-html實(shí)例詳解

    Vue指令之 v-cloak、v-text、v-html實(shí)例詳解

    當(dāng)用戶頻繁刷新頁(yè)面或網(wǎng)速慢時(shí),頁(yè)面未完成 Vue.js 的加載時(shí),導(dǎo)致 Vue 來(lái)不及渲染,這就會(huì)導(dǎo)致在瀏覽器中直接暴露插值(表達(dá)式),這篇文章主要介紹了Vue指令 v-cloak、v-text、v-html,需要的朋友可以參考下
    2019-08-08

最新評(píng)論

浦江县| 台北县| 祁连县| 泽普县| 松原市| 大洼县| 鄂伦春自治旗| 阿尔山市| 南陵县| 元朗区| 宁明县| 东辽县| 景宁| 贡觉县| 陆丰市| 大荔县| 新源县| 晋中市| 时尚| 阿克苏市| 张家川| 永川市| 赣州市| 彰武县| 安龙县| 平湖市| 云南省| 枞阳县| 奇台县| 呼玛县| 察雅县| 五寨县| 砚山县| 金川县| 平泉县| 苍山县| 喀喇| 望奎县| 芦山县| 汉沽区| 平和县|