Przeglądaj źródła

完善花材列表的修改功能

wangn 5 lat temu
rodzic
commit
e725075273

+ 42 - 3
ghs/src/pages/layout/topbar/index.vue

@@ -17,7 +17,12 @@
 				<span>{{ item.name }}</span>
 			</el-menu-item>
 		</el-menu> -->
-
+    <el-dropdown class="user_top" trigger="click" @command="shopCommand"  v-if="shopShow"> 
+		  <div>{{currentShop}}&nbsp;<i class="el-icon-caret-bottom"></i></div>
+      <el-dropdown-menu slot="dropdown" class="popper-dropdown-menu-user">
+        <el-dropdown-item v-for="(item, index) in shopList" :key="index" :class="{'shopActive': item.id == userInfo.currentShopId}" :command="item">{{item.shopName}}</el-dropdown-item>
+      </el-dropdown-menu>
+    </el-dropdown>
 		<div class="flex1"></div>
 
 		<!-- <ul class="tools">
@@ -55,7 +60,8 @@ export default {
 	data() {
 		return {
 			$projectName: this.$projectName,
-			index: '0'
+			index: '0',
+      shopList: []
 		};
 	},
 
@@ -66,6 +72,7 @@ export default {
 		// 		this.SET_MENU_LIST(i);
 		// 	}
 		// });
+    this.getAllShop()
 	},
 
 	computed: {
@@ -75,7 +82,20 @@ export default {
 				return this.shopInfo.smallLogoUrl;
 			}
 			return '';
-		}
+		},
+    currentShop() {
+      let str
+      this.shopList.map(ele => {
+        console.log(ele.id, this.userInfo.currentShopId)
+        if(ele.id == this.userInfo.currentShopId) {
+          str = ele.shopName
+        }
+      })
+      return str
+    },
+    shopShow(){
+      return this.userInfo.super == 1 && this.shopList.length > 1
+    }
 	},
 
 	methods: {
@@ -101,6 +121,19 @@ export default {
 					break;
 			}
 		},
+    shopCommand(item) {
+      console.log(item)
+      this.$service.common.toggleShop({shopId: item.id}).then(res => {
+        this.$router.go(0)
+      }).catch(err => {console.log(err,1111111)})
+    },
+    // 获取门店
+    getAllShop() {
+      this.$service.common.shopAll().then(res => {
+        console.log(res)
+        this.shopList = res
+      }).catch(err => {})
+    },
 		layoutGlobalKd(){
 			this.$router.push('/order/add');
 		}
@@ -258,5 +291,11 @@ export default {
 			margin-left: 10px;
 		}
 	}
+  .user_top{
+    min-width: 100px;
+    margin-left: 50px;
+    cursor: pointer;
+    color: #fff;
+  }
 }
 </style>

+ 17 - 0
ghs/src/service/common/index.js

@@ -235,6 +235,23 @@ export class CommonService extends BaseService {
 			params
 		});
 	}
+
+  // 获取门店列表
+  shopAll(params) {  
+		return this.request({
+			url: '/shop/all',
+			params
+		});
+  }
+  
+  // 切换门店
+  toggleShop(params) {  
+		return this.request({
+      url: '/shop/toggle-shop',
+      method: 'POST',
+      data: params
+		});
+	}
 }
 
 export default new CommonService();

+ 24 - 3
ghs/src/views/item/list.vue

@@ -45,7 +45,7 @@
       <template #slot-modify="{ scope }">
 				<el-button
 					type="text"
-					@click.native.stop="replaceBtnFn"
+					@click.native.stop="replaceBtnFn(scope.row.id)"
 					>修改</el-button
 				>
 			</template>
@@ -320,7 +320,11 @@ export default {
     replaceConfirmFn() {
       this.$refs.replaceForm.validate((valid) => {
         if(valid) {
-          console.log(this.replaceForm)
+          this.$service.product.update(this.replaceForm).then(res => {
+            console.log('res1111', res)
+            this.$message.success('操作成功!');
+            this.addDialog = false
+          }).catch(err => {})
         }
       })
     },
@@ -467,9 +471,26 @@ export default {
       this.canAddPrice = false
       this.costPrice = false
     },
-    replaceBtnFn() {
+    replaceBtnFn(id) {
       this.addDialog = true
       this.getAllClass()
+      this.$service.product.info({id}).then(res => {
+        console.log(res)
+        // this.replaceForm.name = res.name
+				// this.replaceForm.alias = res.alias
+				// this.replaceForm.classId = res.classId
+				// this.replaceForm.className = res.classId
+				// this.replaceForm.cover = res.cover
+        // this.replaceForm.bigUnit = res.bigUnit
+				// this.replaceForm.smallUnit = res.smallUnit
+				// this.replaceForm.stockWarning = res.stockWarning
+				// this.replaceForm.cost = res.cost
+				// this.replaceForm.addPrice = res.addPrice
+				// this.replaceForm.weight = res.weight
+        let index = this.itemClassList.findIndex((e) => e.id == res.classId)
+        this.replaceForm = res
+        this.replaceForm.className = this.itemClassList[index].name
+      })
     },
     changeSort (d, type) {
       this.dataList.form.type = type