From a266434c05adc1436629f91853eecb1237b609a0 Mon Sep 17 00:00:00 2001 From: qiaopengfei <2646186879@qq.com> Date: Fri, 26 Jul 2024 00:36:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/commont.js | 17 +- .../components/specificationDialog.vue | 4 + src/views/NewlyBuiltGoods/index.vue | 253 +++++++++++------- 3 files changed, 177 insertions(+), 97 deletions(-) diff --git a/src/services/commont.js b/src/services/commont.js index 0eb2ee4..fe4e3fe 100644 --- a/src/services/commont.js +++ b/src/services/commont.js @@ -446,7 +446,19 @@ export const initOss = (file) => { } }); } - +//深拷贝 +export function deepClone(obj, hash = new WeakMap()) { + if (obj == null || typeof obj !== "object") return obj + if (obj instanceof Date) return new Date(obj) + if (obj instanceof RegExp) return new RegExp(obj.source, obj.flags) + if (hash.has(obj)) return hash.set(obj) + const deepArr = Array.isArray(obj) ? [] : {} + hash.set(obj, deepArr); + for (const key in obj) { + deepArr[key] = deepClone(obj[key], hash); + } + return deepArr +} let commont = { maskData: maskData, @@ -467,7 +479,8 @@ let commont = { compression: compression, isObject: isObject, isArray: isArray, - initOss: initOss + initOss: initOss, + deepClone: deepClone } diff --git a/src/views/NewlyBuiltGoods/components/specificationDialog.vue b/src/views/NewlyBuiltGoods/components/specificationDialog.vue index b868e84..5054956 100644 --- a/src/views/NewlyBuiltGoods/components/specificationDialog.vue +++ b/src/views/NewlyBuiltGoods/components/specificationDialog.vue @@ -209,6 +209,10 @@ const submit_specification = (formEl) => { }); }; const submitForm = () => { + if (!specification_list.value.length) + return ElMessage.warning("没有添加任何规格属性!"); + if (!specification_list.value.every((item) => item.valueGrop.length)) + return ElMessage.warning("添加规格后至少添加一个属性值!"); $emit("specificationSubmit", specification_list); specificationClose(); }; diff --git a/src/views/NewlyBuiltGoods/index.vue b/src/views/NewlyBuiltGoods/index.vue index f0c430b..ad312fa 100644 --- a/src/views/NewlyBuiltGoods/index.vue +++ b/src/views/NewlyBuiltGoods/index.vue @@ -144,9 +144,9 @@ {{ el.xyName }}187/500
- + + + 新增闲鱼店铺
@@ -229,9 +229,9 @@ v-if="item.type === 'add'" @click="item.add" > - + + + 添加多规格深库存
- - - - - - - - +