|
@@ -134,7 +134,8 @@
|
|
|
|
|
|
<!-- 页脚区域 -->
|
|
<!-- 页脚区域 -->
|
|
<view class="footer-div">
|
|
<view class="footer-div">
|
|
- <u-button type="primary" text="创建工单" @click="openPatrolWorkOrderForm()"></u-button>
|
|
|
|
|
|
+ <u-button v-if="userInfo.roleNames == '巡视员' " type="primary" text="巡视工单" @click="openPatrolWorkOrderForm()"></u-button>
|
|
|
|
+ <u-button v-if="userInfo.roleNames == '村负责人' " type="primary" text="清运工单" @click="openPatrolWorkOrderForm()"></u-button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
@@ -249,8 +250,21 @@
|
|
userId: (state) => state.user.id
|
|
userId: (state) => state.user.id
|
|
}),
|
|
}),
|
|
dynamicStyle() {
|
|
dynamicStyle() {
|
|
|
|
+ // 增加空值检查
|
|
|
|
+ if (!this.userInfo || !this.userInfo.roleNames) {
|
|
|
|
+ // 如果 userInfo 或 roleNames 不存在,返回一个默认样式
|
|
|
|
+ return {
|
|
|
|
+ height: '130px',
|
|
|
|
+ borderRadius: '15px',
|
|
|
|
+ backgroundImage: 'linear-gradient(to right, #3cb54b 0%, #88c546 100%)'
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 直接通过 this.userInfo 访问 userInfo 中的属性
|
|
|
|
+ // 如果 userInfo 存在,继续执行原来的逻辑
|
|
|
|
+ const roleNames = this.userInfo.roleNames;
|
|
// 根据从 Vuex 获取的状态来判断样式
|
|
// 根据从 Vuex 获取的状态来判断样式
|
|
- switch (this.userInfo.roleNames) {
|
|
|
|
|
|
+ switch (roleNames) {
|
|
case '过磅专员':
|
|
case '过磅专员':
|
|
return {
|
|
return {
|
|
height: '130px',
|
|
height: '130px',
|
|
@@ -283,6 +297,7 @@
|
|
async mounted() {
|
|
async mounted() {
|
|
this.loadmore()
|
|
this.loadmore()
|
|
//获取当前人对应的负责流程的信息
|
|
//获取当前人对应的负责流程的信息
|
|
|
|
+ this.fetchUserInfo(); // 模拟获取用户信息
|
|
|
|
|
|
|
|
|
|
/*let res = await actCategoryService.treeData()
|
|
/*let res = await actCategoryService.treeData()
|
|
@@ -314,6 +329,16 @@
|
|
},
|
|
},
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
|
|
+ async fetchUserInfo() {
|
|
|
|
+ try {
|
|
|
|
+ // 这里调用获取数据的 API 或者 Vuex action
|
|
|
|
+ await this.$store.dispatch('fetchUserInfo'); // 示例
|
|
|
|
+ this.isLoading = false; // 数据加载完成,关闭加载状态
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('获取用户信息失败:', error);
|
|
|
|
+ this.isLoading = false; // 即使加载失败也需要关闭加载状态
|
|
|
|
+ }
|
|
|
|
+ },
|
|
tabSelect(index) {
|
|
tabSelect(index) {
|
|
this.tabIndex = index;
|
|
this.tabIndex = index;
|
|
},
|
|
},
|