Bladeren bron

feat:切换权限

zhangxin 1 maand geleden
bovenliggende
commit
e2e0721e4a

+ 5 - 1
pages/person/index.vue

@@ -31,7 +31,7 @@
31 31
 						<u-icon name="arrow-right" color="#aaa"></u-icon>
32 32
 					</view>
33 33
 				</view>
34
-				<view class="parson_menu_wrap">
34
+				<view class="parson_menu_wrap" v-if="isCrmRole">
35 35
 					<view class="parson_menu_list">
36 36
 						<navigator url="/pages/publicClue/index" open-type="switchTab" class="menu_item"
37 37
 							hover-class="none">
@@ -67,6 +67,7 @@
67 67
 import cards from "./cards/index.vue"
68 68
 // import optionList from "./option/index.vue"
69 69
 import permision from "@/js_sdk/wa-permission/permission.js";
70
+import { getRoles } from '@/utils/util.js'
70 71
 export default {
71 72
 	components: {
72 73
 		// optionList,
@@ -82,6 +83,9 @@ export default {
82 83
 		};
83 84
 	},
84 85
 	computed: {
86
+		isCrmRole(){
87
+			return getRoles().some(v => v.includes('CRM'))
88
+		},
85 89
 		userInfo() {
86 90
 			return this.$store.state.user.userInfo;
87 91
 		},

+ 50 - 4
pages/setting/index.vue

@@ -2,6 +2,16 @@
2 2
 	<view class="setting_wrap">
3 3
 		<u-navbar title="我的设置" :autoBack="true" :placeholder="true" v-hideNav></u-navbar>
4 4
 		<view class="option_list">
5
+			<!-- 只有当showRoleSwitch为true时才显示切换权限按钮 -->
6
+			<view v-if="$store.state.user.showRoleSwitch" class="option_item" @click="handleSwitchRole">
7
+				<view class="item_left" >
8
+					<image src="@/static/parson/permission.png" mode=""></image>
9
+					<text class="label">切换权限</text>
10
+				</view>
11
+				<view class="item-right">
12
+					<u-icon name="arrow-right" color="#aaa"></u-icon>
13
+				</view>
14
+			</view>
5 15
 			<view class="option_item" @click="toPersonal">
6 16
 				<view class="item_left">
7 17
 					<image src="@/static/parson/icon-gezl.png" mode=""></image>
@@ -27,6 +37,7 @@
27 37
 		<view class="logout_btn">
28 38
 			<u-button type="warning" :plain="true" text="退出账号" size="large" @click="handleShowModal"></u-button>
29 39
 		</view>
40
+		<u-picker :show="showSwitchRole" :columns="columns" keyName="label" :defaultIndex="defaultIndex" @confirm="confirmSwitchRole" @cancel="showSwitchRole = false"></u-picker>
30 41
 		<u-modal :show="showModal" 
31 42
 			@confirm="confirm" 
32 43
 			ref="uModal" 
@@ -49,13 +60,36 @@
49 60
 		},
50 61
 		data() {
51 62
 			return {
52
-				showModal: false
63
+				showModal: false,
64
+				showSwitchRole: false,
65
+				columns: [],
66
+				defaultIndex: [this.$store.state.user.currentRoleIndex],
67
+				isHaveCRM: false,
68
+				isHaveSalesman: false,
69
+				isHaveWarehouse: false,
53 70
 			}
54 71
 		},
55
-		onLoad: function(opt) {
56
-
57
-		},
58 72
 		methods: {
73
+			handleSwitchRole(){
74
+				this.columns = [];
75
+				const availableRoles = this.$store.state.user.availableRoles;
76
+				const roleOptions = [];
77
+				availableRoles.forEach(role => {
78
+					switch (role) {
79
+						case 'SALESMAN':
80
+							roleOptions.push({ label: '销售权限', value: 'SALESMAN' });
81
+							break;
82
+						case 'WAREHOUSER':
83
+							roleOptions.push({ label: '仓库权限', value: 'WAREHOUSER' });
84
+							break;
85
+						case 'CRM':
86
+							roleOptions.push({ label: 'CRM权限', value: 'CRM' });
87
+							break;
88
+					}
89
+				});
90
+				this.columns = [roleOptions];
91
+				this.showSwitchRole = true;
92
+			},
59 93
 			handleEditPassword(){
60 94
 				uni.navigateTo({
61 95
 					url : "/pages/changePw/index"
@@ -84,6 +118,18 @@
84 118
 						})
85 119
 					},1000)
86 120
 				})
