vue el-table里输入框、下拉框校验弹出框提示

table里面有输入框或下拉框,要执行你的方法进行造作之前需要校验

  1. 可以在form里面嵌套表格,参考https://blog.csdn.net/qq_45039940/article/details/122260642
  2. 可以弹出提示框进行提示,如下
 <el-table :data="yourlist" style="width: 100%">
	<el-table-column prop="name" label="物料名称"></el-table-column>
	<el-table-column label="数量" >
		<template slot-scope="scope">
			<el-input-number
                  v-model="scope.row.amount"
                  :min="0"
                  size="small"
                  :controls="false" >
			</el-input-number>
		</template>
	</el-table-column>
	<el-table-column label="形状">
		<template slot-scope="scope">
			<el-select
                  v-model="scope.row.shape"
                  placeholder="形状"
			>
				<el-option
					v-for="item in yourdata"
                    :label="item.yourLabel"
                    :value="item.yourvalue">
				</el-option>
			</el-select>
		</template>
</el-table-column>            
 check () {
      var result = true
      var message = []
      this.yourlist.forEach((item, index) => {
      if (item.amount == undefined) {
            result = result && false
            message.push(item.name+ " " + '数量不能为空')
          }
      if (item.amount == 0) {
            result = result && false
            message.push(item.name+ " " + '数量不能为0'
           }
      if (item.shape== undefined) {
            result = result && false
            message.push(item.name+ " " + '形状不能为空')
          }
		})
		if (!result) {
			var temp = '';
			message.forEach(v => {
			temp += `<li style="list-style-type: none">${v}</li>`;
        })
          return this.$notify({
          title: '添加物料列表提示',
          dangerouslyUseHTMLString: true,
          type: 'warning',
          duration: 3000,
          message: `<ul style="padding : 0">${temp}</ul>`
        });
      }
      return result
},

yourfun(){
	let check = this.check()
	if (check == true) {
		console.log("true")
	}else{
		console.log("false")
	}
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值