index.vue 9.86 KB
<template>
  <div class="shop-detail-box">
    <div class="shop-info">
      <div class="icon"></div>
      <div class="info">
        <div class="merchant-name flex">
          {{baseInfo.merchantName}}
          <div :class="['tag',{'grey':baseInfo.directSale == 0}]">{{
            {
              0:'非直营',
              1:'直营'
            }[baseInfo.directSale] }}</div>
        </div>
        <div class="text flex">
          <div class="merchant-id">{{baseInfo.merchantId}}</div>
          <div class="year">{{baseInfo.startBusiness}}</div>
          <div class="supervision-name flex">
            <div class="supervision-icon"></div>
            {{baseInfo.supervisionName}}
          </div>
        </div>
      </div>
      <template v-if="pageData.showTips">
        <div class="label-box">
          <div class="label-tab flex">
            <template v-for="(i,index) in labelList">
              <div
                :key="index"
                :class="['label-tab-item flex',{active: index == labelIndex}]"
                @click="labelIndex = index"
              >
                {{i.label}}
              </div>
            </template>
          </div>
          <div class="label-title flex">
            <i class="el-icon-warning"></i>
            异常{{labelList[labelIndex].label}}
          </div>
          <el-tooltip
            placement="bottom-end"
            popper-class="shop-tooltip"
          >
            <div
              slot="content"
              v-html="pageData[labelList[labelIndex].key]"
            ></div>
            <div
              class="two-line"
              v-html="pageData[labelList[labelIndex].key]"
            ></div>
          </el-tooltip>
        </div>
      </template>
    </div>
    <div class="tab">
      <el-tabs v-model="activeName">
        <el-tab-pane
          v-for="item in tabList"
          :key="item.id"
          :label="item.label"
          :name="item.id"
        />
      </el-tabs>
    </div>
    <div class="search-component">
      <search-box
        @search="searchTime = $event"
        :hasConfig="false"
      />
      <template v-if="activeName == '1'">
        <el-button
          class="edit-board flex"
          @click="dialogShow = true"
        >
          <span class="el-icon-edit-outline"></span>
          编辑指标
        </el-button>
      </template>
    </div>
    <div class="component">
      <template v-for="i in tabList">
        <component
          :ref="i.componentName"
          :key="i.id"
          :is="i.componentName"
          v-show="activeName == i.id"
          :show="activeName == i.id && show"
          @openWindow="$emit('openWindow',$event)"
          :pageId="`${pageData.pageId}_${i.id}`"
          :pageData="pageData"
          :searchTime="searchTime"
          @openReceptionDialog="openReceptionDialog"
        />
      </template>
    </div>
    <quality-detail
      v-if="isQualityVisible"
      :is-quality-visible="isQualityVisible"
      :currentNum="currentNum"
      :qualityDetailList="qualityDetailList"
      @closeDialog="closeDialog"
      ref="qualityDetail"
    ></quality-detail>
    <pointer-config
      :show.sync="dialogShow"
      :scope="2"
      @update="getBoardList"
    />
  </div>
</template>

<script type='text/ecmascript-6'>
import Store from './Store/index'
import Human from './Human/index'
import Product from './Product/index'
import SearchBox from '../SearchBox'
import { getMerchantBaseInfo } from '@api/earlyWarningManager'
import dayjs from 'dayjs'
import QualityDetail from "@/views/residentManage/components/qualityDetail.vue"
import PointerConfig from '../PointerConfig.vue'
export default {
  components: { Store, Human, Product, SearchBox, QualityDetail, PointerConfig },
  name: '',
  props: {
    pageData: {
      type: Object,
      default: () => { }
    },
    show: Boolean
  },
  data () {
    return {
      activeName: '',
      tabList: [
        {
          label: '店效指标',
          componentName: 'Store',
          id: '1'
        },
        {
          label: '人效指标',
          componentName: 'Human',
          id: '2'
        },
        {
          label: '品效指标',
          componentName: 'Product',
          id: '3'
        }
      ],
      baseInfo: {},
      labelList: [
        {
          label: '事件标签',
          key: 'eventLabel'
        },
        {
          label: '店效标签',
          key: 'shopEfficiencyLabel'
        }
      ],
      labelIndex: 0,
      searchTime: {},
      isQualityVisible: false,
      qualityDetailList: [],
      currentNum: 0,
      dialogShow: false
    }
  },
  computed: {
    businessType () {
      return this.pageData.businessType
    }
  },
  watch: {
    businessType: {
      handler (val) {
        if (val && this.activeName) this.getMerchantBaseInfo()
      },
      immediate: true
    }
  },
  mounted () {
    this.getMerchantBaseInfo()
    this.activeName = this.tabList[0].id
  },
  methods: {
    getMerchantBaseInfo () {
      let { merchantId, businessType } = this.pageData,
        startDate = dayjs().startOf('month').format("YYYY-MM-DD"),
        endDate = dayjs().startOf('month').format("YYYY-MM-DD"),
        supervisionName = []
      getMerchantBaseInfo({ merchantId, businessType, startDate, endDate }).then(res => {
        res.startBusiness = res.startBusiness ? `${dayjs(res.startBusiness).format("YYYY-MM")}展业` : '-'
        res.supervisionList.map(item => {
          supervisionName.push(item.supervisionName)
        })
        res.supervisionName = supervisionName.join('、')
        this.baseInfo = res
      })
    },
    openReceptionDialog (e) {
      this.qualityDetailList = e.qualityDetailList,
        this.isQualityVisible = e.isQualityVisible
      this.currentNum = e.currentNum
    },
    closeDialog () {
      this.isQualityVisible = false
      this.qualityDetailList = []
      this.currentNum = 0
    },
    getBoardList () {
      this.$nextTick(() => this.$refs.Store[0].getBoardList())
    }
  }
}
</script>

