Commit d4c3a3c9 by 张立顺

fix 提现状态回显逻辑

1 parent c3c70328
...@@ -2,7 +2,7 @@ const { shallowMount } = require("@vue/test-utils"); ...@@ -2,7 +2,7 @@ const { shallowMount } = require("@vue/test-utils");
jest.mock("@/main", () => ({ jest.mock("@/main", () => ({
baseConfig: { baseConfig: {
shelfManageFinanceConfig: [], shelfManageFinanceConfig: [101],
}, },
})); }));
...@@ -18,18 +18,66 @@ jest.mock("@/views/goods/shelfProduct/hooks/fetchRemoteSelect", () => ({ ...@@ -18,18 +18,66 @@ jest.mock("@/views/goods/shelfProduct/hooks/fetchRemoteSelect", () => ({
const Modify = require("./modify.vue").default; const Modify = require("./modify.vue").default;
function createWrapper() { const ElFormItemStub = {
name: "ElFormItem",
props: {
label: String,
prop: String,
rules: Array,
},
template: "<div class=\"el-form-item-stub\"><slot /></div>",
};
const ElOptionStub = {
name: "ElOption",
props: {
label: String,
value: Number,
},
template: "<div :data-label=\"label\" :data-value=\"value\" class=\"el-option-stub\"></div>",
};
const VenusNumberInputStub = {
name: "VenusNumberInput",
props: {
max: Number,
placeholder: String,
title: String,
},
template: "<input :data-max=\"max\" :data-placeholder=\"placeholder\" :data-title=\"title\" class=\"venus-number-input-stub\">",
};
function createRule(applicationObjectType = 1, expenseCategoryCalculateType = 1) {
return {
applicationObjectType,
calculateMode: 1,
expenseCategoryCalculateType,
expenseCategoryValue: 1,
feeCategoryName: "测试费用类目",
id: 101,
};
}
function createWrapper(applicationObjectType, expenseCategoryCalculateType) {
return shallowMount(Modify, { return shallowMount(Modify, {
propsData: { propsData: {
businessCode: "test-business", businessCode: "test-business",
operationMode: 1, operationMode: 1,
specialDetail: { specialDetail: {
expenseCategoryRuleList: [], expenseCategoryRuleList: [createRule(applicationObjectType, expenseCategoryCalculateType)],
goodsTypeGroupRelationList: [], goodsTypeGroupRelationList: [],
groupType: 1, groupType: 1,
id: "test-id", id: "test-id",
}, },
}, },
stubs: {
"el-radio": true,
"el-radio-group": true,
"el-form-item": ElFormItemStub,
"el-option": ElOptionStub,
"el-select": true,
"VenusNumberInput": VenusNumberInputStub,
},
}); });
} }
...@@ -45,7 +93,7 @@ describe("商品上架类目对账模型", () => { ...@@ -45,7 +93,7 @@ describe("商品上架类目对账模型", () => {
jest.clearAllMocks(); jest.clearAllMocks();
}); });
it.each([ 1, 2, 3 ])("应用对象类型 %i 使用统一的对账模式选项", (applicationObjectType) => { it.each([1, 2, 3])("应用对象类型 %i 使用统一的对账模式选项", (applicationObjectType) => {
const options = wrapper.vm.getExpenseCategoryCalculateTypeOptions(applicationObjectType); const options = wrapper.vm.getExpenseCategoryCalculateTypeOptions(applicationObjectType);
expect(options).toEqual([ expect(options).toEqual([
...@@ -56,37 +104,92 @@ describe("商品上架类目对账模型", () => { ...@@ -56,37 +104,92 @@ describe("商品上架类目对账模型", () => {
]); ]);
}); });
it.each([ 1, 2, 3, 10 ])("有效对账模式 %i 可以通过校验", (value) => { it.each([1, 2, 3, 10])("有效对账模式 %i 可以通过校验", (value) => {
const callback = jest.fn(); const callback = jest.fn();
wrapper.vm.validateExpenseCategoryCalculateType({}, value, callback); wrapper.vm.validateExpenseCategoryCalculateType({}, value, callback);
expect(callback).toHaveBeenCalledTimes(1);
expect(callback).toHaveBeenCalledWith(); expect(callback).toHaveBeenCalledWith();
}); });
it.each([ 4, 5, 6, 8, 9 ])("历史对账模式 %i 会提示选择有效模式", (value) => { it.each([4, 5, 6, 8, 9])("历史对账模式 %i 会提示选择有效模式", (value) => {
const callback = jest.fn(); const callback = jest.fn();
wrapper.vm.validateExpenseCategoryCalculateType({}, value, callback); wrapper.vm.validateExpenseCategoryCalculateType({}, value, callback);
expect(callback).toHaveBeenCalledTimes(1);
expect(callback).toHaveBeenCalledWith(expect.objectContaining({ message: "请选择有效的对账模式" })); expect(callback).toHaveBeenCalledWith(expect.objectContaining({ message: "请选择有效的对账模式" }));
}); });
it.each([ undefined, null, "" ])("缺失对账模式 %p 保留必选提示", (value) => { it.each([undefined, null, ""])("缺失对账模式 %p 保留必选提示", (value) => {
const callback = jest.fn(); const callback = jest.fn();
wrapper.vm.validateExpenseCategoryCalculateType({}, value, callback); wrapper.vm.validateExpenseCategoryCalculateType({}, value, callback);
expect(callback).toHaveBeenCalledTimes(1);
expect(callback).toHaveBeenCalledWith(expect.objectContaining({ message: "请选择分润模式" })); expect(callback).toHaveBeenCalledWith(expect.objectContaining({ message: "请选择分润模式" }));
}); });
it.each([ it.each([
[ 1, false, "请输入比例" ], [1, false, "请输入比例"],
[ 2, false, "请输入比例" ], [2, false, "请输入比例"],
[ 3, true, "请输入金额" ], [3, true, "请输入金额"],
[ 10, true, "请输入金额" ], [10, true, "请输入金额"],
])("对账模式 %i 保持金额与比例输入行为", (value, isAmount, placeholder) => { ])("对账模式 %i 保持金额与比例输入行为", (value, isAmount, placeholder) => {
expect(wrapper.vm.isAmountExpenseCategoryCalculateType(value)).toBe(isAmount); expect(wrapper.vm.isAmountExpenseCategoryCalculateType(value)).toBe(isAmount);
expect(wrapper.vm.getExpenseCategoryValuePlaceholder(value)).toBe(placeholder); expect(wrapper.vm.getExpenseCategoryValuePlaceholder(value)).toBe(placeholder);
}); });
it.each([1, 2, 3])("应用对象类型 %i 在渲染的选择器中提供统一对账模式", (applicationObjectType) => {
const renderedWrapper = createWrapper(applicationObjectType);
const options = renderedWrapper.findAll(".el-option-stub").wrappers.map(option => ({
label: option.attributes("data-label"),
value: Number(option.attributes("data-value")),
}));
expect(options).toEqual([
{ label: "按收入比例", value: 2 },
{ label: "按毛利比例", value: 1 },
{ label: "按固定金额", value: 3 },
{ label: "按固定金额*购买数量", value: 10 },
]);
renderedWrapper.destroy();
});
it("将对账模式校验器挂接到渲染的表单项", () => {
const renderedWrapper = createWrapper(1, 4);
const expenseCategoryCalculateTypeFormItem = renderedWrapper.findAll(".el-form-item-stub").at(1);
const validator = expenseCategoryCalculateTypeFormItem.vm.$props.rules[0].validator;
const invalidCallback = jest.fn();
const validCallback = jest.fn();
validator({}, 4, invalidCallback);
validator({}, 10, validCallback);
expect(invalidCallback).toHaveBeenCalledTimes(1);
expect(invalidCallback).toHaveBeenCalledWith(expect.objectContaining({ message: "请选择有效的对账模式" }));
expect(validCallback).toHaveBeenCalledTimes(1);
expect(validCallback).toHaveBeenCalledWith();
renderedWrapper.destroy();
});
it.each([
[1, 100, "请输入比例", "%"],
[2, 100, "请输入比例", "%"],
[3, 9999999999, "请输入金额", "元"],
[10, 9999999999, "请输入金额", "元"],
])("对账模式 %i 在渲染输入框中保留金额或比例属性", (value, max, placeholder, unit) => {
const renderedWrapper = createWrapper(1, value);
const input = renderedWrapper.find(".venus-number-input-stub");
expect(Number(input.attributes("data-max"))).toBe(max);
expect(input.attributes("data-placeholder")).toBe(placeholder);
expect(input.attributes("data-title")).toBe(placeholder);
expect(renderedWrapper.text()).toContain(unit);
renderedWrapper.destroy();
});
}); });
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
<!-- 5.8.4 取消修改 --> <!-- 5.8.4 取消修改 -->
<RemoteSelect v-if="form.categoryType === 3" <RemoteSelect v-if="form.categoryType === 3"
:key="form.categoryType" :key="form.categoryType"
ref="packageGoods"
v-model="form.goodsTypeGroupRelationList" v-model="form.goodsTypeGroupRelationList"
placeholder="请选择套餐商品" placeholder="请选择套餐商品"
style="width:390px" style="width:390px"
...@@ -216,7 +215,7 @@ export default { ...@@ -216,7 +215,7 @@ export default {
}, },
methods: { methods: {
getExpenseCategoryCalculateTypeOptions(applicationObjectType) { getExpenseCategoryCalculateTypeOptions(applicationObjectType) {
if ([ 1, 2, 3 ].includes(applicationObjectType)) { if ([1, 2, 3].includes(applicationObjectType)) {
return expenseCategoryCalculateTypeOptions; return expenseCategoryCalculateTypeOptions;
} }
return []; return [];
...@@ -226,14 +225,14 @@ export default { ...@@ -226,14 +225,14 @@ export default {
callback(new Error("请选择分润模式")); callback(new Error("请选择分润模式"));
return; return;
} }
if (![ 1, 2, 3, 10 ].includes(value)) { if (![1, 2, 3, 10].includes(value)) {
callback(new Error("请选择有效的对账模式")); callback(new Error("请选择有效的对账模式"));
return; return;
} }
callback(); callback();
}, },
isAmountExpenseCategoryCalculateType(value) { isAmountExpenseCategoryCalculateType(value) {
return [ 3, 10 ].includes(value); return [3, 10].includes(value);
}, },
getExpenseCategoryValuePlaceholder(value) { getExpenseCategoryValuePlaceholder(value) {
return this.isAmountExpenseCategoryCalculateType(value) ? "请输入金额" : "请输入比例"; return this.isAmountExpenseCategoryCalculateType(value) ? "请输入金额" : "请输入比例";
......
...@@ -300,7 +300,12 @@ export default { ...@@ -300,7 +300,12 @@ export default {
label: "提现状态", label: "提现状态",
prop: "withdrawSignStatus", prop: "withdrawSignStatus",
formatter: (cellValue) => { formatter: (cellValue) => {
return cellValue.withdrawSignStatus == "1" ? "未签约" : cellValue.withdrawSignStatus == "2" ? "已签约" : "-"; if (cellValue.payPlatform == "ysepay") {
return "-";
} else {
return cellValue.withdrawSignStatus == "1" ? "未签约" : cellValue.withdrawSignStatus == "2" ? "已签约" : "-";
}
// return cellValue.withdrawSignStatus == "1" ? "未签约" : cellValue.withdrawSignStatus == "2" ? "已签约" : "-";
}, },
}, { }, {
label: "虚账编码", label: "虚账编码",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!