vxe-table 校驗,根據行屬性校驗

hello芳芳發表於2024-05-08

data() {
//element校驗
const checkTemplate = (rule, value, callback) => {
if (this._.isEmpty(value)) {
return callback(new Error('單據模板不能為空'))
}
callback()
}
//vxe-table校驗
const roleValid = ({ cellValue }) => {
if (cellValue && !['Develop', 'Test', 'Designer', 'PM'].includes(cellValue)) {
return new Error('角色輸入不正確')
}
}
return {}
}
 
vxeRules: {
         name: [
          { required: true, message: '請輸入' },
          { validator: nameValid }
        ],
 },
validRules: {
        lngoutitemid: [{
          validator(e) {
            if (e.row.dblamount && !e.cellValue) {
              return new Error('必填項')
            }
          }
        }]
}

相關文章