动态添加明细行。每行需要校验是否为空属性。
image.png
<div v-for="(item, index) in detailList"
:key="index.toString()"
:name="index.toString()">
<el-form-item
class="is-required"
:label="$tl('wms_FieldCode','属性编码')"
label-width="120"
:prop="'FieldCode'+index"
:rules="[{validator: (a, b, c) =>validateDetailForm(a, b, c, index, 'Competitor'),trigger: 'blur',}]">
<el-input disabled :placeholder="$tl('MOM_InputPlease')" style="width: 140px" v-model="item.FieldCode"></el-input>
</el-form-item>
</div>
validateDetailForm(rule, value, callback, index, name) {
if (!this.detailList[index][name]) {
callback(new Error(this.$t("MOM_IsRequire")));
} else {
callback();
}
},
网友评论