zoukankan      html  css  js  c++  java
  • 校验table行内的form编辑

    // dom
    
    <el-table-column
                  prop="Name"
                  :show-overflow-tooltip="false"
                  label="name"
                >
                  <template slot-scope="scope">
                    <div>
                      <span v-if="scope.row.butStatus">{{ scope.row.resGroupName}}</span>
                      <el-form
                        v-if="!scope.row.butStatus"
                        :model="scope.row"
                        :rules="scopeRowRules"
                        ref="scopeRowRuleForm"
                      >
                        <el-form-item
                          prop="resGroupName"
                          :rules="scopeRowRules.resGroupName"
                        >
                          <el-input
                            @blur="changePartitionKey(scope, 'resGroupName')"
                            v-if="!scope.row.butStatus"
                            v-model="scope.row.resGroupName"
                            placeholder="请输入字段"
                          />
                        </el-form-item>
                      </el-form>
                    </div>
                  </template>
    </el-table-column>
    

      

    // 定义表单校验字段
    
    private scopeRowRules = {
          resGroupName: [
            {
              required: true,
              message: '提示信息',
            }
          ],
    }
    

      

    // 实现方法
    
    private validateScopeRow() {
          let valid = true;
           //   (ts)scopeRowRuleForm 和table绑定的ref一致
          const settingScopedRowFormElms = <Array<any>>this.$refs["scopeRowRuleForm"];
          const len = settingScopedRowFormElms.length;
          for (let index = 0; index < len; index++) {
            valid = settingScopedRowFormElms[index]
              .validate()
              .catch(e => Promise.reject(index));
          }
          return valid;
        }
    

      

  • 相关阅读:
    React实现双数据绑定
    浏览器兼容
    关于postman
    前端常用插件、工具类库
    媒体查询总结
    Vue开发中可能会使用到的所有插件
    Vue+iView通过a标签导出文件
    类的内置方法
    单元测试
    面向对象的三大特性
  • 原文地址:https://www.cnblogs.com/soonK/p/13395803.html
Copyright © 2011-2022 走看看