Statistics.vue 6.18 KB
<template>
  <div class="statistics">
    <div class="headline">{{ statisticsObj.title }}</div>
    <div class="flex">
      <template v-for="value in statisticsObj.cumulative && statisticsObj.cumulative">
        <div class="text-half" :key="value.id + 'cumulative'">
          <div class="small-text">{{ value.title }}</div>
          <div class="num-text">
            <span v-if="value.type == 0">¥</span>
            {{ value.value(reportData) }}
          </div>
        </div>
      </template>
    </div>
    <div class="flex-between">
      <template v-if="statisticsObj.new && statisticsObj.new.length > 0">
        <van-swipe :loop="false" :show-indicators="false" :width="200">
          <template v-for="(add, addIndex) in statisticsObj.new">
            <van-swipe-item class="container" :key="add.id + 'new'">
              <div class="text-message">{{ add.title }}</div>
              <div class="flex-between">
                <span class="add-count">
                  <label v-if="tabIndex == 1"><template v-if="addIndex == 0">¥</template></label>
                  {{ add.value(reportData) }}
                </span>
                <template v-if="add.sequential(reportData)">
                  <div class="ratio text-message flex">
                    <span :class="['flex', add.up(reportData) == 0 ? 'bcolor' : 'ycolor']">
                      <template v-if="add.sequential(reportData) != '0%'">
                        <div :class="['sprite-icon', add.up(reportData) == 0 ? 'icon-iconup' : 'icon-icondown']"></div>
                      </template>
                      {{ add.sequential(reportData) }}
                    </span>
                  </div>
                </template>
                <template v-else>
                  <span class="text-message">{{ reportType == 0 ? '周环比:' : '月环比:' }}-</span>
                </template>
              </div>
              <div class="flex">
                <div :class="['sprite-icon', 'icon-' + add.icon]"></div>
                <template v-if="add.list">
                  <div class="customer-info">
                    <span class="text-message mb">{{ add.list.customerTitle }}:{{ add.list.customerValue(reportData) }}</span>
                    <span class="text-message">{{ add.list.qyTitle }}:{{ add.list.qyValue(reportData) }}</span>
                  </div>
                </template>

                <template v-if="add.info">
                  <div class="customer-info">
                    <span class="text-message mb">{{ add.info.title }}</span>
                    <div class="gray-text flex">
                      {{ add.info.value(reportData) }}
                      <template v-if="add.info.sequential(reportData)">
                        <div class="ratio text-message flex">
                          {{ reportType == 0 ? '周环比:' : '月环比:' }}
                          <label :class="['flex', add.info.up(reportData) == 0 ? 'applybcolor' : 'applyycolor']">
                            <template v-if="add.info.sequential(reportData) != '0%'">
                              <div :class="['sprite-icon', add.info.up(reportData) == 0 ? 'icon-iconup' : 'icon-icondown']"></div>
                            </template>
                            {{ add.info.sequential(reportData)}}
                          </label>
                        </div>
                      </template>
                       <div v-else class="ratio text-message flex ">
                          {{ reportType == 0 ? '周环比:' : '月环比:' }}-
                        </div>
                    </div>
                  </div>
                </template>
              </div>
            </van-swipe-item>
          </template>
        </van-swipe>
      </template>
    </div>
  </div>
</template>

<script type='text/ecmascript-6'>
import { mapState } from 'vuex'
export default {
  name: 'Statistics',
  data() {
    return {
      value: this.keyword
    }
  },
  computed: {
    ...mapState({
      reportType: state => state.report.reportType,
      reportData: state => state.report.reportData,
      statisticsObj: state => state.report.statisticsObj,
      tabIndex: state => state.report.tabIndex
    })
  },
  mounted() {},
  methods: {}
}
</script>

<style scoped lang='scss'>
.statistics {
  margin: 20px 0 30px 0;
  .headline {
    margin-bottom: 10px;
  }
  .headline::before {
    content: '.';
    width: 3px;
    height: 15px;
    background: #ffffff;
    border-radius: 2px;
    color: #ffffff;
    margin-right: 5px;
    box-sizing: border-box;
  }
  .text-half {
    .small-text {
      margin-bottom: 5px;
    }
  }
  .flex-between {
    width: 100%;
    box-sizing: border-box;
  }

  .container {
    width: 167px !important;
    height: 106px;
    background: #ffffff;
    box-shadow: 0px 3px 8px 0px rgba(170, 180, 209, 0.2);
    border-radius: 4px;
    padding: 10px;
    box-sizing: border-box;
    margin-top: 10px;
    margin-right: 10px;
    .add-count {
      height: 25px;
      font-size: 18px;
      font-weight: 600;
      color: #333333;
      line-height: 25px;
      margin-bottom: 2px;
    }
    .ratio {
      span {
        padding: 0 1px;
        width: auto;
        border-radius: 3px;
        height: 15px;
        font-size: 10px;
        font-weight: 500;
        line-height: 15px;
        margin-left: 5px;
      }
      & .bcolor {
        background: #d0def1;
        color: #3975c6;
      }
      & .ycolor {
        background: #f5ddb5;
        color: #df8500;
      }
      label {
        font-weight: 500;
        color: #3975c6;
        line-height: 15px;
      }
      // & .up {
      //   transform: rotate(180deg);
      //   line-height: 15px;
      // }
    }
    .customer-info {
      width: 65%;
      .gray-text {
        .text-message {
          font-size: 10px;
        }
        .ratio {
          margin-left: 2px;
          margin-bottom: 0;
          & .applybcolor {
            color: #3975c6;
          }
          & .applyycolor {
            color: #df8500;
          }
        }
      }
    }
  }
}

.statistics /deep/ .van-swipe {
  margin-right: -15px;
  .van-swipe__track {
    margin-right: 10px;
    height: auto;
    width: 100% !important;
    .van-swipe-item {
      width: 167px !important;
    }
  }
}
</style>