Commit 0b154d0b by Jaxon

refactor: 提取提成模板条件默认值获取逻辑

重构 clearParamsType2Condition 方法,将参数模板2中条件字段的默认值提取到独立函数 getParams2TableDefaultValue 中,提高代码复用性并简化循环内的赋值逻辑。
1 parent 951e060b
...@@ -280,17 +280,23 @@ export default { ...@@ -280,17 +280,23 @@ export default {
// 模板2的提成方式改变 , 需要清空当个模板2的table中, 对应的condition中的值 // 模板2的提成方式改变 , 需要清空当个模板2的table中, 对应的condition中的值
clearParamsType2Condition(state, params2Index) { clearParamsType2Condition(state, params2Index) {
const params2Table = state.formData.paramConfigList[params2Index].ParamsType2; const params2Table = state.formData.paramConfigList[params2Index].ParamsType2;
if (isArray(params2Table) && params2Table.length) {
const { ParamsType2: [{ conditionType0, conditionType1, conditionType2, conditionType3, conditionType4 }] } = structuredClone(paramConfigListTemplate);
for (const rows of params2Table) { function getParams2TableDefaultValue() {
Object.assign(rows, { const { ParamsType2: [{ conditionType0, conditionType1, conditionType2, conditionType3, conditionType4 }] } = structuredClone(paramConfigListTemplate);
...rows, return {
conditionType0, conditionType0,
conditionType1, conditionType1,
conditionType2, conditionType2,
conditionType3, conditionType3,
conditionType4, conditionType4,
};
}
if (isArray(params2Table) && params2Table.length) {
for (const rows of params2Table) {
Object.assign(rows, {
...rows,
...getParams2TableDefaultValue(),
condition: 0, condition: 0,
}); });
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!