fix
pyt
8 小时以前 c1be9c1e28e022ad37b74e091ca6eb90e5032c19
fix
1个文件已修改
120 ■■■■ 已修改文件
H5/pages/statistics/index.vue 120 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/pages/statistics/index.vue
@@ -50,7 +50,7 @@
          <view class="color6"> 同比上月 </view>
          <view class="txt-aligin-r color4 font-bold mt-4">
            {{ statisticsData.satisfaction.compare > 0 ? "+" : ""
            }}{{ statisticsData.satisfaction.compare }}%
            }}{{ (statisticsData.satisfaction.compare * 1).toFixed(2) }}%
          </view>
        </view>
      </view>
@@ -75,8 +75,7 @@
          <view class="fs-23">
            <view class=""> 同比上月 </view>
            <view class="font-bold color8 txt-aligin-r mt-4">
              {{ statisticsData.demands.compare > 0 ? "+" : ""
              }}{{ statisticsData.demands.compare }}
              {{ (statisticsData.demands.compare * 1).toFixed(2) }}
            </view>
          </view>
        </view>
@@ -99,8 +98,7 @@
          <view class="fs-23">
            <view class=""> 同比上月 </view>
            <view class="font-bold color4 txt-aligin-r mt-4">
              {{ statisticsData.processTime.compare > 0 ? "+" : ""
              }}{{ statisticsData.processTime.compare }}
              {{ (statisticsData.processTime.compare * 1).toFixed(2) }}
            </view>
          </view>
        </view>
@@ -154,8 +152,7 @@
        <view class="fs-23 mt-44">
          <view class="color6"> 同比上月 </view>
          <view class="txt-aligin-r color4 font-bold mt-4">
            {{ statisticsData.overtime.compare > 0 ? "+" : ""
            }}{{ statisticsData.overtime.compare }}
            {{ (statisticsData.overtime.compare * 1).toFixed(2) }}
          </view>
        </view>
      </view>
@@ -311,13 +308,13 @@
        <view class="txt-center pt-38 pb-40 fs-35 lh-48 font-bold"
          >请选择服务社区</view
        >
        <!-- <view
        <view
          class="flex a-center j-between txt-center py-10 fs-27 font-bold bgColor1"
        >
          <view v-if="hasTier(2)" class="flex1">区县</view>
          <view v-if="hasTier(3)" class="flex1">街道</view>
          <view v-if="hasTier(4)" class="flex1">社区</view>
        </view> -->
          <view v-if="showCountyColumn" class="flex1">区县</view>
          <view v-if="showStreetColumn" class="flex1">街道</view>
          <view v-if="showCommunityColumn" class="flex1">社区</view>
        </view>
        <view class="mb-20">
          <picker-view
            :value="value"
@@ -325,7 +322,7 @@
            class="picker-view"
            immediate-change
          >
            <picker-view-column v-if="hasTier(2)">
            <picker-view-column v-if="showCountyColumn">
              <view
                class="item"
                v-for="(item, index) in regionTree"
@@ -334,7 +331,7 @@
                {{ item.name }}
              </view>
            </picker-view-column>
            <picker-view-column v-if="hasTier(3)">
            <picker-view-column v-if="showStreetColumn">
              <view
                class="item"
                v-for="(item, index) in getStreets()"
@@ -343,7 +340,7 @@
                {{ item.name }}
              </view>
            </picker-view-column>
            <picker-view-column v-if="hasTier(4)">
            <picker-view-column v-if="showCommunityColumn">
              <view
                class="item"
                v-for="(item, index) in getCommunities()"
