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

vue使用el-table 添加行手動填寫數(shù)據(jù)和刪除行及提交保存功能

 更新時間:2023年12月21日 14:16:19   作者:MXin5  
遇到這樣的需求點擊新增按鈕實現(xiàn)下列彈窗的效果,點擊添加行新增一行,點擊刪除進行刪除行,點擊提交將數(shù)據(jù)傳遞到后端進行保存,怎么實現(xiàn)的呢,下面通過實例代碼給大家詳細講解,感興趣的朋友一起看看吧

        需求:點擊新增按鈕實現(xiàn)下列彈窗的效果,點擊添加行新增一行,點擊刪除進行刪除行,點擊提交將數(shù)據(jù)傳遞到后端進行保存。

代碼

      <el-dialog :title="titleDataDictionary" :visible.sync="openDataDictionary" width="1300px" append-to-body>
        <el-button type="primary" class="add-btn" @click="addDemo">添加行</el-button>
        <el-table
          :data="tableData"
          size="mini"
          stripe
          highlight-current-row
          border
          style="width: 97.3%"
          class="el-tb-edit"
          :header-cell-style="{
        background: '#2a87ed',
        color: '#fff',
        fontSize: ' 1.2rem',
        fontWeight: 'normal',
        height: '2.88rem',
      }"
          ref="demoTable"
        >
          <el-table-column prop="index" label="序號" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.index"></el-input>
              <!--              <span>{{ scope.row.index }}</span>  顯示在輸入框的下面-->
            </template>
          </el-table-column>
          <el-table-column prop="assetNo" label="資產(chǎn)編號" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.assetNo"></el-input>
            </template>
          </el-table-column>
          <!-- <el-table-column type="index" width="50">序號</el-table-column> -->
          <el-table-column prop="riskSourceName" label="表中文名" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.riskSourceName"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="riskPointName" label="表英文名" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.riskPointName"></el-input>
              <!--              <span>{{ scope.row.riskPointName }}</span>-->
            </template>
          </el-table-column>
          <el-table-column prop="riskLevel" label="字段中文名" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.riskLevel"></el-input>
              <!--              <span>{{ scope.row.riskLevel }}</span>-->
            </template>
          </el-table-column>
          <el-table-column prop="hiddenDanger" label="字段類型" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.hiddenDanger"></el-input>
              <!--              <span>{{ scope.row.hiddenDanger }}</span>-->
            </template>
          </el-table-column>
          <el-table-column prop="type" label="字段長度" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.type"></el-input>
              <!--              <span>{{ scope.row.type }}</span>-->
            </template>
          </el-table-column>
          <el-table-column prop="accident" label="取值范圍" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.accident"></el-input>
              <!--              <span>{{ scope.row.accident }}</span>-->
            </template>
          </el-table-column>
          <el-table-column prop="remark" label="備注" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.remark"></el-input>
              <!--              <span>{{ scope.row.remark }}</span>-->
            </template>
          </el-table-column>
          <el-table-column prop="accident" label="操作" width="120">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDeleteDataDictionary(scope.$index,tableData)"
              >刪除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-button type="primary" class="add-btn" @click="handleDataDictionaryAssetInfo">提交</el-button>
      </el-dialog>

data

      data(){
        return{
          //錄入數(shù)據(jù)字典資產(chǎn)信息
          dataId: 1,
          //數(shù)據(jù)字典資產(chǎn)信息的集合
          tableData: [],
          //數(shù)據(jù)字典資產(chǎn)信息錄入
          openDataDictionary: false,
          //數(shù)據(jù)字典資產(chǎn)信息錄入彈出框標題
          titleDataDictionary: "",
        }
      }

methods

