Commit 2f42269a by 张立顺

Merge branch 'feature/V5.8.4/zls' into 'SAAS+V5.8.4'

fix 财务删除bug修复

See merge request !908
2 parents b0699c16 30c0a64c
...@@ -6,7 +6,15 @@ function formatDate(val) { ...@@ -6,7 +6,15 @@ function formatDate(val) {
} }
function formatDelayDeadline(val) { function formatDelayDeadline(val) {
return val ? Util.dateFormate(val, "YYYY-MM-DD") : "-" if (!val) {
return "-";
}
const str = String(val).trim();
const dateMatch = str.match(/^(\d{4}-\d{2}-\d{2})/);
if (dateMatch) {
return dateMatch[1];
}
return Util.dateFormate(val, "YYYY-MM-DD");
} }
export const APPROVAL_STATUS = { export const APPROVAL_STATUS = {
......
...@@ -167,6 +167,10 @@ import { ...@@ -167,6 +167,10 @@ import {
getStableReconciliationRuleId, getStableReconciliationRuleId,
mergeReconciliationRuleServerFields, mergeReconciliationRuleServerFields,
} from "./utils/reconciliationIncrementalRules"; } from "./utils/reconciliationIncrementalRules";
import {
getReconciliationRuleIndexForTab,
hasPhantomFullCategoryRuleSlot,
} from "./utils/reconciliationRuleTabIndex";
import { applyGoodsTypeGroupRelationBranches } from "./utils/reconciliationRuleBranches"; import { applyGoodsTypeGroupRelationBranches } from "./utils/reconciliationRuleBranches";
import { import {
fillDjGoodsTypeGroupRelations, fillDjGoodsTypeGroupRelations,
...@@ -475,20 +479,11 @@ export default { ...@@ -475,20 +479,11 @@ export default {
* 首条规则为特殊品类时 tab0「全部品类」仅占位,无对应规则行,返回 null(不可按 tab 下标写 rules[0])。 * 首条规则为特殊品类时 tab0「全部品类」仅占位,无对应规则行,返回 null(不可按 tab 下标写 rules[0])。
*/ */
reconciliationRuleIndexForTabIndex(tabIndex) { reconciliationRuleIndexForTabIndex(tabIndex) {
const rules = this.goodsTypeGroupReconciliationRules; return getReconciliationRuleIndexForTab(
if (!Array.isArray(rules) || !rules.length) { this.goodsTypeGroupReconciliationRules,
return tabIndex; tabIndex,
} this.getEffectivePhantomFullCategoryRuleRaw(),
if (rules[0]?.groupType == 1) { );
return tabIndex;
}
if (rules[0]?.groupType == 2) {
if (tabIndex <= 0) {
return null;
}
return tabIndex - 1;
}
return tabIndex;
}, },
/** /**
* live phantom 在 getEffectRule 末尾会清空;与基线比对、resolve、子组件 props 需回落 baseline.phantomFullCategoryRule。 * live phantom 在 getEffectRule 末尾会清空;与基线比对、resolve、子组件 props 需回落 baseline.phantomFullCategoryRule。
...@@ -520,7 +515,10 @@ export default { ...@@ -520,7 +515,10 @@ export default {
* tab0「全部品类」仅占位:首条接口规则为特殊品类时,tab0 无 goodsTypeGroupReconciliationRules 行。 * tab0「全部品类」仅占位:首条接口规则为特殊品类时,tab0 无 goodsTypeGroupReconciliationRules 行。
*/ */
hasPhantomFullCategoryTab() { hasPhantomFullCategoryTab() {
return this.reconciliationRuleIndexForTabIndex(0) == null; return hasPhantomFullCategoryRuleSlot(
this.goodsTypeGroupReconciliationRules,
this.getEffectivePhantomFullCategoryRuleRaw(),
);
}, },
/** /**
* 基线中与 Tab ti 对应的原始规则行(tab0 phantom 用 baseline.phantomFullCategoryRule,否则 rules[ruleIdx])。 * 基线中与 Tab ti 对应的原始规则行(tab0 phantom 用 baseline.phantomFullCategoryRule,否则 rules[ruleIdx])。
...@@ -1400,38 +1398,27 @@ export default { ...@@ -1400,38 +1398,27 @@ export default {
newActiveIndex -= 1; newActiveIndex -= 1;
} }
const goodsTypeGroupRules = this.getAllReconciliationParams();
const upgradeArr = []; const upgradeArr = [];
const packageArr = []; const packageArr = [];
const prevTabsMeta = this.editableTabs.map(t => ({ if (
classificationUserTouched: !!t.classificationUserTouched, ruleIdxRemoved != null
sessionAdded: !!t.sessionAdded, && ruleIdxRemoved < this.goodsTypeGroupReconciliationRules.length
})); ) {
this.editableTabs = []; this.goodsTypeGroupReconciliationRules.splice(ruleIdxRemoved, 1);
goodsTypeGroupRules.splice(removeIdx, 1); }
// this.$set(this.goodsTypeGroupReconciliationRules, goodsTypeGroupRules) tabs.splice(removeIdx, 1);
this.$nextTick(() => { tabs.forEach((tab, index) => {
this.goodsTypeGroupReconciliationRules = goodsTypeGroupRules; this.$set(tab, "title", index ? "特殊品类" + index : "全部品类");
this.$set(tab, "name", (index + 1).toString());
});
const typeList = goodsTypeGroupRules; newActiveIndex = Math.max(0, Math.min(newActiveIndex, tabs.length - 1));
const newLen = typeList.length; this.editableTabsValue = tabs[newActiveIndex].name;
newActiveIndex = Math.max(0, Math.min(newActiveIndex, newLen - 1));
this.editableTabsValue = (newActiveIndex + 1).toString();
typeList.forEach((item, index) => { this.goodsTypeGroupReconciliationRules.forEach((item) => {
const oldIdx = index < removeIdx ? index : index + 1;
const meta = prevTabsMeta[oldIdx];
const classificationUserTouched = !!(meta && meta.classificationUserTouched);
const sessionAdded = !!(meta && meta.sessionAdded);
this.editableTabs[index] = {
title: index ? "特殊品类" + index : "全部品类",
name: (index + 1).toString(),
classificationUserTouched,
sessionAdded,
};
applyGoodsTypeGroupRelationBranches( applyGoodsTypeGroupRelationBranches(
item, item,
this.goodsTypeGroupReconciliationRules[index], item,
upgradeArr, upgradeArr,
packageArr, packageArr,
); );
...@@ -1440,12 +1427,12 @@ export default { ...@@ -1440,12 +1427,12 @@ export default {
this.getSelectingListPackage(packageArr); this.getSelectingListPackage(packageArr);
this.rebuildCrossTabGoodsSelectionsFromRules(); this.rebuildCrossTabGoodsSelectionsFromRules();
this.bumpReconciliationInteractionEpoch(); this.bumpReconciliationInteractionEpoch();
// this.queryFeeCategoryByTypeFlow = deepClone(this.queryFeeCategoryByTypeFlow) await this.$nextTick();
this.$message({ this.$message({
type: "success", type: "success",
message: "删除成功!", message: "删除成功!",
}); });
}); return true;
}, },
deleteGoodsTypeItem(item) { deleteGoodsTypeItem(item) {
......
/**
* “全部品类”没有服务端规则行、但页面保留了草稿快照时,该 Tab 使用独立的 phantom 槽位。
* rules 为空时仍需保留此语义,否则删除最后一个特殊品类后会把全部品类草稿判成空槽位。
*/
export function hasPhantomFullCategoryRuleSlot(rules, phantomRule) {
const list = Array.isArray(rules) ? rules : [];
if (list[0]?.groupType == 1) {
return false;
}
if (list[0]?.groupType == 2) {
return true;
}
return !!(phantomRule && typeof phantomRule === "object");
}
/**
* 页面 Tab 下标转服务端规则数组下标。
* phantom 占用 Tab 0,但不占 rules 数组位置,因此特殊品类需向前偏移一位。
*/
export function getReconciliationRuleIndexForTab(
rules,
tabIndex,
phantomRule,
) {
if (!hasPhantomFullCategoryRuleSlot(rules, phantomRule)) {
return tabIndex;
}
if (tabIndex <= 0) {
return null;
}
return tabIndex - 1;
}
const {
getReconciliationRuleIndexForTab,
hasPhantomFullCategoryRuleSlot,
} = require("./reconciliationRuleTabIndex");
describe("对账规则 Tab 下标映射", () => {
const phantomRule = {
groupType: 1,
expenseCategoryRules: [ { expenseCategoryId: "flow" } ],
};
it("全部品类为占位草稿时,特殊品类从 rules[0] 开始映射", () => {
const rules = [
{ groupType: 2, groupDivisionRuleId: "special-1" },
{ groupType: 2, groupDivisionRuleId: "special-2" },
];
expect(hasPhantomFullCategoryRuleSlot(rules, phantomRule)).toBe(true);
expect(getReconciliationRuleIndexForTab(rules, 0, phantomRule)).toBeNull();
expect(getReconciliationRuleIndexForTab(rules, 1, phantomRule)).toBe(0);
expect(getReconciliationRuleIndexForTab(rules, 2, phantomRule)).toBe(1);
});
it("删除最后一个特殊品类后 rules 为空,仍保留全部品类占位草稿", () => {
const rules = [];
expect(hasPhantomFullCategoryRuleSlot(rules, phantomRule)).toBe(true);
expect(getReconciliationRuleIndexForTab(rules, 0, phantomRule)).toBeNull();
});
it("已有正式全部品类规则时,优先使用 rules[0]", () => {
const rules = [ { groupType: 1, groupDivisionRuleId: "full-1" } ];
expect(hasPhantomFullCategoryRuleSlot(rules, phantomRule)).toBe(false);
expect(getReconciliationRuleIndexForTab(rules, 0, phantomRule)).toBe(0);
});
it("规则和草稿都为空时,全部品类使用可写的 rules[0] 槽位", () => {
expect(hasPhantomFullCategoryRuleSlot([], null)).toBe(false);
expect(getReconciliationRuleIndexForTab([], 0, null)).toBe(0);
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!