courseConfig.vue 9.17 KB
<!-- 课程任务配置 -->
<template>
  <div class="couse-wrap">
    <div class="header">
      课程任务配置
      <count-down></count-down>
      <!-- <div class="count-down">
        <img class="error-circle" src="../../images/error-circle.png" />
        倒计时:还剩 2天11时23分57秒 完成本周课程配置
      </div> -->
    </div>
    <div class="condition">
      <div class="couse-tabs" v-if="longForm.scene != 3">
        <div
          :class="['couse-tabs-item', activeIndex == index ? 'active' : '']"
          v-for="(item, index) in longAllData[longForm.scene]"
          :key="index"
          @click="handleClick(index)"
        >
          {{ item.brand }}
        </div>
      </div>

      <el-button
        size="small"
        type="primary"
        class="custom-btn"
        @click="handleCustom"
        v-if="longForm.isDisabled"
        >自定义配课</el-button
      >
    </div>
    <div class="couse-content">
      <div
        class="content-item"
        v-for="(metric, mIndex) in metricRuleList"
        :key="mIndex"
      >
        <div class="name">{{ metric.metricName }}</div>
        <div class="value">{{ metric.itemBrand }}</div>
        <div class="configuration">
          <div class="item">
            <div>可配置</div>
            <div
              class="number"
              v-if="metric.merchantCount || metric.merchantCount === 0"
            >
              {{ metric.merchantCount }}家
            </div>
            <div v-else class="number">-</div>
          </div>
          <div class="item">
            <div>
              {{
                metric.matchMerchantCourseCount == null ? "未配课" : "已配置"
              }}
            </div>
            <div
              class="number"
              v-if="
                metric.matchMerchantCourseCount ||
                metric.matchMerchantCourseCount === 0
              "
            >
              {{ metric.matchMerchantCourseCount }}家
            </div>
            <div v-else class="number">-</div>
          </div>
        </div>
        <div class="btns">
          <div
            :class="[metric.merchantCount ? 'details' : 'disabled']"
            @click="handleDetail(metric)"
          >
            详情
          </div>
          <div
            :class="[metric.merchantCount ? 'configure-course' : 'disabled']"
            @click="handleConfigureCourse(metric)"
            v-if="longForm.isDisabled"
          >
            配置课程
          </div>
        </div>
      </div>
    </div>
    <!-- 自定义 -->

    <custom-couse
      :longForm="longForm"
      :longItemData="longAllData[longForm.scene][activeIndex]"
      :customVisible="customVisible"
      v-if="customVisible"
      @dialogClose="handleCloseDialog"
    ></custom-couse>
  </div>
