From edb6be283fea79b0d231da6e3c5a044f4046a377 Mon Sep 17 00:00:00 2001
From: lixiaomin <gdc@1357>
Date: Sun, 22 May 2022 15:18:29 +0800
Subject: [PATCH] 修改店铺添加商品列表

---
 src/api/system/goods.js                      |  9 +++++++++
 src/components/SelectGoods/index.vue         | 24 +++++++++++++-----------
 src/views/shop/shop/components/commodity.vue | 80 ++++++++++++++++++++++++++++++++++----------------------------------------------
 3 files changed, 56 insertions(+), 57 deletions(-)

diff --git a/src/api/system/goods.js b/src/api/system/goods.js
index 41ee79f..bd35486 100644
--- a/src/api/system/goods.js
+++ b/src/api/system/goods.js
@@ -62,3 +62,12 @@ export function offShop(params) {
 }
 
 
+// 店铺添加商品查询列表
+export function goodslist(query) {
+  return request({
+    url: "/system/shop/goodslist",
+    method: "get",
+    params: query,
+  });
+}
+
diff --git a/src/components/SelectGoods/index.vue b/src/components/SelectGoods/index.vue
index f50dc93..6558f2c 100644
--- a/src/components/SelectGoods/index.vue
+++ b/src/components/SelectGoods/index.vue
@@ -2,8 +2,8 @@
 	<el-dialog title="选择商品" :visible.sync="open" width="1000px" append-to-body>
 		<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
 			label-width="68px">
-			<el-form-item label="商品名称" prop="spuName">
-				<el-input v-model="queryParams.spuName" placeholder="请输入商品名称" clearable
+			<el-form-item label="商品名称" prop="goodsName">
+				<el-input v-model="queryParams.goodsName" placeholder="请输入商品名称" clearable
 					@keyup.enter.native="handleQuery" />
 			</el-form-item>
 			<el-form-item label="分类" prop="category">
@@ -42,7 +42,7 @@
 </template>
 
 <script>
-import { listSpu } from "@/api/system/goods";
+import { goodslist } from "@/api/system/goods";
 import SelectCategory from '@/components/SelectCategory'
 export default {
 	components: { SelectCategory },
@@ -64,9 +64,10 @@ export default {
 			queryParams: {
 				pageNum: 1,
 				pageSize: 10,
-				spuName: null,
+				goodsName: null,
 				category: null,
 				state: 3,
+        shopId: null
 			},
 		};
 	},
@@ -85,9 +86,10 @@ export default {
       return list;
     },
 		/** 查询列表 */
-		getList() {
+		getList(shopId) {
 			this.loading = true;
-			listSpu(this.queryParams).then((response) => {
+      this.queryParams.shopId=shopId
+			goodslist(this.queryParams).then((response) => {
 				this.spuList = response.rows;
 				this.total = response.total;
 				this.loading = false;
@@ -101,7 +103,7 @@ export default {
 		},
 		/** 重置按钮操作 */
 		resetQuery() {
-      this.queryParams.spuName=null;
+      this.queryParams.goodsName=null;
       this.queryParams.category=null;
 			this.handleQuery();
 		},
@@ -114,13 +116,13 @@ export default {
 			this.open = false;
 			//this.reset();
 		},
-		openModal() {
+		openModal(shopId) {
 			this.open = true;
-      this.getList();
+      this.getList(shopId);
 		},
 		submit() {
-			this.$emit('callback', this.ids)
-			this.open = false
+			this.$emit('callback', this.ids);
+			//this.open = false
 		}
 	},
 };
diff --git a/src/views/shop/shop/components/commodity.vue b/src/views/shop/shop/components/commodity.vue
index c9a1283..47816da 100644
--- a/src/views/shop/shop/components/commodity.vue
+++ b/src/views/shop/shop/components/commodity.vue
@@ -46,13 +46,10 @@
 			<el-table-column label="总销量" align="center" prop="salesVolume" />
       <el-table-column label="上架时间" align="center" prop="shelfat" width="150" /> 
 			<el-table-column label="状态" align="center" prop="state" width="150">
-        <!-- <template slot-scope="scope">
-          <span v-if="scope.row.state == 1">已创建</span>
-          <span v-if="scope.row.state == 2">已完成编程</span>
-          <span v-if="scope.row.state == 3">已上架</span>
-          <span v-if="scope.row.state == 4">已下架</span>
-          <span v-if="scope.row.state == 5">已删除</span>
-        </template> -->
+        <template slot-scope="scope">
+          <span v-if="scope.row.state == 1">售卖</span>
+          <span v-if="scope.row.state == 2">告罄</span>
+        </template>
       </el-table-column>
 			<el-table-column label="排序" align="center">
 			</el-table-column>
@@ -134,62 +131,53 @@ export default {
     handleSelectionChange(selection) {
       this.outIds = selection.map((item) => item.id);
     },
-    soldOutGoos(){
-
-    
-     this.$confirm('是否确认下架所选商品?', '提示', {
+    soldOutGoos(){    
+      this.$confirm('是否确认下架所选商品?', '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
           type: 'warning'
         }).then(() => {
-          offGoods({"shopId":this.shopId,"goodsIds":this.outIds}).then(({ response }) => {
-            if(response.code=="200"){
+          offGoods({"shopId":this.shopId,"goodsIds":this.outIds}).then(res => {
+            if(res.code=="200"){
+              this.getList();
               this.$message({
                 type: 'success',
-                message: '删除成功!'
+                message: '所选商品下架成功!'
               });
             }
 			    })
         }).catch(() => {
           this.$message({
             type: 'info',
-            message: '已取消删除'
+            message: '已取消下架所选商品!'
           });          
-        });
-
-
-
-
-      // offGoods({"shopId":this.shopId,"goodsIds":this.outIds}).then(({ response }) => {
-			// 	console.log("response",response);
-			// })
-
-      // this.$modal
-      //   .confirm('是否确认下架所选商品?')
-      //   .then(function () {
-      //     return offGoods({"shopId":this.shopId,"goodsIds":this.outIds});
-      //   })
-      //   .then((response) => {
-      //     // console.log("response",response);
-      //     // if(response.code=="200"){
-      //     //   this.getList();
-      //       //this.$modal.msgSuccess('' + mess + '成功');
-      //     // }          
-      //   })
-      //   .catch(() => { });
-
-
-
-
-
+      });
     },
 		openSelectGoos() {
-			this.$refs.selectGoods.openModal()
+			this.$refs.selectGoods.openModal(this.shopId)
 		},
 		selectGoos(ids) {
-			addGoods({ shopId: this.shopId, goodsIds: ids.join(',') }).then(res => {
-				this.getList()
-			})
+      this.$confirm('是否确认添加所选商品?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          addGoods({"shopId":this.shopId,"goodsIds":ids.join(',')}).then(res => {
+            if(res.code=="200"){
+              this.$refs.selectGoods.open = false;
+              this.getList();
+              this.$message({
+                type: 'success',
+                message: '所选商品添加成功!'
+              });
+            }
+			    })
+        }).catch(() => {
+          this.$message({
+            type: 'info',
+            message: '已取消所选的商品!'
+          });          
+      });
 		}
 	}
 }
--
libgit2 0.26.0