zoukankan      html  css  js  c++  java
  • element ui 表格实现input验证

    <template>
      <div>
        <el-form :model="forms" ref="forms" :rules="rules">
          <el-table :data="forms.voList">
            <el-table-column
            label="商品名称">
              <template slot-scope="scope">
                  <el-input v-model="scope.row.goodsName"></el-input>
              </template>
            </el-table-column>
    
            <el-table-column
              label="商品编码">
              <template slot-scope="scope">
                  <el-input v-model="scope.row.goodsCode"></el-input>
              </template>
            </el-table-column>
    
            <el-table-column
              label="价格">
              <template slot-scope="scope">
                <el-form-item :prop="'voList.'+scope.$index+'.unitPrice'" :rules="rules.unitPrice">
                  <el-input v-model="scope.row.unitPrice"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
    
            <el-table-column
              label="数量">
              <template slot-scope="scope">
                  <el-input v-model="scope.row.num"></el-input>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
        <el-button type="primary" @click="save">保存</el-button>
      </div>
    </template>
    
    <script>
    export default {
      name: "table",
      data(){
        return {
          forms:{
            id:1,
            documentNo:null,
            buyerName:"服务技术",
            buyerDp:"42118XXXXXXXXXX72X",
            buyerBankAccount:"招商银行4890284",
            buyerAddressPhone:"深圳市宝安区110112",
            buyerEmail:null,
            buyerPhone:null,
            buyerType:"01",
            remarks:"这是备注",
            total:350.9,
            voList:[
              {
                goodsName:"黄金",
                goodsCode:"44021940",
                specification:null,
                unit:"克",
                num:1,
                unitPrice:291.37,
                taxRate:0.17,
                taxAmount:49.53,
                favouredPolicy:"0",
                zeroTaxRate:"",
                hsbz:"1"
              },
              {
                goodsName:"花生",
                goodsCode:"4574511",
                specification:null,
                unit:"斤",
                num:1,
                unitPrice:8.55,
                taxRate:0.17,
                taxAmount:1.45,
                favouredPolicy:"0",
                zeroTaxRate:"",
                hsbz:"1"
              }
            ]
          },
          rules:{
            num:[{required:true,message:'数量不能为空',trigger:'blur'}],
            unitPrice:[{required:true,message:'单价不能为空',trigger:'blur'}]
          }
        }
      },
      methods:{
        save(){
          this.$refs['forms'].validate((valid)=>{
            if(valid){
              console.log(1)
            }
          })
        }
      }
    }
    </script>
    <style scoped lang="scss">
    
    </style>
  • 相关阅读:
    山寨 《寻找房祖名》
    css3 弹性效果上下翻转demo
    CSS3 Hover 动画特效
    判断一个字符串通过变化字符的位置,是否可以组成回文
    获取多个字符串中的共同字符
    转换为回文的步数
    IOS中图片的一些处理方法
    python django的一点笔记
    一个图片切割的例子
    一个批量修改文件夹中文件名的命令
  • 原文地址:https://www.cnblogs.com/javascript9527/p/12555290.html
Copyright © 2011-2022 走看看