Skip to content

Commit

Permalink
bugfix: 选用“业务脚本”或“公共脚本”时匹配中高危语句的交互,要和手工输入的保持一致 TencentBlueKing#1294
Browse files Browse the repository at this point in the history
  • Loading branch information
hLinx committed Sep 21, 2022
1 parent 79b2bb7 commit b3b23f5
Showing 1 changed file with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,31 @@
handler (newData) {
this.isReadonly = newData[this.scriptSourceField] !== TaskStepModel.scriptStep.TYPE_SOURCE_LOCAL;
this.lang = formatScriptTypeValue(newData[this.languageField]);
if (this.isReadonly) {
this.rules = [];
} else {
this.rules = [
{
required: true,
message: I18n.t('脚本内容必填'),
trigger: 'change',
},
{
validator: value => ScriptManageService.getScriptValidation({
content: value,
scriptType: newData[this.languageField],
}).then((data) => {
// 高危语句报错状态需要全局保存
const dangerousContent = _.find(data, _ => _.isDangerous);
this.$store.commit('setScriptCheckError', dangerousContent);
return true;
}),
message: I18n.t('脚本内容检测失败'),
trigger: 'blur',
},
];

const rules = [
{
validator: value => ScriptManageService.getScriptValidation({
content: value,
scriptType: newData[this.languageField],
}).then((data) => {
// 高危语句报错状态需要全局保存
const dangerousContent = _.find(data, _ => _.isDangerous);
this.$store.commit('setScriptCheckError', dangerousContent);
return true;
}),
message: I18n.t('脚本内容检测失败'),
trigger: 'blur',
},
];

if (!this.isReadonly) {
rules.unshift({
required: true,
message: I18n.t('脚本内容必填'),
trigger: 'change',
});
}
this.rules = rules;
},
deep: true,
immediate: true,
Expand Down

0 comments on commit b3b23f5

Please sign in to comment.