在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ vue 如何完成多選的table表格把數(shù)據(jù)放到一個(gè)對(duì)象里的問(wèn)題?

vue 如何完成多選的table表格把數(shù)據(jù)放到一個(gè)對(duì)象里的問(wèn)題?

 <el-table :data="tableData" style="width: 100%;" @selection-change="handleSelectionChange" ref="multipleTable">
             <el-table-column align="center" type="selection" width="55" fixed></el-table-column>
        <el-table-column align="center" prop="name" label="方案名稱" width='120'>
          <!-- <template slot-scope="scope">{{scope.row.beginCardNo}} - {{scope.row.endCardNo}}</template> -->
        </el-table-column>
        <el-table-column align="center" prop ="type" label="兌換類型">
          <!-- <template slot-scope="scope">{{scope.row.cardTypeName}}</template> -->
        </el-table-column>
        <el-table-column align="center"  label="兌換個(gè)數(shù)" width="160px" prop ="exchangeNum">
          <template slot-scope="scope">
             <!-- <el-col :span="16"> -->
            <el-input placeholder="請(qǐng)輸入兌換個(gè)數(shù)" v-model="scope.row.exchangeNum" @change="change"></el-input>
             <!-- </el-col> -->
          </template>
        </el-table-column>
        <!--<el-table-column align="center" prop="" label="未配送數(shù)量"></el-table-column>-->
        <el-table-column align="center" label="消耗積分" prop="costPointsNum">
           <template slot-scope="scope">{{scope.row.exchangeNum*scope.row.costPointsNum}}</template>
          <!-- <template slot-scope="scope">{{scope.row.deposit | money}}</template> -->
        </el-table-column>
        <!-- <el-table-column align="center" label="操作" fixed="right">
          <template slot-scope="scope">
            <a class="operation" @click="deleteItem(scope.row)" v-authority="508003">刪除</a>
          </template>
        </el-table-column> -->
      </el-table>

在handleSelectionChange方法中實(shí)現(xiàn)把 選中的一個(gè)或者多個(gè)行的時(shí)候把 costPointsNum exchangeNum schemeId 這幾個(gè)參數(shù)傳入到detaiList里面 形成如下形式的數(shù)組?

{
  
  "detailList": [
    {
      "costPointsNum": 0,
      "exchangeNum": 0,
      "schemeId": 0
    },{
      "costPointsNum": 0,
      "exchangeNum": 0,
      "schemeId": 0
    }
  ],
 
}
回答
編輯回答
不歸路

不知道是不是你要的

    handleSelectionChange(selections){
        this.dataList = selections.map(v => {
            const {costPointsNum,exchangeNum,schemeId} = v;
            return {
                costPointsNum,
                exchangeNum,
                schemeId}
        })
    }
2017年4月14日 09:51