亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

基于el-table實(shí)現(xiàn)行內(nèi)增刪改功能

 更新時(shí)間:2024年04月01日 10:32:55   作者:@小匠  
這篇文章主要介紹了基于el-table實(shí)現(xiàn)行內(nèi)增刪改功能,用過(guò)通過(guò)操作按鈕點(diǎn)擊刪除或者編輯功能即可實(shí)現(xiàn)相應(yīng)的效果,下面小編給大家分享實(shí)例代碼感興趣的朋友跟隨小編一起看看吧

實(shí)現(xiàn)效果:

在這里插入圖片描述

核心代碼:

<el-table :data="items"
                  style="width: 100%;margin-top: 16px"
                  border
                  :key="randomKey">
          <el-table-column label="計(jì)劃名稱"
                           property="name">
            <template slot-scope="{row}">
              <template v-if="row.edit">
                <el-input v-model="row.name"></el-input>
              </template>
              <span v-else>{{ row.name }}</span>
            </template>
          </el-table-column>
          <el-table-column label="計(jì)劃完成時(shí)間"
                           property="executionDate" width="175">
            <template slot-scope="scope">
              <el-date-picker v-if="scope.row.edit" style="width: 153px;" type="date"
                              v-model="scope.row.timeEnd">
              </el-date-picker>
              <span v-else>{{ parseTime(scope.row.timeEnd) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="協(xié)同人"
                           property="leaderList">
            <template slot-scope="scope">
              <template v-if="scope.row.edit">
                <el-select
                  v-model="scope.row.leaderList"
                  clearable filterable multiple>
                  <el-option
                    v-for="item in userList"
                    :key="item.userId"
                    :label="item.nickname"
                    :value="item.userId">
                  </el-option>
                </el-select>
              </template>
              <span v-else>{{ scope.row.leaderName }}</span>
            </template>
          </el-table-column>
          <el-table-column label="執(zhí)行人" width="80">
            <template>
              <span>{{ $store.getters.name }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="操作" width="100">
            <template slot-scope="{row,column,$index}">
              <el-button
                v-if="row.edit"
                type="success" icon="el-icon-check" circle
                size="small"
                @click="confirmEdit(row)"
              >
              </el-button>
              <el-button
                v-if="row.edit"
                icon="el-icon-close" circle
                size="small"
                @click="cancelEdit(row)"
              >
              </el-button>
              <el-button
                type="primary" icon="el-icon-edit" circle
                v-if="!row.edit"
                size="small"
                @click="row.edit=!row.edit"
              >
              </el-button>
              <el-button
                type="danger" icon="el-icon-delete" circle
                size="small" @click="handleDelete($index)"
                v-if="!row.edit"
              >
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div style="display: flex;margin-top: 28px;justify-content: center;">
        <el-button @click="addSon" size="small" icon="el-icon-plus">添加子計(jì)劃</el-button>
      </div>

Method:

cancelEdit(row) {
      row.name = row.oldName
      row.leaderList = row.oldLeaderList
      row.timeEnd = row.oldTimeEnd
      row.leaderName = row.oldLeaderName
      row.edit = false
      this.$message({
        message: '已恢復(fù)原值',
        type: 'warning'
      })
    },
    confirmEdit(row) {
      row.edit = false
      row.oldName = row.name
      row.oldLeaderList = row.leaderList
      row.oldTimeEnd = row.timeEnd
      let arr = []
      row.leaderList.forEach(i => {
        let userName = this.userList.find(({userId}) => userId === i).nickname
        arr.push(userName)
      })
      row.leaderName = arr.join()
      row.oldLeaderName = row.leaderName
      this.$message({
        message: '修改成功',
        type: 'success'
      })
    },
    handleDelete(index) {
      this.items.splice(index, 1)
    },
    addSon() {
      this.items.push({
        name: null,
        timeEnd: null,
        leaderList: [],
        leaderName: null,
        edit: true
      })
    },

到此這篇關(guān)于基于el-table實(shí)現(xiàn)行內(nèi)增刪改的文章就介紹到這了,更多相關(guān)el-table行內(nèi)增刪改內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vuex的使用步驟

    vuex的使用步驟

    這篇文章主要介紹了vuex的使用步驟,幫助大家更好的理解和使用vue框架,感興趣的朋友可以了解下
    2021-01-01
  • Vue如何獲取元素高度總是不準(zhǔn)確的問(wèn)題

    Vue如何獲取元素高度總是不準(zhǔn)確的問(wèn)題

    這篇文章主要介紹了Vue如何獲取元素高度總是不準(zhǔn)確的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • vue axios用法教程詳解

    vue axios用法教程詳解

    axios是vue-resource后出現(xiàn)的Vue請(qǐng)求數(shù)據(jù)的插件。下面我們通過(guò)本文給大家介紹vue axios用法教程詳解,感興趣的朋友一起看看吧
    2017-07-07
  • Vue中input被賦值后,無(wú)法再修改編輯的問(wèn)題及解決

    Vue中input被賦值后,無(wú)法再修改編輯的問(wèn)題及解決

    這篇文章主要介紹了Vue中input被賦值后,無(wú)法再修改編輯的問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • 詳解Vue webapp項(xiàng)目通過(guò)HBulider打包原生APP(vue+webpack+HBulider)

    詳解Vue webapp項(xiàng)目通過(guò)HBulider打包原生APP(vue+webpack+HBulider)

    這篇文章主要介紹了詳解Vue webapp項(xiàng)目通過(guò)HBulider打包原生APP(vue+webpack+HBulider),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-02-02
  • 解決vue-cli3 使用子目錄部署問(wèn)題

    解決vue-cli3 使用子目錄部署問(wèn)題

    這篇文章主要介紹了解決vue-cli3 使用子目錄部署問(wèn)題,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-07-07
  • vue前端sku實(shí)現(xiàn)的方法小結(jié)

    vue前端sku實(shí)現(xiàn)的方法小結(jié)

    這篇文章主要為大家詳細(xì)介紹了vue前端sku實(shí)現(xiàn)的相關(guān)方法,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,有需要的小伙伴可以參考一下
    2024-11-11
  • 淺談vue單一組件下動(dòng)態(tài)修改數(shù)據(jù)時(shí)的全部重渲染

    淺談vue單一組件下動(dòng)態(tài)修改數(shù)據(jù)時(shí)的全部重渲染

    下面小編就為大家分享一篇淺談vue單一組件下動(dòng)態(tài)修改數(shù)據(jù)時(shí)的全部重渲染,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-03-03
  • vue組件學(xué)習(xí)教程

    vue組件學(xué)習(xí)教程

    這篇文章主要為大家詳細(xì)介紹了vue組件學(xué)習(xí)教程,根據(jù)Vue官方文檔學(xué)習(xí)的筆記,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-09-09
  • 如何在vue項(xiàng)目中嵌入jsp頁(yè)面的方法(2種)

    如何在vue項(xiàng)目中嵌入jsp頁(yè)面的方法(2種)

    這篇文章主要介紹了如何在vue項(xiàng)目中嵌入jsp頁(yè)面的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-02-02

最新評(píng)論