Commit faec3cfc by 张立顺

feat 功能开发

1 parent fe63646f
...@@ -164,6 +164,12 @@ export function purchaseGoodsInfoUpdateBatchWaitAudit(data) { ...@@ -164,6 +164,12 @@ export function purchaseGoodsInfoUpdateBatchWaitAudit(data) {
return request(data, "post"); return request(data, "post");
} }
// 批量修改采购价
export function purchaseGoodsInfoUpdateBatchPrice(data) {
data.method = `${path}purchaseGoodsInfo.updateBatchPrice`;
return request(data, "post");
}
// 上下架操作 // 上下架操作
export function purchaseGoodsInfoUpdateStatus(data) { export function purchaseGoodsInfoUpdateStatus(data) {
data.method = `${path}purchaseGoodsInfo.updateStatus`; data.method = `${path}purchaseGoodsInfo.updateStatus`;
...@@ -184,8 +190,8 @@ export function savePaymentChannelConfig(data) { ...@@ -184,8 +190,8 @@ export function savePaymentChannelConfig(data) {
// 根据已选产品实时查询运营成本 // 根据已选产品实时查询运营成本
export function getOperationCost(data) { export function getOperationCost(data) {
data.method = 'dj.api.smartcarlife.merchantGoodsInfo.operationCost.calculate' data.method = "dj.api.smartcarlife.merchantGoodsInfo.operationCost.calculate";
return request(data, "post") return request(data, "post");
} }
// 查询商品成本(默认带入产品成本) // 查询商品成本(默认带入产品成本)
......
import { purchaseGoodsInfoUpdateBatchPrice } from "./grounding";
import mockRequest from "./request";
jest.mock("./request", () => jest.fn((data, method) => Promise.resolve({ data, method })));
describe("grounding api", () => {
beforeEach(() => {
mockRequest.mockClear();
});
it("submits selected purchase ids and price to the batch price endpoint", async () => {
const payload = { ids: [1, "2"], purchasePrice: 88.5 };
await purchaseGoodsInfoUpdateBatchPrice(payload);
expect(mockRequest).toHaveBeenCalledWith({
ids: [1, "2"],
purchasePrice: 88.5,
method: "dj.api.smartcarlife.purchaseGoodsInfo.updateBatchPrice",
}, "post");
});
});
import auth from "@/store/modules/d2admin/modules/auth"; // eslint-disable-next-line node/prefer-global/process
const _import = require("@/libs/util.import." + process.env.NODE_ENV); const _import = require("@/libs/util.import." + process.env.NODE_ENV);
export const routerName = { export const routerName = {
903: { 903: {
...@@ -645,6 +644,14 @@ export const routerName = { ...@@ -645,6 +644,14 @@ export const routerName = {
type: "primary", type: "primary",
handle: "handleBatchImport", handle: "handleBatchImport",
}, },
{
authId: "9031412",
parentId: "90314",
label: "批量修改采购价",
category: "Button",
type: "primary",
handle: "handleBatchModifyPrice",
},
], ],
component: _import("goods/purchaseOnShelves/index"), component: _import("goods/purchaseOnShelves/index"),
}, },
......
...@@ -861,6 +861,9 @@ export default { ...@@ -861,6 +861,9 @@ export default {
trigger: ["change", "blur"], trigger: ["change", "blur"],
}, },
], ],
saleMode: [
{ required: true, message: "请选择销售模式", trigger: "change" },
],
}, },
storeSelected: [], storeSelected: [],
relateStoreVisible: false, relateStoreVisible: false,
......
export const SALE_MODE_RETAIL = 0;
export const SALE_MODE_WHOLESALE = 1;
export const saleModeList = [
{ confId: SALE_MODE_RETAIL, confName: "零售" },
{ confId: SALE_MODE_WHOLESALE, confName: "批发" },
];
export function resolveSaleMode(saleMode, saleModeStr) {
if (saleMode !== "" && saleMode !== null && saleMode !== undefined) {
return Number(saleMode) === SALE_MODE_WHOLESALE ? SALE_MODE_WHOLESALE : SALE_MODE_RETAIL;
}
return saleModeStr === "批发" ? SALE_MODE_WHOLESALE : SALE_MODE_RETAIL;
}
import { resolveSaleMode } from "./saleMode";
describe("sale mode", () => {
it.each([
["零售", 0],
["批发", 1],
["", 0],
[undefined, 0],
])("maps %s to %s", (saleModeStr, expected) => {
expect(resolveSaleMode(undefined, saleModeStr)).toBe(expected);
});
it("prefers a numeric API value when available", () => {
expect(resolveSaleMode("1", "零售")).toBe(1);
});
});
...@@ -151,6 +151,10 @@ export default { ...@@ -151,6 +151,10 @@ export default {
label: "商品别名", label: "商品别名",
}, },
{ {
name: "saleModeStr",
label: "销售模式",
},
{
name: "warrantyTypeStr", name: "warrantyTypeStr",
label: "质保卡类型", label: "质保卡类型",
}, },
......
...@@ -28,6 +28,7 @@ import { convertYuanToWan, filterSpecsStr } from "@/views/goods/filterOption"; ...@@ -28,6 +28,7 @@ import { convertYuanToWan, filterSpecsStr } from "@/views/goods/filterOption";
import groundingForm from "@/views/goods/grounding/components/groundingForm.vue"; import groundingForm from "@/views/goods/grounding/components/groundingForm.vue";
import { baseSupplyModeList, productList, upgradeSupplyModeList } from "@/views/goods/grounding/constants/data"; import { baseSupplyModeList, productList, upgradeSupplyModeList } from "@/views/goods/grounding/constants/data";
import { isSelfOperatedEquityExtended, mapServiceItemOption } from "@/views/goods/grounding/utils/productCost"; import { isSelfOperatedEquityExtended, mapServiceItemOption } from "@/views/goods/grounding/utils/productCost";
import { resolveSaleMode, saleModeList } from "@/views/goods/grounding/utils/saleMode";
export default { export default {
name: "EditGrounding", name: "EditGrounding",
...@@ -181,6 +182,16 @@ export default { ...@@ -181,6 +182,16 @@ export default {
width: "432px", width: "432px",
}, },
{ {
name: "saleMode",
label: "销售模式",
type: "flagRadio",
isRequired: true,
radioGroupList: saleModeList.map(item => ({
label: item.confName,
value: item.confId,
})),
},
{
name: "warrantyType", name: "warrantyType",
label: "质保卡类型", label: "质保卡类型",
type: "select", type: "select",
...@@ -343,6 +354,7 @@ export default { ...@@ -343,6 +354,7 @@ export default {
financeCheckFlag: "N", financeCheckFlag: "N",
serviceItemId: "", serviceItemId: "",
productCostType: "", productCostType: "",
saleMode: 0,
warrantyType: 0, warrantyType: 0,
}, },
secondGoodsList: [], secondGoodsList: [],
...@@ -446,6 +458,7 @@ export default { ...@@ -446,6 +458,7 @@ export default {
if (isSelfOperatedEquityExtended(res.goodsType, res.supplierCode)) { if (isSelfOperatedEquityExtended(res.goodsType, res.supplierCode)) {
res.productCostType = 1; res.productCostType = 1;
} }
res.saleMode = resolveSaleMode(res.saleMode, res.saleModeStr);
res.upgradeGoods = { res.upgradeGoods = {
...res?.upgradeGoods, ...res?.upgradeGoods,
goodsName: res.goodsInfo.goodsName, goodsName: res.goodsInfo.goodsName,
...@@ -610,6 +623,7 @@ export default { ...@@ -610,6 +623,7 @@ export default {
thirdPartyCost: "", thirdPartyCost: "",
serviceItemId: "", serviceItemId: "",
productCostType: "", productCostType: "",
saleMode: 0,
}; };
addOrUpdateAPI(this.dealObjectValue(params)).then((res) => { addOrUpdateAPI(this.dealObjectValue(params)).then((res) => {
this.notice.okTips(); this.notice.okTips();
......
import { getShopMerchantList } from "@api/deviceManage"; import { getShopMerchantList } from "@api/deviceManage";
import { getParkStore } from "@api/editCustomer"; import { getParkStore } from "@api/editCustomer";
import { getAllCategory, getList as getProductList } from "@api/product"; import { getList as getProductList } from "@api/product";
import { getAreaDataList, getBaseSceneCodeList } from "@api/productManage"; import { getBaseSceneCodeList } from "@api/productManage";
import { cloneDeep, isFunction } from "lodash-es"; import { cloneDeep, isFunction } from "lodash-es";
import { BaseData, sceneCodeList } from "@/common/constants.js"; import { BaseData } from "@/common/constants.js";
import { Util } from "@/common/util"; import { Util } from "@/common/util";
import store from "@/store"; import store from "@/store";
import { baseSupplyModeList, upgradeSupplyModeList } from "@/views/goods/grounding/constants/data"; import { baseSupplyModeList, upgradeSupplyModeList } from "@/views/goods/grounding/constants/data";
import { financeCheckFlagList, inventoryTypeList, productCostTypeList, sellPriceTempValidStatusList, statusList } from "@/views/goods/grounding/constants/index"; import { financeCheckFlagList, inventoryTypeList, productCostTypeList, sellPriceTempValidStatusList, statusList } from "@/views/goods/grounding/constants/index";
import { priceFilter } from "@/views/goods/grounding/utils/number"; import { priceFilter } from "@/views/goods/grounding/utils/number";
import { saleModeList } from "@/views/goods/grounding/utils/saleMode";
export async function getSearchFromSchema(_refreshTableFn) { export async function getSearchFromSchema(_refreshTableFn) {
const refreshTableFn = isFunction(_refreshTableFn) ? _refreshTableFn : () => {}; const refreshTableFn = isFunction(_refreshTableFn) ? _refreshTableFn : () => {};
...@@ -81,6 +82,15 @@ export async function getSearchFromSchema(_refreshTableFn) { ...@@ -81,6 +82,15 @@ export async function getSearchFromSchema(_refreshTableFn) {
keyFn: refreshTableFn, keyFn: refreshTableFn,
}, },
{ {
label: "销售模式",
name: "saleMode",
type: "select",
optionList: cloneDeep(saleModeList),
optionId: "confId",
optionLabel: "confName",
optionsName: "saleModeList",
},
{
label: "状态", label: "状态",
name: "status", name: "status",
type: "select", type: "select",
...@@ -362,6 +372,11 @@ export async function getTableSchema() { ...@@ -362,6 +372,11 @@ export async function getTableSchema() {
}, },
}, },
{ {
label: "销售模式",
prop: "saleMode",
width: 100,
},
{
label: "基础产品供货模式", label: "基础产品供货模式",
prop: "baseSupplyMode", prop: "baseSupplyMode",
width: 150, width: 150,
......
import { getSearchFromSchema, getTableSchema } from "./index.data";
jest.mock("@api/deviceManage", () => ({ getShopMerchantList: jest.fn().mockResolvedValue([]) }));
jest.mock("@api/editCustomer", () => ({ getParkStore: jest.fn().mockResolvedValue([]) }));
jest.mock("@api/product", () => ({ getList: jest.fn().mockResolvedValue({ list: [] }) }));
jest.mock("@api/productManage", () => ({
getAreaDataList: jest.fn(),
getBaseSceneCodeList: jest.fn().mockResolvedValue([]),
}));
jest.mock("@/store", () => ({ dispatch: jest.fn().mockResolvedValue([]) }));
describe("grounding table schema", () => {
it("includes sale mode in search and result columns", async () => {
const searchSchema = await getSearchFromSchema();
const tableSchema = await getTableSchema();
expect(searchSchema.find(item => item.name === "saleMode")).toMatchObject({
type: "select",
optionId: "confId",
});
expect(tableSchema.find(item => item.prop === "saleMode")).toMatchObject({
label: "销售模式",
});
});
});
...@@ -251,6 +251,7 @@ export default { ...@@ -251,6 +251,7 @@ export default {
financeCheckFlag: "", financeCheckFlag: "",
inventoryType: "", inventoryType: "",
productCostType: "", productCostType: "",
saleMode: "",
cityCodeList: [], cityCodeList: [],
}, },
tempGoodsType: [], tempGoodsType: [],
...@@ -459,6 +460,8 @@ export default { ...@@ -459,6 +460,8 @@ export default {
financeCheckFlag: "", financeCheckFlag: "",
inventoryType: "", inventoryType: "",
productCostType: "", productCostType: "",
saleMode: "",
cityCodeList: [],
}; };
this.tempGoodsType = []; this.tempGoodsType = [];
this.applicableAreas = []; this.applicableAreas = [];
......
...@@ -230,9 +230,11 @@ export default { ...@@ -230,9 +230,11 @@ export default {
// 出来form表单显示内容 // 出来form表单显示内容
filterEditForm() { filterEditForm() {
const { copyFormList, formData } = this const { copyFormList, formData } = this
const productFormIndex = this.formList.findIndex(item => item.title === '产品信息')
const copyProductFormIndex = copyFormList.findIndex(item => item.title === '产品信息')
// 1 太阳膜 2 (1.3场景商品) // 1 太阳膜 2 (1.3场景商品)
const shopType = formData?.goodsType == 1 ? '1' : formData?.sceneType == 3 ? '2' : '' const shopType = formData?.goodsType == 1 ? '1' : formData?.sceneType == 3 ? '2' : ''
const shopForm = deepClone(copyFormList[0].formBlock) const shopForm = deepClone(copyFormList[copyProductFormIndex].formBlock)
// 太阳膜保留上架部位字段 positionStr // 太阳膜保留上架部位字段 positionStr
const spliceForm = shopType == '1' const spliceForm = shopType == '1'
? ['giftCost', 'recoveryCost', 'virtualAccountCost', 'djCost', 'thirdPartyCost'] ? ['giftCost', 'recoveryCost', 'virtualAccountCost', 'djCost', 'thirdPartyCost']
...@@ -258,7 +260,7 @@ export default { ...@@ -258,7 +260,7 @@ export default {
// 仅选中基础产品类型 不展示 售价字段 // 仅选中基础产品类型 不展示 售价字段
if (formData.productType?.length == 1 && formData.productType?.includes(1)) spliceForm.push('sellPrice', 'minSellPrice', 'upgradeProductCost', 'upgradeSupplyModeStr') if (formData.productType?.length == 1 && formData.productType?.includes(1)) spliceForm.push('sellPrice', 'minSellPrice', 'upgradeProductCost', 'upgradeSupplyModeStr')
const newForm = shopForm.filter(v => !spliceForm?.includes(v.name)) const newForm = shopForm.filter(v => !spliceForm?.includes(v.name))
this.$set(this.formList[0], 'formBlock', newForm) this.$set(this.formList[productFormIndex], 'formBlock', newForm)
this.$nextTick(() => { this.$nextTick(() => {
this.show = true this.show = true
}) })
......
import { validateStoreRegion } from "@api/grounding";
import GroundingForm from "./groundingForm.vue";
jest.mock("@api/grounding", () => ({
validateStoreRegion: jest.fn(),
}));
jest.mock("@api/serviceManage", () => ({ searchServiceMerchant: jest.fn() }));
jest.mock("glsk-oss-jssdk", () => jest.fn());
jest.mock("./relateStoreDialog.vue", () => ({}));
jest.mock("./relateStoreTable.vue", () => ({}));
jest.mock("../../components/selectGoodsDialog.vue", () => ({}));
jest.mock("../../components/ellipsisPopover.vue", () => ({}));
jest.mock("@/main", () => ({
baseConfig: {
equitySceneType: [],
extendedPosiType: [],
membraneTypeList: [],
},
}));
describe("purchase grounding form", () => {
it("blocks product selection until stores are selected", () => {
const warning = jest.fn();
const context = {
formData: { merchantRefList: [] },
$message: { warning },
selectGoodsVisible: false,
};
GroundingForm.methods.handleSelectGoods.call(context);
expect(warning).toHaveBeenCalledWith("请选择上架商户");
expect(context.selectGoodsVisible).toBe(false);
});
it("rolls stores back when an invalid region confirmation is cancelled", async () => {
validateStoreRegion.mockResolvedValue({
allMatch: false,
invalidUpgradeGoodsIds: [10],
});
const previousStores = [{ merchantId: 1 }];
const context = {
formData: {
upgradeGoodsId: 10,
merchantRefList: [{ merchantId: 2 }],
upgradeGoods: { upgradeGoodsName: "测试产品" },
},
$confirm: jest.fn().mockRejectedValue(new Error("cancel")),
$set(target, key, value) {
target[key] = value;
},
clearPurchaseGoods: jest.fn(),
};
await GroundingForm.methods.validateStoreRegionAfterChange.call(context, {
previousMerchantRefList: previousStores,
revertStoresOnCancel: true,
});
expect(context.formData.merchantRefList).toEqual(previousStores);
expect(context.clearPurchaseGoods).not.toHaveBeenCalled();
});
it("keeps the new stores and clears product data after invalid-region confirmation", async () => {
validateStoreRegion.mockResolvedValue({
allMatch: false,
invalidUpgradeGoodsIds: [10],
});
const context = {
formData: {
upgradeGoodsId: 10,
merchantRefList: [{ merchantId: 2 }],
upgradeGoods: { upgradeGoodsName: "测试产品" },
},
$confirm: jest.fn().mockResolvedValue(),
$set: jest.fn(),
clearPurchaseGoods: jest.fn(),
};
await GroundingForm.methods.validateStoreRegionAfterChange.call(context);
expect(context.clearPurchaseGoods).toHaveBeenCalledTimes(1);
expect(context.formData.merchantRefList).toEqual([{ merchantId: 2 }]);
});
});
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
</el-table-column> </el-table-column>
<el-table-column prop="merchantId" label="商户号" align="center"> <el-table-column prop="merchantId" label="商户号" align="center">
</el-table-column> </el-table-column>
<el-table-column prop="address" label="商户地址" align="center" min-width="160">
</el-table-column>
<el-table-column prop="yqMerchantName" label="商户类型" align="center"> <el-table-column prop="yqMerchantName" label="商户类型" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{merchantClassifyList.find(item => item.confId == scope.row.merchantType).confLabel}}</span> <span>{{merchantClassifyList.find(item => item.confId == scope.row.merchantType).confLabel}}</span>
......
...@@ -17,6 +17,7 @@ import { mapActions } from 'vuex' ...@@ -17,6 +17,7 @@ import { mapActions } from 'vuex'
import { deepClone } from '@/common/util' import { deepClone } from '@/common/util'
import { baseConfig } from '@/main' import { baseConfig } from '@/main'
import { filterSpecsStr, convertYuanToWan } from "../filterOption" import { filterSpecsStr, convertYuanToWan } from "../filterOption"
import { purchaseCostTypeList, resolvePurchasePrice } from "./utils/purchaseCost"
export default { export default {
name: 'EditGrounding', name: 'EditGrounding',
components: { components: {
...@@ -64,6 +65,11 @@ export default { ...@@ -64,6 +65,11 @@ export default {
unit: true unit: true
}, },
{ {
label: '运营成本',
value: 'operationCost',
unit: true
},
{
label: '参考售价', label: '参考售价',
value: 'upgradePrice', value: 'upgradePrice',
unit: true unit: true
...@@ -101,6 +107,15 @@ export default { ...@@ -101,6 +107,15 @@ export default {
value: "purchaseGoodsName" value: "purchaseGoodsName"
}, },
{ {
name: 'purchaseCostType',
label: '采购价带入方式',
type: 'flagRadio',
radioGroupList: purchaseCostTypeList.map(item => ({
label: item.confName,
value: item.confId
}))
},
{
name: 'purchasePrice', name: 'purchasePrice',
label: '采购价', label: '采购价',
type: 'input', type: 'input',
...@@ -164,6 +179,7 @@ export default { ...@@ -164,6 +179,7 @@ export default {
baseSupplyMode: '', baseSupplyMode: '',
upgradeSupplyMode: '', upgradeSupplyMode: '',
purchasePrice: '', purchasePrice: '',
purchaseCostType: 1,
// minSellPrice: '', // minSellPrice: '',
giveCostPrice: '', giveCostPrice: '',
recoveryCostPrice: '', recoveryCostPrice: '',
...@@ -183,6 +199,7 @@ export default { ...@@ -183,6 +199,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.editForm = [this.editForm[1], this.editForm[0]]
this.getBaseData() this.getBaseData()
const id = this.$route.query.id const id = this.$route.query.id
if (!id) { if (!id) {
...@@ -253,6 +270,11 @@ export default { ...@@ -253,6 +270,11 @@ export default {
carTypeConfigName: res?.upgradeGoods?.carTypeConfigList?.map(item => item.seriesName).join('/'), carTypeConfigName: res?.upgradeGoods?.carTypeConfigList?.map(item => item.seriesName).join('/'),
upgradeCommodityCode: res?.upgradeGoods?.commodityCode upgradeCommodityCode: res?.upgradeGoods?.commodityCode
} }
res.purchasePrice = resolvePurchasePrice({
purchaseCostType: res.purchaseCostType,
purchasePrice: res.purchasePrice,
operationCost: res.upgradeGoods?.operationCost
})
this.editData = res || {} this.editData = res || {}
this.$nextTick(() => { this.$nextTick(() => {
this.show = true this.show = true
......
...@@ -17,6 +17,7 @@ import { deepClone, Util } from '@/common/util' ...@@ -17,6 +17,7 @@ import { deepClone, Util } from '@/common/util'
import { productList, baseSupplyModeList, upgradeSupplyModeList, crowdUpgradeSupplyModeList } from './constants/data' import { productList, baseSupplyModeList, upgradeSupplyModeList, crowdUpgradeSupplyModeList } from './constants/data'
import { baseConfig } from "@/main" import { baseConfig } from "@/main"
import { filterSpecsStr, convertYuanToWan } from '../filterOption' import { filterSpecsStr, convertYuanToWan } from '../filterOption'
import { getPurchaseCostTypeText } from './utils/purchaseCost'
export default { export default {
name: 'purchaseOnShelvesGroundingDetail', name: 'purchaseOnShelvesGroundingDetail',
components: { components: {
...@@ -115,6 +116,19 @@ export default { ...@@ -115,6 +116,19 @@ export default {
handleInput: true handleInput: true
}, },
{ {
name: 'operationCost',
label: '产品运营成本',
type: 'input',
width: '432px',
unit: true
},
{
name: 'purchaseCostTypeStr',
label: '采购价带入方式',
type: 'input',
width: '432px'
},
{
name: 'suitCarType', name: 'suitCarType',
label: '适用车型', label: '适用车型',
type: 'flagRadio', type: 'flagRadio',
...@@ -255,6 +269,7 @@ export default { ...@@ -255,6 +269,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.editForm = [this.editForm[1], this.editForm[0], this.editForm[2]]
this.getBaseData() this.getBaseData()
// 获取商品详情 // 获取商品详情
const id = this.$route.query.id const id = this.$route.query.id
...@@ -318,6 +333,8 @@ export default { ...@@ -318,6 +333,8 @@ export default {
carTypeConfigName: res?.upgradeGoods?.carTypeConfigList?.map(item => item.seriesName).join('/'), carTypeConfigName: res?.upgradeGoods?.carTypeConfigList?.map(item => item.seriesName).join('/'),
upgradeCommodityCode: res?.upgradeGoods?.commodityCode upgradeCommodityCode: res?.upgradeGoods?.commodityCode
} }
res.operationCost = res.upgradeGoods?.operationCost
res.purchaseCostTypeStr = getPurchaseCostTypeText(res.purchaseCostType)
const { commodityCode, upgradeGoodsName } = res.upgradeGoods const { commodityCode, upgradeGoodsName } = res.upgradeGoods
res.commodityCode = commodityCode res.commodityCode = commodityCode
res.upgradeGoodsName = upgradeGoodsName res.upgradeGoodsName = upgradeGoodsName
......
...@@ -45,6 +45,10 @@ ...@@ -45,6 +45,10 @@
<span style="display: inline-block;margin-left: 10px;"> <span style="display: inline-block;margin-left: 10px;">
<auth-button category="Button" :show-btn-ids="['9031402']" /> <auth-button category="Button" :show-btn-ids="['9031402']" />
</span> </span>
<!-- 批量修改采购价 -->
<span style="display: inline-block;margin-left: 10px;">
<auth-button category="Button" :show-btn-ids="['9031412']" />
</span>
</d2-table-header> </d2-table-header>
<d2-table ref="groundingIndexTable" :has-num="false" :search-form="searchForm" :table-params="tableParams" <d2-table ref="groundingIndexTable" :has-num="false" :search-form="searchForm" :table-params="tableParams"
:get-list-api="getListApi" :before-search-fn="beforeSearchFn" :selectable-fn="selectableFn" :get-list-api="getListApi" :before-search-fn="beforeSearchFn" :selectable-fn="selectableFn"
...@@ -119,6 +123,15 @@ ...@@ -119,6 +123,15 @@
</batch-copy-dialog> </batch-copy-dialog>
<d2-file-import-dialog :is-visible="fileVisible" title="上传文件" @closeDialog="handleBatchImport" <d2-file-import-dialog :is-visible="fileVisible" title="上传文件" @closeDialog="handleBatchImport"
@confirmDialog="handleConfirmImport" @downloadTemplate="exportTemplate" /> @confirmDialog="handleConfirmImport" @downloadTemplate="exportTemplate" />
<d2-dialog title="批量修改采购价" width="480px" :is-visible="batchPriceVisible"
@closeDialog="handleBatchPriceClose" @confirmDialog="handleBatchPriceConfirm">
<el-form ref="batchPriceForm" :model="batchPriceForm" :rules="batchPriceRules" label-width="100px">
<el-form-item label="采购价:" prop="purchasePrice">
<el-input-number v-model="batchPriceForm.purchasePrice" :min="0" :max="999999.99" :precision="2"
:step="1" controls-position="right" style="width: 300px;" />
</el-form-item>
</el-form>
</d2-dialog>
</d2-container> </d2-container>
</template> </template>
<script> <script>
...@@ -127,7 +140,8 @@ import { getList, getAllCategory } from '@api/product' ...@@ -127,7 +140,8 @@ import { getList, getAllCategory } from '@api/product'
import { import {
purchaseGoodsInfoPage as getGroundingManageList, purchaseGoodsInfoUpdateStatus as updateGoodsStatus, purchaseGoodsInfoUpdateBatchWaitAudit as batchReviewAPI, purchaseGoodsInfoPage as getGroundingManageList, purchaseGoodsInfoUpdateStatus as updateGoodsStatus, purchaseGoodsInfoUpdateBatchWaitAudit as batchReviewAPI,
purchaseGoodsInfoDeleteById as delGroundingById, purchaseGoodsInfoUpdateBatchOffShelf as batchUpdateStatus, purchaseGoodsInfoDeleteById as delGroundingById, purchaseGoodsInfoUpdateBatchOffShelf as batchUpdateStatus,
batchUpdateBatchCopy, batchSetValidMinSellPrice, purchaseGoodsInfoImport as groundingImport batchUpdateBatchCopy, batchSetValidMinSellPrice, purchaseGoodsInfoImport as groundingImport,
purchaseGoodsInfoUpdateBatchPrice
} from '@api/grounding' } from '@api/grounding'
import { deepClone, Util } from '@/common/util' import { deepClone, Util } from '@/common/util'
import { sceneCodeList, sceneList, BaseData } from '@/common/constants.js' import { sceneCodeList, sceneList, BaseData } from '@/common/constants.js'
...@@ -135,6 +149,7 @@ import { getParkStore } from '@api/editCustomer' ...@@ -135,6 +149,7 @@ import { getParkStore } from '@api/editCustomer'
import { mapActions, mapState, mapMutations } from 'vuex' import { mapActions, mapState, mapMutations } from 'vuex'
import { baseConfig } from '@/main' import { baseConfig } from '@/main'
import batchCopyDialog from './components/batchCopyDialog.vue' import batchCopyDialog from './components/batchCopyDialog.vue'
import { getPurchaseCostTypeText, purchaseCostTypeList } from './utils/purchaseCost'
export default { export default {
components: { batchCopyDialog }, components: { batchCopyDialog },
name: 'PurchaseOnShelves', name: 'PurchaseOnShelves',
...@@ -157,7 +172,8 @@ export default { ...@@ -157,7 +172,8 @@ export default {
goodsSource: 0, goodsSource: 0,
financeCheckFlag: '', financeCheckFlag: '',
thirdPartyName: '', thirdPartyName: '',
thirdPartyCode: '' thirdPartyCode: '',
purchaseCostType: ''
}, },
tempGoodsType: [], tempGoodsType: [],
getListApi: getGroundingManageList, getListApi: getGroundingManageList,
...@@ -260,6 +276,14 @@ export default { ...@@ -260,6 +276,14 @@ export default {
type: 'input', type: 'input',
isClear: true, isClear: true,
keyFn: this.keyDowmGetList keyFn: this.keyDowmGetList
}, {
label: '采购价带入方式',
name: 'purchaseCostType',
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confName',
optionsName: 'purchaseCostTypeList'
} }
// { // {
// label: '财务校验', // label: '财务校验',
...@@ -334,6 +358,12 @@ export default { ...@@ -334,6 +358,12 @@ export default {
} }
}, },
{ {
label: '采购价带入方式',
prop: 'purchaseCostType',
width: 160,
formatter: cellValue => getPurchaseCostTypeText(cellValue.purchaseCostType)
},
{
label: '产品ID', label: '产品ID',
prop: 'commodityCode', prop: 'commodityCode',
parentProp: 'upgradeGoods', parentProp: 'upgradeGoods',
...@@ -519,13 +549,21 @@ export default { ...@@ -519,13 +549,21 @@ export default {
}, { }, {
confId: 'N', confId: 'N',
confValue: '关闭' confValue: '关闭'
}] }],
purchaseCostTypeList: deepClone(purchaseCostTypeList)
}, },
selfBuildGoodsType: baseConfig.selfBuildGoodsType || '', selfBuildGoodsType: baseConfig.selfBuildGoodsType || '',
batchCopySelectScene: '', // 批量复制选中的场景值 batchCopySelectScene: '', // 批量复制选中的场景值
batchCopyVisible: false, batchCopyVisible: false,
batchCopySelectData: [], // 批量辅助选中的上架数据 batchCopySelectData: [], // 批量辅助选中的上架数据
fileVisible: false fileVisible: false,
batchPriceVisible: false,
batchPriceForm: {
purchasePrice: undefined
},
batchPriceRules: {
purchasePrice: [{ required: true, message: '请输入采购价', trigger: 'blur' }]
}
} }
}, },
mounted() { mounted() {
...@@ -740,7 +778,8 @@ export default { ...@@ -740,7 +778,8 @@ export default {
status: '', status: '',
yqMerchantId: '', yqMerchantId: '',
goodsSource: 0, goodsSource: 0,
financeCheckFlag: '' financeCheckFlag: '',
purchaseCostType: ''
} }
this.tempGoodsType = [] this.tempGoodsType = []
// 重新查询 // 重新查询
...@@ -788,7 +827,7 @@ export default { ...@@ -788,7 +827,7 @@ export default {
}) })
}, },
handleExport() { handleExport() {
var params = this.searchForm var params = deepClone(this.searchForm)
params.method = 'dj.api.smartcarlife.purchaseGoodsInfo.export.async' params.method = 'dj.api.smartcarlife.purchaseGoodsInfo.export.async'
const list = [ const list = [
...this.dowloadList, ...this.dowloadList,
...@@ -801,6 +840,34 @@ export default { ...@@ -801,6 +840,34 @@ export default {
] ]
this.actionSetDownloadList({ list, type: 'dowloadList' }) this.actionSetDownloadList({ list, type: 'dowloadList' })
}, },
getSelectedRows() {
return this.$refs.groundingIndexTable?.mutiSelectArr?.groundingIndex || []
},
handleBatchModifyPrice() {
if (!this.getSelectedRows().length) {
return this.$message.warning('请选择需要修改采购价的记录')
}
this.batchPriceVisible = true
},
handleBatchPriceClose() {
this.batchPriceVisible = false
this.batchPriceForm.purchasePrice = undefined
this.$refs.batchPriceForm?.clearValidate()
},
handleBatchPriceConfirm() {
this.$refs.batchPriceForm.validate(valid => {
if (!valid) return
const ids = this.getSelectedRows().map(item => item.id)
purchaseGoodsInfoUpdateBatchPrice({
ids,
purchasePrice: this.batchPriceForm.purchasePrice
}).then(() => {
this.notice.okTips()
this.handleBatchPriceClose()
this.$refs.groundingIndexTable.refreshTable()
})
})
},
// 校验是否为空 不包含0 // 校验是否为空 不包含0
filterEmpty(data) { filterEmpty(data) {
return data instanceof Array ? data.length <= 0 : (data ?? '') === '' return data instanceof Array ? data.length <= 0 : (data ?? '') === ''
......
export const PURCHASE_COST_TYPE_CUSTOM = 0;
export const PURCHASE_COST_TYPE_AUTO = 1;
export const purchaseCostTypeList = [
{ confId: PURCHASE_COST_TYPE_AUTO, confName: "默认带入产品成本" },
{ confId: PURCHASE_COST_TYPE_CUSTOM, confName: "自定义成本" },
];
export function isAutoPurchaseCostType(value) {
return Number(value) === PURCHASE_COST_TYPE_AUTO;
}
export function hasOperationCost(value) {
return value !== "" && value !== null && value !== undefined;
}
export function resolvePurchasePrice({ purchaseCostType, purchasePrice, operationCost }) {
return isAutoPurchaseCostType(purchaseCostType) ? operationCost : purchasePrice;
}
export function getPurchaseCostTypeText(value) {
return Number(value) === PURCHASE_COST_TYPE_CUSTOM ? "自定义成本" : "默认带入产品成本";
}
import {
getPurchaseCostTypeText,
hasOperationCost,
resolvePurchasePrice,
} from "./purchaseCost";
describe("purchase cost mode", () => {
it("uses the precise SKU operation cost in automatic mode", () => {
expect(resolvePurchasePrice({
purchaseCostType: 1,
purchasePrice: 20,
operationCost: 36.8,
})).toBe(36.8);
});
it("keeps the current price in custom mode", () => {
expect(resolvePurchasePrice({
purchaseCostType: 0,
purchasePrice: 20,
operationCost: 36.8,
})).toBe(20);
});
it("treats zero as a maintained operation cost", () => {
expect(hasOperationCost(0)).toBe(true);
expect(hasOperationCost("")).toBe(false);
});
it("maps cost modes to display text", () => {
expect(getPurchaseCostTypeText(0)).toBe("自定义成本");
expect(getPurchaseCostTypeText("1")).toBe("默认带入产品成本");
});
});
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
inactive-value="0"> inactive-value="0">
</el-switch> </el-switch>
</template> </template>
<template #lowPriceOrder>
<el-switch v-model="searchForm.lowPriceFlag" active-color="#2A58AD" active-value="1"
inactive-value="0">
</el-switch>
</template>
</d2-search> </d2-search>
<div class="up-btns"> <div class="up-btns">
<el-button size="small" type="primary" @click="handleSearch"> <el-button size="small" type="primary" @click="handleSearch">
...@@ -174,11 +179,11 @@ ...@@ -174,11 +179,11 @@
<auth-button v-if="scope.row.profitAllocationStatus == 5" :data="scope.row" :show-btn-ids="['9040107']" /> <auth-button v-if="scope.row.profitAllocationStatus == 5" :data="scope.row" :show-btn-ids="['9040107']" />
<div> <div>
<!-- 通过 --> <!-- 通过 -->
<auth-button v-if="scope.row.canApplyFlag == 1" :data="scope.row" :show-btn-ids="['9040147']" /> <auth-button v-if="scope.row.canApplyFlag == 1 || approveAuthFlag" :data="scope.row" :show-btn-ids="['9040147']" />
</div> </div>
<div> <div>
<!-- 驳回 --> <!-- 驳回 -->
<auth-button v-if="scope.row.canApplyFlag == 1" :data="scope.row" :show-btn-ids="['9040148']" /> <auth-button v-if="scope.row.canApplyFlag == 1 || rejectAuthFlag" :data="scope.row" :show-btn-ids="['9040148']" />
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
...@@ -578,6 +583,10 @@ export default { ...@@ -578,6 +583,10 @@ export default {
label: "我的待审", label: "我的待审",
addHtml: "myPendingReview", addHtml: "myPendingReview",
}, },
{
label: "仅查看低价订单",
addHtml: "lowPriceOrder",
},
], ],
searchForm: { searchForm: {
sceneType: 1, sceneType: 1,
...@@ -605,6 +614,7 @@ export default { ...@@ -605,6 +614,7 @@ export default {
djOrderType: "", djOrderType: "",
goodsOrderApplyStatus: "", goodsOrderApplyStatus: "",
myWaitApplySwitch: 0, myWaitApplySwitch: 0,
lowPriceFlag: 0,
}, },
baseData: { baseData: {
orderStatusList: [ orderStatusList: [
...@@ -756,6 +766,8 @@ export default { ...@@ -756,6 +766,8 @@ export default {
totalCount: "", totalCount: "",
jurisdictionFlag: false, // 待补录按钮权限标识 jurisdictionFlag: false, // 待补录按钮权限标识
signRefundFlag: false, // 标记退款权限标识 signRefundFlag: false, // 标记退款权限标识
approveAuthFlag: false, // 通过按钮权限标识
rejectAuthFlag: false, // 驳回按钮权限标识
subShopMerchanShowHide: true, subShopMerchanShowHide: true,
ruleVisible: false, ruleVisible: false,
recordInfo: null, recordInfo: null,
...@@ -893,6 +905,14 @@ export default { ...@@ -893,6 +905,14 @@ export default {
if (signRefundItem) { if (signRefundItem) {
this.signRefundFlag = true; // 是否有标记退款权限 this.signRefundFlag = true; // 是否有标记退款权限
} }
const approveItem = $store.find(i => i.authId === "9040147");
const rejectItem = $store.find(i => i.authId === "9040148");
if (approveItem) {
this.approveAuthFlag = true;
}
if (rejectItem) {
this.rejectAuthFlag = true;
}
this.getBaseData(); this.getBaseData();
const hasCustomerFilter = this.customerFilter const hasCustomerFilter = this.customerFilter
&& (this.customerFilter.customerName || this.customerFilter.customerPhone); && (this.customerFilter.customerName || this.customerFilter.customerPhone);
...@@ -973,6 +993,7 @@ export default { ...@@ -973,6 +993,7 @@ export default {
djOrderType: "", djOrderType: "",
goodsOrderApplyStatus: "", goodsOrderApplyStatus: "",
myWaitApplySwitch: 0, myWaitApplySwitch: 0,
lowPriceFlag: 0,
}; };
this.tempGoodsType = []; this.tempGoodsType = [];
// this.baseData.storeIdList = [] // this.baseData.storeIdList = []
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!