<style scoped lang='scss'>
.shop-detail-box {
  height: 100%;
  overflow-y: auto;
  .flex {
    display: flex;
    align-items: center;
  }
  padding: 0 20px;
  .shop-info {
    min-height: 104px;
    background-color: #fff;
    display: flex;
    box-sizing: border-box;
    padding: 16px 20px;
    position: relative;
    .label-box {
      position: absolute;
      width: 556px;
      height: 80px;
      background: #f47f131a;
      top: 16px;
      right: 16px;
      box-sizing: border-box;
      padding: 8px;
      .label-title {
        color: #888888;
        font-size: 12px;
        font-weight: 500;
        line-height: 20px;
        .el-icon-warning {
          margin: 0 8px 0 3px;
          font-size: 14px;
          color: #f47f13;
        }
      }
      .two-line {
        color: #888888;
        font-size: 12px;
        line-height: 20px;
        padding-left: 25px;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        word-break: break-all;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        cursor: pointer;
        width: fit-content;
      }
      .label-tab {
        width: 124px;
        height: 24px;
        border-radius: 2px;
        background: #f9fafb;
        position: absolute;
        top: 0;
        right: 0;
        box-sizing: border-box;
        border: 2px solid #f9fafb;

        &-item {
          width: 60px;
          height: 20px;
          color: #666666;
          font-size: 11px;
          justify-content: center;
          cursor: pointer;
        }
        .active {
          background: #fff;
          color: #2a58ad;
        }
      }
    }
    .icon {
      width: 48px;
      height: 48px;
      border-radius: 4px;
      overflow: hidden;
      margin-right: 16px;
      background: url("@/assets/d+.png");
      background-size: 100% 100%;
    }
    .info {
      width: 45%;
      .merchant-name {
        color: #1d2129;
        font-size: 16px;
        line-height: 24px;
        font-weight: 500;
        .tag {
          font-weight: 400;
          line-height: 20px;
          height: 20px;
          border-radius: 2px;
          opacity: 1;
          background: #e8ffea;
          padding: 0 8px;
          color: #00b42a;
          font-size: 12px;
          margin-left: 16px;
        }
        .grey {
          color: #a8a8a8;
          background: #f6f6f6;
        }
      }
      .text {
        color: #888888;
        font-size: 14px;
        line-height: 22px;
        .merchant-id {
          line-height: 20px;
          height: 20px;
          border-radius: 2px;
          opacity: 1;
          background: #e8f3ff;
          padding: 0 8px;
          color: #2a58ad;
          font-size: 12px;
          margin-right: 16px;
          flex-shrink: 0;
        }
        .year {
          margin-right: 16px;
          flex-shrink: 0;
        }
        .supervision-icon {
          margin-right: 4px;
          flex-shrink: 0;
          width: 14px;
          height: 14px;
          background: url("@/assets/supervision-icon.png");
          background-size: 100% 100%;
        }
      }
    }
  }
  .tab {
    background-color: #fff;
    ::v-deep .el-tabs__nav-wrap {
      padding: 0 20px;
    }
    ::v-deep .el-tabs__item {
      height: 54px;
      line-height: 54px;
    }
    ::v-deep.el-tabs__nav-wrap::after {
      height: 1px;
      background: #e5e5e5;
    }
  }
  .search-component {
    position: relative;
    display: flex;
    justify-content: flex-end;
    background: #fff;
    z-index: 2;
    width: fit-content;
    margin-left: auto;
    .search-box {
      padding: 0 10px 20px 0;
    }
    .edit-board {
      width: 92px;
      height: 32px;
      border-radius: 4px;
      border: 1px solid #2020201a;
      color: #202020;
      font-size: 12px;
      margin-right: 20px;
      justify-content: center;
      span {
        color: #2a58ad;
        font-size: 14px;
      }
    }
  }
}
</style>