longDetailDialog.vue 9.3 KB
<!-- 查看课程 -->
<template>
  <div class="detail-dialog">
    <baseDialog
      :dialog-config="dialogConfig"
      :is-show.sync="visible"
      @handleClick="handleConfirm"
      @closeDialog="handleClose"
    >
      <div class="item" v-for="(detail, index) in configData" :key="index">
        <div class="title">{{ detail.title }}</div>
        <div class="detail-content">
          <div
            class="form_div"
            v-if="detail.infoData && detail.infoData.length"
          >
            <el-form class="edit-sub-block" label-width="110px" :inline="true">
              <el-row :gutter="20">
                <template v-for="(item, key) in detail.infoData">
                  <el-col :span="item.col ? item.col : 8" :key="key">
                    <el-form-item :label="item.title">
                      <div
                        v-if="item.className"
                        :class="[item.className(detailInfo)]"
                      ></div>
                      {{
                        item.formatter
                          ? item.formatter(detailInfo)
                          : detailInfo[item.key]
                          ? detailInfo[item.key]
                          : "-"
                      }}
                    </el-form-item></el-col
                  >
                </template>
              </el-row>
            </el-form>
          </div>
          <div style="margin-top: 20px">
            <d2-table
              :hasNum="detail.hasNum"
              :table-params="detail.tableParams"
              :tableData="
                detail.key == 'infoTableData'
                  ? detailInfo.infoTableData
                  : detailInfo.configTableData
              "
              :hasPage="false"
            >
              <div slot="OutputValue" slot-scope="scope">
                <div>
                  ¥{{ scope.scope.lastOutputValue || "-" }} → ¥{{
                    scope.scope.currentOutputValue || "-"
                  }}
                </div>
                <div
                  v-if="scope.scope.currentOutputValue"
                  :class="[
                    scope.scope.outputValueRate.indexOf('-') > -1
                      ? 'dowm'
                      : 'up'
                  ]"
                >
                  环 {{ scope.scope.outputValueRate }}
                </div>
              </div>
              <div slot="Conversion" slot-scope="scope">
                <div>
                  {{ scope.scope.lastConversion || "-" }}% →
                  {{ scope.scope.currentConversion || "-" }}%
                </div>
                <div
                  v-if="scope.scope.conversionRate"
                  :class="[
                    scope.scope.conversionRate.indexOf('-') > -1 ? 'dowm' : 'up'
                  ]"
                >
                  环 {{ scope.scope.conversionRate }}
                </div>
              </div>
              <div slot="CustomerUnitPrice" slot-scope="scope">
                <div>
                  ¥{{ scope.scope.lastCustomerUnitPrice || "-" }} → ¥{{
                    scope.scope.currentCustomerUnitPrice || "-"
                  }}
                </div>
                <div
                  v-if="scope.scope.customerUnitPriceRate"
                  :class="[
                    scope.scope.customerUnitPriceRate.indexOf('-') > -1
                      ? 'dowm'
                      : 'up'
                  ]"
                >
                  环 {{ scope.scope.customerUnitPriceRate }}
                </div>
              </div>
            </d2-table>
          </div>
        </div>
      </div>
    </baseDialog>
  </div>
</template>
<script>
import { Util, deepClone } from "@/common/util"
import { staffCourse, staffInfo } from "@api/serviceCentre"
import {
  course_taskStatusOpt,
  punishStatusOpt,
  learningProgressOpt
} from "@/common/constants.js"
export default {
  data() {
    return {
      dialogConfig: {
        title: "查看课程",
        width: "1080px"
      },
      detailInfo: {
        infoTableData: [],
        configTableData: []
      },
      getListApi: staffCourse,
      learningProgressOpt: deepClone(learningProgressOpt),
      configData: [
        {
          title: "个人信息",
          infoData: [
            {
              title: "姓名:",
              key: "staffName"
            },
            {
              title: "手机号码:",
              key: "staffPhone"
            },
            {
              title: "门店:",
              key: "merchantNames"
            },
            {
              title: "上级:",
              key: "superiors"
            },
            {
              title: "导师:",
              key: "mentors"
            }
          ],
          hasNum: false,
          tableParams: {
            tableColumns: [
              {
                label: "个人产值变化",
                prop: "OutputValue",
                addHtml: "OutputValue"
              },
              {
                label: "个人转化率变化",
                prop: "Conversion",
                addHtml: "Conversion"
              },

              {
                label: "个人客单价变化",
                prop: "CustomerUnitPrice",
                addHtml: "CustomerUnitPrice"
              }
            ]
          },
          key: "infoTableData"
        },
        {
          title: "课程配置",
          hasNum: true,
          tableParams: {
            btnId: new Date().getTime() + parseInt(Math.random() * 1000),
            tableOption: false,
            tableColumns: [
              {
                label: "课程名称",
                prop: "courseName"
              },
              {
                label: "学习时长",
                prop: "learnDuration"
              },
              {
                label: "学习进度",
                prop: "failReason",
                formatter: (cellValue) => {
                  return (
                    this.learningProgressOpt.find(
                      (item) => item.confId === cellValue.status
                    )?.confValue +
                    (cellValue.status == 2 ? `(${cellValue.progress}%)` : "")
                  )
                },
                className: (cellValue) => {
                  return {
                    1: "ashSpot",
                    2: "orgenSpot",
                    5: "greenSpot"
                  }[cellValue.status]
                }
              },
              {
                label: "成绩",
                prop: "totalScore"
              },
              {
                label: "完成时间",
                prop: "finishDate",
                width: "200"
              }
            ]
          },
          key: "configTableData"
        }
      ]
    }
  },
  props: {
    longVisible: {
      type: Boolean,
      default: false
    },
    paramsObj: {
      type: Object,
      default: {}
    }
  },
  computed: {
    visible: {
      get() {
        return this.longVisible
      },
      set(newVal) {
        this.$emit("dialogClose", {
          flag: newVal,
          attrName: "longVisible"
        })
      }
    }
  },
  mounted() {
    this.getStaffInfo()
  },
  methods: {
    getStaffCourse() {
      var params = { staffStudyId: this.paramsObj.id }
      staffCourse(params).then((res) => {
        this.detailInfo.configTableData = res.list
      })
    },
    getStaffInfo() {
      var params = { staffPhone: this.paramsObj.staffPhone }
      staffInfo(params).then((res) => {
        Object.assign(this.detailInfo, res, {
          infoTableData: [
            {
              lastConversion: res.lastConversion,
              currentConversion: res.currentConversion,
              conversionRate: res.conversionRate,
              lastCustomerUnitPrice: res.lastCustomerUnitPrice,
              currentCustomerUnitPrice: res.currentCustomerUnitPrice,
              customerUnitPriceRate: res.customerUnitPriceRate,
              lastOutputValue: res.lastOutputValue,
              currentOutputValue: res.currentOutputValue,
              outputValueRate: res.outputValueRate
            }
          ]
        })

        this.getStaffCourse()
      })
    },
    handleClose() {
      this.visible = false
    },
    handleConfirm() {
      this.visible = false
    }
  }
}
</script>
<style scoped lang="scss">
.detail-dialog {
  .item {
    margin-bottom: 20px;
    .title {
      color: #111111;
      font-size: 16px;
      font-weight: 500;
      padding: 10px 0;
      border-bottom: 1px solid #e5e5e5;
    }
    .form_div {
      color: #333333;
      padding: 20px 30px;

      .edit-sub-block {
        .el-form-item {
          width: 100%;
          margin-bottom: 0px;
        }
        .itemDiv {
          display: flex;
          .halfItem {
            width: 50%;
          }
        }
        .detail-txt {
          display: inline-block;
          width: 200px;
          vertical-align: bottom;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        ::v-deep .el-form-item__content {
          max-width: calc(100% - 110px);
          word-break: break-all;
        }
      }

      .edit-sub-block-two {
        .el-form-item {
          margin-bottom: 0px;
        }
      }
    }
  }
}
.up {
  font-size: 12px;
  color: #eb4e4e;
}
.dowm {
  font-size: 12px;
  color: #43cf7c;
}
</style>