@@ -439,7 +436,29 @@
      satisfactionRate: 0,
      generalSatisfactionRate: 0,
      dissatisfactionRate: 0,
      showCountyColumn: false,
    };
  },
  computed: {
    showStreetColumn() {
      // 判断当前选中的区县/第一级是否有 children 且有街道
      const lastItem = this.regionTree[this.regionTree.length - 1];
      if (!lastItem) return false;
      // 区县为第一级
      if (lastItem.tier === 2) {
        const county = this.regionTree[this.value[0]];
        return county && Array.isArray(county.children) && county.children.some(c => c && c.tier === 3);
      }
      // 街道为第一级
      if (lastItem.tier === 3) {
        return this.regionTree.length > 1;
      }
      return false;
    },
    showCommunityColumn() {
      const communities = this.getCommunities();
      return communities.length > 0;
    },
  },
  onLoad() {
    this.userInfo = uni.getStorageSync("userInfo");
@@ -476,6 +495,9 @@
          this.address = "全部";
          this.currentAreaId = '';
          this.currentTier = -1;
          // showCountyColumn 仍然根据最后一项 tier 判断
          const lastItem = this.regionTree[this.regionTree.length - 1];
          this.showCountyColumn = lastItem && lastItem.tier === 2;
          this.getStatisticsData("", -1);
          this.getChartData(1);
          this.getTypeRankData();
@@ -592,6 +614,8 @@
      this.value = newValue;
    },
    openSelectPopup() {
      console.log(this.regionTree);
      this.value = this.confirmValue;
    },
    handleTabClick(index) {
@@ -716,7 +740,7 @@
        tooltip: {
          trigger: "item",
          confine: true,
          // formatter: '{b}: {c}%',
          formatter: '{b}: {c}%',
          backgroundColor: "rgba(255, 255, 255, 0.9)",
          borderColor: "#FFE0E0",
          borderWidth: 1,
@@ -799,9 +823,13 @@
      }
    },
    hasTier(tier) {
      // tier=2: 区县始终有
      // 检查最后一项的数据类型
      const lastItem = this.regionTree[this.regionTree.length - 1];
      if (!lastItem) return false;
      // 如果最后一项是区县
      if (lastItem.tier === 2) {
      if (tier === 2) return true;
      // tier=3: 当前区县children里有tier=3
      if (tier === 3) {
        const county = this.regionTree[this.value[0]];
        return (
@@ -810,7 +838,6 @@
          county.children.some((c) => c && c.tier === 3)
        );
      }
      // tier=4: 当前区县children里有tier=4,或街道children里有tier=4
      if (tier === 4) {
        const county = this.regionTree[this.value[0]];
        if (!county || !Array.isArray(county.children)) return false;
@@ -824,31 +851,78 @@
          street.children.some((c) => c && c.tier === 4)
        );
      }
      }
      // 如果最后一项是街道
      else if (lastItem.tier === 3) {
        if (tier === 3) return true;
        if (tier === 4) {
          const street = this.regionTree[this.value[0]];
          return (
            street &&
            Array.isArray(street.children) &&
            street.children.some((c) => c && c.tier === 4)
          );
        }
      }
      // 如果最后一项是社区
      else if (lastItem.tier === 4) {
        return tier === 4;
      }
      return false;
    },
    getStreets() {
      const county = this.regionTree[this.value[0]];
      if (!county || !Array.isArray(county.children)) return [];
      // 只返回tier=3的
      // 如果第一层是街道
      if (this.regionTree[this.regionTree.length - 1]?.tier === 3) {
        return this.regionTree.slice(1).map(item => ({
          name: item.name,
          id: item.id,
          tier: item.tier,
          children: item.children || []
        }));
      }
      // 如果当前选中的是区县
      if (county.tier === 2) {
      const streets = county.children.filter((c) => c && c.tier === 3);
      return streets.length
        ? [{ name: "全部", id: "all", tier: 3, children: [] }, ...streets]
        : [];
      }
      return [];
    },
    getCommunities() {
      const county = this.regionTree[this.value[0]];
      if (!county || !Array.isArray(county.children)) return [];
      // 如果第一层是街道
      if (this.regionTree[this.regionTree.length - 1]?.tier === 3) {
        const street = this.regionTree[this.value[0]];
        if (!street || street.id === 'all') return [];
        const communities = street.children?.filter(c => c && c.tier === 4) || [];
        return communities.length ? [{ name: "全部", id: "all", tier: 4 }, ...communities] : [];
      }
      // 如果当前选中的是区县
      if (county.tier === 2) {
      // 区县下直接有社区
      const communities = county.children.filter((c) => c && c.tier === 4);
      if (communities.length)
        return [{ name: "全部", id: "all", tier: 4 }, ...communities];
      // 区县下有街道,街道下有社区
      const street = county.children[this.value[1]];
        const street = county.children[this.value[1] - 1];
      if (street && Array.isArray(street.children)) {
        const comms = street.children.filter((c) => c && c.tier === 4);
        if (comms.length)
          return [{ name: "全部", id: "all", tier: 4 }, ...comms];
      }
      }
      return [];
    },
    async getChartData(timeType = 1) {
@@ -1189,5 +1263,9 @@
.type-rank-list-scroll {
  max-height: 500rpx;
  overflow-y: auto;
  /deep/ .u-line-progress__line {
    min-width: 40rpx;
  }
}
</style>