vue 根据下拉框动态切换form的rule

时间:2023-03-09 02:50:39
vue 根据下拉框动态切换form的rule

vue 根据下拉框动态切换form的rule

taskCategorySelect (val) {  // 任务类别下拉选择
if ( val == 5 ) {
this.cameraORgateway = false; // true不可以使用 = 不可以使用
this.cameraORgatewayCP = true;
this.rules.gatewayCode = [{ required: true, message: '请选择关联网关', trigger: 'blur' }];
this.rules.cameraCode = [{}];
this.$refs['form'].clearValidate('cameraCode');
this.form.cameraCode = undefined;
} else if ( val == 1 || val == 2 || val == 3 || val == 4) {
this.cameraORgateway = true; // false不可以使用 = 可以使用
this.cameraORgatewayCP = false;
this.rules.cameraCode = [{ required: true, message: '请选择摄像机', trigger: 'blur' }];
this.rules.gatewayCode = [{}];
this.form.gatewayCode = undefined;
} else {
this.cameraORgateway = true;
this.cameraORgatewayCP = true;
this.form.cameraCode = undefined;
this.form.gatewayCode = undefined;
}
},