121
+			},
122
+			confirmSwitchRole(e) {
123
+				console.log(e);
124
+				uni.navigateBack({
125
+					delta: 1
126
+				}).then(()=>{
127
+					this.showSwitchRole = false;
128
+					this.$store.commit('user/SET_CURRENT_ROLE_INDEX', e.indexs[0]);
129
+					setTimeout(()=>{
130
+						this.$store.commit('user/SWITCH_ROLE', e.value[0]);
131
+					},100)
132
+				})
87 133
 			}
88 134
 		}
89 135
 	}

+ 8 - 1
pages/wareHouse/components/detail.vue

@@ -213,7 +213,7 @@
213 213
                     <text class="bar_text">确认入库</text>
214 214
                 </view>
215 215
             </view>
216
-            <view :class="['bar_item', { 'disabled': lockStatus === '1' ||  globalEditMode}]" @click="handleOpenOrder">
216
+            <view :class="['bar_item', { 'disabled': lockStatus === '1' ||  globalEditMode || downStatus == '0'}]" @click="handleOpenOrder">
217 217
                 <view class="primary orange">
218 218
                     <u-icon name="bag" size="44rpx" color="#fff"></u-icon>
219 219
                     <text class="bar_text">开单</text>
@@ -397,6 +397,13 @@ export default {
397 397
                 })
398 398
                 return
399 399
             }
