Commit 74922c38 by Jaxon

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

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