Skip to content

Commit

Permalink
perf: 代码逻辑优化 TencentBlueKing#87
Browse files Browse the repository at this point in the history
  • Loading branch information
hLinx committed Aug 3, 2021
1 parent f868c8a commit ef42cf0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,12 @@
confirmFn: () => {
const currentVar = this.variable[index];
if (currentVar.id > 0) {
// 删除已存在的变量——设置delete
// 删除已存在的变量
// —设置delete
currentVar.delete = 1;
} else {
// 删除新建的变量——直接删除
// 删除新建的变量
// —直接删除
this.variable.splice(index, 1);
}
this.triggerChange();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
<component
ref="handler"
:is="globalVarCom"
:variable="variable"
:data="formData"
@on-change="handleGetValue" />
v-bind="$attrs"
v-on="$listeners" />
</jb-form>
</template>
<script>
Expand All @@ -99,12 +99,6 @@
VarArray,
},
props: {
variable: {
type: Array,
default () {
return [];
},
},
data: {
type: Object,
default () {
Expand Down Expand Up @@ -138,12 +132,13 @@
},
watch: {
data: {
handler (data) {
handler (data) {
if (data.name) {
// 编辑变量
this.formData = data;
} else {
// 新建变量
// 初始化默认值
this.formData = createVariable();
}
this.globalType = this.formData.typeDescription;
Expand All @@ -167,9 +162,6 @@
this.globalType = '';
});
},
handleGetValue (payload) {
this.$emit('on-change', payload);
},
},
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,6 @@
immediate: true,
},
},
created () {
this.innerChange = false;
},
methods: {
/**
* @desc 外部调用——点击指定 index 的步骤
Expand Down Expand Up @@ -409,8 +406,12 @@

const currentStep = steps[index];
if (currentStep.id) {
// 删除已存在的步骤
// —设置delete
currentStep.delete = 1;
} else {
// 删除新建的步骤
// —直接删除
steps.splice(index, 1);
}

Expand All @@ -425,7 +426,6 @@
* @param {Boolean} localValidator 表单验证结果
*/
handleTaskStepSubmit (payload, localValidator) {
this.innerChange = true;
const operationStep = new TaskStepModel(payload);
const steps = [...this.steps];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@
if (this.isEdit) {
this.editSuccessCallback(taskId, planSync, isPlanEmpty);
} else {
this.createSuccessCallback(taskId, planSync, isPlanEmpty);
this.createSuccessCallback(taskId);
}
});
}))
Expand Down

0 comments on commit ef42cf0

Please sign in to comment.