400
+            if(this.downStatus === '0'){
401
+                uni.showToast({
402
+                    title: '已下架,不能开单',
403
+                    icon: 'none'
404
+                })
405
+                return
406
+            }
400 407
             const params = {
401 408
                 id: this.goodsId,
402 409
                 url: this.imgsUrl[0]?.url,

+ 75 - 43
pages/wareHouse/components/edit.vue

@@ -11,14 +11,14 @@
11 11
             <view class="form_list">
12 12
                 <u--form labelPosition="top" :model="formData" :rules="rules" ref="addForm" labelWidth="100%">
13 13
                     <u-form-item borderBottom class="u-form-item-col">
14
-                        <u--textarea v-model="recognitionContent" placeholder='品牌:浪琴
15
-来源:【麒麟】私信-杰3-3
16
-实价:6500
17
-型号:L2.257.5.89.7
18
-编码:52356065
19
-日期:2021-11-09
20
-备注:全套
21
-付款方式:微信/支付宝/银行卡/现金/数字货币/挂账' confirmType="done" height="170" :maxlength="-1">
14
+                        <u--textarea v-model="recognitionContent" placeholder='品牌:-
15
+来源:-
16
+实价:-
17
+型号:-
18
+编码:-
19
+日期:-
20
+备注:-
21
+付款方式:-' confirmType="done" height="170" :maxlength="-1">
22 22
                         </u--textarea>
23 23
                         <view class="btn_group_recognition">
24 24
                             <u-button text="清除" @click="clearRecognitionContent()"></u-button>
@@ -155,12 +155,12 @@
155 155
                             @tabChange="handleTabChangeStockStatus"></TabSelect>
156 156
                     </u-form-item>
157 157
                     <u-form-item label="回收类型" borderBottom>
158
-                        <TabSelect :tabList="recycleTypeList" :colNum="4" mode="single" :isClear="recycleTypeIsClear"
158
+                        <TabSelect :tabList="recycleTypeList" :colNum="4" mode="single" :isClear="recycleTypeIsClear" :echoInfo="echoInfoRecycleType"
159 159
                             @tabChange="handleTabChangeRecycleType">
160 160
                         </TabSelect>
161 161
                     </u-form-item>
162 162
                     <u-form-item label="标签" borderBottom>
163
-                        <TabSelect :tabList="labelList" :colNum="5" mode="single" :isClear="labelIsClear"
163
+                        <TabSelect :tabList="labelList" :colNum="5" mode="single" :isClear="labelIsClear" :echoInfo="echoInfoLabel"
164 164
                             @tabChange="handleTabChangeLabel">
165 165
                         </TabSelect>
166 166
                     </u-form-item>
@@ -246,7 +246,7 @@
246 246
                         </view>
247 247
                     </u-form-item>
248 248
                     <u-form-item label="付款方式">
249
-                        <TabSelect :tabList="paymentTabList" :echoInfo="payTypeEcho" :colNum="4" mode="single"
249
+                        <TabSelect :tabList="paymentTabList" :echoInfo="echoInfoPayType" :colNum="4" mode="single"
250 250
                             :isClear="payTypeIsClear" @tabChange="handlePayTypeTabChange">
251 251
                         </TabSelect>
252 252
                     </u-form-item>
@@ -442,27 +442,27 @@ export default {
442 442
             paymentTabList: [
443 443
                 {
444 444
                     name: '微信',
445
-                    value: 1,
445
+                    value: "1",
446 446
                 },
447 447
                 {
448 448
                     name: '支付宝',
449
-                    value: 2,
449
+                    value: "2",
450 450
                 },
451 451
                 {
452 452
                     name: '银行卡',
453
-                    value: 3,
453
+                    value: "3",
454 454
                 },
455 455
                 {
456 456
                     name: '现金',
457
-                    value: 4,
457
+                    value: "4",
458 458
                 },
459 459
                 {
460 460
                     name: '数字货币',
461
-                    value: 5,
461
+                    value: "5",
462 462
                 },
463 463
                 {
464 464
                     name: '挂账',
465
-                    value: 6,
465
+                    value: "6",
466 466
                 },
467 467
             ],
468 468
             typeIsClear: false,//商品分类是否清空
@@ -472,17 +472,21 @@ export default {
472 472
             stockStatusIsClear: false,//是否入库是否清空
473 473
             labelIsClear: false,//商品标签是否清空
474 474
             payTypeIsClear: false,//付款方式是否清空
475
-            payTypeEcho: '',//付款方式识别回显
475
+            echoInfoPayType: '',//付款方式识别回显
476
+            echoInfoRecycleType:'',//入库回显的时候 回收类型回显
477
+            echoInfoLabel:'',//入库回显的时候 商品标签回显
476 478
             echoInfoType:'',//入库回显的时候 类型回显
477 479
             echoInfoProductAttribute:'',//入库回显的时候 商品属性回显
478 480
             echoInfoProductCondition:'',//入库回显的时候 商品成色回显
479 481
             echoInfoStockStatus:'',//入库回显的时候 是否入库回显
480 482
             isWareHouser: permissionCheck('WAREHOUSER',false),
483
+            formType: '',//表单类型 add:新增 edit:编辑
481 484
         }
482 485
     },
483 486
     onLoad(options) {
484 487
         this.getTypeList();
485 488
         this.$nextTick(async()=>{
489
+            this.formType = options.formType
486 490
             if(options.formType == 'add'){
487 491
                 this.clearForm()
488 492
             }else if(options.formType == 'edit'){
@@ -492,16 +496,27 @@ export default {
492 496
                 })
493 497
                 this.formData = res.data
494 498
                 this.formData.recycleTime = this.$dayjs(res.data.recycleTime).format('YYYY-MM-DD') || ''
495
-                this.echoInfoType = res.data.type || '1'
496
-                this.formData.type = res.data.type || '1'
497
-                this.echoInfoProductAttribute = res.data.productAttribute || '1'
498
-                this.formData.productAttribute = res.data.productAttribute || '1'
499
-                this.echoInfoProductCondition = res.data.productCondition || '1'
500
-                this.formData.productCondition = res.data.productCondition || '1'
501
-                this.echoInfoStockStatus = res.data.stockStatus || '0'
502
-                this.formData.stockStatus = res.data.stockStatus || '0'
503
-                this.formData.stock = res.data.stock ? res.data.stock : 1
504
-                
499
+                this.echoInfoType = res.data.type || '1'//商品分类回显
500
+                this.formData.type = res.data.type || '1'//商品分类校验
501
+                this.echoInfoProductAttribute = res.data.productAttribute || '1'//商品属性回显
502
+                this.formData.productAttribute = res.data.productAttribute || '1'//商品属性校验
503
+                this.echoInfoProductCondition = res.data.productCondition || '1'//商品成色回显
504
+                this.formData.productCondition = res.data.productCondition || '1'//商品成色校验
505
+                this.echoInfoStockStatus = res.data.stockStatus || '0'//是否入库回显
506
+                this.formData.stockStatus = res.data.stockStatus || '0'//是否入库校验
507
+                this.formData.stock = res.data.stock ? res.data.stock : 1//入库数量校验
508
+                this.echoInfoPayType = res.data.payType//付款方式回显
509
+                this.echoInfoRecycleType = res.data.recycleType//回收类型回显
510
+                this.echoInfoLabel = res.data.label//商品标签回显
511
+                this.recognitionContent = `品牌:${res.data.dictLabel || '-'}
512
+来源:${res.data.origin || '-'}
513
+实价:${res.data.costPrice || '-'}
514
+型号:${res.data.model || '-'}
515
+编码:${res.data.indentifyCode || '-'}
516
+日期:${res.data.recycleTime || '-'}
517
+备注:${res.data.productDesc || '-'}
518
+付款方式:${this.paymentTabList.find(item => item.value == res.data.payType)?.name || '-'}
519
+`
505 520
             }
506 521
         })
507 522
     },