methods: {
    /** 刪除按鈕操作 */
    handleDeleteDataDictionary(index, rows) {
      alert("index" + index);//這個index就是當前行的索引坐標
      this.$modal.confirm('是否刪除當前行?').then(function () {
        rows.splice(index, 1); //對tableData中的數(shù)據(jù)刪除一行
      }).then(() => {
        this.$modal.msgSuccess("刪除成功");
      }).catch(() => {
      });
    },
    //   添加行
    addDemo() {
      var d = {
        index: this.dataId++,
        assetNo: "", //資產(chǎn)編號實時回顯
        riskSourceName: "",
        riskLevel: "",
        riskPointName: "",
        type: "",
        hiddenDanger: "",
        dangerLevel: "",
        accident: "",
        remark: ""
      };
      this.tableData.push(d);
      setTimeout(() => {
        this.$refs.demoTable.setCurrentRow(d);
      }, 10);
    },
    /**
     * 數(shù)據(jù)字典資產(chǎn)信息錄入點擊提交執(zhí)行的方法
     * */
    handleDataDictionaryAssetInfo() {
      addDataDictionaryAssetInfo(this.tableData).then(response => {
        this.$modal.msgSuccess("新增成功");
        this.open = false;
      });
    },

到此這篇關于vue采用el-table 添加行手動填寫數(shù)據(jù)和刪除行及提交的文章就介紹到這了,更多相關vue el-table 添加行刪除行內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • vue-seamless-scroll 實現(xiàn)簡單自動無縫滾動且添加對應點擊事件的簡單整理

    vue-seamless-scroll 實現(xiàn)簡單自動無縫滾動且添加對應點擊事件的簡單整理

    vue-seamless-scroll是一個基于Vue.js的簡單無縫滾動組件, 基于requestAnimationFrame實現(xiàn),配置多滿足多樣需求,目前支持上下左右無縫滾動,單步滾動,及支持水平方向的手動切換功能,本節(jié)介紹,vue添加 vue-seamless-scroll實現(xiàn)自動無縫滾動的效果,并對應添加點擊事件
    2023-01-01
  • Vue裝飾器中的vue-property-decorator?和?vux-class使用詳解

    Vue裝飾器中的vue-property-decorator?和?vux-class使用詳解

    這篇文章主要介紹了Vue裝飾器中的vue-property-decorator?和?vux-class使用詳解,通過示例代碼給大家介紹的非常詳細,對vue-property-decorator?和?vux-class的使用感興趣的朋友一起看看吧
    2022-08-08
  • Vue模擬鍵盤組件的使用和封裝方法

    Vue模擬鍵盤組件的使用和封裝方法

    文章詳細介紹了如何封裝和使用Vue模擬鍵盤組件,涵蓋了組件封裝方法以及使用技巧,還提供了擴展方法,如新增鍵盤類型和添加動畫效果,并強調(diào)了事件處理、響應式設計和無障礙支持的關鍵點,需要的朋友可以參考下
    2025-10-10
  • vue選項卡組件的實現(xiàn)方法

    vue選項卡組件的實現(xiàn)方法

    這篇文章主要為大家詳細介紹了vue選項卡組件的實現(xiàn)方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • Vue網(wǎng)絡請求的三種實現(xiàn)方式介紹

    Vue網(wǎng)絡請求的三種實現(xiàn)方式介紹

    這篇文章主要介紹了Vue網(wǎng)絡請求的三種實現(xiàn)方式,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-09-09
  • 在Vue中實現(xiàn)網(wǎng)頁截圖與截屏功能詳解

    在Vue中實現(xiàn)網(wǎng)頁截圖與截屏功能詳解

    在Web開發(fā)中,有時候需要對網(wǎng)頁進行截圖或截屏,Vue作為一個流行的JavaScript框架,提供了一些工具和庫,可以方便地實現(xiàn)網(wǎng)頁截圖和截屏功能,本文將介紹如何在Vue中進行網(wǎng)頁截圖和截屏,需要的朋友可以參考下
    2023-06-06
  • 前端架構(gòu)vue動態(tài)組件使用基礎教程

    前端架構(gòu)vue動態(tài)組件使用基礎教程

    這篇文章主要為大家介紹了前端架構(gòu)vue動態(tài)組件使用的基礎教程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步早日升職加薪
    2022-02-02
  • vue-cli腳手架搭建方式(vue腳手架方式搭建)

    vue-cli腳手架搭建方式(vue腳手架方式搭建)

    這篇文章主要介紹了vue-cli(vue腳手架方式搭建),本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-04-04
  • Vue2實現(xiàn)Office文檔(docx、xlsx、pdf)在線預覽功能

    Vue2實現(xiàn)Office文檔(docx、xlsx、pdf)在線預覽功能

    在現(xiàn)代的Web應用開發(fā)中,實現(xiàn)Office文檔(如docx、xlsx、pdf)的在線預覽功能是一個常見的需求,下面小編就來和大家詳細介紹一下如何使用vue2實現(xiàn)這一功能吧
    2025-05-05
  • Vue+Element實現(xiàn)頁面生成快照截圖

    Vue+Element實現(xiàn)頁面生成快照截圖

    這篇文章主要為大家詳細介紹了Vue如何結(jié)合Element實現(xiàn)頁面生成快照截圖功能,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下
    2024-03-03

最新評論

台湾省| 宝清县| 嘉定区| 绥阳县| 绍兴县| 卓资县| 甘洛县| 宜丰县| 冀州市| 滕州市| 越西县| 惠来县| 星子县| 周至县| 青阳县| 镇雄县| 宜丰县| 攀枝花市| 调兵山市| 黄大仙区| 大同市| 永平县| 东辽县| 察雅县| 武乡县| 馆陶县| 朝阳县| 原阳县| 措勤县| 昭觉县| 元谋县| 大姚县| 江川县| 阿勒泰市| 社会| 芮城县| 墨江| 桂平市| 长垣县| 盘山县| 甘泉县|