Commit 4e41ff3a by Jaxon

feat(商品上架): 上架商品/套餐确认 - 初步联调

1 parent ecd329f1
......@@ -133,9 +133,9 @@ export default {
packageSelectIds: {},
// 嘀加上架所需 - 业务场景
// 0 为之前的 逻辑默认值
sceneType: {
type: Number,
default: 0,
baseSceneCode: {
type: String,
default: "",
},
// 用于嘀加上架获取商品时过滤只筛选出权益和延保类
filterParams: {
......@@ -326,9 +326,9 @@ export default {
},
beforeSearchFn() {
return new Promise((resolve) => {
// 嘀加上架获取商品时 过滤 只 筛选出权益和延保类
// TODO: 改sceneType的判断 嘀加上架获取商品时 过滤 只 筛选出权益和延保类
if (this.filterParams.length > 0) {
this.searchForm[this.sceneType === 1 ? "excludeGoodsTypeList" : "goodsTypeList"] = this.filterParams;
this.searchForm[this.baseSceneCode === 1 ? "excludeGoodsTypeList" : "goodsTypeList"] = this.filterParams;
}
resolve();
});
......
......@@ -41,18 +41,22 @@ export function getTrafficSourceListApi(data) {
// 获取商品/套餐列表
export function getProductPackagesListApi(data) {
data.method = "dj.api.goods.listing.product.page";
return mockRequest(data, RequestMethods.POST);
return request(data, RequestMethods.POST);
}
// 获取商品/套餐详情
export function getProductPackagesDetailApi(data) {
data.method = "dj.api.goods.listing.product.getDetailById";
return mockRequest(data, RequestMethods.POST);
return request(data, RequestMethods.POST);
}
// 新增 商品 / 套餐
export function postProductPackagesApi(data) {
data.method = "dj.api.goods.listing.product.insertOrUpdate";
return request(data, RequestMethods.POST);
}
// 放到 commondity.js 里 分页查询 商户列表-带关联关系
export function getMerchantListApi1(data) {
data.method = "dj.api.scenemerchantref.findAllMerchantPage";
return mockRequest(data, RequestMethods.POST);
export function delProductPackagesApi(data) {
data.method = "dj.api.goods.listing.product.delete";
return request(data, RequestMethods.POST);
}
// 分页查询 商户列表-带关联关系
......
......@@ -32,7 +32,7 @@ export default {
},
isCreate(id) {
return String(id).startsWith(this.$data._prefixId);
return String(id).startsWith(this.$data._prefix);
},
getEditState() {
return this.editState;
......@@ -47,6 +47,7 @@ export default {
if (this.editState !== VIEW_MODE.VIEW)
return;
// 缓存数据
console.log("得到数据 -> this.getData()", this.getData());
this.editCache = cloneDeep(this.getData());
this.editState = VIEW_MODE.EDIT;
......@@ -73,10 +74,8 @@ export default {
cancelEdit() {
if (this.editState !== VIEW_MODE.EDIT)
return;
if (this.editCache) {
this.setData(this.editCache);
}
this.setData(this.editCache);
this.editState = VIEW_MODE.VIEW;
this.editCache = null;
},
......
......@@ -7,7 +7,7 @@
class="product-detail-wrapper">
<Product :product="productData"
:edit-state="VIEW_MODE.VIEW"
:scene-type="sceneType"
:base-scene-code="baseSceneCode"
:show-business-line="false"
:show-sales-proportion-percent="false"
:show-settlement-type="false"
......@@ -36,8 +36,8 @@ export default {
type: Object,
default: () => ({ }),
},
sceneType: {
type: Number,
baseSceneCode: {
type: String,
required: true,
},
},
......
......@@ -145,7 +145,7 @@
:product.sync="goodsForm"
:edit-state="VIEW_MODE.EDIT"
:disabled-ids="packageSelectedGoodsIds"
:scene-type="sceneType"
:base-scene-code="baseSceneCode"
:show-gift-cost="false"
:show-business-line="false"
:show-sales-proportion-percent="false"
......@@ -176,10 +176,14 @@ export default {
Product,
},
props: {
sceneType: {
type: Number,
baseSceneCode: {
type: String,
required: true,
},
prefix: {
type: String,
default: "create-",
},
packages: {
type: Object,
default: () => ({ }),
......@@ -276,7 +280,7 @@ export default {
//
handleAppendProduct() {
this.packageForm.detailList?.unshift({
id: nanoid(),
id: this.prefix + nanoid(),
sellPrice: 0,
minSellPrice: 0,
thirdPartyCost: 0,
......@@ -330,7 +334,13 @@ export default {
}
await ref.validate();
}
return this.packageForm;
return {
...this.packageForm,
detailList: this.packageForm.detailList.map(item => ({
...item,
upgradeGoods: undefined,
})),
};
},
submitValidate() {
......
......@@ -22,20 +22,27 @@
删除
</el-button>
</div>
<div v-if="product.upgradeGoodsId" class="info-div">
<div v-if="product.upgradeGoodsId || product.detailList[0].upgradeGoodsId" class="info-div">
<Descriptions class="sub-desc-wrapper"
:data="product"
:schema="productShelvingProductDetailSubFormItems" />
</div>
</el-form-item>
</el-col>
<!-- <el-col :span="12">
<el-form-item label="商品名称:" prop="productName">
<el-input v-model="product.productName" placeholder="请输入商品名称" />
</el-form-item>
</el-col> -->
<!-- v-if="isSolarFilm(formData.goodsType)" -->
<el-col :span="12">
<el-form-item label="上架部位:" prop="detailList[0].position">
<el-select v-model="product.detailList[0].position"
placeholder="请选择">
<template v-for="item in options.position">
<el-option v-if="product.detailList[0].upgradeGoods.positionList.includes(item.position)"
<el-option v-if="showPositionItem(item.position)"
:key="item.position"
:label="item.confName"
:value="item.position">
......@@ -200,7 +207,7 @@
</el-form>
<SelectGoodsDialog v-if="dialog.selectGoods.show"
append-to-body
:scene-type="sceneType"
:base-scene-code="baseSceneCode"
:package-select-ids="disabledIds"
:filter-params="dialog.selectGoods.filterParams"
:select-goods-visible="dialog.selectGoods.show"
......@@ -236,8 +243,8 @@ export default {
type: Object,
required: true,
},
sceneType: {
type: Number,
baseSceneCode: {
type: String,
required: true,
},
// 当套餐加载这个组件的时候 不需要业务线
......@@ -315,10 +322,14 @@ export default {
isMemberRightsUpgrade,
isQualityUpgrade,
isSolarFilm,
showPositionItem(position) {
return this.product?.detailList[0]?.upgradeGoods?.positionList?.includes(position);
},
handleRemove() {
this.$emit("remove");
},
async initOptions() {
console.log("product init", BaseData.positionTypeList);
this.options.position = await this.get(BaseData.positionTypeList);
},
......@@ -341,27 +352,14 @@ export default {
await this.$refs.formRef.validate();
// 如果校验不通过不会往下执行
return {
// 新增时,这里是空的
id: this.product?.id,
upgradeGoodsId: this.product.upgradeGoodsId,
goodsAlias: this.product.goodsAlias,
businessLine: this.product.businessLine,
sellPrice: this.product.sellPrice,
minSellPrice: this.product.minSellPrice,
djCost: this.product.djCost,
thirdPartyCost: this.product.thirdPartyCost,
settlementType: this.product.settlementType,
salesProportionPercent: this.product.salesProportionPercent,
// 部位
position: this.product.position,
// 渗透率
penetrationRate: this.product.penetrationRate,
// 升级成本
upgradeProductCost: this.product.upgradeProductCost,
// 赠送成本
giftCost: this.product.giftCost,
// 回收成本
recoveryCost: this.product.recoveryCost,
...this.product,
detailList: [
{
...this.product.detailList[0],
upgradeGoodsId: this.product.detailList[0].upgradeGoods.id,
upgradeGoods: undefined,
},
],
};
},
},
......
......@@ -91,14 +91,15 @@
ref="productRefs"
:key="tabsActive"
:edit-state="editState"
:scene-type="sceneType"
:base-scene-code="baseSceneCode"
:product="productDetail || { detailList: [] }"
@update:upgradeGoods="handleProductUpdateUpgradeGoods" />
<Combo v-if="productDetail.productType === 2"
ref="packageRefs"
:key="tabsActive"
:prefix="$data._prefix"
:edit-state="editState"
:scene-type="sceneType"
:base-scene-code="baseSceneCode"
:shelf-type="shelfType"
:packages="productDetail || { detailList: [] }" />
</div>
......@@ -115,19 +116,16 @@
</template>
<script>
import {
delProductPackagesApi,
getGoodsDetail,
getProductPackagesApi,
getProductPackagesListApi,
postPackageApi,
postProductApi,
} from "@api/shelfManage.js";
import { cloneDeep, isArray, isEmpty, remove } from "lodash-es";
import { nanoid } from "nanoid";
import RemoteSelect from "@/components/remoteSearchSelect/index.vue";
import { syncTime } from "@/libs/sleep.js";
import { getProductPackagesDetailApi } from "@/views/goods/shelfProduct/api/index.js";
import {
delProductPackagesApi,
getProductPackagesDetailApi,
getProductPackagesListApi,
postProductPackagesApi,
} from "@/views/goods/shelfProduct/api/index.js";
import { VIEW_MODE } from "@/views/goods/shelfProduct/constant/index.js";
import { isEdit, isMemberRightsUpgrade, isQualityUpgrade, isSolarFilm, isView } from "@/views/goods/shelfProduct/utils/status.js";
import FormProvideItemMixin from "../formProvider/formItemMixin.js";
......@@ -149,16 +147,13 @@ export default {
type: Boolean,
default: true,
},
shelveId: {
type: [String, Number],
required: true,
},
businessCode: {
type: String,
required: true,
},
sceneType: {
type: Number,
baseSceneCode: {
type: String,
required: true,
},
shelfType: {
......@@ -199,7 +194,7 @@ export default {
},
// mixin
setData(cache) {
Object.assign(this.productDetail, cache);
this.$set(this, "productDetail", cache);
},
async handleTitleSelectChange(id) {
if (!id) {
......@@ -254,14 +249,80 @@ export default {
// 获取 某个商品/套餐 详情
async getProductPackageDetail(id) {
return await getProductPackagesDetailApi({ id });
const detail = await getProductPackagesDetailApi({ id });
if (detail.productType === 1) {
// 商品在这个层级依赖
detail.upgradeGoodsId = detail.detailList[0].upgradeGoodsId;
}
return detail;
},
// mixin
// 点击保存按钮
async handleSave() {
async handleSave({
changeMode = true,
useMessage = true,
} = {}) {
const form = await this.validate();
const isCreate = this.isCreate(form.id);
const req = {
...form,
productType: this.productDetail.productType,
businessCode: this.businessCode,
detailList: form.detailList.map((item) => {
return {
...item,
id: this.isCreate(item.id) ? undefined : item.id,
};
}),
id: isCreate ? undefined : form.id,
};
console.log(req);
const { id } = await postProductPackagesApi(req);
if (id) {
const newDetail = await this.getProductPackageDetail(id);
const { list } = await getProductPackagesListApi({ id, businessCode: this.businessCode });
if (!list || !list.length) {
console.log("没有返回新的行");
return;
}
const newRow = list[0];
if (isCreate) {
// 有值 为 修改
const index = this.tabs.list.findIndex(item => item.id === req.id);
if (index === -1) {
return;
}
this.$set(this.tabs.list, index, newRow);
} else {
// 空值 为 新增
// id 由临时 nanoid- 改为正式id 所以要多做一些步骤
// tabs list 先 push 接口返回的 存储好的id
this.tabs.list.unshift(newRow);
// 删掉新增时 临时存的
const index = this.tabs.list.findIndex(item => item.id === this.tabsActive);
this.tabs.list.splice(index, 1);
this.tabs.active = newRow.id;
// 通过现有 nanoid 找到对应index 删掉
// 设置 active值
}
this.$refs.remoteSelectRef.forceUpdate();
console.log(form);
// // 根据id 修改 productName
// await this.$refs.remoteSelectRef.getApi(false);
this.productDetail = newDetail;
this.handleChangeIntegrity(this.tabsActive, "Y");
if (useMessage) {
this.$message({
message: "保存成功",
type: "success",
});
}
if (changeMode) {
this.mode = VIEW_MODE.VIEW;
}
}
// /dj.api.goods.listing.product.insertOrUpdate/1.0.0
},
handleChangeEditState() {
if (this.editState === VIEW_MODE.VIEW) {
......@@ -290,10 +351,7 @@ export default {
if (!this.isCreate(row.id)) {
// TODO: 更新接口
// 这是在库里的, 需要执行接口
await delProductPackagesApi({
id: row.id,
businessCode: this.businessCode,
});
await delProductPackagesApi({ id: row.id });
}
// 其他情况直接操作数组删除
// 查找对应的 项 并删掉
......@@ -325,35 +383,30 @@ export default {
// 如果没有长度了 active赋为undefined(清空)
// 然后清空detail
this.tabs.active = undefined;
this.productDetail = {};
this.productDetail = undefined;
this.$refs.remoteSelectRef.forceUpdate();
},
// 获取头部的select选择项
async getTitleOptions({ pageQuery, isImmediate }) {
return await this.withLoading(async () => {
const { list, pages } = await getProductPackagesListApi({
businessCode: "CG202604241141251498",
productName: pageQuery.searchValue,
...pageQuery,
});
if (isImmediate) {
if (list && list.length) {
const { list, pages } = await getProductPackagesListApi({
businessCode: this.businessCode,
productName: pageQuery.searchValue,
...pageQuery,
});
if (isImmediate) {
if (list && list.length) {
// 这个id不代表商品或套餐id.仅做唯一值用
this.tabs.active = list[0]?.id;
await this.$nextTick();
await this.handleTitleSelectChange(this.tabsActive, true);
}
}
for (const item of list) {
item.productName = item.upgradeGoodsName || item.packageName;
this.tabs.active = list[0]?.id;
await this.$nextTick();
await this.handleTitleSelectChange(this.tabsActive, true);
}
pageQuery.pages = pages;
return {
list,
query: pageQuery,
};
});
}
pageQuery.pages = pages;
return {
list,
query: pageQuery,
};
},
// productType === 1 商品时, 需要处理 upgradeGoods的更新
......@@ -364,33 +417,31 @@ export default {
// 新增按钮
async handleAppendProductPackages(command) {
await this.withLoading(async () => {
if (!isArray(this.tabs.list)) {
this.tabs.list = [];
}
const defaultData = {
goodsDefaultForm: { productType: 1, productName: "新增的商品" },
packagesDefaultForm: { productType: 2, productName: "新增的套餐" },
};
const form = {
...cloneDeep(defaultForm),
...defaultData[command],
};
if (command === "packagesDefaultForm") {
form.detailList = [];
}
const packageItem = {
productName: form.productName,
id: `${this.$data._prefixId}${nanoid()}`,
};
this.startEdit();
await this.$nextTick();
this.tabs.list.unshift(packageItem);
this.tabs.active = packageItem.id;
this.productDetail = {
...packageItem,
...form,
};
if (!isArray(this.tabs.list)) {
this.tabs.list = [];
}
const defaultData = {
goodsDefaultForm: { productType: 1, productName: "新增的商品" },
packagesDefaultForm: { productType: 2, productName: "新增的套餐" },
};
const form = {
...cloneDeep(defaultForm),
...defaultData[command],
};
if (command === "packagesDefaultForm") {
form.detailList = [];
}
const packageItem = {
productName: form.productName,
id: `${this.$data._prefix}${nanoid()}`,
};
this.startEdit();
await this.$nextTick();
this.tabs.list.unshift(packageItem);
this.tabs.active = packageItem.id;
this.$set(this, "productDetail", {
...form,
...packageItem,
});
},
......
......@@ -44,7 +44,6 @@ export const goodsDefaultForm = {
export const defaultForm = {
sceneType: undefined,
id: undefined,
productName: undefined,
packageAlias: undefined,
businessLine: undefined,
......@@ -54,7 +53,7 @@ export const defaultForm = {
sellPrice: undefined,
minSellPrice: undefined,
djCost: undefined,
thirdPartyCost: "",
thirdPartyCost: undefined,
upgradeProductCost: undefined,
recoveryCost: undefined,
detailList: [
......
......@@ -16,19 +16,18 @@
<el-step title="5、利润率测算"></el-step>
</el-steps>
</div>
<div v-loading="data.globalLoading" class="wrapper">
<div v-loading="data.isProviderLoading" class="wrapper">
<FormStep name="ProductImport" :on-submit="handleSubmitProductImport">
<ShelfProductImport ref="shelfProductImportRef" @handleNext="handleNextProductImport()" />
</FormStep>
<FormStep v-loading="data.isStepLoading" name="ProductConfirm">
<ShelfProductConfirm business-code="CG202604241141251498"
:scene-type="0"
:shelf-type="1"
:shelve-id="1545" />
<ShelfProductConfirm business-code="GL202604281514047652"
base-scene-code="100101"
:shelf-type="1" />
</FormStep>
<FormStep v-loading="data.isStepLoading" name="ProfitSharingConfig">
<ProfitSharingConfig business-code="CG202604241141251498"
:scene-type="0"
<ProfitSharingConfig business-code="GL202604281514047652"
base-scene-code="100101"
:shelf-type="1"
:shelve-id="1545" />
</FormStep>
......@@ -108,7 +107,7 @@ export default {
data() {
return {
step: {
confirmStep: 0,
confirmStep: 1,
},
// 第一步轮训用的 , null || Fn, 为Fn时, 执行即取消轮训
polling: null,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!