@@ -525,20 +540,37 @@ export default {
525 540
                         submitType: submitType, //提交类型 onlyIn:仅入库/暂存入库 inAndUp:入库并上架
526 541
                         continuousWarehousing: this.continuousWarehousing[0] || '0',//是否连续入库 1:是 0:否
527 542
                     }
528
-                    uni.$u.api.wareHouseAdd(data).then(res => {
529
-                        uni.$u.toast('操作成功');
530
-                        if (data.continuousWarehousing == '0') {
531
-                            setTimeout(() => {
532
-                                uni.navigateBack({
533
-                                    delta: 1
534
-                                });
535
-                            }, 1000);
536
-                        } else {
537
-                            this.clearForm();
538
-                        }
539
-                    }).catch(err => {
540
-                        uni.$u.toast(err);
541
-                    })
543
+                    if(this.formType == 'add'){
544
+                        uni.$u.api.wareHouseAdd(data).then(res => {
545
+                            uni.$u.toast('操作成功');
546
+                            if (data.continuousWarehousing == '0') {
547
+                                setTimeout(() => {
548
+                                    uni.navigateBack({
549
+                                        delta: 1
550
+                                    });
551
+                                }, 1000);
552
+                            } else {
553
+                                this.clearForm();
554
+                            }
555
+                        }).catch(err => {
556
+                            uni.$u.toast(err);
557
+                        })
558
+                    }else if(this.formType == 'edit'){
559
+                        uni.$u.api.wareHouseUpdate(data).then(res => {
560
+                            uni.$u.toast('操作成功');
561
+                            if (data.continuousWarehousing == '0') {
562
+                                setTimeout(() => {
563
+                                    uni.navigateBack({
564
+                                        delta: 1
565
+                                    });
566
+                                }, 1000);
567
+                            } else {
568
+                                this.clearForm();
569
+                            }
570
+                        }).catch(err => {
571
+                            uni.$u.toast(err);
572
+                        })
573
+                    }
542 574
                 } else {
543 575
                     console.log('表单校验不通过');
544 576
                 }
@@ -855,7 +887,7 @@ export default {
855 887
                 if (item.name == val) arr.push(item.value)
856 888
             })
857 889
             if (arr.length > 0) {
858
-                this.payTypeEcho = arr[0]
890
+                this.echoInfoPayType = arr[0]
859 891
             }
