Commit 4b71e06a by 张立顺

feat 功能开发

1 parent 2f472807
Showing 37 changed files with 768 additions and 38 deletions
......@@ -19,7 +19,7 @@
- 视图/组件(89):`src/views/goods/components/applicable-area-query-select/index.vue`、`src/views/goods/components/ellipsisPopover.vue`、`src/views/goods/components/selectGoodsDialog.vue`、`src/views/goods/coupons/couponsDetail.vue`、`src/views/goods/coupons/editCouponsDialog.vue`、`src/views/goods/coupons/index.vue`、`src/views/goods/coupons/indexControl.vue`、`src/views/goods/coupons/remarkDialog.vue`、`src/views/goods/coupons/reservationDialog.vue`、`src/views/goods/coupons/scheduling.vue`、`src/views/goods/coupons/selectedShowTable.vue`、`src/views/goods/coupons/storeList.vue`、`src/views/goods/coupons/workSetDialog.vue`、`src/views/goods/grounding/components/batchCopyDialog.vue`、`src/views/goods/grounding/components/batchModifyInventoryDialog.vue`、`src/views/goods/grounding/components/detail.vue`、`src/views/goods/grounding/components/groundingForm.vue`、`src/views/goods/grounding/components/relateStoreDialog.vue`、`src/views/goods/grounding/components/relateStoreTable.vue`、`src/views/goods/grounding/views/detail/index.vue`、`src/views/goods/grounding/views/modify/index.vue`、`src/views/goods/grounding/views/table/index.vue`、`src/views/goods/packageManage/components/BatchModifyPackageInventoryDialog.vue`、`src/views/goods/packageManage/components/detail.vue`、`src/views/goods/packageManage/components/packageForm/index.vue`;另有 64 项见 JSON 图谱
- API/ROP(220):`addBrandSupplyMerchant`、`addGoodsProvider`、`addOrUpdateAPI`、`addOrUpdatePackage`、`addOrUpdateProductCatalog`、`baseGoodsDelete`、`batchCheckPackage`、`batchEditInventoryTypeByPackageId`、`batchModifyInventoryType`、`batchReviewAPI`、`batchSetValidMinSellPrice`、`batchUpdateBatchCopy`、`batchUpdateStatus`、`cancelInvite`、`checkGroundingLog`、`commonConfigApi`、`dateUpdate`、`deleteCouponApi`、`deleteProductCatalog`、`delGroundingById`、`delPackageById`、`delProductPackagesApi`、`delReconciliationConfigSpecialCategoryApi`、`delSpecialCategoryApi`、`dj.api.basegoods.get.byId`;另有 195 项见 JSON 图谱
- Vuex(6):`d2admin.user`、`d2admin/auth/curBtns`、`d2admin/base/get`、`d2admin/user/actionSetDownloadList`、`d2admin/user/setUpdateRefesh`、`goodsInfoData/setUpdateGoodsInfo`
- 测试(8):`src/api/grounding.spec.js`、`src/views/goods/grounding/utils/saleMode.spec.js`、`src/views/goods/grounding/views/table/index.data.spec.js`、`src/views/goods/purchaseOnShelves/components/groundingForm.spec.js`、`src/views/goods/purchaseOnShelves/components/relateStoreDialog.spec.js`、`src/views/goods/purchaseOnShelves/utils/batchPrice.spec.js`、`src/views/goods/purchaseOnShelves/utils/purchaseCost.spec.js`、`src/views/goods/shelfProduct/components/reconciliationConfig/components/specialCategory/modify.spec.js`
- 测试(13):`src/api/grounding.spec.js`、`src/views/goods/grounding/utils/saleMode.spec.js`、`src/views/goods/grounding/views/table/index.data.spec.js`、`src/views/goods/productManage/components/productManage/drawerUpdate.spec.js`、`src/views/goods/productManage/components/productManage/goodsStatus.spec.js`、`src/views/goods/productManage/components/productManage/skuDeleteButton.spec.js`、`src/views/goods/purchaseOnShelves/components/groundingForm.spec.js`、`src/views/goods/purchaseOnShelves/components/relateStoreDialog.spec.js`、`src/views/goods/purchaseOnShelves/index.spec.js`、`src/views/goods/purchaseOnShelves/utils/batchPrice.spec.js`、`src/views/goods/purchaseOnShelves/utils/purchaseCost.spec.js`、`src/views/goods/purchaseOnShelves/utils/purchaseGoodsStatus.spec.js`、`src/views/goods/shelfProduct/components/reconciliationConfig/components/specialCategory/modify.spec.js`
- 业务文档:`.ai/docs/knowledge/903-product-management.md`
## 904 订单管理
......@@ -39,7 +39,7 @@
- 视图/组件(97):`src/views/financeManage/account/accountRecord.vue`、`src/views/financeManage/account/index.vue`、`src/views/financeManage/account/offlineAccountList.vue`、`src/views/financeManage/account/onlineAccountList.vue`、`src/views/financeManage/account/serviceAccount/cashDialog.vue`、`src/views/financeManage/account/serviceAccount/myAccountRecord.vue`、`src/views/financeManage/account/serviceAccount/serviceOfflineList.vue`、`src/views/financeManage/account/serviceAccount/serviceOnlineList.vue`、`src/views/financeManage/accountStateManage/index.vue`、`src/views/financeManage/accountTmplManage/components/AccountTmpl.vue`、`src/views/financeManage/accountTmplManage/editTmpl.vue`、`src/views/financeManage/accountTmplManage/index.vue`、`src/views/financeManage/balanceStatistics/components/detailDialog.vue`、`src/views/financeManage/balanceStatistics/components/manageOtherDialog.vue`、`src/views/financeManage/balanceStatistics/index.vue`、`src/views/financeManage/components/AddDetailDialog.vue`、`src/views/financeManage/components/captchaInput.vue`、`src/views/financeManage/components/ChangeDetailDialog.vue`、`src/views/financeManage/components/ChooseRefundOrderDialog.vue`、`src/views/financeManage/components/CreateServiceDialog.vue`、`src/views/financeManage/components/DynamicAddTable.vue`、`src/views/financeManage/components/EditPayReceive.vue`、`src/views/financeManage/components/EditTransfer.vue`、`src/views/financeManage/components/ImportBillDialog.vue`、`src/views/financeManage/components/MarketTransferDialog.vue`;另有 72 项见 JSON 图谱
- API/ROP(253):`addFundUsageLimit`、`advancePaymentMerchantPage`、`advancePaymentTradeAdd`、`approvePcAbnormalFlowDeclaration`、`association`、`batchPrinting`、`batchRepush`、`batchTransferDetail`、`billCancel`、`billCancelChange`、`billComputePage`、`billConfirm`、`billConfirmChange`、`billDetailPage`、`bindDetailTag`、`checkPermission`、`confirmPendingCorporateOrder`、`createPaymentBill`、`createReceiptBill`、`createServiceBill`、`createWithdraw`、`deleteDetailTag`、`deleteDetailTagPreview`、`deleteTmpl`、`detailExcelImport`;另有 228 项见 JSON 图谱
- Vuex(5):`d2admin.user`、`d2admin/base/get`、`d2admin/user/actionSetDownloadList`、`d2admin/user/setTaskIdRefesh`、`d2admin/user/setUpdateRefesh`
- 测试(1):`src/views/financeManage/ysprepaymentManage/onlineDetail.spec.js`
- 测试(2):`src/views/financeManage/theAssetData/index.spec.js`、`src/views/financeManage/ysprepaymentManage/onlineDetail.spec.js`
- 文档缺口:尚无人工维护的深度业务文档;不要据此臆造业务规则。
## 906 系统设置
......@@ -79,7 +79,7 @@
- 视图/组件(25):`src/views/purchase/batchReview.vue`、`src/views/purchase/components/addressCom.vue`、`src/views/purchase/components/AllocateDialog.vue`、`src/views/purchase/components/CardDialog.vue`、`src/views/purchase/components/CheckDialog.vue`、`src/views/purchase/components/deliveryDetailDialog.vue`、`src/views/purchase/components/EditOrderDialog.vue`、`src/views/purchase/components/examineRecord.vue`、`src/views/purchase/components/factoryDeliveryDetailDialog.vue`、`src/views/purchase/components/goodsDetailCom.vue`、`src/views/purchase/components/orderDetailDialog.vue`、`src/views/purchase/components/rejectDialog.vue`、`src/views/purchase/components/shoppingCartCom.vue`、`src/views/purchase/directorReview.vue`、`src/views/purchase/factoryPurchaseAndDelivery.vue`、`src/views/purchase/invoiceRecord.vue`、`src/views/purchase/managerReview.vue`、`src/views/purchase/managerReviewBatchReview.vue`、`src/views/purchase/procurementBusiness.vue`、`src/views/purchase/procurementReview.vue`、`src/views/purchase/purchaseAndDelivery.vue`、`src/views/purchase/purchaseOrder.vue`、`src/views/purchase/purchasingMall.vue`、`src/views/purchase/singleBusinessReview.vue`、`src/views/purchase/singleReview.vue`
- API/ROP(72):`addressGet`、`addressSave`、`checkCard`、`deleteShipWarehouse`、`deliveryBatchCheck`、`deliveryCard`、`deliveryPdf`、`dj.api.goodsCategoryConfiguration.page.new`、`dj.api.goodsinfo.get.byId`、`dj.api.goodsInfo.listWithPage.purchaseInfo`、`dj.api.servicemerchantref.list`、`dj.api.smarcarlife.operatorreview.view`、`dj.api.smarcarlife.purchaseOrder.add`、`dj.api.smarcarlife.purchaseOrder.cancelOrCheck`、`dj.api.smarcarlife.purchaseOrder.checkDeliveryCard`、`dj.api.smarcarlife.purchaseOrder.delivery.batch`、`dj.api.smarcarlife.purchaseOrder.delivery.batch.check`、`dj.api.smarcarlife.purchaseOrder.delivery.detail`、`dj.api.smarcarlife.purchaseOrder.delivery.update`、`dj.api.smarcarlife.purchaseOrder.delivery.withdraw`、`dj.api.smarcarlife.purchaseOrder.generatedDeliveryCard`、`dj.api.smarcarlife.purchaseOrder.importDeliveryCard`、`dj.api.smarcarlife.purchaseOrder.listShipper`、`dj.api.smarcarlife.purchaseOrder.putIn`、`dj.api.smarcarlife.purchaseOrder.saveshipper`;另有 47 项见 JSON 图谱
- Vuex(2):`d2admin.user`、`d2admin/user/actionSetDownloadList`
- 测试(0):未发现候选测试
- 测试(1):`src/views/purchase/productId.integration.spec.js`
- 文档缺口:尚无人工维护的深度业务文档;不要据此臆造业务规则。
## 910 权益配置
......
This diff could not be displayed because it is too large.
......@@ -60,7 +60,7 @@
{
"kind": "route",
"path": "src/views/purchase/singleReview.vue",
"line": 408,
"line": 410,
"column": 3,
"reason": "dynamic-expression",
"note": "返回目标由来源页运行时决定"
......
......@@ -12,8 +12,8 @@
"env": "develop",
"swaggerPath": "/swagger-rop/api-docs",
"snapshot": "src/libs/rop/__snapshots__/smartcarlife.swagger.json",
"sha256": "5324f2c256ac54fadecd80e69111ebc407eb74e0535168973441680019e19ac7",
"syncedAt": "2026-08-21T09:21:56.374Z",
"sha256": "cbc17da14d9e2a5197a3355d5237d824c1b52ff61a1e0a2567be0b9371fccf04",
"syncedAt": "2026-09-02T09:12:01.448Z",
"methodCount": 1633
}
]
......
const SCENE_TYPE_MAP = {
0: { bizType: 2, bizTypeName: "权益" },
1: { bizType: 1, bizTypeName: "轻改" },
7: { bizType: 7, bizTypeName: "二手车" },
};
const SCENE_CODE_MAP = {
......@@ -11,6 +12,7 @@ const SCENE_CODE_MAP = {
110102: { bizType: 2, bizTypeName: "权益" },
110201: { bizType: "延保", bizTypeName: "延保" },
110202: { bizType: "延保", bizTypeName: "延保" },
120101: { bizType: 7, bizTypeName: "二手车" },
};
export function collectSceneCodes(value) {
......
export function formatProductId(value) {
return value || "-";
}
export function createProductIdFilter() {
return {
label: "产品ID",
name: "commodityCode",
type: "input",
isClear: true,
placeholder: "请输入产品ID",
};
}
export function createProductIdColumn(options = {}) {
return {
label: "产品ID",
prop: "upgradeGoodsCommodityCode",
formatter: cellValue => formatProductId(cellValue.upgradeGoodsCommodityCode),
...options,
};
}
import {
createProductIdColumn,
createProductIdFilter,
formatProductId,
} from "./productId";
describe("product ID UI config", () => {
it("builds the shared fuzzy-search filter", () => {
expect(createProductIdFilter()).toEqual({
label: "产品ID",
name: "commodityCode",
type: "input",
isClear: true,
placeholder: "请输入产品ID",
});
});
it("builds a product ID column from the API response field", () => {
const column = createProductIdColumn({ width: 120 });
expect(column.label).toBe("产品ID");
expect(column.prop).toBe("upgradeGoodsCommodityCode");
expect(column.width).toBe(120);
expect(column.formatter({
upgradeGoodsCommodityCode: "U2509010001",
})).toBe("U2509010001");
});
it.each([undefined, null, ""])("shows missing historical product IDs as a dash", (value) => {
expect(formatProductId(value)).toBe("-");
});
});
const mockGetGoodsInfoById = jest.fn();
jest.mock("@api/commodity", () => ({
getGoodsInfoById: mockGetGoodsInfoById,
}));
jest.mock("@api/productManage", () => ({
addProductManage: jest.fn(),
UpdateProductManage: jest.fn(),
}));
jest.mock("@/main", () => ({
baseConfig: {
equitySceneType: [],
extendedPosiType: [],
membraneTypeList: [],
supplierCode: [],
},
}));
jest.mock("./sourceMaterial.vue", () => ({
name: "SourceMaterial",
render(createElement) {
return createElement("div");
},
}));
jest.mock("./specifications.vue", () => ({
name: "Specifications",
render(createElement) {
return createElement("div");
},
}));
const DrawerUpdate = require("./drawerUpdate.vue").default;
function createGoodsDetail() {
return {
baseGoodsName: "测试产品",
distributionType: 0,
goodsInfo: {
goodsCode: "P001",
goodsName: "测试产品",
goodsType: 1,
scrmFlag: "N",
secondaryGoodsType: -1,
supplierCode: "S001",
thirdLevelGoodsType: -1,
},
goodsSpecificationNameList: [],
id: 1,
shoppingMallFlag: 0,
status: 1,
upgradeGoodsList: [{
id: 11,
merchantGoodsInfos: [],
providerIds: [],
purchaseGoodsInfos: [{ id: 22 }],
specificationData: "默认规格",
upgradeGoodsAreaList: [],
}],
};
}
describe("产品编辑详情映射", () => {
beforeEach(() => {
mockGetGoodsInfoById.mockResolvedValue(createGoodsDetail());
});
afterEach(() => {
jest.clearAllMocks();
});
it("将采购上架记录保留到单规格和多规格编辑行", async () => {
const context = {
addToUpgradeGoodsList: jest.fn(),
baseConfig: { supplierCode: [] },
copyUpgradeGoodsList: [],
extendedPosiType: [],
pageDisabled: false,
productFormData: {},
setUpdateGoodsInfo: jest.fn(),
show: false,
};
DrawerUpdate.methods.getGoodsInfo.call(context, { id: 1 });
await Promise.resolve();
await Promise.resolve();
expect(context.setUpdateGoodsInfo).toHaveBeenCalledTimes(1);
const [goodsInfoData] = context.setUpdateGoodsInfo.mock.calls[0];
expect(goodsInfoData.goodsSpecificationSingleList[0].purchaseGoodsInfos).toEqual([{ id: 22 }]);
expect(goodsInfoData.goodsSpecificationList[0].purchaseGoodsInfos).toEqual([{ id: 22 }]);
});
});
......@@ -26,6 +26,7 @@ import { applicableModelTypeList, BaseData, priceUnitTypeList } from '@/common/c
import { deepClone } from '@/common/util'
import { baseConfig } from '@/main'
import { convertYuanToWan } from '@/views/goods/filterOption'
import { pickSkuShelfRelations } from "./goodsStatus";
import sourceMaterial from './sourceMaterial.vue'
import specifications from './specifications.vue'
......@@ -185,7 +186,7 @@ export default {
serviceItemArr: val.upgradeGoodsServiceItemsList || [],
extendServiceItemArr: val.upgradeGoodsServiceItemsList || [],
entityCardFlag: val.entityCardFlag == 'Y',
merchantGoodsInfos: val?.merchantGoodsInfos,
...pickSkuShelfRelations(val),
djCost: val.djCost,
// 编辑产品价格输入框限制
oldupgradePrice: val.upgradePrice,
......
const GOODS_STATUS_TEXT = {
0: "待上架",
1: "已上架",
2: "部分上架",
3: "草稿",
};
export function formatGoodsStatus(status) {
return GOODS_STATUS_TEXT[status];
}
export function createGoodsStatusOptions() {
return Object.entries(GOODS_STATUS_TEXT).map(([confId, confValue]) => ({
confId: Number(confId),
confValue,
}));
}
export function hasSkuShelfRelations(sku) {
return [sku?.merchantGoodsInfos, sku?.purchaseGoodsInfos]
.some(relations => Array.isArray(relations) && relations.length > 0);
}
export function pickSkuShelfRelations(sku) {
return {
merchantGoodsInfos: sku?.merchantGoodsInfos,
purchaseGoodsInfos: sku?.purchaseGoodsInfos,
};
}
import {
createGoodsStatusOptions,
formatGoodsStatus,
hasSkuShelfRelations,
pickSkuShelfRelations,
} from "./goodsStatus";
describe("产品管理商品状态", () => {
it.each([
{
name: "普通商品上架记录非空时禁止删除 SKU",
sku: { merchantGoodsInfos: [{ id: 1 }], purchaseGoodsInfos: [] },
},
{
name: "采购上架记录非空时禁止删除 SKU",
sku: { merchantGoodsInfos: [], purchaseGoodsInfos: [{ id: 2 }] },
},
])("$name", ({ sku }) => {
expect(hasSkuShelfRelations(sku)).toBe(true);
});
it.each([
undefined,
null,
{},
{ merchantGoodsInfos: null, purchaseGoodsInfos: null },
{ merchantGoodsInfos: [], purchaseGoodsInfos: [] },
])("上架关联为空时允许删除 SKU:%p", (sku) => {
expect(hasSkuShelfRelations(sku)).toBe(false);
});
it("将详情接口中的两类上架关系透传到编辑行", () => {
const merchantGoodsInfos = [{ id: 1 }];
const purchaseGoodsInfos = [{ id: 2 }];
expect(pickSkuShelfRelations({ merchantGoodsInfos, purchaseGoodsInfos })).toEqual({
merchantGoodsInfos,
purchaseGoodsInfos,
});
});
it.each([
[0, "待上架"],
[1, "已上架"],
[2, "部分上架"],
[3, "草稿"],
["1", "已上架"],
])("商品状态 %p 显示为 %s", (status, expected) => {
expect(formatGoodsStatus(status)).toBe(expected);
});
it("未知商品状态保持为空,由表格按默认方式展示", () => {
expect(formatGoodsStatus()).toBeUndefined();
expect(formatGoodsStatus(4)).toBeUndefined();
});
it("商品状态筛选项与列文案共用同一映射", () => {
expect(createGoodsStatusOptions()).toEqual([
{ confId: 0, confValue: "待上架" },
{ confId: 1, confValue: "已上架" },
{ confId: 2, confValue: "部分上架" },
{ confId: 3, confValue: "草稿" },
]);
});
});
......@@ -181,6 +181,7 @@ import ApplicableAreaQuerySelect from "@/views/goods/components/applicable-area-
import drawerDetail from "./drawerDetail.vue";
import drawerSkuDetail from "./drawerSkuDetail.vue";
import drawerUpdate from "./drawerUpdate.vue";
import { createGoodsStatusOptions, formatGoodsStatus } from "./goodsStatus";
export default {
name: "Commodity",
......@@ -486,12 +487,7 @@ export default {
}[cellValue.status];
},
formatter: (cellValue) => {
return {
0: "待上架",
1: "上架",
2: "部分上架",
3: "草稿",
}[cellValue.status];
return formatGoodsStatus(cellValue.status);
},
},
{
......@@ -522,24 +518,7 @@ export default {
// 基本数据
baseData: {
productTypeList: [],
statusList: [
{
confId: 0,
confValue: "待上架",
},
{
confId: 1,
confValue: "上架",
},
{
confId: 2,
confValue: "部分上架",
},
{
confId: 3,
confValue: "草稿",
},
],
statusList: createGoodsStatusOptions(),
supplierCodeList: [], // 供应方
brandMerchantCodeList: [], // 品牌方
showSkuListOptions: [
......
......@@ -512,7 +512,7 @@
</td>
<td style="width: 60px">
<el-button type="text"
:disabled="(row.item.merchantGoodsInfos && row.item.merchantGoodsInfos.length > 0) || goodsInfoData.scrmFlag == 'Y' || pageData.pageDisabled"
:disabled="hasSkuShelfRelations(row.item) || goodsInfoData.scrmFlag === 'Y' || pageData.pageDisabled"
@click="delspecificationValueList(row.originalIndex)">
删除
</el-button>
......@@ -763,6 +763,7 @@ import useTableVirtualScroll from "@/views/goods/productManage/mixins/useTableVi
// import ApplicableAreaSelect from "@/views/goods/components/applicable-area-select/index.vue";
import carSeriesDialog from "./carSeriesDialog.vue";
import extendServiceItemsDialog from "./extendServiceItemsDialog.vue";
import { hasSkuShelfRelations, pickSkuShelfRelations } from "./goodsStatus";
import serviceItemsDialog from "./serviceItemsDialog.vue";
import specsManage from "./specsManage.vue";
import SupplierSelect from "./SupplierSelect.vue";
......@@ -1035,6 +1036,7 @@ export default {
},
},
methods: {
hasSkuShelfRelations,
// ========== 批量赋值方法 ==========
/**
* 批量设置产品编码
......@@ -2031,6 +2033,7 @@ export default {
item.supplySource = temp.supplySource;
item.remark = temp.remark;
item.merchantGoodsExist = temp.merchantGoodsExist;
Object.assign(item, pickSkuShelfRelations(temp));
break;
}
}
......
......@@ -496,7 +496,7 @@
<td style="width: 60px">
<el-button type="text"
:disabled="row.item.merchantGoodsInfos && row.item.merchantGoodsInfos.length > 0"
:disabled="hasSkuShelfRelations(row.item)"
@click="delgoodsSpecificationSingleList(row.originalIndex)">
删除
</el-button>
......@@ -650,6 +650,7 @@ import useResizableColumns from "@/views/goods/productManage/mixins/useResizable
import useTableVirtualScroll from "@/views/goods/productManage/mixins/useTableVirtualScroll";
import carSeriesDialog from "./carSeriesDialog.vue";
import extendServiceItemsDialog from "./extendServiceItemsDialog.vue";
import { hasSkuShelfRelations } from "./goodsStatus";
import serviceItemsDialog from "./serviceItemsDialog.vue";
import SupplierSelect from "./SupplierSelect.vue";
......@@ -851,6 +852,7 @@ export default {
});
},
methods: {
hasSkuShelfRelations,
...mapMutations("goodsInfoData", ["setUpdateGoodsInfo"]),
...mapActions({
get: "d2admin/base/get",
......
import { shallowMount } from "@vue/test-utils";
import Vue from "vue";
Vue.config.ignoredElements = [/^el-/, /^d2-/];
jest.mock("@api/productManage", () => ({
getCarSeriesList: jest.fn(),
getExtendServiceItems: jest.fn(),
getProductServiceItems: jest.fn(),
}));
jest.mock("@/main", () => ({
baseConfig: {
equitySceneType: [],
extendedPosiType: [],
membraneTypeList: [],
supplierCode: [],
},
}));
jest.mock("@/views/goods/components/applicable-area-query-select/index.vue", () => ({
name: "ApplicableAreaQuerySelect",
render(createElement) {
return createElement("div");
},
}));
jest.mock("./carSeriesDialog.vue", () => ({
name: "CarSeriesDialog",
render(createElement) {
return createElement("div");
},
}));
jest.mock("./extendServiceItemsDialog.vue", () => ({
name: "ExtendServiceItemsDialog",
render(createElement) {
return createElement("div");
},
}));
jest.mock("./serviceItemsDialog.vue", () => ({
name: "ServiceItemsDialog",
render(createElement) {
return createElement("div");
},
}));
jest.mock("./specsManage.vue", () => ({
name: "SpecsManage",
render(createElement) {
return createElement("div");
},
}));
jest.mock("./SupplierSelect.vue", () => ({
name: "SupplierSelect",
render(createElement) {
return createElement("div");
},
}));
const MultipleSpecificationForm = require("./multipleSpecificationForm.vue").default;
const SingleSpecificationForm = require("./singleSpecificationForm.vue").default;
const ElButtonStub = {
props: {
disabled: {
type: Boolean,
default: false,
},
},
render(createElement) {
return createElement("button", {
attrs: { disabled: this.disabled },
}, this.$slots.default);
},
};
let wrapper;
function createGoodsInfoData(listKey, { goodsInfoOverrides = {}, skuOverrides = {} } = {}) {
const sku = {
merchantGoodsInfos: [],
providerIds: [],
purchaseGoodsInfos: [{ id: 2 }],
selectCarSerise: [],
serviceItemArr: [],
specificationData: "测试规格",
specsValueList: ["测试规格"],
statusFlag: 0,
upgradeGoodsAreaList: [],
...skuOverrides,
};
return {
goodsSpecificationList: [],
goodsSpecificationNameList: [{ specificationName: "规格" }],
goodsSpecificationSingleList: [],
goodsType: null,
scrmFlag: "N",
specificationDetailList: [{
specificationName: "规格",
specificationValueList: [{ specificationValue: "测试规格" }],
}],
supplierCode: "",
upgradeGoodsList: [sku],
[listKey]: [sku],
...goodsInfoOverrides,
};
}
function createWrapper(component, listKey, {
goodsInfoOverrides = {},
pageDataOverrides = {},
runMounted = false,
skuOverrides = {},
} = {}) {
const goodsInfoData = createGoodsInfoData(listKey, { goodsInfoOverrides, skuOverrides });
const TestComponent = {
...component,
computed: {
...component.computed,
goodsInfoData() {
return goodsInfoData;
},
},
};
if (!runMounted) {
TestComponent.mounted = function mounted() {};
}
return shallowMount(TestComponent, {
mocks: {
$$: (value, key) => value?.[key],
$store: {
commit: jest.fn(),
dispatch: jest.fn().mockResolvedValue([]),
state: {
d2admin: {
user: { info: {} },
},
},
},
},
provide: {
pageData: {
addOrEdit: "edit",
pageDisabled: false,
...pageDataOverrides,
},
},
stubs: {
"el-button": ElButtonStub,
},
});
}
describe("产品编辑 SKU 删除按钮", () => {
afterEach(() => {
wrapper?.destroy();
jest.clearAllMocks();
});
it.each([
["单规格", SingleSpecificationForm, "goodsSpecificationSingleList"],
["多规格", MultipleSpecificationForm, "goodsSpecificationList"],
])("%s SKU 有采购上架记录时删除按钮置灰", (name, component, listKey) => {
wrapper = createWrapper(component, listKey);
const buttons = wrapper.find(".body-table").findAll("button");
const deleteButton = buttons.wrappers.find(button => button.text().trim() === "删除");
expect(deleteButton.element.disabled).toBe(true);
});
it("多规格挂载重建 SKU 后仍保留采购上架禁删状态", async () => {
wrapper = createWrapper(MultipleSpecificationForm, "goodsSpecificationList", { runMounted: true });
await wrapper.vm.$nextTick();
const deleteButton = wrapper.find(".body-table").findAll("button").wrappers.find(button => button.text().trim() === "删除");
expect(wrapper.vm.goodsInfoData.goodsSpecificationList[0].purchaseGoodsInfos).toEqual([{ id: 2 }]);
expect(deleteButton.element.disabled).toBe(true);
});
it.each([
[
"单规格无上架关联时允许删除",
SingleSpecificationForm,
"goodsSpecificationSingleList",
{ skuOverrides: { purchaseGoodsInfos: [] } },
false,
],
[
"多规格无上架关联时允许删除",
MultipleSpecificationForm,
"goodsSpecificationList",
{ skuOverrides: { purchaseGoodsInfos: [] } },
false,
],
[
"多规格普通上架关联非空时禁止删除",
MultipleSpecificationForm,
"goodsSpecificationList",
{ skuOverrides: { merchantGoodsInfos: [{ id: 1 }], purchaseGoodsInfos: [] } },
true,
],
[
"多规格 SCRM 商品禁止删除",
MultipleSpecificationForm,
"goodsSpecificationList",
{ goodsInfoOverrides: { scrmFlag: "Y" }, skuOverrides: { purchaseGoodsInfos: [] } },
true,
],
[
"多规格页面只读时禁止删除",
MultipleSpecificationForm,
"goodsSpecificationList",
{ pageDataOverrides: { pageDisabled: true }, skuOverrides: { purchaseGoodsInfos: [] } },
true,
],
])("%s", (name, component, listKey, options, expectedDisabled) => {
wrapper = createWrapper(component, listKey, options);
const deleteButton = wrapper.find(".body-table").findAll("button").wrappers.find(button => button.text().trim() === "删除");
expect(deleteButton.element.disabled).toBe(expectedDisabled);
});
});
import { shallowMount } from "@vue/test-utils";
const mockGetList = jest.fn().mockResolvedValue({ list: [] });
const mockGetAllCategory = jest.fn().mockResolvedValue({ list: [] });
const mockGetParkStore = jest.fn().mockResolvedValue([]);
const mockSearchServiceMerchant = jest.fn().mockResolvedValue({ list: [] });
jest.mock("@api/product", () => ({
getAllCategory: mockGetAllCategory,
getList: mockGetList,
}));
jest.mock("@api/serviceManage", () => ({
searchServiceMerchant: mockSearchServiceMerchant,
}));
jest.mock("@api/editCustomer", () => ({
getParkStore: mockGetParkStore,
}));
jest.mock("@api/grounding", () => ({
batchSetValidMinSellPrice: jest.fn(),
batchUpdateBatchCopy: jest.fn(),
purchaseGoodsInfoDeleteById: jest.fn(),
purchaseGoodsInfoImport: jest.fn(),
purchaseGoodsInfoPage: jest.fn(),
purchaseGoodsInfoUpdateBatchOffShelf: jest.fn(),
purchaseGoodsInfoUpdateBatchPrice: jest.fn(),
purchaseGoodsInfoUpdateBatchWaitAudit: jest.fn(),
purchaseGoodsInfoUpdateStatus: jest.fn(),
}));
jest.mock("@/main", () => ({
baseConfig: {},
}));
jest.mock("./components/batchCopyDialog.vue", () => ({
name: "BatchCopyDialog",
render(createElement) {
return createElement("div");
},
}));
const PurchaseOnShelves = require("./index.vue").default;
let currentRow;
let wrapper;
const AuthButtonStub = {
props: {
showBtnIds: {
type: Array,
default: () => [],
},
},
render(createElement) {
return createElement("button", {
attrs: {
"data-auth-id": this.showBtnIds[0],
},
});
},
};
const D2ContainerStub = {
render(createElement) {
return createElement("div", this.$slots.default);
},
};
const EmptyStub = {
render(createElement) {
return createElement("div");
},
};
const D2TableStub = {
render(createElement) {
return createElement("div", [
this.$scopedSlots["auth-button"]({ scope: currentRow }),
]);
},
};
function createWrapper(row) {
currentRow = row;
return shallowMount(PurchaseOnShelves, {
mocks: {
$store: {
commit: jest.fn(),
dispatch: jest.fn().mockResolvedValue([]),
state: {
d2admin: {
user: {
dowloadList: [],
info: {},
updateList: [],
updateRefesh: false,
},
},
},
},
},
stubs: {
AuthButton: AuthButtonStub,
D2Container: D2ContainerStub,
D2Dialog: EmptyStub,
D2FileImportDialog: EmptyStub,
D2Table: D2TableStub,
D2TableHeader: EmptyStub,
},
});
}
describe("purchase goods delete button visibility", () => {
afterEach(() => {
wrapper.destroy();
jest.clearAllMocks();
});
it("shows delete for an off-shelf record that was previously on shelf", () => {
wrapper = createWrapper({
lastOnShelfTime: "2026-08-27 10:00:00",
status: 0,
});
expect(wrapper.find("[data-auth-id='9031404']").exists()).toBe(true);
});
it("hides delete for an on-shelf record without a previous shelf time", () => {
wrapper = createWrapper({
lastOnShelfTime: "",
status: 1,
});
expect(wrapper.find("[data-auth-id='9031404']").exists()).toBe(false);
});
});
......@@ -107,7 +107,7 @@
<auth-button :data="scope.scope" :show-btn-ids="['9031407']" />
</span>
<!-- 删除 -->
<span style="margin-right: 10px;" v-if="!scope.scope.lastOnShelfTime">
<span v-if="canDeletePurchaseGoods(scope.scope)" style="margin-right: 10px;">
<auth-button :data="scope.scope" :show-btn-ids="['9031404']" />
</span>
<!-- 上架/下架 -->
......@@ -154,6 +154,8 @@ import { baseConfig } from '@/main'
import batchCopyDialog from './components/batchCopyDialog.vue'
import { getBatchPriceSelectionSummary, hasUnsupportedPurchaseCostType } from './utils/batchPrice'
import { getPurchaseCostTypeText, purchaseCostTypeList } from './utils/purchaseCost'
import { canDeletePurchaseGoods } from "./utils/purchaseGoodsStatus";
export default {
components: { batchCopyDialog },
name: 'PurchaseOnShelves',
......@@ -641,6 +643,7 @@ export default {
}),
...mapMutations('d2admin/user', ['setUpdateRefesh']),
...mapActions('d2admin/user', ['actionSetDownloadList']),
canDeletePurchaseGoods,
selectAddAttr(value) {
this.searchForm.goodsType = value?.[0]
this.searchForm.secondaryGoodsType = value?.[1]
......
const DELETABLE_PURCHASE_GOODS_STATUS = ["0", "3", "4"];
export function canDeletePurchaseGoods(record) {
const status = record?.status;
if (typeof status !== "number" && typeof status !== "string") {
return false;
}
return DELETABLE_PURCHASE_GOODS_STATUS.includes(String(status));
}
import { canDeletePurchaseGoods } from "./purchaseGoodsStatus";
describe("purchase goods delete visibility", () => {
it.each([3, 4, 0, "3", "4", "0"])("allows deletion when status is %s", (status) => {
expect(canDeletePurchaseGoods({
status,
lastOnShelfTime: "2026-08-27 10:00:00",
})).toBe(true);
});
it.each([1, "1", "", " ", null, undefined, false, true, 2])("hides deletion when status is %s", (status) => {
expect(canDeletePurchaseGoods({ status })).toBe(false);
});
it("hides deletion when the purchase goods record is missing", () => {
expect(canDeletePurchaseGoods()).toBe(false);
});
});
......@@ -102,6 +102,7 @@ import {
operatorreviewOperatorAudit,
operatorreviewView,
} from "@/api/purchaseShopping.js";
import { createProductIdColumn } from "@/common/productId";
import { deepClone, Util } from "@/common/util";
import { baseConfig } from "@/main";
import StockDetailDialog from "@/views/stockManage/components/stockDetailDialog.vue";
......@@ -191,6 +192,7 @@ export default {
addHtml: "upgradeGoodsName",
prop: "upgradeGoodsName",
},
createProductIdColumn(),
{
label: "供应商名称",
prop: 'thirdPartyName',
......
......@@ -170,6 +170,7 @@ import {
operatorreviewView,
purchaseOrderDetail,
} from "@/api/purchaseShopping.js";
import { createProductIdColumn } from "@/common/productId";
import { deepClone, Util } from "@/common/util";
import { baseConfig } from "@/main";
import ExamineRecord from "./examineRecord.vue";
......@@ -224,6 +225,7 @@ export default {
addHtml: "upgradeGoodsName",
prop: "upgradeGoodsName",
},
createProductIdColumn(),
{
label: "供应商名称",
prop: "thirdPartyName",
......@@ -402,7 +404,10 @@ export default {
}
// 采购订单-自采入库显示膜卷号
if (this.showFilmRollNo) {
this.tableParams.tableColumns.splice(5, 0, {
const carNameColumnIndex = this.tableParams.tableColumns.findIndex(
item => item.prop === "carName",
);
this.tableParams.tableColumns.splice(carNameColumnIndex, 0, {
label: "膜卷号",
prop: "filmRollNo",
type: "slot",
......
......@@ -105,6 +105,7 @@ import {
operatorreviewView,
purchaseOrderReject,
} from "@/api/purchaseShopping.js";
import { createProductIdColumn } from "@/common/productId";
import { deepClone, Util } from "@/common/util";
import { baseConfig } from "@/main";
import StockDetailDialog from "@/views/stockManage/components/stockDetailDialog.vue";
......@@ -184,6 +185,7 @@ export default {
addHtml: "upgradeGoodsName",
prop: "upgradeGoodsName",
},
createProductIdColumn(),
{
label: "供应商名称",
prop: 'thirdPartyName',
......
......@@ -30,6 +30,7 @@
</template>
<script>
import { createProductIdFilter } from "@/common/productId";
import { Util, deepClone } from '@/common/util'
import { director_statusOptions, defaultDeliveryStatusOptions, defaultPutStatusOptions, purchasingPatternOptions, director_statusOptions_table } from './constant'
import { mapActions, mapState } from 'vuex'
......@@ -54,7 +55,8 @@ export default {
merchantName: '',
sortType: 2,
orderTimeStr: [],
purchasingPattern: ''
purchasingPattern: "",
commodityCode: "",
},
tableSearchForm: {},
tableData: [],
......@@ -65,6 +67,7 @@ export default {
type: 'input',
isClear: true
},
createProductIdFilter(),
{
label: '下单时间',
name: 'placeOrderTimeStr',
......@@ -382,4 +385,3 @@ export default {
}
</script>
<style lang="scss" scoped></style>
......@@ -66,6 +66,7 @@
<script>
import { mapActions, mapState } from "vuex";
import { getManagerReviewPageApi, getMerchantList, managerreviewManagerAudit, managerReviewReject } from "@/api/purchaseShopping.js";
import { createProductIdFilter } from "@/common/productId";
import { deepClone, Util } from "@/common/util";
import CheckDialog from "./components/CheckDialog";
import orderDeatilDialog from "./components/orderDetailDialog";
......@@ -92,6 +93,7 @@ export default {
sortType: 2,
orderTimeStr: [],
purchasingPattern: "",
commodityCode: "",
},
tableSearchForm: {},
tableData: [],
......@@ -102,6 +104,7 @@ export default {
type: "input",
isClear: true,
},
createProductIdFilter(),
{
label: "下单时间",
name: "placeOrderTimeStr",
......
......@@ -54,6 +54,7 @@
</template>
<script>
import { createProductIdFilter } from "@/common/productId";
import { Util, deepClone } from '@/common/util'
import { business_statusOptions, defaultDeliveryStatusOptions, defaultPutStatusOptions, purchasingPatternOptions, business_statusOptions_table } from './constant'
import { mapActions, mapState } from 'vuex'
......@@ -79,7 +80,8 @@ export default {
sortType: 2,
orderTimeStr: [],
purchasingPattern: '',
onlyAllocateOrder: false
onlyAllocateOrder: false,
commodityCode: "",
},
tableSearchForm: {},
tableData: [],
......@@ -90,6 +92,7 @@ export default {
type: 'input',
isClear: true
},
createProductIdFilter(),
{
label: '下单时间',
name: 'placeOrderTimeStr',
......
......@@ -73,6 +73,7 @@
<script>
import { mapActions, mapState } from "vuex";
import { getMerchantList, getPurchaseOrderList, operatorreviewOperatorAudit, operatorreviewPage, purchaseOrderCancelOrCheck } from "@/api/purchaseShopping.js";
import { createProductIdFilter } from "@/common/productId";
import { deepClone, Util } from "@/common/util";
import CheckDialog from "./components/CheckDialog";
import orderDeatilDialog from "./components/orderDetailDialog";
......@@ -97,6 +98,7 @@ export default {
sortType: 2,
orderTimeStr: [],
purchasingPattern: "",
commodityCode: "",
},
tableSearchForm: {},
tableData: [],
......@@ -107,6 +109,7 @@ export default {
type: "input",
isClear: true,
},
createProductIdFilter(),
{
label: "下单时间",
name: "placeOrderTimeStr",
......
const fs = require("fs");
const path = require("path");
const SOURCE_ROOT = path.resolve(__dirname, "../..");
function readSource(file) {
return fs.readFileSync(path.resolve(SOURCE_ROOT, file), "utf8");
}
describe("purchase and transfer approval product ID coverage", () => {
it.each([
"views/purchase/procurementReview.vue",
"views/purchase/managerReview.vue",
"views/purchase/directorReview.vue",
"views/purchase/procurementBusiness.vue",
"views/stockManage/transferOperationsReview/index.vue",
"views/stockManage/transferCommercialReview/index.vue",
])("adds the product ID filter to %s", (file) => {
const source = readSource(file);
expect(source).toContain("commodityCode: \"");
expect(source).toContain("createProductIdFilter()");
});
it.each([
"views/purchase/components/orderDetailDialog.vue",
"views/purchase/components/CheckDialog.vue",
"views/purchase/components/rejectDialog.vue",
"views/purchase/singleReview.vue",
"views/purchase/singleBusinessReview.vue",
"views/stockManage/components/transferDetailDialog.vue",
"views/stockManage/transferOperationsReview/handleReview.vue",
"views/stockManage/transferOperationsReview/handleReject.vue",
])("adds the product ID column to %s", (file) => {
const source = readSource(file);
const tableConfig = source.slice(source.indexOf("tableColumns:"));
const productNameIndex = Math.max(
tableConfig.indexOf("label: \"产品名称\""),
tableConfig.indexOf("label: '产品名称'"),
);
const productIdIndex = tableConfig.indexOf("createProductIdColumn()");
expect(productNameIndex).toBeGreaterThanOrEqual(0);
expect(productIdIndex).toBeGreaterThan(productNameIndex);
});
it.each([
"views/stockManage/transferOperationsReview/index.vue",
"views/stockManage/transferCommercialReview/index.vue",
])("keeps product ID in the reset model for %s", (file) => {
const source = readSource(file);
expect(source.match(/commodityCode: ""/g)).toHaveLength(2);
});
it("keeps the film-roll column anchored before the car column", () => {
const detailSource = readSource("views/purchase/components/orderDetailDialog.vue");
expect(detailSource).toContain("item => item.prop === \"carName\"");
expect(detailSource).not.toContain("tableColumns.splice(5, 0");
});
});
......@@ -178,6 +178,7 @@ import {
operatorreviewOperatorAudit,
operatorreviewView,
} from "@/api/purchaseShopping.js";
import { createProductIdColumn } from "@/common/productId";
import {
getyqMerchantList,
getServicemerchantrefList
......@@ -264,6 +265,7 @@ export default {
addHtml: "upgradeGoodsName",
prop: "upgradeGoodsName",
},
createProductIdColumn(),
{
label: "供应商名称",
prop: 'thirdPartyName',
......
......@@ -83,6 +83,7 @@
<script>
import { getShippingEntityInfoAll } from "@api/serviceManage";
import { directorCheck, directorReject, operatorreviewView, purchaseOrderDetail } from "@/api/purchaseShopping.js";
import { createProductIdColumn } from "@/common/productId";
import { deepClone, Util } from "@/common/util";
import { baseConfig } from "@/main";
import ExamineRecord from "./components/examineRecord.vue";
......@@ -120,6 +121,7 @@ export default {
addHtml: "upgradeGoodsName",
prop: "upgradeGoodsName",
},
createProductIdColumn(),
{
label: "供应商名称",
prop: 'thirdPartyName',
......
......@@ -158,6 +158,7 @@
<script>
import { getTransferGoodsInfo, getTransferAuitInfo } from "@/api/stockManage";
import { createProductIdColumn } from "@/common/productId";
import { baseConfig } from "@/main";
import { Util, deepClone } from "@/common/util";
import EllipsisTooltip from "./EllipsisTooltip.vue";
......@@ -251,6 +252,7 @@ export default {
label: "产品名称",
prop: "goodsName",
},
createProductIdColumn(),
{
label: "产品编码",
prop: "productCode",
......
......@@ -57,6 +57,7 @@ import {
yqRelatedList,
} from "@api/stockManage";
import { mapActions, mapState } from "vuex";
import { createProductIdFilter } from "@/common/productId";
import { deepClone, Util } from "@/common/util";
// import allocationDetailDialog from "../transferOperationsReviewDetailDialog"
export default {
......@@ -70,6 +71,7 @@ export default {
userInfo: this.$store.state.d2admin.user.info,
searchForm: {
allocateCode: "",
commodityCode: "",
callInName: "",
billStatus: "",
deliveryStatus: "",
......@@ -90,6 +92,7 @@ export default {
maxlength: "20",
isClear: true,
},
createProductIdFilter(),
{
label: "调入仓库",
name: "callInName",
......@@ -351,6 +354,7 @@ export default {
handleReset() {
this.searchForm = {
allocateCode: "",
commodityCode: "",
callInName: "",
billStatus: "",
deliveryStatus: "",
......
......@@ -245,6 +245,7 @@ import {
stockAllocateInfo,
stockAllocateOperatorReject,
} from "@api/stockManage";
import { createProductIdColumn } from "@/common/productId";
import { deepClone, Util } from "@/common/util";
import { baseConfig } from "@/main";
import stockDetailDialog from "@/views/stockManage/components/stockDetailDialog.vue";
......@@ -310,6 +311,7 @@ export default {
label: "产品名称",
prop: "goodsName",
},
createProductIdColumn(),
{
label: "产品编码",
prop: "productCode",
......
......@@ -279,6 +279,7 @@ import {
stockAllocateOperatorAudit,
stockAllocateYqMerchantList,
} from "@api/stockManage";
import { createProductIdColumn } from "@/common/productId";
import { deepClone, Util } from "@/common/util";
import { baseConfig } from "@/main";
import stockDetailDialog from "@/views/stockManage/components/stockDetailDialog.vue";
......@@ -320,6 +321,7 @@ export default {
label: "产品名称",
prop: "goodsName",
},
createProductIdColumn(),
{
label: "产品编码",
prop: "productCode",
......
......@@ -57,6 +57,7 @@ import {
yqRelatedList,
} from "@api/stockManage";
import { mapActions, mapState } from "vuex";
import { createProductIdFilter } from "@/common/productId";
import { deepClone, Util } from "@/common/util";
// import allocationDetailDialog from "../transferOperationsReviewDetailDialog"
export default {
......@@ -70,6 +71,7 @@ export default {
userInfo: this.$store.state.d2admin.user.info,
searchForm: {
allocateCode: "",
commodityCode: "",
callInName: "",
billStatus: "",
deliveryStatus: "",
......@@ -90,6 +92,7 @@ export default {
maxlength: "20",
isClear: true,
},
createProductIdFilter(),
{
label: "调入仓库",
name: "callInName",
......@@ -345,6 +348,7 @@ export default {
handleReset() {
this.searchForm = {
allocateCode: "",
commodityCode: "",
callInName: "",
billStatus: "",
deliveryStatus: "",
......
......@@ -25,6 +25,15 @@ describe("mapDetailResponse", () => {
expect(detail.bizTypeName).toBe("延保");
});
it("详情应使用精确场景码识别二手车", () => {
const detail = mapDetailResponse({
sceneType: 7,
baseSceneCode: 120101,
});
expect(detail.bizType).toBe(7);
expect(detail.bizTypeName).toBe("二手车");
});
it("列表业务兜底应优先于旧 sceneType 映射", () => {
const detail = mapDetailResponse(
{ sceneType: "0" },
......
......@@ -24,6 +24,12 @@ describe("mapOverviewRow", () => {
expect(row.bizType).toBe(2);
});
it("二手车场景应映射为列表业务大类文案", () => {
const row = mapOverviewRow({ sceneType: "7" });
expect(row.bizTypeName).toBe("二手车");
expect(row.bizType).toBe(7);
});
it("应保留详情显隐需要的品牌和场景上下文", () => {
const row = mapOverviewRow({
brandIds: [3454, 3503],
......
......@@ -7,10 +7,15 @@ describe("mapSceneType", () => {
[100101, { bizType: 1, bizTypeName: "轻改" }],
[110201, { bizType: "延保", bizTypeName: "延保" }],
[110101, { bizType: 2, bizTypeName: "权益" }],
[120101, { bizType: 7, bizTypeName: "二手车" }],
])("场景码 %s 应映射到对应业务大类", (baseSceneCode, expected) => {
expect(mapSceneType("0", { baseSceneCode })).toEqual(expected);
});
it("缺少精确场景码时应使用二手车 sceneType 回显", () => {
expect(mapSceneType("7")).toEqual({ bizType: 7, bizTypeName: "二手车" });
});
it("sceneList 精确场景码应优先于旧 sceneType", () => {
expect(mapSceneType("0", {
sceneList: [{ baseSceneCode: 110202 }],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!