国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

vue+element ui+vuedraggable實(shí)現(xiàn)表格內(nèi)不同格子間標(biāo)簽的拖拽

這篇具有很好參考價(jià)值的文章主要介紹了vue+element ui+vuedraggable實(shí)現(xiàn)表格內(nèi)不同格子間標(biāo)簽的拖拽。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。


一、效果視頻

最近有個(gè)需求是實(shí)現(xiàn)在表格內(nèi)上下不同格子間標(biāo)簽的拖拽,然而element ui并沒有提供此類api,后面我導(dǎo)入vuedraggable包實(shí)現(xiàn)了此需求,效果見視頻。

demo視頻:

element ui表格內(nèi)標(biāo)簽拖拽demo

二、代碼實(shí)現(xiàn)

首先要去下載vuedraggable包

npm i vuedraggable

去package.json文件里看包是否下載成功
element ui如何使用draggable,vue.js,ui,前端,javascript,elementui,vue
下載完成后新建頁面

頁面完整代碼如下:

ps:若要實(shí)現(xiàn)表格橫向的移動(dòng),將代碼中的:group="jndex + 1"改為group="a"即可

<template>
  <div class="app-container">
    <el-table
      v-loading="loading"
      :data="tableData"
      :max-height="maxHeight"
      class="small-table"
      border
      style="width: 100%"
    >
      <el-table-column align="center" prop="week_date" min-width="160">
      </el-table-column>
      <el-table-column
        align="center"
        prop="start_date"
        label="日期"
        min-width="160"
      />
      <template v-for="(jtem, jndex) in list">
        <el-table-column align="center" :label="jtem.name" min-width="160">
          <template slot-scope="scope">
            <template v-for="(item, index) in jtem.taskList">
              <template v-if="scope.$index === index">
                <draggable
                  :list="item.ground"
                  class="list-group"
                  animation="500"
                  handle=".el-tag"
                  :group="jndex + 1"
                  @start="dragStart($event, jndex)"
                  @end="dragEnd($event, jndex)"
                >
                  <template v-if="item.ground.length > 0">
                    <div
                      class="list-group-item"
                      v-for="(item2, index2) in item.ground"
                      :key="item2.groundId"
                    >
                      <el-tag style="margin: 5px 0">{{ item2.name }}</el-tag>
                    </div>
                  </template>
                </draggable>
              </template>
            </template>
          </template>
        </el-table-column>
      </template>
    </el-table>
  </div>
</template>

<script>
import draggable from "vuedraggable";
export default {
  components: {
    draggable
  },
  data() {
    return {
      loading: false,
      maxHeight: window.innerHeight - 250,
      tableData: [
        {
          start_date: "2019-12-23",
          week_date: "星期一"
        },
        {
          start_date: "2019-12-24",
          week_date: "星期二"
        },
        {
          start_date: "2019-12-25",
          week_date: "星期三"
        },
        {
          start_date: "2019-12-26",
          week_date: "星期四"
        },
        {
          start_date: "2019-12-27",
          week_date: "星期五"
        },
        {
          start_date: "2019-12-28",
          week_date: "星期六"
        },
        {
          start_date: "2019-12-29",
          week_date: "星期日"
        }
      ],
      departmentList: [],
      list: [
        {
          name: "小王",
          taskList: [
            {
              ground: [
                {
                  groundId: 1,
                  name: "John1",
                  no: "1"
                },
                {
                  groundId: 2,
                  name: "heo1",
                  no: "2"
                },
                {
                  groundId: 3,
                  name: "mary1",
                  no: "3"
                }
              ]
            },
            {
              ground: [
                {
                  groundId: 11,
                  name: "John2",
                  no: "4"
                },
                {
                  groundId: 12,
                  name: "heo2",
                  no: "5"
                }
              ]
            },
            {
              ground: [
                {
                  groundId: 21,
                  name: "John3",
                  no: "6"
                }
              ]
            },
            {
              ground: []
            },
            {
              ground: []
            },
            {
              ground: []
            },
            {
              ground: []
            }
          ]
        },
        {
          name: "小lv",
          taskList: [
            {
              ground: [
                {
                  groundId: 150,
                  name: "John1",
                  no: "45"
                },
                {
                  groundId: 250,
                  name: "heo1",
                  no: "55"
                },
                {
                  groundId: 350,
                  name: "mary1",
                  no: "65"
                }
              ]
            },
            {
              ground: [
                {
                  groundId: 1150,
                  name: "John2",
                  no: "75"
                },
                {
                  groundId: 1250,
                  name: "heo2",
                  no: "85"
                }
              ]
            },
            {
              ground: [
                {
                  groundId: 2150,
                  name: "John3",
                  no: "95"
                }
              ]
            },
            {
              ground: []
            },
            {
              ground: []
            },
            {
              ground: []
            },
            {
              ground: []
            }
          ]
        }
      ],
      listNo: []
    };
  },
  methods: {
    dragStart(e, listIndex) {
      this.listNo = [];
      this.list[listIndex].taskList.forEach(item => {
        let array = item.ground.map(item2 => {
          return item2.no;
        });
        this.listNo = [...this.listNo, ...array];
      });
      console.log(this.listNo);
    },
    dragEnd(e, listIndex) {
      this.list[listIndex].taskList.forEach(item => {
        item.ground.forEach(item2 => {
          item2.no = this.listNo.shift();
        });
      });
      console.log(this.list[listIndex].taskList);
    }
  }
};
</script>

<style scoped>
.el-tag {
  cursor: move;
}
</style>

其中dragStart函數(shù)是拖拽點(diǎn)擊開始時(shí)所觸發(fā),dragEnd函數(shù)是拖拽完后觸發(fā)文章來源地址http://www.zghlxwxcb.cn/news/detail-861624.html