860 892
         }
861 893
     }

+ 6 - 6
pages/wareHouse/components/openOrder.vue

@@ -57,8 +57,8 @@
57 57
             </view>
58 58
             <view class="card_item">
59 59
                <u-form-item label="收款方式">
60
-                  <TabSelect :tabList="payTypeTabList" mode="single" :colNum="4" :defaultIndex="1"
61
-                     @tabChange="changepayTypeTab">
60
+                  <TabSelect :tabList="payTypeList" mode="single" :colNum="4" :defaultIndex="1"
61
+                     @tabChange="changepayType">
62 62
                   </tabSelect>
63 63
                </u-form-item>
64 64
             </view>
@@ -127,13 +127,13 @@ export default {
127 127
             recyclePersonId: '',
128 128
             orderType: '',
129 129
             orderDate: this.$dayjs().format('YYYY-MM-DD'),
130
-            payTypeTab: 1,
130
+            payType: 1,
131 131
             afterSaleTab: [],
132 132
             remark: '',
133 133
             address: '',
134 134
          },
135 135
          orderTypeList: [],
136
-         payTypeTabList: [
136
+         payTypeList: [
137 137
             {
138 138
                name: '微信',
139 139
                value: 1,
@@ -211,8 +211,8 @@ export default {
211 211
       changeOrderType(val) {
212 212
          this.openOrderForm.orderType = val
213 213
       },
214
-      changepayTypeTab(val) {
215
-         this.openOrderForm.payTypeTab = val
214
+      changepayType(val) {
215
+         this.openOrderForm.payType = val
216 216
       },
217 217
       changeAfterSaleTab(val) {
218 218
          this.openOrderForm.afterSaleTab = val

+ 2 - 2
pages/wareHouse/styles/index.scss

@@ -256,7 +256,7 @@
256 256
     padding: 20rpx;
257 257
     box-sizing: border-box;
258 258
     display: flex;
259
-    align-items: flex-start;
259
+    align-items: stretch;
260 260
     gap: 20rpx;
261 261
 
262 262
     .goods-img-container {
@@ -351,8 +351,8 @@
351 351
     .more{
352 352
       display: flex;
353 353
       flex-direction: column;
354
-      height: auto;
355 354
       align-items: flex-end;
355
+      justify-content: space-between;
356 356
       gap: 20rpx;
357 357
       .goods-stock {
358 358
         font-size: 24rpx;

BIN
static/parson/permission.png


+ 140 - 28
store/modules/user.js

@@ -42,6 +42,9 @@ export default {
42 42
 		systemList: [],
43 43
 
44 44
 		redirectUrl: null,
45
+		availableRoles: [], // 可用的角色列表
46
+		currentRoleIndex: 0, // 当前选中的角色索引
47
+		showRoleSwitch: false, // 是否显示切换权限按钮
45 48
 	},
46 49
 	mutations: {
47 50
 		SET_REDIRECTURL(state, data) {
@@ -52,11 +55,61 @@ export default {
52 55
 		},
53 56
 		SET_USERINFO: (state, data) => {
54 57
 			state.userInfo = data;
55
-			// 动态设置 tabBar
56
-				setTimeout(() => {
57
-					setupTabBar(data);
58
-				}, 100);
58
+			const roles = data.roles || [];
59
+			
60
+			const validRoles = [];
61
+			
62
+			const hasWarehouser = roles.some(role => role.roleKey === 'WAREHOUSER');
63
+			if (hasWarehouser) {
64
+				validRoles.push('WAREHOUSER');
65
+			}
66
+			
67
+			const hasSalesman = roles.some(role => role.roleKey === 'SALESMAN');
68
+			if (hasSalesman) {
69
+				validRoles.push('SALESMAN');
70
+			}
71
+			
72
+			const hasCrmRole = roles.some(role => role.roleKey && role.roleKey.includes('CRM'));
73
+			if (hasCrmRole) {
74
+				validRoles.push('CRM');
75
+			}
76
+			
77
+			const showSwitch = validRoles.length >= 2;
78
+			state.showRoleSwitch = showSwitch;
79
+			state.availableRoles = validRoles;
80
+			state.currentRoleIndex = 0;
81
+			
82
+			setTimeout(() => {
83
+				const allIndices = [0, 1, 2, 3, 4, 5, 6];
84
+				allIndices.forEach(index => {
85
+					uni.setTabBarItem({ index, visible: false });
86
+				});
87
+				
88
+				const currentRole = validRoles[0] || '';
89
+				
90
+				switch (currentRole) {
91
+					case 'SALESMAN':
92
+						// 展示核价中心、询价中心、我的
93
+						uni.setTabBarItem({ index: 3, visible: true }); // 询价中心
94
+						uni.setTabBarItem({ index: 4, visible: true }); // 核价中心
95
+						break;
96
+					case 'WAREHOUSER':
97
+						// 展示仓库中心、我的
98
+						uni.setTabBarItem({ index: 2, visible: true }); // 仓库
99
+						break;
100
+					case 'CRM':
101
+						// 展示首页、线索公海、销售线索、接单中心、我的
102
+						uni.setTabBarItem({ index: 0, visible: true }); // 首页
103
+						uni.setTabBarItem({ index: 1, visible: true }); // 线索公海
104
+						uni.setTabBarItem({ index: 5, visible: true }); // 销售线索
105
+						uni.setTabBarItem({ index: 6, visible: true }); // 接单中心
106
+						break;
107
+				}
108
+				
109
+				uni.setTabBarItem({ index: 7, visible: true }); // 我的
110
+			}, 100);
59 111
 		},
112
+
60 113
 		SET_TOKEN: (state, data) => {
61 114
 			state.token = data;
62 115
 		},
@@ -98,6 +151,44 @@ export default {
98 151
 		},
99 152
 		SET_SYSTEM_LIST(state, data) {
100 153
 			state.systemList = data;
154
+		},
155
+		// 权限相关mutations
156
+		SET_AVAILABLE_ROLES(state, roles) {
157
+			state.availableRoles = roles;
158
+		},
159
+		SET_CURRENT_ROLE_INDEX(state, index) {
160
+			state.currentRoleIndex = index;
161
+		},
162
+		SET_SHOW_ROLE_SWITCH(state, show) {
163
+			state.showRoleSwitch = show;
164
+		},
165
+		SWITCH_ROLE({}, role) {
166
+			setTimeout(() => {
167
+				const allIndices = [0, 1, 2, 3, 4, 5, 6];
168
+				allIndices.forEach(index => {
169
+					uni.setTabBarItem({ index, visible: false });
170
+				});
171
+				switch (role.value) {
172
+					case 'SALESMAN':
173
+						// 展示核价中心、询价中心、我的
174
+						uni.setTabBarItem({ index: 3, visible: true }); // 询价中心
175
+						uni.setTabBarItem({ index: 4, visible: true }); // 核价中心
176
+						break;
177
+					case 'WAREHOUSER':
178
+						// 展示仓库中心、我的
179
+						uni.setTabBarItem({ index: 2, visible: true }); // 仓库
180
+						break;
181
+					case 'CRM':
182
+						// 展示首页、线索公海、销售线索、接单中心、我的
183
+						uni.setTabBarItem({ index: 0, visible: true }); // 首页
184
+						uni.setTabBarItem({ index: 1, visible: true }); // 线索公海
185
+						uni.setTabBarItem({ index: 5, visible: true }); // 销售线索
186
+						uni.setTabBarItem({ index: 6, visible: true }); // 接单中心
187
+						break;
188
+				}
189
+				
190
+				uni.setTabBarItem({ index: 7, visible: true }); // 我的
191
+			}, 100);
101 192
 		}
102 193
 	},
103 194
 	actions: {
@@ -168,30 +259,51 @@ export default {
168 259
 	}
169 260
 }
170 261
 
171
-function setupTabBar(userInfo) {
172
-		const roles = userInfo.roles;
173
-		// 我的 是所有用户都有的
174
-		// 如果是销售经理SALESMAN,则也展示询价中心、核价中心、仓库
175
-		// 如果是其他角色,则也展示首页、线索公海、销售线索、接单中心
262
+export function setupTabBar(userInfo, availableRoles, currentRoleIndex) {
263
+		// 隐藏所有tabbar项,然后根据当前角色显示对应的项
176 264
 		// 下标index从0开始
177
-		const hasSalesmanRole = roles.some(role => role.roleKey === 'SALESMAN');
178
-		if (hasSalesmanRole) {
179
-			uni.setTabBarItem({ index: 2,visible: true });//仓库
180
-			uni.setTabBarItem({ index: 3,visible: true });//询价中心
181
-			uni.setTabBarItem({ index: 4,visible: true });//核价中心
182
-
183
-			uni.setTabBarItem({ index: 0,visible: false });//首页
184
-			uni.setTabBarItem({ index: 1,visible: false });//线索公海
185
-			uni.setTabBarItem({ index: 5,visible: false });//销售线索
186
-			uni.setTabBarItem({ index: 6,visible: false });//接单中心
187
-		}else{
188
-			uni.setTabBarItem({ index: 0,visible: true });//首页
189
-			uni.setTabBarItem({ index: 1,visible: true });//线索公海
190
-			uni.setTabBarItem({ index: 5,visible: true });//销售线索
191
-			uni.setTabBarItem({ index: 6,visible: true });//接单中心
192
-
193
-			uni.setTabBarItem({ index: 2,visible: false });//仓库
194
-			uni.setTabBarItem({ index: 3,visible: false });//询价中心
195
-			uni.setTabBarItem({ index: 4,visible: false });//核价中心
265
+		const allIndices = [0, 1, 2, 3, 4, 5, 6];
266
+		allIndices.forEach(index => {
267
+			uni.setTabBarItem({ index, visible: false });
268
+		});
269
+		
270
+		// 获取当前角色
271
+		const currentRole = availableRoles[currentRoleIndex] || '';
272
+		
273
+		// 根据当前角色显示对应的tabbar
274
+		switch (currentRole) {
275
+			case 'SALESMAN':
276
+				// 展示核价中心、询价中心、我的
277
+				uni.setTabBarItem({ index: 3, visible: true }); // 询价中心
278
+				uni.setTabBarItem({ index: 4, visible: true }); // 核价中心
279
+				break;
280
+			case 'WAREHOUSER':
281
+				// 展示仓库中心、我的
282
+				uni.setTabBarItem({ index: 2, visible: true }); // 仓库
283
+				break;
284
+			case 'CRM':
285
+				// 展示首页、线索公海、销售线索、接单中心、我的
286
+				uni.setTabBarItem({ index: 0, visible: true }); // 首页
287
+				uni.setTabBarItem({ index: 1, visible: true }); // 线索公海
288
+				uni.setTabBarItem({ index: 5, visible: true }); // 销售线索
289
+				uni.setTabBarItem({ index: 6, visible: true }); // 接单中心
290
+				break;
291
+			default:
292
+				// 默认情况,显示CRM相关的tabbar
293
+				uni.setTabBarItem({ index: 0, visible: true }); // 首页
294
+				uni.setTabBarItem({ index: 1, visible: true }); // 线索公海
295
+				uni.setTabBarItem({ index: 5, visible: true }); // 销售线索
296
+				uni.setTabBarItem({ index: 6, visible: true }); // 接单中心
297
+				break;
196 298
 		}
299
+		
300
+		// "我的"tab默认都展示(假设我的tab是index为7的位置)
301
+		// 注意:这里需要根据实际的tabbar配置来调整index
302
+		// 如果"我的"tab的index不是7,请修改下面的代码
303
+		uni.setTabBarItem({ index: 7, visible: true }); // 我的
304
+}
305
+
306
+// 导出切换权限的action
307
+export function switchRole({ commit, state }, currentRole) {
308
+	commit('SWITCH_ROLE', currentRole);
197 309
 }