form

<div v-for="(DTOList, i) in productSpecsSaveDTOList" :key="i">
                  <el-form :model="DTOList" ref="DTOList" style="margin:20px">
                    <el-form-item label="规格名" class="noneBorderLeft">
                      <el-row>
                        <el-col :span="4">
                          <el-input v-model="DTOList.specsName" />
                        </el-col>
                        <el-col :span="1" :offset="18">
                          <span><i @click.prevent="removeDTOList(DTOList)" slot="suffix" class="el-input__icon el-icon-error" style="font-size: 20px"></i></span>
                        </el-col>
                      </el-row>
                    </el-form-item>
                    <el-form-item  label="规格值" class="noneBorderLeft">
                      <el-row :gutter="4">
                        <el-col :span="4" v-for="(item1, index1) in DTOList.productSpecsValueSaveDTOS" :key="index1" style="display:inline-block">
                          <el-input v-model="item1.specsValues">
                            <i @click.prevent="removespecsValues(item1, DTOList, i)" slot="suffix" class="el-input__icon el-icon-close" style="color:black;font-weight:bold;font-size:20px"></i>
                          </el-input>
                        </el-col>
                        <el-col :span="4" >
                          <el-button type="text" size="small" style="padding:5px" @click="addSpecsValues(DTOList,i)">添加规格值</el-button>
                        </el-col>
                      </el-row>
                    </el-form-item>
                  </el-form>
                </div>
                <el-button type="primary" size="small" @click="addList()">添加规格</el-button>
// 删除规格名和下面的规格值
    removeDTOList(DTOList) {
      var index = this.productSpecsSaveDTOList.indexOf(DTOList)
      if (index !== -1) {
        this.productSpecsSaveDTOList.splice(index, 1)
      }
    },
    // 删除规格值
    removespecsValues(item1,DTOList,i) {
      let index = DTOList.productSpecsValueSaveDTOS.indexOf(item1)
      if (index !== -1) {
        DTOList.productSpecsValueSaveDTOS.splice(index, 1)
      }
    },
    // 添加规格名
    addList() {
      this.productSpecsSaveDTOList.push({
        productSpecsValueSaveDTOS:[
          {
            cost : null,
            imgUrl : "",
            marketValue : null,
            price : null,
            specsValues: "",
            stock : null,
          }

        ],
        specsName : "",
        key: Date.now()
      })
    },
    // 添加规格值
    addSpecsValues(DTOList, i) {
      DTOList.productSpecsValueSaveDTOS.push({
          cost : null,
          imgUrl : "",
          marketValue : null,
          price : null,
          stock : null,
          specsValues: '',
          key: Date.now()
      })
    },

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值