index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar
  4. fixed
  5. statusBar
  6. left-icon="back"
  7. :title="navTitle"
  8. @clickLeft="back"
  9. />
  10. <!-- Tab 切换 -->
  11. <view class="tab-bar">
  12. <view
  13. class="tab-item"
  14. :class="{ active: activeTab === 'accident' }"
  15. @click="switchTab('accident')"
  16. >事故事件</view
  17. >
  18. <view
  19. class="tab-item"
  20. :class="{ active: activeTab === 'process' }"
  21. @click="switchTab('process')"
  22. >处理</view
  23. >
  24. </view>
  25. <!-- 内容 -->
  26. <view class="tab-content">
  27. <accident v-if="activeTab === 'accident'" ref="accidentRef" />
  28. <process v-if="activeTab === 'process'" ref="processRef" />
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import accident from "./accident.vue";
  34. import process from "./process.vue";
  35. export default {
  36. components: { accident, process },
  37. data() {
  38. return {
  39. activeTab: "accident",
  40. };
  41. },
  42. computed: {
  43. navTitle() {
  44. return "事故上报";
  45. },
  46. },
  47. methods: {
  48. back() {
  49. uni.navigateBack();
  50. },
  51. switchTab(tab) {
  52. if (this.activeTab === tab) return;
  53. this.activeTab = tab;
  54. // 刷新对应列表
  55. this.$nextTick(() => {
  56. if (tab === "accident" && this.$refs.accidentRef) {
  57. this.$refs.accidentRef.reloadList();
  58. } else if (tab === "process" && this.$refs.processRef) {
  59. this.$refs.processRef.reloadList();
  60. }
  61. });
  62. },
  63. },
  64. };
  65. </script>
  66. <style lang="scss" scoped>
  67. .mainBox {
  68. background: #f5f7fb;
  69. min-height: 100vh;
  70. }
  71. .tab-bar {
  72. display: flex;
  73. background: #fff;
  74. border-bottom: 2rpx solid #eef2f6;
  75. .tab-item {
  76. flex: 1;
  77. text-align: center;
  78. padding: 24rpx 0;
  79. font-size: 30rpx;
  80. color: #666;
  81. &.active {
  82. color: $theme-color;
  83. font-weight: bold;
  84. border-bottom: 4rpx solid $theme-color;
  85. }
  86. }
  87. }
  88. .tab-content {
  89. flex: 1;
  90. padding: 16rpx 24rpx;
  91. }
  92. </style>