Commit 4e41ff3a by Jaxon

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

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