到了這里,關(guān)于vue+element ui+vuedraggable實(shí)現(xiàn)表格內(nèi)不同格子間標(biāo)簽的拖拽的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • vue+Element UI實(shí)現(xiàn)表格表頭縱向顯示

    vue+Element UI實(shí)現(xiàn)表格表頭縱向顯示

    提示:文章寫完后,目錄可以自動(dòng)生成,如何生成可參考右邊的幫助文檔 element框架的teble表格的數(shù)據(jù)展示由橫向轉(zhuǎn)向豎向,主要包括element框架的teble表格的數(shù)據(jù)展示由橫向轉(zhuǎn)向豎向使用實(shí)例、應(yīng)用技巧、基本知識(shí)點(diǎn)總結(jié)和需要注意事項(xiàng),具有一定的參考價(jià)值,需要的朋友可以

    2024年02月06日
    瀏覽(28)
  • Vue+Element UI彈窗實(shí)現(xiàn)表格編輯

    點(diǎn)擊編輯按鈕彈出Dialog js如下 時(shí)間格式化 3.1 方法一

    2024年02月12日
    瀏覽(22)
  • vue表格顯示圖片,采用element ui實(shí)現(xiàn)

    vue表格顯示圖片,采用element ui實(shí)現(xiàn) 首先定義一個(gè)數(shù)組tableData,然后return這個(gè)數(shù)組,采用element的表格模板,需要注意的是el-table-column標(biāo)簽包裹著el-image圖片顯示標(biāo)簽,但是由于作用域插槽只允許在template模板使用,所以el-image圖片顯示標(biāo)簽外加一層template模板標(biāo)簽,在vue3中作用

    2024年02月16日
    瀏覽(28)
  • 基于vue+element ui實(shí)現(xiàn)下拉表格選擇組件

    基于vue+element ui實(shí)現(xiàn)下拉表格選擇組件

    根據(jù)https://lolicode.gitee.io/scui-doc/demo/#/dashboard里的組件修改

    2024年02月16日
    瀏覽(33)
  • (vue)element-ui 表格實(shí)現(xiàn)勾選單選

    (vue)element-ui 表格實(shí)現(xiàn)勾選單選

    效果: 重選后: 解決參考:https://blog.csdn.net/m0_58373910/article/details/125912828

    2024年02月12日
    瀏覽(26)
  • Vue+Element ui動(dòng)態(tài)表格 實(shí)現(xiàn)表頭自適應(yīng)寬度

    Vue+Element ui動(dòng)態(tài)表格 實(shí)現(xiàn)表頭自適應(yīng)寬度

    根據(jù)業(yè)務(wù)需求,工作中會(huì)出現(xiàn)表頭信息不固定,根據(jù)后臺(tái)返回?cái)?shù)據(jù),我們要實(shí)現(xiàn)動(dòng)態(tài)表格的實(shí)現(xiàn) 1. tableData為表格數(shù)據(jù),tableHeader為表頭數(shù)據(jù)。 2. 實(shí)現(xiàn)表頭自適應(yīng)寬度(二種方法) ? ? ① 第一種通過動(dòng)態(tài)width來定義,通過表頭數(shù)據(jù)的遍歷,將label的表頭信息傳入方法中 ????

    2024年02月15日
    瀏覽(32)
  • vue搭配element-ui前端實(shí)現(xiàn)表格分頁

    如果不從后臺(tái)請求數(shù)據(jù),那么就需要在前端手動(dòng)管理數(shù)據(jù)??梢允褂靡韵虏襟E實(shí)現(xiàn)該功能: 在 Vue 組件的 data 中定義一個(gè)數(shù)組來存放所有數(shù)據(jù)(不分頁)。 在 mounted 鉤子函數(shù)中,手動(dòng)獲取數(shù)據(jù)并存放到上一步定義的數(shù)組中。 在模板中使用 element-ui 的表格組件來展示數(shù)據(jù),同

    2024年02月11日
    瀏覽(31)
  • vue+element-UI實(shí)現(xiàn)跟隨滾動(dòng)條加載表格數(shù)據(jù)

    el-table當(dāng)數(shù)據(jù)量大的時(shí)候,實(shí)現(xiàn)滾動(dòng)到底部后加載數(shù)據(jù),直接上js代碼,有其他需求請各自更改 ?第一步、在data中定義兩個(gè)數(shù)組 第二步、在數(shù)據(jù)發(fā)生改變的方法中先循環(huán)存放一部分?jǐn)?shù)據(jù)用于頁面顯示 第三步、在mounted監(jiān)聽滾動(dòng)事件

    2024年02月16日
    瀏覽(29)
  • vue2&Element-ui實(shí)現(xiàn)表格單元格合并

    vue2&Element-ui實(shí)現(xiàn)表格單元格合并

    由于項(xiàng)目需要實(shí)現(xiàn)單元格合并目前只是單頁沒有做分頁處理先上效果圖 看下數(shù)據(jù)結(jié)構(gòu) Element table提供的api arraySpanMethod columnIndex=0表示從第一列開始 rowIndex表示需要操作的行數(shù) 同濟(jì)醫(yī)院加上合計(jì)有12行從0開始=11 判斷條件是rowIndex余12===0 我們打印一下 或者改成 表示從0開始到1

    2024年02月12日
    瀏覽(37)
  • vue element ui table表格--實(shí)現(xiàn)列的顯示與隱藏

    vue element ui table表格--實(shí)現(xiàn)列的顯示與隱藏

    實(shí)現(xiàn)效果 提示:代碼段太簡單就不解釋了,自己看代碼自己更改,下面代碼直接無腦復(fù)制更改就行

    2024年02月02日
    瀏覽(26)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包