exerciseRecord.vue 9.75 KB
<!--
 * @Description: AI对练记录
 * @Author: huyue
 * @Date: 2024-04-15 16:26:57
 * @LastEditors: 前端 qianduan01@didihu.com.cn
 * @LastEditTime: 2024-10-31 17:58:36
-->
<template>
  <d2-container class="m-t-40">
    <div class="header" slot="header" style="padding: 10px 20px">
      <d2-search
        ref="showSearch"
        class="show-search"
        label-width="110px"
        :search-form="searchForm"
        :form-data="showFormData"
      >
        <div class="up-btns">
          <el-button size="small" type="primary" @click="handleSearch">
            查询
          </el-button>
          <el-button size="small" @click="handleReset"> 重置 </el-button>
        </div>
      </d2-search>
    </div>
    <div class="d2-container-content" style="position: positive">
      <d2-table-header>
        <auth-button
          category="Button"
          style="
             {
              display: inline-block;
            }
          "
          :show-btn-ids="['9120802']"
        />
      </d2-table-header>
      <d2-table
        ref="exerciseTable"
        :has-num="true"
        :search-form="searchFormSearch"
        :table-params="tableParams"
        :get-list-api="getListApi"
        :before-search-fn="beforeSearchFn"
      >
        <!-- v-if="scope.scope.sparringStatus === 1" -->
        <template slot="auth-button-other" slot-scope="scope">
          <el-button type="text" @click="btnClick(scope)">查看结果</el-button>
        </template>
        <div slot="taskState" slot-scope="scope">
          <div class="online-status">
            <span
              :class="[
                scope.scope.taskState === 0
                  ? 'dot blue'
                  : scope.scope.taskState === 1
                  ? 'dot orange'
                  : 'dot gray'
              ]"
            ></span
            >{{ statusObj[scope.scope.taskState] }}
          </div>
        </div>
      </d2-table>
    </div>
    <!-- <d2-dialog
      :title="title"
      :is-visible.sync="relateStoreVisible"
      width="70%"
      btn-ok-label="确定"
      @confirmDialog="handleRelateStoreConfirm"
      @closeDialog="handleRelateStoreClose"
      class="relateStore"
    >
      <evaluatingReport></evaluatingReport>
    </d2-dialog> -->
    <quality-detail
      :is-quality-visible="isQualityVisible"
      v-if="isQualityVisible"
      :detail-obj="detailObj"
      @closeDialog="closeDialog"
    ></quality-detail>
  </d2-container>
</template>

