From ddb2ab313f88b100420c60d15bf29cfd1a678d55 Mon Sep 17 00:00:00 2001 From: fanfan Date: Thu, 6 Jun 2024 17:12:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=80=E9=94=AE=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/goods/index.js | 11 +- src/components/SelectImage/SelectImage.vue | 369 +++-- src/views/goods/Create.vue | 42 +- src/views/goods/modules/Update.vue | 1418 +++++++++----------- 4 files changed, 840 insertions(+), 1000 deletions(-) diff --git a/src/api/goods/index.js b/src/api/goods/index.js index 74fb413..e6ad5e3 100644 --- a/src/api/goods/index.js +++ b/src/api/goods/index.js @@ -14,7 +14,16 @@ const api = { exportData: '/goods/import', setStorePrice: 'store/setStorePrice', getStorePriceInfo: 'store/getStorePriceInfo', - pool: '/goods/pool' + pool: '/goods/pool', + collector:'/goods/collector' +} + +export function getCollector (params) { + return axios({ + url: api.collector, + method: 'get', + params + }) } /** * 更新状态 diff --git a/src/components/SelectImage/SelectImage.vue b/src/components/SelectImage/SelectImage.vue index 8033bef..8ccc528 100644 --- a/src/components/SelectImage/SelectImage.vue +++ b/src/components/SelectImage/SelectImage.vue @@ -1,55 +1,28 @@ diff --git a/src/views/goods/Create.vue b/src/views/goods/Create.vue index 3324d94..df3232b 100644 --- a/src/views/goods/Create.vue +++ b/src/views/goods/Create.vue @@ -15,14 +15,14 @@ - + @@ -38,7 +38,7 @@ - + @@ -86,9 +86,9 @@ - - - + @@ -407,7 +407,8 @@ export default { } ], // 城市总数 - citysCount: null + citysCount: null, + goods_images: [] } }, // 初始化数据 @@ -420,11 +421,30 @@ export default { }, methods: { handInfo() { - let obj = { - goods_name: '测试', - goods_price: 123 + const { form } = this + const goods_no = form.getFieldValue('goods_no') + if(goods_no){ + let param = { + sku: goods_no + } + this.isLoading = true + GoodsApi.getCollector(param).then((result) => { + this.goods_images = result.data.goods_images + let obj = { + goods_name: result.data.name, + content: result.data.content, + goods_price: result.data.proxyPrice, + } + this.form.setFieldsValue(obj) + this.isLoading = false + }) + .catch(() => { + this.isLoading = false + }) + .finally(() => (this.isLoading = false)) + }else{ + this.$message.warning('请输入商品SKU', 1.5) } - this.form.setFieldsValue(obj) }, // 手动强制更新页面 onForceUpdate(bool = false) { diff --git a/src/views/goods/modules/Update.vue b/src/views/goods/modules/Update.vue index c208e3e..9f268fc 100644 --- a/src/views/goods/modules/Update.vue +++ b/src/views/goods/modules/Update.vue @@ -1,568 +1,356 @@ From 60dea96dc9112879be00a03f6dcdb33244273b06 Mon Sep 17 00:00:00 2001 From: fanfan Date: Thu, 6 Jun 2024 17:29:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/goods/Create.vue | 49 +++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/views/goods/Create.vue b/src/views/goods/Create.vue index df3232b..097aee9 100644 --- a/src/views/goods/Create.vue +++ b/src/views/goods/Create.vue @@ -38,7 +38,7 @@ - + @@ -408,7 +408,6 @@ export default { ], // 城市总数 citysCount: null, - goods_images: [] } }, // 初始化数据 @@ -420,29 +419,41 @@ export default { }) }, methods: { + generateRandomDigits(length) { + let result = ''; + for (let i = 0; i < length; i++) { + result += Math.floor(Math.random() * 10); // 生成0-9的随机数字 + } + return result; + }, handInfo() { const { form } = this const goods_no = form.getFieldValue('goods_no') - if(goods_no){ - let param = { - sku: goods_no - } - this.isLoading = true - GoodsApi.getCollector(param).then((result) => { - this.goods_images = result.data.goods_images - let obj = { - goods_name: result.data.name, - content: result.data.content, - goods_price: result.data.proxyPrice, + if (goods_no) { + let param = { + sku: goods_no } - this.form.setFieldsValue(obj) - this.isLoading = false - }) - .catch(() => { + this.isLoading = true + GoodsApi.getCollector(param).then((result) => { + if (result.data.goods_images.length > 0) { + result.data.goods_images.forEach(item => { + item.id = Number(this.generateRandomDigits(7)) + }); + } + this.$refs.childComponent.selectedItems= result.data.goods_images + let obj = { + goods_name: result.data.name, + content: result.data.content, + goods_price: result.data.proxyPrice, + } + this.form.setFieldsValue(obj) this.isLoading = false }) - .finally(() => (this.isLoading = false)) - }else{ + .catch(() => { + this.isLoading = false + }) + .finally(() => (this.isLoading = false)) + } else { this.$message.warning('请输入商品SKU', 1.5) } },