基于vue,el-table的增删查改

 

<el-table-column label="SKU" align="center">

          <template #default="scope">

            <div v-for="(item,index) in scope.row.itemList" :key="index">

              <div style="margin-bottom:2px;display:flex" >

                <el-input

                v-model="item.code"

                ></el-input>

                <span class="icon-style" @click="addSku(scope.row.itemList)"><el-icon color="#2869E8"><CirclePlus /></el-icon></span>

                <span class="icon-style" @click="deleteSku(scope.row.itemList,index)"><el-icon color="#2869E8"><Remove /></el-icon></span>

              </div>

            </div>

          </template>

        </el-table-column>

        <el-table-column label="barcode" align="center">

          <template #default="scope">

            <div v-for="(item,index) in scope.row.itemList" :key="index">

              <el-input

              style="margin-bottom:2px"

              v-model="item.barcode"

              ></el-input>

            </div>

          </template>

        </el-table-column>

        <el-table-column label="SKU预报数量" align="center">

          <template #default="scope">

            <div v-for="(item,index) in scope.row.itemList" :key="index">

              <el-input

              style="margin-bottom:2px"

              v-model="item.sum"

              ></el-input>

            </div>

          </template>

        </el-table-column>

        <el-table-column :label="$t('common.operation')" fixed="right" width="100"  class-name="small-padding fixed-width">

            <template #default="scope">

              <el-button @click="copyRow(scope.row)" type="text">{{$t('common.copy')}}</el-button>

              <el-button :disabled="cargoList.length < 2" @click="deleteRow(scope.$index, cargoList)" type="text">{{$t('common.delete')}}</el-button>

            </template>

        </el-table-column>

js部分:

//增加一条SKU

function addSku(el){

  let obj = {

  }

  el.push(obj)

}

//删除一条SKU

function deleteSku(arr,index){

  if(arr.length == 1){

    return proxy.$modal.msgError('每个箱号至少维护一条SKU');

  }else{

    arr.splice(index,1)

  }

}

/** 删除一行 */

function deleteRow(index, rows) {

  rows.splice(index, 1);

}

//复制

function copyRow(row){

  let obj = JSON.parse(JSON.stringify(row));

  cargoList.value.push(obj)

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值