欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

代碼

      <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="資產編號" 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{
          //錄入數據字典資產信息
          dataId: 1,
          //數據字典資產信息的集合
          tableData: [],
          //數據字典資產信息錄入
          openDataDictionary: false,
          //數據字典資產信息錄入彈出框標題
          titleDataDictionary: "",
        }
      }

methods

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

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

相關文章

  • Vue3中簡單實現動態(tài)添加路由

    Vue3中簡單實現動態(tài)添加路由

    本文主要介紹了Vue3中簡單實現動態(tài)添加路由,,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-05-05
  • 基于Vue.js實現數字拼圖游戲

    基于Vue.js實現數字拼圖游戲

    為了進一步讓大家了解Vue.js的神奇魅力,了解Vue.js的一種以數據為驅動的理念,本文主要利用Vue實現了一個數字拼圖游戲,其原理并不是很復雜,下面跟著小編一起來學習學習。
    2016-08-08
  • vue?動態(tài)路由component?傳遞變量報錯問題解決

    vue?動態(tài)路由component?傳遞變量報錯問題解決

    這篇文章主要為大家介紹了vue?動態(tài)路由component?傳遞變量報錯問題解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-05-05
  • vue調用微信JSDK 掃一掃,相冊等需要注意的事項

    vue調用微信JSDK 掃一掃,相冊等需要注意的事項

    這篇文章主要介紹了vue調用微信JSDK 掃一掃,相冊等需要注意的事項,幫助大家更好的理解和使用vue框架,感興趣的朋友可以了解下
    2021-01-01
  • 淺談vue使用axios的回調函數中this不指向vue實例,為undefined

    淺談vue使用axios的回調函數中this不指向vue實例,為undefined

    這篇文章主要介紹了淺談vue使用axios的回調函數中this不指向vue實例,為undefined,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-09-09
  • Vue2+marked.js實現AI流式輸出的項目實踐

    Vue2+marked.js實現AI流式輸出的項目實踐

    本文主要介紹了Vue2+marked.js實現AI流式輸出的項目實踐,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2025-04-04
  • Vue使用自定義指令實現拖拽行為實例分析

    Vue使用自定義指令實現拖拽行為實例分析

    這篇文章主要介紹了Vue使用自定義指令實現拖拽行為,結合實例形式分析了Vue使用自定義指令實現拖拽行為具體步驟、原理與操作注意事項,需要的朋友可以參考下
    2020-06-06
  • vue2.0 常用的 UI 庫實例講解

    vue2.0 常用的 UI 庫實例講解

    這篇文章主要介紹了vue2.0 常用的 UI 庫實例講解,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2017-12-12
  • 解決VUE-Router 同一頁面第二次進入不刷新的問題

    解決VUE-Router 同一頁面第二次進入不刷新的問題

    這篇文章主要介紹了解決VUE-Router 同一頁面第二次進入不刷新的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-07-07
  • vuex如何修改狀態(tài)state的方法

    vuex如何修改狀態(tài)state的方法

    這篇文章主要介紹了vuex如何修改狀態(tài)state的方法,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-08-08

最新評論