From 3ef4c729be2a59435b5226bc12bb1ec45ebc8f53 Mon Sep 17 00:00:00 2001 From: ly5156 <361112237@qq.com> Date: Tue, 7 Jan 2025 18:42:40 +0800 Subject: [PATCH] chore(workload): disable access to unreturned data attributes in data method --- shell/edit/workload/mixins/workload.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/shell/edit/workload/mixins/workload.js b/shell/edit/workload/mixins/workload.js index c26dc289061..dce16334160 100644 --- a/shell/edit/workload/mixins/workload.js +++ b/shell/edit/workload/mixins/workload.js @@ -250,7 +250,6 @@ export default { } } - this.selectContainer(container); if (this.realMode === _CLONE && this.value.type === WORKLOAD_TYPES.JOB) { this.cleanUpClonedJobData(); } @@ -280,12 +279,10 @@ export default { podFsGroup: podTemplateSpec.securityContext?.fsGroup, savePvcHookName: 'savePvcHook', tabWeightMap: TAB_WEIGHT_MAP, - fvFormRuleSets: [{ - path: 'image', rootObject: this.container, rules: ['required'], translationKey: 'workload.container.image' - }], - fvReportedValidationPaths: ['spec'], - isNamespaceNew: false, - idKey: ID_KEY + fvFormRuleSets: [], + fvReportedValidationPaths: ['spec'], + isNamespaceNew: false, + idKey: ID_KEY }; }, @@ -605,6 +602,15 @@ export default { this.value['type'] = neu; delete this.value.apiVersion; }, + + container: { + handler(c) { + this.fvFormRuleSets = [{ + path: 'image', rootObject: c, rules: ['required'], translationKey: 'workload.container.image' + }]; + }, + immediate: true + } }, created() { @@ -612,6 +618,8 @@ export default { this.registerBeforeHook(this.getPorts, 'getPorts'); this.registerAfterHook(this.saveService, 'saveService'); + + this.selectContainer(this.container); }, methods: {