From 21b39800da73c0583f99f0f6094f487b694ee48d Mon Sep 17 00:00:00 2001 From: weiwei Date: Mon, 17 Feb 2025 10:22:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=87=E8=B4=AD=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smErpCgPlan/createCgPlan.vue | 37 +++++++------ .../supermarketerp/smErpCgPlan/index.vue | 53 +++++-------------- 2 files changed, 33 insertions(+), 57 deletions(-) diff --git a/src/views/supermarketerp/smErpCgPlan/createCgPlan.vue b/src/views/supermarketerp/smErpCgPlan/createCgPlan.vue index 1ba15b1..7345376 100644 --- a/src/views/supermarketerp/smErpCgPlan/createCgPlan.vue +++ b/src/views/supermarketerp/smErpCgPlan/createCgPlan.vue @@ -60,8 +60,8 @@ 行新增 删除选中 - 商品选择 重置数据 + 商品选择 import { ref, reactive, computed, onMounted } from "vue" -import { useRouter } from "vue-router" +import { useRouter, useRoute } from "vue-router" import { useDict } from "/@/hooks/dict" import { useMessage } from "/@/hooks/message" import { getObj, addObj, putObj, getPlanCode, getCgPlanSpuPage } from "/@/api/supermarketerp/smErpCgPlan" @@ -279,6 +279,7 @@ interface RowVO { } const router = useRouter() +const route = useRoute() const loading = ref(false) // 采购计划加载 const spuListLoading = ref(false) // 对话框商品列表加载 const baseDataFormRef = ref() // 基本数据表单ref @@ -325,7 +326,21 @@ const validRules = ref>({ quantity: [{ required: true, type: "number", min: 1, max: 99, message: "数值范围1~99" }], }) +// 初始化数据 const getInitData = async () => { + const id = route.query.id as string + if (id) { + // 获取数据 + loading.value = true + getObj(id) + .then((res: any) => { + Object.assign(baseDataForm, res.data) + }) + .finally(() => { + loading.value = false + }) + } + // 获取货商选项 & 获取采购计划编号 const [supplierTypeOptions, planCode] = await Promise.allSettled([getSupplierTypeOptions(), getPlanCode()]).then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)), @@ -551,7 +566,7 @@ const onSave = async () => { (await editableTableValidate()) && (await submitData()) && clearData() && - router.back() + router.replace({ path: "/supermarketerp/smErpCgPlan/index" }) } // 校验基本数据表单 成功返回 true 失败返回 undefined @@ -614,7 +629,7 @@ const submitData = async () => { } } -// 清空填写的数据 +// 清空填写的数据 返回 true const clearData = () => { for (const key in baseDataForm) { if (key === "planCode") continue @@ -624,6 +639,7 @@ const clearData = () => { state.editableTableData = [] state.selectedRowsErpSpuIds = [] state.selectedSpuObjs = [] + return true } onMounted(() => { @@ -640,17 +656,4 @@ onMounted(() => { // loading.value = false // } // } - -// 初始化表单数据 -// const getsmErpCgPlanData = (id: string) => { -// // 获取数据 -// loading.value = true -// getObj(id) -// .then((res: any) => { -// Object.assign(form, res.data) -// }) -// .finally(() => { -// loading.value = false -// }) -// } diff --git a/src/views/supermarketerp/smErpCgPlan/index.vue b/src/views/supermarketerp/smErpCgPlan/index.vue index d353b04..c841ee5 100644 --- a/src/views/supermarketerp/smErpCgPlan/index.vue +++ b/src/views/supermarketerp/smErpCgPlan/index.vue @@ -27,13 +27,7 @@
- + 新 增
+ 编辑 - + 删除 @@ -107,21 +96,16 @@ - - -