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

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

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

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

代碼

      <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="序號(hào)" 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)編號(hào)" 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">序號(hào)</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="字段類(lèi)型" 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="字段長(zhǎng)度" 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)信息錄入彈出框標(biāo)題
          titleDataDictionary: "",
        }
      }

methods

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

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

相關(guān)文章

  • vue-seamless-scroll 實(shí)現(xiàn)簡(jiǎn)單自動(dòng)無(wú)縫滾動(dòng)且添加對(duì)應(yīng)點(diǎn)擊事件的簡(jiǎn)單整理

    vue-seamless-scroll 實(shí)現(xiàn)簡(jiǎn)單自動(dòng)無(wú)縫滾動(dòng)且添加對(duì)應(yīng)點(diǎn)擊事件的簡(jiǎn)單整理

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

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

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

    Vue模擬鍵盤(pán)組件的使用和封裝方法

    文章詳細(xì)介紹了如何封裝和使用Vue模擬鍵盤(pán)組件,涵蓋了組件封裝方法以及使用技巧,還提供了擴(kuò)展方法,如新增鍵盤(pán)類(lèi)型和添加動(dòng)畫(huà)效果,并強(qiáng)調(diào)了事件處理、響應(yīng)式設(shè)計(jì)和無(wú)障礙支持的關(guān)鍵點(diǎn),需要的朋友可以參考下
    2025-10-10
  • vue選項(xiàng)卡組件的實(shí)現(xiàn)方法

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

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

    Vue網(wǎng)絡(luò)請(qǐng)求的三種實(shí)現(xiàn)方式介紹

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

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

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

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

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

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

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

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

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

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

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

最新評(píng)論

遵义县| 巨野县| 临武县| 化隆| 五河县| 镇巴县| 镇远县| 阜南县| 南江县| 大余县| 宁波市| 麻城市| 泾源县| 观塘区| 桂林市| 辽宁省| 磐安县| 台山市| 黔西| 涿鹿县| 奎屯市| 黄梅县| 栾城县| 甘德县| 织金县| 鄱阳县| 江津市| 武清区| 工布江达县| 宜昌市| 丰都县| 合川市| 东台市| 青阳县| 南木林县| 德阳市| 敦煌市| 彭泽县| 广安市| 西林县| 偃师市|