</template>
<script>
import customCouse from "./customCouse.vue"
import countDown from "./countDown.vue"
import {
  findAllItemByConfigId,
  findStaffByMerchantNo
} from "@/api/serviceCentre"
export default {
  components: { customCouse, countDown },
  data() {
    return {
      activeIndex: 0,
      customVisible: false
    }
  },
  props: {
    longAllData: {
      type: Object,
      default: () => {}
    },
    longForm: {
      type: Object,
      default: () => {}
    }
  },
  watch: {
    longForm: {
      handler(val) {
        this.activeIndex = 0
        this.findAllItemByConfigIdData()
      },
      deep: true
    }
  },
  computed: {
    metricRuleList() {
      if (this.longAllData[this.longForm.scene]) {
        return this.longAllData[this.longForm.scene][this.activeIndex]
          .metricRuleList
      }
    }
  },
  mounted() {
    // this.findAllItemByConfigIdData()
  },

  methods: {
    findAllItemByConfigIdData() {
      setTimeout(() => {
        let params = {
          ...this.longForm,
          configId: this.longAllData[this.longForm.scene][this.activeIndex].id
        }
        findAllItemByConfigId(params).then((res) => {
          if (
            params.configId ==
            this.longAllData[this.longForm.scene][this.activeIndex].id
          ) {
            this.longAllData[this.longForm.scene][
              this.activeIndex
            ].metricRuleList = res
          }
        })
        this.$emit("changeBrand", params.configId)
      }, 0)
    },
    async handleConfigureCourse(item) {
      let brandId = this.longAllData[this.longForm.scene][this.activeIndex].id
      if (item.merchantCount) {
        let data = await this.getStaffInfoData(item.merchantNos)
        if (data && data.length > 0) {
          this.$router.push({
            name: "configureCourse",
            query: {
              scene: this.longForm.scene,
              merchantNos: item.merchantNos,
              brandId: brandId
            }
          })
        } else {
          this.$message({
            message: "选中指标无匹配驻店人员",
            type: "warning"
          })
        }
      }
    },
    //获取门店下的员工
    getStaffInfoData(merchantNos) {
      return new Promise((resolve, reject) => {
        findStaffByMerchantNo({
          merchantNos,
          scene: this.longForm.scene
        }).then((res) => {
          console.log(res)
          resolve(res)
        })
      })
    },
    handleDetail(row) {
      if (row.merchantCount) {
        row.isDisabled = this.longForm.isDisabled
        row.activeName = "indicatorInfo"
        row.scene = this.longForm.scene
        row.pageId = row.id
        this.$emit("openWindow", row)
      }
    },
    handleClick(index) {
      console.log(index)
      this.activeIndex = index
      this.findAllItemByConfigIdData()
    },
    handleCustom() {
      this.customVisible = true
    },
    handleCloseDialog() {
      this.customVisible = false
    }
  }
}
</script>
<style lang="scss" scoped>
.couse-wrap {
  margin-top: 16px;
  background: #fff;
  .header {
    color: #111111;
    font-size: 16px;
    font-weight: 500;
    padding: 14px 20px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    .count-down {
      margin-left: 20px;
      display: flex;
      align-items: center;
      width: 376px;
      height: 32px;
      border-radius: 2px;
      opacity: 1;
      background: #f47f131a;
      padding: 6px 11px;
      box-sizing: border-box;
      color: #666666;
      font-size: 12px;
      font-weight: 400;
      .error-circle {
        width: 14px;
        height: 14px;
        margin-right: 8px;
      }
    }
  }
  .condition {
    display: flex;
    align-items: center;
    margin: 16px 20px 8px 20px;
    position: relative;
    height: 32px;
    .couse-tabs {
      flex: 3;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      &-item {
        padding: 6px 20px;
        background: #f2f3f5;
        border-radius: 2px;
        line-height: 20px;
        color: #333333;
        font-size: 14px;
        font-weight: 500;
        margin: 0 8px 8px 0;
        cursor: pointer;
      }
      .active {
        color: #2a58ad;
        background: #2a58ad26;
      }
    }
    .custom-btn {
      position: absolute;
      right: 0;
      top: -1px;
    }
  }
  .couse-content {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin: 0 20px;
    .content-item {
      min-width: 278px;
      width: calc((100% / 4) - (16px * 3 / 4));
      padding: 20px;
      border-radius: 4px;
      background: #f8faff;
      height: 204px;
      box-sizing: border-box;
      margin-right: 16px;
      margin-bottom: 16px;
      .name {
        color: #1d1d1d;
        font-size: 20px;
        font-weight: 500;
        line-height: 28px;
      }
      .value {
        color: #1d1d1d;
        font-size: 14px;
        font-weight: 400;
        line-height: 20px;
        margin: 4px 0 16px;
      }
      .configuration {
        display: flex;
        align-items: center;
        margin-bottom: 16px;
        justify-content: space-between;
        .item {
          width: 114px;
          color: #888888;
          font-size: 14px;
          font-weight: 400;
          .number {
            color: #1d1d1d;
            font-size: 16px;
            font-weight: 400;
            line-height: 24px;
            margin-top: 4px;
          }
        }
      }
    }
    .content-item:nth-child(4n) {
      margin-right: 0;
    }
    .btns {
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: #2a58ad;
      font-size: 14px;
      font-weight: 400;

      .details {
        width: 114px;
        height: 32px;
        border-radius: 24px;
        opacity: 1;
        border: 1px solid #2a58ad80;
        background: #ffffff;
        line-height: 32px;
        text-align: center;
        cursor: pointer;
      }
      .disabled {
        width: 114px;
        height: 32px;
        border-radius: 24px;
        opacity: 1;
        line-height: 32px;
        text-align: center;
        color: rgb(188, 190, 194);
        background-color: rgb(244, 244, 245);
        border-color: rgb(233, 233, 235);
      }
      .configure-course {
        width: 114px;
        height: 32px;
        border-radius: 24px;
        opacity: 1;
        background: #dfe6f3;
        line-height: 32px;
        text-align: center;
        cursor: pointer;
      }
    }
  }
}
</style>