storeIndicators.vue 5.28 KB
<!-- 门店指标 -->
<template>
  <div class="store-wrap" v-if="storeIndicatoerInfo">
    <div class="store-item">
      <div class="name">门店总数</div>
      <div class="value">{{ storeIndicatoerInfo.merchantCount }}</div>
      <div class="detail" @click="handleDetail(storeIndicatoerInfo)">
        详情<i class="el-icon-arrow-right"></i>
      </div>
    </div>
    <template
      v-if="storeIndicatoerInfo && storeIndicatoerInfo.metricDTOList.length"
    >
      <div
        v-for="(item, index) in storeIndicatoerInfo.metricDTOList"
        :key="index"
        class="store-item"
      >
        <template v-if="item">
          <div class="name">{{ indicatorCode[item.metricCode] }}</div>
          <div class="value">
            {{ item.metricValue === 0 ? 0 : item.metricValue || "-" }}
          </div>
          <div class="link">
            环比<span
              v-if="item.linkRelativeRatio || item.linkRelativeRatio === 0"
              :class="[
                item.linkRelativeRatio
                  ? String(item.linkRelativeRatio).indexOf('-') > -1
                    ? 'dowm'
                    : 'up'
                  : ''
              ]"
              >{{
                item.linkRelativeRatio === 0
                  ? "0%"
                  : item.linkRelativeRatio + "%" || "-"
              }}</span
            >
            <span v-else>-</span>
            <template v-if="item.linkRelativeRatio">
              <div
                class="triangle-down"
                v-if="String(item.linkRelativeRatio).indexOf('-') > -1"
              ></div>
              <div class="triangle-up" v-else></div>
            </template>
          </div>
        </template>
      </div>
    </template>
  </div>
</template>
<script>
import { findAllItem } from "@/api/serviceCentre"
export default {
  data() {
    return {
      storeIndicatoerInfo: "",
      indicatorCode: {
        A075: "订单数",
        A036: "产值(元)",
        A076: "客单价(元)",
        A062: "交车数",
        A063: "触客数"
      },
      storeList: [
        {
          name: "门店总数",
          value: "100",
          addHtml: "store",
          id: 9999
        },
        {
          name: "产值(元)",
          value: "100",
          link: "11%",
          trend: () => {
            return false
          }
        },
        {
          name: "客单价(元)",
          value: "100",
          link: "11%",
          trend: () => {
            return false
          }
        },
        {
          name: "交车数",
          value: "100",
          link: "11%",
          trend: () => {
            return false
          }
        },
        {
          name: "触客数",
          value: "100",
          link: "11%",
          trend: () => {
            return false
          }
        },
        {
          name: "订单数",
          value: "100",
          link: "11%",
          trend: () => {
            return false
          }
        }
      ]
    }
  },
  props: {
    longAllData: {},
    longForm: {
      type: Object,
      default: () => {}
    }
  },
  watch: {
    longForm: {
      handler(val) {
        this.findAllItemData()
      },
      deep: true,
      immediate: true
    }
  },
  mounted() {
    this.findAllItemData()
  },
  methods: {
    findAllItemData() {
      console.log(33333333333333333)
      let params = {
        ...this.longForm
      }
      findAllItem(params)
        .then((res) => {
          this.storeIndicatoerInfo = res
          this.storeIndicatoerInfo.id = "-9999"
        })
        .catch((err) => {
          new Error(err)
        })
    },
    handleDetail(row) {
      row.activeName = "storeInfo"
      row.pageId = row.id
      row.merchantNos = row.merchantCount ? row.merchantNos : [-1]
      row.scene = this.longForm.scene
      this.$emit("openWindow", row)
    }
  },
  mounted() {}
}
</script>
<style lang="scss" scoped>
.store-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
  .store-item {
    width: calc((100% / 3) - (16px * 2 / 3));
    min-width: 376px;
    height: 124px;
    border-radius: 4px;
    opacity: 1;
    background: #f8faff;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-sizing: border-box;
    margin-right: 16px;
    .name {
      color: #333333;
      font-size: 14px;
      font-weight: 400;
    }
    .value {
      color: #1d1d1d;
      font-size: 32px;
      font-weight: 500;
      margin: 8px 0;
    }
    .detail {
      color: #2a58ad;
      font-size: 14px;
      font-weight: 400;
      cursor: pointer;
    }
    .link {
      display: flex;
      align-items: center;
      color: #888888;
      font-size: 14px;
      font-weight: 400;
      span {
        margin: 0 6px;
      }
      span.up {
        color: #eb4e4e;
      }
      span.dowm {
        color: #43cf7c;
      }
    }
  }
  .store-item:nth-child(3n) {
    margin-right: 0;
  }
}
// 向上
.triangle-up {
  width: 0;
  height: 0;
  border-left: 3px solid transparent; /* 左半边透明 */
  border-right: 3px solid transparent; /* 右半边透明 */
  border-bottom: 6px solid #eb4e4e; /* 底部红色形成三角形 */
}
/* 向下 */
.triangle-down {
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 6px solid #43cf7c;
}
</style>