<script>
import { mapActions, mapState } from "vuex"
import { Util, deepClone } from "@/common/util"
import { staffRecordPage, updateTaskPromptStatus } from "@api/exercise"
// import evaluatingReport from "./components/evaluatingReport"
import QualityDetail from "./components/dialogResult.vue"
export default {
  name: "exerciseRecord",
  components: {
    QualityDetail
  },
  data() {
    return {
      title: "查看结果",
      isQualityVisible: false,
      searchForm: {
        sparringStatus: 1
      },
      showFormData: [
        {
          label: "手机号",
          name: "staffPhone",
          type: "input",
          isclear: true
        },
        {
          label: "员工名称",
          name: "staffName",
          type: "input",
          isclear: true
        },
        {
          label: "分类",
          name: "sparringType",
          type: "select",
          isclear: true,
          optionList: [
            {
              value: null,
              label: "全部"
            },
            {
              value: "1",
              label: "话术演练"
            },
            {
              value: "2",
              label: "攻防演练"
            }
          ],
          optionId: "value",
          optionLabel: "label"
        },
        {
          label: "完成时间",
          name: "completionTime",
          type: "datePicker",
          isclear: true
        }
      ],
      statusObj: { 0: "未开始", 1: "进行中", 2: "已结束" },
      activeName: "all",
      // table相关
      getListApi: staffRecordPage,
      searchFormSearch: { sparringStatus: 1 },
      tableParams: {
        listName: "list",
        tableOption: true,
        tableColumns: [
          {
            label: "分类",
            prop: "sparringType",
            formatter: (cellValue) => {
              return cellValue.sparringType == 1 ? "话术演练" : "攻防演练"
            }
          },
          {
            label: "手机号",
            prop: "staffInfo.staffPhone",
            formatter: (cellValue) => {
              return cellValue.staffInfo.staffPhone
            }
          },
          {
            label: "员工名称",
            prop: "staffInfo.staffName",
            formatter: (cellValue) => {
              return cellValue.staffInfo.staffName
            }
          },
          {
            label: "客户类型",
            prop: "roleTypeDesc"
          },
          {
            label: "评级",
            prop: "level"
          },
          {
            label: "对练时长",
            prop: "sparringDuration",
            formatter: (cellValue) => {
              let timeInMs = cellValue.sparringDuration
              const totalSeconds = Math.floor(timeInMs / 1000)
              const hours = Math.floor(totalSeconds / 3600)
              const minutes = Math.floor((totalSeconds % 3600) / 60)
              const seconds = totalSeconds % 60

              if (hours > 0) {
                return `${hours}时${minutes}分${seconds}秒`
              } else {
                return `${minutes}分${seconds}秒`
              }
            }
          },
          {
            label: "完成时间",
            prop: "completionTime"
          }
        ]
      }
    }
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  methods: {
    ...mapActions({
      get: "d2admin/base/get",
      close: "d2admin/page/close"
    }),
    ...mapActions("d2admin/user", ["actionSetDownloadList"]),
    handleSearch() {
      this.$refs.exerciseTable.refreshTable(true, true)
    },
    closeDialog() {
      this.isQualityVisible = false
    },
    btnClick(scope) {
      console.log(scope, "scope")
      // staffInfo
      // 查看结果
      this.detailObj = {
        ...scope.scope.staffInfo,
        ...scope.scope
      }
      this.isQualityVisible = true
    },
    beforeSearchFn() {
      console.log(this.searchForm)
      return new Promise((resolve) => {
        this.searchFormSearch = this.getParams()
        resolve()
      })
    },
    getParams() {
      var params = deepClone(this.searchForm)
      const { activeName } = this
      // params.taskId = this.taskInfo.id
      if (params.completionTime && params.completionTime.length) {
        params.startTime = Util.dateFormate(
          params.completionTime[0],
          "YYYY-MM-DD HH:mm:ss"
        )
        params.endTime =
          Util.dateFormate(params.completionTime[1], "YYYY-MM-DD") + " 23:59:59"
        delete params.completionTime
      }
      params.sparringStatus = 1
      // console.log(params, "4444444444")
      return params
    },
    handleReset() {
      console.log("handleReset")
      this.searchForm = {}
      // this.activeName = "all"
      this.searchFormSearch = {}
      this.$refs.exerciseTable.refreshTable(true, true)
    },
    // tab 列表切换
    handleTabChange(tab, event) {
      console.log(tab, event)
      this.searchForm.taskState = tab.name != "all" ? tab.name : ""
      this.handleSearch()
    },
    // 状态改变
    handleSwitch(scope, e) {
      console.log(scope)
      const { promptOnOff, id } = scope.scope
      this.$confirm(
        `是否确认${promptOnOff ? "关闭" : "开启"}提示词?`,
        "提示",
        {
          confirmButtonText: "确定",
          type: "warning"
        }
      ).then(() => {
        console.log("dia开启")
        updateTaskPromptStatus({
          id,
          promptOnOff: !promptOnOff
        })
          .then((res) => {
            if (res && res.id) {
              this.$message.success("修改成功")
            } else {
              this.$message.error("修改失败")
            }
            this.$refs.exerciseTable.refreshTable(true)
          })
          .catch((err) => {
            console.log(err)
            this.$message.error("修改失败")
          })
      })
    },
    // 明细
    handleToDetail(row) {
      this.close({ tagName: "/exercise" })
      this.$router.push({
        path: "/exerciseDetail",
        query: { detail: JSON.stringify(row) }
      })
    },
    // 查看
    handleToView(row) {
      this.close({ tagName: "/exercise" })
      this.$router.push({
        path: "/exerciseView",
        query: { detail: JSON.stringify(row) }
      })
    },
    // 新建任务
    handleToAdd() {
      this.close({ tagName: "/exercise" })
      this.$router.push({
        path: "/exerciseAdd"
      })
    },
    // 导出
    handleExport() {
      console.log("导出", this.searchFormSearch, this.getParams())
      var params = this.getParams()
      params.method =
        "dj.api.smartcarlife.ai.sparring.task.staff.record.list.export"
      const list = [
        ...this.dowloadList,
        {
          name: "对练记录列",
          exportParam: JSON.stringify(params),
          status: "waiting",
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: "dowloadList" })
    }
  }
}
</script>

<style scoped lang="scss">
.m-t-40 {
  margin-top: 40px;
}
.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>