Commit 74922c38 by Jaxon

feat(商品上架): 完善批量上架流程并优化组件交互

1 parent 414d6eac
......@@ -169,6 +169,12 @@ export default {
/* ========= 校验 ========= */
async validate(group) {
if (this.isEditing) {
throw new Error("请先保存当前编辑项");
}
if (this.isSaving) {
throw new Error("正在保存,请稍后");
}
const items = this.getItems(group);
for (const item of items) {
if (item.validate) {
......@@ -206,8 +212,6 @@ export default {
// 👉 1. 提交前:设置当前步骤 loading 为 true
this.$set(this.stepLoadingMap, group, true);
console.log("stepLoadingMap", this.stepLoadingMap);
console.log("stepSubmitting", this.stepSubmitting);
try {
const res = await step.onSubmit(payload, this.formData);
if (res && typeof res === "object") {
......@@ -219,28 +223,26 @@ export default {
this.$set(this.stepLoadingMap, group, false);
}
},
/* ========= 下一步(核心) ========= */
/**
* 下一步(校验 + 提交)
* @returns {Promise<void>}
*/
async next() {
async next({ next = true } = {}) {
if (this.isEditing) {
throw new Error("请先保存当前编辑项");
}
if (this.isSaving) {
throw new Error("正在保存,请稍后");
}
const step = this.steps[this.currentStep];
console.log("step", step);
await this.validate(step.name);
await this.submitStep(step.name);
// this.$emit("stepChange", this.currentStep + 1);
if (next) {
this.$emit("stepChange", this.currentStep + 1);
}
},
/**
* 上一步
*/
......
<template>
<div class="">
<div class="detail-wrapper">
<Descriptions :data="data" :schema="schema" />
</div>
</template>
<script>
import Descriptions from "@/components/descriptions/index.vue";
import { getShelfProductImportSchema } from "@/views/goods/shelfProduct/components/shelfProductImport/shelfProductImport.data";
export default {
name: "",
components: {
Descriptions,
},
props: {
data: {
type: Object,
default: () => ({}),
},
},
data() {
return {
schema: [],
};
},
computed: {
},
mounted() {
},
methods: {
async mounted() {
this.schema = await getShelfProductImportSchema();
},
};
</script>
<style scoped lang="scss">
</style>
......@@ -6,7 +6,7 @@
class="starting-wrapper">
<el-progress stroke-linecap="square"
type="circle"
width="80"
:width="80"
color="#2A58AD"
:percentage="percentage">
</el-progress>
......
<template>
<div v-loading="_getLoading()" class="shelf-product-import-wrapper">
<Detail :data="formData" />
<Modify ref="modifyRef" :form-data="formData" />
<VenusDialog v-model="dialog.importProgress.show"
title="提示"
......@@ -9,7 +10,8 @@
:show-close="false"
:close-on-click-modal="false"
:confirm-loading="false"
v-bind="dialog.importProgress[dialog.importProgress.status]">
v-bind="dialog.importProgress[dialog.importProgress.status]"
@confirm="handleConfirm">
<ImportProgress :status="dialog.importProgress.status" />
<!-- <el-button @click="dialog.importProgress.status = 'starting'">
starting
......@@ -29,12 +31,14 @@ import VenusDialog from "@/components/venusDialog/index.vue";
import { getShelfProductBaseInfoApi } from "@/views/goods/shelfProduct/api/index.js";
import { VIEW_MODE } from "@/views/goods/shelfProduct/constant/index.js";
import FormProvideItemMixin from "../formProvider/formItemMixin.js";
import Detail from "./components/detail/index.vue";
import ImportProgress from "./components/importProgress/index.vue";
import Modify from "./components/modify/index.vue";
export default {
name: "ShelfProductImport",
components: {
Detail,
Modify,
VenusDialog,
ImportProgress,
......@@ -59,18 +63,18 @@ export default {
},
dialog: {
importProgress: {
show: true,
show: false,
status: "starting",
starting: {
height: "192px",
showFooter: false,
},
failed: {
height: "56px",
height: "60px",
showFooter: true,
},
success: {
height: "56px",
height: "60px",
showFooter: true,
confirmText: "继续下一步",
},
......@@ -103,6 +107,13 @@ export default {
const formData = await modifyRef.validate();
Object.assign(this.formData, formData);
},
handleConfirm() {
this.$emit("handleNext");
},
showImportProgress(status) {
this.dialog.importProgress.show = true;
this.dialog.importProgress.status = status;
},
},
};
</script>
......
import { getTrafficSourceListApi } from "@/views/goods/shelfProduct/api";
import { sceneTypeOptions } from "@/views/goods/shelfProduct/constant/index";
import { sceneTypeOptions, shelfTypeOptions } from "@/views/goods/shelfProduct/constant/index";
export const shelfProductImportModifyFormSchema = [
{
......@@ -14,10 +14,7 @@ export const shelfProductImportModifyFormSchema = [
label: "上架类型",
name: "shelfType",
type: "radio",
optionList: [
{ value: 1, label: "单店模式" },
{ value: 2, label: "项目制批量上架" },
],
optionList: shelfTypeOptions,
optionId: "value",
optionLabel: "label",
},
......@@ -75,3 +72,40 @@ export const shelfProductImportModifyFormSchema = [
addHtml: "goodsCreateExcel",
},
];
export async function getShelfProductImportSchema() {
return [
{ name: "baseSceneCode", label: "业务场景", col: 24 },
{
name: "shelfType",
label: "上架类型",
col: 24,
render(h, { data }) {
const item = shelfTypeOptions.find(item => item.value === data?.shelfType)?.label;
return h(
"div",
{
attrs: {
title: item.label,
},
class: "text-hide",
},
item.label,
);
},
},
{
name: "merchantNames",
label: "流量方信息",
col: 24,
isHide({ formModel }) {
return formModel.shelfType === 2;
},
},
{
name: "goodsCreateExcel",
label: "商品上架表",
col: 24,
},
];
}
......@@ -18,3 +18,9 @@ export const VIEW_MODE = {
VIEW: "view",
SAVING: "saving",
};
// 商品上架 上架类型
export const shelfTypeOptions = [
{ value: 1, label: "单店模式" },
{ value: 2, label: "项目制批量上架" },
];
......@@ -17,7 +17,7 @@
</div>
<div v-loading="data.globalLoading" class="wrapper">
<FormStep name="step1" :on-submit="handleSubmitProductImport">
<ShelfProductImport />
<ShelfProductImport ref="shelfProductImportRef" @handleNext="handleNextProductImport()" />
</FormStep>
<FormStep name="step2">
<ShelfProductConfirm />
......@@ -143,8 +143,13 @@ export default {
handlePreviousSteps() {
this.$refs.formProviderRef.prev();
},
handleNextSteps() {
this.$refs.formProviderRef.next();
async handleNextSteps(params) {
// 第一步不同
if (this.step.confirmStep === 0) {
this.$refs.formProviderRef.next({ ...params, next: false });
return;
}
this.$refs.formProviderRef.next(params);
},
// 这个是最后一步才有的大提交
handleSubmit() {},
......@@ -152,8 +157,12 @@ export default {
// 第一步的提交 -> 第一步比较特殊, 内部没有自己的保存与取消.要放在next中做
handleSubmitProductImport(stepFormData, formData) {
this.$refs.shelfProductImportRef.showImportProgress("success");
return {};
},
handleNextProductImport() {
this.step.confirmStep += 1;
},
},
};
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!