Commit eaca37ac by Jaxon

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

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