<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="项目" prop="courseId">
        <el-select filterable  v-model="queryParams.project" placeholder="请选择项目"  clearable size="small">
          <el-option
            v-for="dict in projectLists"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="parseInt(dict.dictValue)"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="课程" prop="courseId">
        <el-select filterable  v-model="queryParams.courseId" placeholder="请选择课程"  clearable size="small" @change="courseChange(queryParams.courseId)">
          <el-option
            v-for="dict in courseLists"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="parseInt(dict.dictValue)"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="小节" prop="videoId">
        <el-select filterable  v-model="queryParams.videoId" placeholder="请选择小节"  clearable size="small">
          <el-option
            v-for="dict in videoList"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="parseInt(dict.dictValue)"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="公司名称" prop="companyId">
        <el-select style="width: 220px" @change="handleSeller" filterable v-model="queryParams.companyId" placeholder="请选择公司名" clearable size="small">
          <el-option
            v-for="item in companys"
            :key="item.companyId"
            :label="item.companyName"
            :value="item.companyId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="销售" prop="nickName" v-if="queryParams.companyId">
        <el-select v-model="queryParams.companyUserId" remote placeholder="请选择" filterable clearable @keyup.enter.native="handleQuery">
          <el-option
            v-for="dict in companyUserList"
            :key="`${dict.nickName} - ${dict.userName}`"
            :label="`${dict.nickName} - ${dict.userName}`"
            :value="dict.userId">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="添加时间" prop="createTime">
        <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table border v-loading="loading" :data="courseWatchLogList" @selection-change="handleSelectionChange"  show-summary height="600">
      <el-table-column type="selection" width="55" align="center" />
