indicatorInfo.vue 6.59 KB
<template>
  <d2-container class="customer-tags">
    <div class="d2-container-content">
      <d2-table-header title="门店列表">
        <el-button size="small" type="primary" @click="handleBatch">
          批量配课
        </el-button>
      </d2-table-header>
      <d2-table
        ref="storeTable"
        :tableData="tableData"
        :search-form="searchForm"
        :table-params="tableParams"
        @refreshTable="refreshTable"
        @pageChange="pageChange"
      >
      </d2-table>
    </div>
  </d2-container>
</template>

<script type="text/ecmascript-6">
import { mapActions, mapState } from "vuex"
import {
  findStoreInfoByMerchantNo,
  findStaffByMerchantNo
} from "@api/serviceCentre"
import { Util, deepClone } from "@/common/util"
import noDataImg from "@/assets/empty.png"
import dayjs from "dayjs"
export default {
  name: "indicatorInfo",
  data() {
    return {
      listOfPenaltiesShow: false,
      noDataImg,
      searchForm: {
        scene: "",
        merchantNos: []
      },
      tableData: [],
      // 表格参数
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        mutiSelectUniqueKey: "id",
        mutiSelectName: "indicatorIndex",
        tableOption: false,
        tableColumns: [
          {
            label: "门店名称",
            prop: "storeName"
          },
          {
            label: "商户号",
            prop: "merchantNo"
            // minWidth: 144,
          },
          {
            label: "是否直营",
            prop: "isDirectOperated",
            formatter: (cellValue) => {
              return this.baseData.directOperateOpt.find(
                (item) => item.confId === cellValue.isDirectOperated
              )?.confValue
            }
          },
          {
            label: "展业时间",
            prop: "businessDevDate",
            formatter: (cellValue) => {
              return cellValue.businessDevDate
                ? Util.dateFormate(cellValue.businessDevDate, "YYYY-MM-DD")
                : ""
            }
          },
          {
            label: "归属业务",
            formatter: () => {
              return ["延保", "权益", "轻改"][this.queryData.scene - 1]
            }
          },
          {
            label: "主营品牌",
            prop: "mainBrand"
          },
          {
            label: "区域运营经理",
            prop: "regionalManager"
          },
          {
            label: "驻店人数",
            prop: "staffCount"
          },
          {
            label: "已配课程人数",
            prop: "courseConfiguredCount"
          }
        ]
      },
      baseData: {
        directOperateOpt: [
          { confId: 0, confValue: "非直营" },
          { confId: 1, confValue: "直营" }
        ]
      }
    }
  },
  props: {
    queryData: {
      type: Object,
      default: () => {}
    }
  },
  watch: {
    queryData: {
      handler(val) {
        // this.findStoreInfoByMerchantNoData()
      },
      deep: true,
      immediate: true
    }
  },
  mounted() {
    this.findStoreInfoByMerchantNoData()
  },
  methods: {
    findStoreInfoByMerchantNoData() {
      console.log(this.queryData, "queryData")
      this.searchForm = {
        ...this.$refs.storeTable.page
      }
      this.searchForm.scene = this.queryData.scene
      this.searchForm.merchantNos = this.queryData.merchantNos
        ? this.queryData.merchantNos
        : [44211227]

      findStoreInfoByMerchantNo(this.searchForm).then((res) => {
        this.tableData = res
      })
    },
    refreshTable() {
      this.findStoreInfoByMerchantNoData()
    },
    pageChange(page) {
      object.assign(this.searchForm, page)
      this.refreshTable()
    },

    handleBatch() {
      let selectedData = []
      let merchantNos = []
      if (this.$refs.storeTable.mutiSelectArr.indicatorIndex) {
        selectedData = this.$refs.storeTable.mutiSelectArr.indicatorIndex
      }
      console.log(selectedData)
      if (selectedData.length > 0) {
        selectedData.forEach((item) => {
          if (item.merchantNo) {
            merchantNos.push(item.merchantNo)
          }
          this.handleConfigureCourse(merchantNos)
        })
      } else {
        this.$message.error("请先选择门店")
      }
      console.log(selectedData)
    },
    //获取门店下的员工
    getStaffInfoData(merchantNos) {
      return new Promise((resolve, reject) => {
        findStaffByMerchantNo({
          merchantNos,
          scene: this.queryData.scene
        }).then((res) => {
          console.log(res)
          resolve(res)
        })
      })
    },
    async handleConfigureCourse(merchantNos) {
      let data = await this.getStaffInfoData(merchantNos)
      if (data && data.length > 0) {
        this.$router.push({
          name: "configureCourse",
          query: {
            scene: this.queryData.scene,
            merchantNos
          }
        })
      } else {
        this.$message({
          message: "选中指标无匹配驻店人员",
          type: "warning"
        })
      }
    }
  }
}
</script>

<style scoped lang="scss">
.emptyBg {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 120px 0;

  .noDataImg {
    width: 64px;
    height: 40px;
  }
}

.error-input {
  ::v-deep.el-input__inner {
    border-color: red;
  }
}

.tag-item {
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;

  .tag {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .more-info {
    white-space: nowrap;
    color: #2a58ad;
    cursor: pointer;
    margin-left: 2px;
  }
}

::v-deep.tags-popover {
  max-width: 50vw;
}

.static-box {
  display: flex;
  gap: 0 16px;
  margin-bottom: 12px;

  .static-item {
    flex: 1;
    flex-shrink: 0;
    height: 82px;
    background: #f8faff;
    border-radius: 5px;
    box-sizing: border-box;
    padding: 16px 20px;

    .static-title {
      font-size: 14px;
      color: #333333;
      line-height: 20px;
      margin-bottom: 4px;
    }

    .static-value {
      display: flex;
      font-weight: 700;
      font-size: 24px;
      line-height: 30px;
      align-items: baseline;

      ::v-deep.static-unit {
        font-weight: 600;
        font-size: 14px;
        margin: 0 2px;
      }
    }
  }
}

.online-status {
  display: flex;
  justify-content: center;
  align-items: center;

  .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
  }

  .gray {
    background-color: #c5c5c5;
  }

  .orange {
    background-color: #fdb757;
  }

  .blue {
    background-color: #2a58ad;
  }
}
</style>