Commit eaca37ac by Jaxon

fix(货架商品): 修正特殊品类配置的保存和删除逻辑

修复删除特殊品类后未正确切换当前激活标签的问题,确保删除非当前项时不会影响界面状态。
为 handleSave 方法添加可选参数以控制成功消息的显示,避免在特定场景下重复弹窗。
重构新增特殊品类逻辑,将编辑状态切换与数据初始化合并,提升操作原子性。
调整确认步骤的默认值以匹配实际业务流程。
1 parent d05cf180
...@@ -410,11 +410,12 @@ export default { ...@@ -410,11 +410,12 @@ export default {
if (index !== -1) { if (index !== -1) {
this.tabs.list.splice(index, 1); this.tabs.list.splice(index, 1);
} }
const isDeleteCurrent = this.tabsActive === rows.id;
this.$message({ this.$message({
type: "success", type: "success",
message: "删除成功!", message: "删除成功!",
}); });
const isDeleteCurrent = this.tabsActive === rows.id;
// 不是删除自己的话, 不执行下面的 // 不是删除自己的话, 不执行下面的
if (!isDeleteCurrent) { if (!isDeleteCurrent) {
return; return;
...@@ -422,9 +423,7 @@ export default { ...@@ -422,9 +423,7 @@ export default {
// 如果list还有长度, 则取第一 // 如果list还有长度, 则取第一
if (this.tabs.list && this.tabs.list.length) { if (this.tabs.list && this.tabs.list.length) {
const detail = await getProfitSharingTypeDetail({ businessCode: this.businessCode, goodsTypeGroupId: this.tabs.list[0]?.id }); await this.handleSpecialChange(this.tabs.list[0]?.id);
this.$set(this.profitSharingForm, "specialDetail", detail);
this.tabs.active = detail.id;
return; return;
} }
// 如果没有长度了 active赋为undefined(清空) // 如果没有长度了 active赋为undefined(清空)
...@@ -434,27 +433,26 @@ export default { ...@@ -434,27 +433,26 @@ export default {
}, },
// 新增特殊品类 // 新增特殊品类
async handleAppendSpecialCategory() { async handleAppendSpecialCategory() {
const specialId = `${this.$data._prefix}${nanoid()}`; await this.startEdit(async () => {
this.startEdit(); const specialId = `${this.$data._prefix}${nanoid()}`;
await this.$nextTick(); const expenseCategoryRuleList = await syncExpenseCategoryRulesToFeeCategoryType(this.baseSceneCode, []);
const expenseCategoryRuleList = await syncExpenseCategoryRulesToFeeCategoryType(this.baseSceneCode, []); this.tabs.list.push({
id: specialId,
groupType: 2,
title: "特殊品类",
});
this.tabs.active = specialId;
this.tabs.list.push({ this.profitSharingForm.specialDetail = {
id: specialId, categoryType: undefined,
groupType: 2, groupType: 2,
title: "特殊品类", id: specialId,
goodsTypeGroupRelationList: [],
expenseCategoryRuleList,
merchantDistributionRules: [],
owningMerchantDistributionRules: [],
};
}); });
this.tabs.active = specialId;
this.profitSharingForm.specialDetail = {
categoryType: undefined,
groupType: 2,
id: specialId,
goodsTypeGroupRelationList: [],
expenseCategoryRuleList,
merchantDistributionRules: [],
owningMerchantDistributionRules: [],
};
}, },
// 点击编辑按钮 // 点击编辑按钮
handleChangeMode() { handleChangeMode() {
......
...@@ -367,6 +367,7 @@ export default { ...@@ -367,6 +367,7 @@ export default {
message: "删除成功!", message: "删除成功!",
}); });
const isDeleteCurrent = this.tabsActive === rows.id; const isDeleteCurrent = this.tabsActive === rows.id;
// 不是删除自己的话, 不执行下面的 // 不是删除自己的话, 不执行下面的
if (!isDeleteCurrent) { if (!isDeleteCurrent) {
return; return;
...@@ -385,7 +386,7 @@ export default { ...@@ -385,7 +386,7 @@ export default {
async validate() { async validate() {
return await this.$refs.formRef.validate(); return await this.$refs.formRef.validate();
}, },
async handleSave() { async handleSave({ useMessage = true } = {}) {
const shelfManageFinanceConfig = baseConfig.shelfManageFinanceConfig || []; const shelfManageFinanceConfig = baseConfig.shelfManageFinanceConfig || [];
const isCreate = this.isCreate(this.tabs.active); const isCreate = this.isCreate(this.tabs.active);
const expenseCategoryRuleList = this.form.specialDetail.expenseCategoryRuleList.filter(item => shelfManageFinanceConfig.includes(item.id)); const expenseCategoryRuleList = this.form.specialDetail.expenseCategoryRuleList.filter(item => shelfManageFinanceConfig.includes(item.id));
...@@ -415,6 +416,13 @@ export default { ...@@ -415,6 +416,13 @@ export default {
})), })),
}); });
if (useMessage) {
this.$message({
message: "保存成功",
type: "success",
});
}
if (id) { if (id) {
const detail = await getSpecialCategoryDetail({ businessCode: this.businessCode, goodsTypeGroupId: id }); const detail = await getSpecialCategoryDetail({ businessCode: this.businessCode, goodsTypeGroupId: id });
this.$set(this.form, "specialDetail", detail); this.$set(this.form, "specialDetail", detail);
......
...@@ -158,7 +158,7 @@ export default { ...@@ -158,7 +158,7 @@ export default {
return { return {
sceneTypeOptions, sceneTypeOptions,
step: { step: {
confirmStep: 3, confirmStep: 2,
}, },
// 第一步轮训用的 , null || Fn, 为Fn时, 执行即取消轮训 // 第一步轮训用的 , null || Fn, 为Fn时, 执行即取消轮训
polling: null, polling: null,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!