lilei 2 lat temu
rodzic
commit
e3fecde6b8

+ 1 - 1
public/version.json

@@ -1,5 +1,5 @@
 {
   "message": "发现有新版本发布,确定更新系统?",
   "vendorJsVersion": "",
-  "version": 1675931329289
+  "version": 1675933163094
 }

+ 5 - 3
src/components/tools/UserMenu.vue

@@ -6,8 +6,10 @@
         <span style="vertical-align: middle;">帮助</span>
       </p>
       <p class="help-cont" @click="showShopCar">
-        <a-icon type="shopping-cart" style="font-size:16px;vertical-align: middle;margin: 0 5px;"/>
-        <span style="vertical-align: middle;">购物车</span>
+        <a-badge :count="cartCount">
+          <a-icon type="shopping-cart" style="font-size:16px;margin: 0 5px;"/>
+          <span>购物车</span>
+        </a-badge>
       </p>
       <!-- 通知 -->
       <notice-icon class="action"/>
@@ -106,7 +108,7 @@ export default {
     NoticeIcon
   },
   computed: {
-    ...mapGetters(['nickname', 'avatar', 'authOrgs', 'userInfo', 'nowRoute', 'theme', 'fontSize', 'printDefNeedle']),
+    ...mapGetters(['nickname', 'avatar', 'authOrgs', 'userInfo', 'nowRoute', 'theme', 'fontSize', 'printDefNeedle','cartCount']),
     authOrgsList () { //  过滤掉当前登录账户(不可由自己切换为自己)
       const _this = this
       const arr = []

+ 1 - 0
src/config/router.config.js

@@ -76,6 +76,7 @@ export const asyncRouterMap = [
                 meta: {
                   title: '购物车',
                   icon: 'contacts',
+                  replaceTab: true,
                   hidden: true
                 }
               }

+ 2 - 1
src/store/getters.js

@@ -27,7 +27,8 @@ const getters = {
   printDefInk:state => state.app.printDefInk,
   printUseing:state => state.app.printUseing,
   printSettingType:state => state.app.printSettingType,
-  returnReason: state => state.app.returnReason
+  returnReason: state => state.app.returnReason,
+  cartCount: state => state.cart.cartCount
 }
 
 export default getters

+ 3 - 1
src/store/index.js

@@ -4,6 +4,7 @@ import Vuex from 'vuex'
 import app from './modules/app'
 import user from './modules/user'
 import socket from './modules/websocketStore'
+import cart from './modules/shoppingCart'
 
 // default router permission control
 import permission from './modules/permission'
@@ -19,7 +20,8 @@ export default new Vuex.Store({
     app,
     user,
     permission,
-    socket
+    socket,
+    cart
   },
   state: {
 

+ 28 - 0
src/store/modules/shoppingCart.js

@@ -0,0 +1,28 @@
+import { purchaseCartList } from '@/api/purchaseCart'
+export default {
+  state: {
+    cartCount: 0,
+  },
+  getters: {
+    cartCount: state => {
+      return () => state.cartCount
+    },
+  },
+  mutations: {
+    setCartCount (state, count) {
+      state.cartCount = count
+    },
+  },
+  actions: {
+    // 获取购物车列表
+    getCartList ({ state, commit }) {
+      purchaseCartList({pageNo:1,pageSize:1}).then(res => {
+        commit('setCartCount', res.data ? res.data.count : 0)
+      })
+    },
+    // 更新购物车数量
+    updateCartCount ({ state, commit }, count) {
+      commit('setCartCount', count)
+    }
+  }
+}

+ 3 - 0
src/views/inventoryManagement/inventoryQuery/setPurchaseQty.vue

@@ -45,6 +45,7 @@
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { purchaseCartSave } from '@/api/purchaseCart'
+import { mapActions } from 'vuex'
 export default {
   name: 'ChainTransferOutBasicInfoModal',
   mixins: [commonMixin],
@@ -76,6 +77,7 @@ export default {
     }
   },
   methods: {
+    ...mapActions(['getCartList']),
     setData(row){
       this.dateilData = row
       this.form.productSn = row.productSn
@@ -96,6 +98,7 @@ export default {
               setTimeout(() => {
                 _this.isShow = false
                 _this.$emit('ok', res.data)
+                _this.getCartList()
                 _this.spinning = false
               }, 1000)
             } else {

+ 1 - 0
src/views/shoppingCarManagement/shoppingCar/list.vue

@@ -135,6 +135,7 @@ export default {
           let data
           if (res.status == 200) {
             data = res.data
+            this.$store.commit('setCartCount', data.count)
             const no = (data.pageNo - 1) * data.pageSize
             for (var i = 0; i < data.list.length; i++) {
               data.list[i].no = no + i + 1