Commit d6ad5366 by wangzhihui

fixed

1 parent 18ea8515
......@@ -1373,11 +1373,15 @@ export default {
item.inventoryType = 2; // 默认实物管控
}
});
const previousMerchantGoodsRefList = deepClone(this.formData.merchantGoodsRefList || []);
// 先应用门店并关闭弹窗,再校验区域
this.$set(this.formData, "merchantGoodsRefList", selectedData);
this.relateStoreVisible = false;
await this.$nextTick();
await this.validateStoreRegionAfterChange();
await this.validateStoreRegionAfterChange({
previousMerchantGoodsRefList,
revertStoresOnCancel: true,
});
},
handleRelateStoreClose() {
this.relateStoreVisible = false;
......@@ -1399,8 +1403,12 @@ export default {
},
/**
* 门店变更后校验区域;不匹配时提示是否清空产品
* @param {Object} options
* @param {Array} options.previousMerchantGoodsRefList 变更前门店列表(弹窗确认场景取消时回滚)
* @param {Boolean} options.revertStoresOnCancel 区域不匹配弹窗点取消时是否回滚门店
*/
async validateStoreRegionAfterChange() {
async validateStoreRegionAfterChange(options = {}) {
const { previousMerchantGoodsRefList, revertStoresOnCancel } = options;
const { upgradeGoodsId, merchantGoodsRefList } = this.formData;
if (!upgradeGoodsId || !merchantGoodsRefList?.length) {
return;
......@@ -1433,7 +1441,17 @@ export default {
);
this.clearUpgradeGoods();
} catch (_cancel) {
// 取消:门店已变更,仅保留产品不清空
// 弹窗选门店:取消则回滚到确认前门店;删除门店:取消则保留当前门店变更
if (revertStoresOnCancel) {
this.$set(
this.formData,
"merchantGoodsRefList",
deepClone(previousMerchantGoodsRefList || [])
);
if (previousMerchantGoodsRefList?.length) {
await this.refreshOperationCost(previousMerchantGoodsRefList);
}
}
}
} catch (err) {
console.log(err);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!