Commit 8aaf4739 by 张立顺

feat 功能修改

1 parent 59dd1703
import { validateStoreRegion } from "@api/grounding";
import { createLocalVue, shallowMount } from "@vue/test-utils";
import ElementUI from "element-ui";
import EditGrounding from "../editGrounding.vue";
import GroundingForm from "./groundingForm.vue";
const localVue = createLocalVue();
localVue.use(ElementUI);
jest.mock("@api/grounding", () => ({
validateStoreRegion: jest.fn(),
}));
......@@ -33,39 +39,47 @@ describe("purchase grounding form", () => {
expect(context.selectGoodsVisible).toBe(false);
});
it("shows the selected product purchase cost in the product details", () => {
const context = {
formData: {
purchaseCostType: 0,
purchasePrice: "",
upgradeGoods: {},
it("renders the selected product purchase cost in the product details", async () => {
const editForm = EditGrounding.data.call({}).editForm;
const wrapper = shallowMount(GroundingForm, {
localVue,
mocks: {
$$: (value, key) => value?.[key],
$store: {
state: {
d2admin: { loading: { value: false } },
},
},
},
positionTypeList: [],
filterSpecsStr: jest.fn().mockReturnValue("黑色"),
filterEmpty: GroundingForm.methods.filterEmpty,
$set(target, key, value) {
target[key] = value;
propsData: {
formList: editForm,
originData: {
goodsType: 3,
productType: [],
purchaseCostType: 0,
purchasePrice: "",
upgradeGoodsId: 10,
upgradeGoods: { purchaseCost: 1 },
},
},
handleSelectGoodsClose: jest.fn(),
};
context.syncAutomaticPurchasePrice = () => GroundingForm.methods.syncAutomaticPurchasePrice.call(context);
GroundingForm.methods.handleSelectGoodsConfirm.call(context, {
id: 10,
commodityCode: "UID-001",
position: "",
djCost: "",
purchaseCost: 28.6,
goodsInfo: {
goodsName: "测试系列",
goodsType: 3,
supplierCode: "SUP-001",
stubs: {
ElForm: {
methods: {
clearValidate() {},
},
template: "<form><slot /></form>",
},
EllipsisPopover: {
props: ["content"],
template: "<span class=\"rendered-product-detail\">{{ content }}</span>",
},
},
upgradeGoodsServiceItemsList: [],
carTypeConfigList: [],
});
await wrapper.vm.$nextTick();
const purchasePriceItem = wrapper.findAll(".incid_box .item").wrappers.find(item => item.find(".label").text().includes("采购价"));
expect(context.formData.upgradeGoods.purchasePrice).toBe(28.6);
expect(purchasePriceItem.find(".rendered-product-detail").text()).toBe("1.00元");
});
it("rolls stores back when an invalid region confirmation is cancelled", async () => {
......
......@@ -54,8 +54,8 @@
</div>
<div class="value">
<EllipsisPopover :content="subItem.unit
? priceFilter(formData.upgradeGoods[subItem.value])
: formData.upgradeGoods[subItem.value] || ''
? priceFilter(getProductDetailValue(subItem))
: getProductDetailValue(subItem) || ''
">
</EllipsisPopover>
</div>
......@@ -793,6 +793,12 @@ export default {
filterEmpty(data) {
return (data ?? "") === "";
},
getProductDetailValue(item) {
if (item.value === "purchasePrice" && !this.filterEmpty(this.formData.upgradeGoods?.purchaseCost)) {
return this.formData.upgradeGoods.purchaseCost;
}
return this.formData.upgradeGoods?.[item.value];
},
// 清空上传文件数组项内容
clearItem(targetItem, subIndex) {
this.$set(this.formData[targetItem.name][subIndex], "voucherFileUrl", "");
......@@ -1007,7 +1013,6 @@ export default {
.join("/")
: "",
specificationData: this.filterSpecsStr(_valueObj),
purchasePrice: _valueObj?.purchaseCost,
djCost: _valueObj?.djCost,
carTypeConfigName: _valueObj?.carTypeConfigList
?.map(item => item.seriesName)
......
......@@ -14,15 +14,17 @@ describe("purchase shelves merchant dialog", () => {
"el-row": { template: "<div><slot /></div>" },
"el-table": { template: "<div><slot /></div>" },
"el-table-column": {
props: ["prop"],
template: "<div class='merchant-column' :data-prop='prop'></div>",
props: ["label", "prop"],
template: "<div class='merchant-column' :data-label='label' :data-prop='prop'></div>",
},
},
});
await wrapper.vm.$nextTick();
const columnProps = wrapper.findAll(".merchant-column").wrappers.map(column => column.attributes("data-prop"));
const addressColumn = wrapper.find("[data-prop='address']");
expect(columnProps.slice(1, 4)).toEqual(["merchantName", "address", "merchantId"]);
expect(addressColumn.attributes("data-label")).toBe("商户地址");
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!