混凝土运输管理微信小程序、替班
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.1 KiB

2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
2 weeks ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
  1. <template>
  2. <view class="page">
  3. <navbar :title="pageTitle" />
  4. <view class="content">
  5. <!-- 用户/泵司抢单大厅 -->
  6. <user-hall v-if="Number(role) === 0" ref="us"></user-hall>
  7. <!-- 企业订单管理 -->
  8. <enterprise-hall v-if="Number(role) === 1" ref="eh"></enterprise-hall>
  9. <!-- 员工订单大厅 -->
  10. <staff-hall v-if="Number(role) === 2" ref="ss"></staff-hall>
  11. <!-- 区域管理员订单 -->
  12. <region-hall v-if="Number(role) === 3" ref="rh"></region-hall>
  13. </view>
  14. <tabber select="order" />
  15. </view>
  16. </template>
  17. <script>
  18. import navbar from '@/components/base/navbar.vue'
  19. import tabber from '@/components/base/tabbar.vue'
  20. import UserHall from '@/components/user/hall.vue'
  21. import StaffHall from '@/components/staff/hall.vue'
  22. import EnterpriseHall from '@/components/enterprise/hall.vue'
  23. import RegionHall from '@/components/region/hall.vue'
  24. import { mapState, mapGetters, mapMutations } from 'vuex'
  25. export default {
  26. components: {
  27. navbar,
  28. tabber,
  29. UserHall,
  30. StaffHall,
  31. EnterpriseHall,
  32. RegionHall
  33. },
  34. data() {
  35. return {
  36. }
  37. },
  38. computed: {
  39. ...mapState(['role']),
  40. ...mapGetters(['currentRoleText']),
  41. pageTitle() {
  42. const roleNum = Number(this.role);
  43. if (roleNum === 0) {
  44. return '抢单大厅';
  45. } else if (roleNum === 1) {
  46. return '企业订单';
  47. } else if (roleNum === 2) {
  48. return '员工订单';
  49. } else if (roleNum === 3) {
  50. return '区域订单';
  51. } else {
  52. return '订单';
  53. }
  54. }
  55. },
  56. onShow() {
  57. // 初始化角色
  58. this.initRole();
  59. // 设置导航栏标题
  60. uni.setNavigationBarTitle({ title: this.pageTitle });
  61. // 监听角色变更事件
  62. uni.$on('roleChanged', this.handleRoleChange);
  63. // 刷新对应的组件数据
  64. this.refreshCurrentComponent();
  65. },
  66. onHide() {
  67. // 移除事件监听
  68. uni.$off('roleChanged', this.handleRoleChange);
  69. },
  70. methods: {
  71. ...mapMutations(['initRole']),
  72. // 处理角色变更
  73. handleRoleChange(newRole) {
  74. console.log('订单页面收到角色变更:', newRole);
  75. // 更新导航栏标题
  76. uni.setNavigationBarTitle({ title: this.pageTitle });
  77. // 刷新对应组件
  78. this.$nextTick(() => {
  79. this.refreshCurrentComponent();
  80. });
  81. },
  82. // 刷新当前角色对应的组件
  83. refreshCurrentComponent() {
  84. this.$nextTick(() => {
  85. try {
  86. const roleNum = Number(this.role);
  87. if (roleNum === 0) {
  88. this.$refs.us && this.$refs.us.loadPage && this.$refs.us.loadPage();
  89. } else if (roleNum === 1) {
  90. this.$refs.eh && this.$refs.eh.loadPage && this.$refs.eh.loadPage();
  91. } else if (roleNum === 2) {
  92. this.$refs.ss && this.$refs.ss.loadPage && this.$refs.ss.loadPage();
  93. } else if (roleNum === 3) {
  94. this.$refs.rh && this.$refs.rh.loadPage && this.$refs.rh.loadPage();
  95. }
  96. } catch (e) {
  97. console.log('组件方法调用失败:', e);
  98. }
  99. });
  100. }
  101. }
  102. }
  103. </script>
  104. <style scoped lang="scss">
  105. .page {
  106. display: flex;
  107. flex-direction: column;
  108. height: 100vh;
  109. background-color: #f5f5f5;
  110. }
  111. .content {
  112. flex: 1;
  113. overflow: hidden;
  114. padding-bottom: 120rpx; /* 为底部tabbar留出空间 */
  115. }
  116. </style>