<!--        <el-table-column label="会员名称" align="center" prop="fsUserName" />-->
      <el-table-column label="销售名称" align="center" prop="qwUserName" />
      <el-table-column label="项目" align="center" prop="projectName" />
      <el-table-column label="课程" align="center" prop="courseName" />
      <el-table-column label="小节" align="center" prop="videoName" />
            <!-- 发课时间 -->
            <el-table-column label="进线时间" align="center" prop="createTime"/>
            <!-- 进线数 -->
            <el-table-column label="进线数" align="center" prop="line" />

            <!-- 先导课上线 -->
            <el-table-column label="先导上线" align="center" prop="firstOnline">
                <template slot-scope="scope">
                    <span>{{ scope.row.firstOnline }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.firstOnline / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <!-- 先导课完课 -->
            <el-table-column label="先导完课" align="center" prop="firstOver">
                <template slot-scope="scope">
                    <span>{{ scope.row.firstOver }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.firstOver / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>


            <el-table-column label="D1上线" align="center" prop="d1Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d1Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d1Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D1完课" align="center" prop="d1Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d1Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d1Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D2上线" align="center" prop="d2Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d2Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d2Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D2完课" align="center" prop="d2Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d2Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d2Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D3上线" align="center" prop="d3Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d3Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d3Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D3完课" align="center" prop="d3Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d3Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d3Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D4上线" align="center" prop="d4Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d4Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d4Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D4完课" align="center" prop="d4Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d4Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d4Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D5上线" align="center" prop="d5Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d5Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d5Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D5完课" align="center" prop="d5Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d5Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d5Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D6上线" align="center" prop="d6Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d6Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d6Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D6完课" align="center" prop="d6Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d6Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d6Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D7上线" align="center" prop="d7Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d7Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d7Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D7完课" align="center" prop="d7Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d7Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d7Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D8上线" align="center" prop="d8Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d8Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d8Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D8完课" align="center" prop="d8Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d8Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d8Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D9上线" align="center" prop="d9Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d9Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d9Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D9完课" align="center" prop="d9Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d9Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d9Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D10上线" align="center" prop="d10Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d10Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d10Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D10完课" align="center" prop="d10Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d10Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d10Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D11上线" align="center" prop="d11Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d11Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d11Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D11完课" align="center" prop="d11Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d11Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d11Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D12上线" align="center" prop="d12Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d12Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d12Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D12完课" align="center" prop="d12Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d12Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d12Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D13上线" align="center" prop="d13Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d13Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d13Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D13完课" align="center" prop="d13Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d13Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d13Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D14上线" align="center" prop="d14Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d14Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d14Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D14完课" align="center" prop="d14Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d14Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d14Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D15上线" align="center" prop="d15Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d15Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d15Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D15完课" align="center" prop="d15Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d15Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d15Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D16上线" align="center" prop="d16Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d16Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d16Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D16完课" align="center" prop="d16Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d16Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d16Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D17上线" align="center" prop="d17Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d17Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d17Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D17完课" align="center" prop="d17Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d17Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d17Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D18上线" align="center" prop="d18Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d18Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d18Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D18完课" align="center" prop="d18Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d18Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d18Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D19上线" align="center" prop="d19Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d19Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d19Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D19完课" align="center" prop="d19Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d19Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d19Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D20上线" align="center" prop="d20Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d20Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d20Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D20完课" align="center" prop="d20Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d20Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d20Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D21上线" align="center" prop="d21Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d21Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d21Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D21完课" align="center" prop="d21Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d21Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d21Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D22上线" align="center" prop="d22Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d22Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d22Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D22完课" align="center" prop="d22Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d22Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d22Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D23上线" align="center" prop="d23Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d23Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d23Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D23完课" align="center" prop="d23Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d23Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d23Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D24上线" align="center" prop="d24Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d24Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d24Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D24完课" align="center" prop="d24Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d24Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d24Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D25上线" align="center" prop="d25Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d25Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d25Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D25完课" align="center" prop="d25Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d25Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d25Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D26上线" align="center" prop="d26Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d26Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d26Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D26完课" align="center" prop="d26Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d26Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d26Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D27上线" align="center" prop="d27Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d27Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d27Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D27完课" align="center" prop="d27Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d27Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d27Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D28上线" align="center" prop="d28Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d28Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d28Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D28完课" align="center" prop="d28Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d28Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d28Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D29上线" align="center" prop="d29Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d29Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d29Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D29完课" align="center" prop="d29Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d29Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d29Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>
            <el-table-column label="D30上线" align="center" prop="d30Online">
                <template slot-scope="scope">
                    <span>{{ scope.row.d30Online }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d30Online / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>

            <el-table-column label="D30完课" align="center" prop="d30Over">
                <template slot-scope="scope">
                    <span>{{ scope.row.d30Over }}</span>
                    <span style="font-size: 12px; color: #959595;margin-left: 5px;">({{ ((scope.row.d30Over / scope.row.line) * 100).toFixed(2) }}%)</span>
                </template>
            </el-table-column>


    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog,statisticsList,qwWatchLogStatisticsList,qwWatchLogAllStatisticsList } from "@/api/course/courseWatchLog";
import { courseList,videoList } from '@/api/course/courseRedPacketLog'
import {getUserList} from "@/api/company/companyUser";
import {getCompanyList} from "@/api/company/company";
export default {
  name: "CourseWatchLog",
  data() {
    return {
      companys:[],
      activeName:"00",
      createTime:null,
      courseLists:[],
      videoList:[],
      logTypeOptions:[],
      // 遮罩层
      loading: false,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 短链课程看课记录表格数据
      courseWatchLogList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      companyUserList: [],
      projectLists: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        nickName: null,
        videoId: null,
        logType: null,
        qwExternalContactId: null,
        duration: null,
        qwUserId: null,
        companyUserId: null,
        companyId: null,
        courseId: null,
        sTime:null,
        eTime:null,
        scheduleStartTime: null,
        scheduleEndTime: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      scheduleTime: null,
    };
  },
  created() {
    getCompanyList().then(response => {
      this.companys = response.data;
      if(this.companys!=null&&this.companys.length>0){
      }
    });
    courseList().then(response => {
      this.courseLists = response.list;
    });
    // this.getList();
    this.getDicts("sys_course_watch_log_type").then(response => {
      this.logTypeOptions = response.data;
    });
    this.getDicts("sys_course_project").then(response => {
      this.projectLists = response.data;
    })
  },
  methods: {
    handleSeller(){
      if(this.queryParams.companyId != null) {
        getUserList(this.queryParams.companyId).then(res=>{
          if(res.code === 200) {
            this.companyUserList = res.data
          }
        })
      }
    },
    courseChange(row){
      this.queryParams.videoId=null;
      if(row === ''){
        this.videoList=[];
        return
      }
      videoList(row).then(response => {
        this.videoList=response.list
      });
    },
    change() {
      if (this.createTime != null) {
        this.queryParams.sTime = this.createTime[0];
        this.queryParams.eTime = this.createTime[1];
      } else {
        this.queryParams.sTime = null;
        this.queryParams.eTime = null;
      }
    },
    handleClickX(tab,event){
      this.activeName=tab.name;
      if(tab.name=="00"){
        this.queryParams.logType=null;
      }else{
        this.queryParams.logType=tab.name;
      }
      this.getList()
    },
    /** 查询短链课程看课记录列表 */
    getList() {
      this.loading = true;
      qwWatchLogAllStatisticsList(this.queryParams).then(response => {
        this.courseWatchLogList = response.rows;
        this.total = response.total;
      }).finally(()=>{
        this.loading = false;
      })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        logId: null,
        userId: null,
        videoId: null,
        logType: null,
        createTime: null,
        updateTime: null,
        qwExternalContactId: null,
        duration: null,
        qwUserId: null,
        companyUserId: null,
        companyId: null,
        courseId: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      if(this.queryParams.companyId == null) {
        this.$message.warning("公司为必选!");
        return;
      }
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.createTime = null;
      this.scheduleTime = null;
      this.queryParams.sTime = null;
      this.queryParams.eTime = null;
      this.queryParams.scheduleStartTime = null;
      this.queryParams.scheduleEndTime = null;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.logId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加短链课程看课记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const logId = row.logId || this.ids
      getCourseWatchLog(logId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改短链课程看课记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.logId != null) {
            updateCourseWatchLog(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addCourseWatchLog(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const logIds = row.logId || this.ids;
      this.$confirm('是否确认删除短链课程看课记录编号为"' + logIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delCourseWatchLog(logIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportCourseWatchLog(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    },
    handleScheduleTimeChange(val) {
      if (val) {
        this.queryParams.scheduleStartTime = val[0];
        this.queryParams.scheduleEndTime = val[1];
      } else {
        this.queryParams.scheduleStartTime = null;
        this.queryParams.scheduleEndTime = null;
      }
    },
  }
};
</script>
