实习开发中发现经常会有表格检验的需求,目前我遇到的做法是判断表格是否为空然后提示即可,以后要用到rule规则检验的我再记录。
效果如图(其中的星号是自己画上去的,,,,)
在computed里面写计算方法
checkForm () {let check = trueif (this.form.annexInfos.length != 0) {this.form.annexInfos.forEach(e => {if (e.annexDate == '') {check = false}});}return check},
然后是点击保存后触发
save(status) {if (!this.checkForm ) {this.$("请检查数据是否输入完整");return;}//下面是不为空触发的后端请求等方法
}
最后是通过插槽给表格头添加星号
步骤一:给表格对应列添加插槽
{dataIndex: "annexDate",// title: "附件有效期至,scopedSlots: { customRender: "annexDate", title: "customName" }}
步骤二:修改表头文字(后面的是表格每行的时间选择框)
<span slot="customName"><i class="toRequired">*</i>附件有效期至</span><template slot="annexDate"slot-scope="text, record"><a-date-picker :locale="locale"format="YYYY-MM-DD"v-model="record.annexDate"valueFormat="YYYY-MM-DD" /><div v-show="!record.annexDate && showAnnexError"class="show-error">请选择附件有效期</div></template>
步骤三:css画星号
.toRequired {color: #ff4949;padding-right: 2px;
}
本文发布于:2024-01-29 19:12:22,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170652674417642.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |