lastWeekReplay.vue 7.45 KB
<!-- 上周学习复盘 -->
<template>
  <div class="week-replay">
    <div class="header">
      上周学习复盘<span class="time"
        >({{ lastForm.startTime }} 至 {{ lastForm.endTime }})</span
      >
    </div>
    <div class="improve">
      <div
        :class="['item', activeIndex == index + 1 ? 'active' : '']"
        v-for="(item, index) in improveList"
        :key="item.id"
      >
        {{ item.name }}
      </div>
    </div>
    <d2-table
      class="couse-table"
      ref="lastTable"
      :search-form="searchFormSearch"
      :table-params="tableParams"
      :get-list-api="getListApi"
      :before-search-fn="beforeSearchFn"
      v-if="show"
    >
      <div slot="merchantName" slot-scope="scope">
        <template
          v-if="
            scope.scope.merchantName &&
            scope.scope.merchantName.split(',').length > 1
          "
        >
          <span>{{
            scope.scope.merchantName.split(",").slice(0, 1).join("")
          }}</span>
          <el-popover placement="top" width="fit-content" trigger="hover">
            <div
              :class="{
                serverHeight: scope.scope.merchantName.split(',').length >= 10
              }"
            >
              <div
                v-for="(item, index) in scope.scope.merchantName.split(',')"
                :key="index"
              >
                {{ item }}
              </div>
            </div>
            <span class="more-info" slot="reference"
              >...({{ scope.scope.merchantName.split(",").length }})</span
            >
          </el-popover>
        </template>
        <template v-else>
          <span>{{
            scope.scope.merchantName ? scope.scope.merchantName : "--"
          }}</span>
        </template>
      </div>
      <div slot="auth-button" slot-scope="scope">
        <!-- 查看 -->
        <span style="margin-right: 10px; cursor: pointer">
          <el-button type="text" @click="handleLookCouse(scope.scope)">
            查看课程
          </el-button>
        </span>
      </div>
      <!-- 查看课程 -->
    </d2-table>
    <long-detail-dialog
      :longForm="longForm"
      :longVisible.sync="detailVisible"
      v-if="detailVisible"
      :params-obj="recordInfo"
      @dialogClose="closeDetailDialog"
    />
  </div>
</template>
<script>
import longDetailDialog from "./longDetailDialog"
import { Util, deepClone } from "@/common/util"
import { course_taskStatusOpt } from "@/common/constants.js"
import { taskStaffStudyPage } from "@api/serviceCentre"
export default {
  components: { longDetailDialog },
  data() {
    return {
      detailVisible: false,
      recordInfo: "",
      show: false,
      activeIndex: 1,
      searchFormSearch: {
        studyStatus: "1",
        sendStartTime: "",
        sendEndTime: ""
      },
      baseData: {
        taskStatusOpt: deepClone(course_taskStatusOpt)
      },
      getListApi: taskStaffStudyPage,
      improveList: [
        {
          name: "未改善",
          id: 1
        }
        // {
        //   name: "已改善",
        //   id: 2
        // }
      ],
      column: [
        {
          label: "驻店人员",
          prop: "staffName",
          width: "150",
          isHide: false
        },
        {
          label: "手机号码",
          prop: "staffPhone",
          width: "150",
          isHide: false
        },
        {
          label: "门店名称",
          prop: "merchantName",
          addHtml: "merchantName",
          width: "300",
          isHide: false
        },
        {
          label: "主营品牌",
          prop: "mainBrand",
          isHide: true
        },
        {
          label: "学习任务情况",
          width: "120px",
          isHide: false,
          formatter: (cellValue) => {
            return (
              this.baseData.taskStatusOpt.find(
                (item) => item.confId === cellValue.taskStatus
              )?.confValue +
              (cellValue.taskStatus == 1
                ? `(${
                    cellValue.progress ? cellValue.progress.toFixed(1) : "0"
                  }%)`
                : "")
            )
          },
          className: (cellValue) => {
            return {
              2: "ashSpot",
              1: "orgenSpot",
              0: "greenSpot"
            }[cellValue.taskStatus]
          }
        },
        {
          label: "任务完成时间",
          prop: "passedTime",
          isHide: false
        }
      ],
      // 表格参数
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: "list",
        tableOption: { width: "150px" },
        tableColumns: []
      }
    }
  },
  props: {
    longForm: {
      type: Object,
      default: () => {}
    },
    lastForm: {
      type: Object,
      default: () => {}
    },
    configId: {
      type: String
    }
  },
  mounted() {
    // this.handleClick()
  },

  methods: {
    handleSearch() {
      setTimeout(() => {
        this.$refs.lastTable.refreshTable()
      }, 0)
    },
    beforeSearchFn() {
      console.log(this.longForm)
      return new Promise((resolve) => {
        this.searchFormSearch.sendStartTime =
          this.lastForm.startTime + " 00:00:00"
        this.searchFormSearch.studyStatus = 1
        this.searchFormSearch.sendEndTime = this.lastForm.endTime + " 23:59:59"

        this.searchFormSearch.scene = this.longForm.scene
        this.searchFormSearch.startTime = this.lastForm.startTime + " 00:00:00"
        this.searchFormSearch.endTime = this.lastForm.endTime + " 23:59:59"
        this.searchFormSearch.configId = this.configId
        resolve()
      })
    },
    closeDetailDialog() {
      this.detailVisible = !this.detailVisible
      this.handleSearch()
    },
    handleLookCouse(row) {
      this.recordInfo = row
      this.detailVisible = true
    },
    handleClick(index) {
      this.show = false
      this.activeIndex = index ? index : this.activeIndex
      if (this.activeIndex == 1) {
        this.column[this.findAttrIdx("mainBrand")].isHide = true
        this.column[this.findAttrIdx("staffPhone")].isHide = false
      } else {
        this.column[this.findAttrIdx("mainBrand")].isHide = false
        this.column[this.findAttrIdx("staffPhone")].isHide = true
      }
      this.searchFormSearch.studyStatus = index
      this.filterColumn()
    },
    filterColumn() {
      let arr = this.column.filter((item) => {
        return !item.isHide
      })
      this.tableParams.tableColumns = arr
      this.$nextTick(() => {
        this.show = true
      })
      this.handleSearch()
    },
    findAttrIdx(attrName) {
      return this.column.findIndex((item) => item.prop == attrName)
    }
  }
}
</script>
<style lang="scss" scoped>
.week-replay {
  margin: 16px 0;
  background: #fff;
  padding: 0 0 16px 0;
  .header {
    color: #111111;
    font-size: 16px;
    font-weight: 500;
    padding: 14px 20px;
    border-bottom: 1px solid #e5e5e5;
    .time {
      color: #999999;
      font-size: 14px;
      font-weight: 400;
      margin-left: 8px;
    }
  }
  .improve {
    display: flex;
    align-items: center;
    margin: 16px 20px;
    .item {
      width: 82px;
      height: 32px;
      line-height: 32px;
      border-radius: 2px;
      background: #f2f3f5;
      color: #333333;
      font-size: 14px;
      font-weight: 400;
      margin-right: 8px;
      text-align: center;
      cursor: pointer;
    }
    .active {
      background: #2a58ad26;
      color: #2a58ad;
    }
  }
}
.couse-table {
  margin: 0 20px;
}
</style>