<script setup lang="ts">
import { getLiveList } from '../api'

const props = defineProps<{ data: any }>()

defineEmits<{
  (e: 'update'): void
  (e: 'update:modelValue', visible: boolean): void
}>()

// 列表配置
const listOptions = $computed(() => {
  return {
    remote: {
      httpRequest: getLiveList,
      params: {
        experiment_id: props.data.eid,
        student_id: props.data.sid
      }
    },
    columns: [
      { label: '序号', type: 'index', width: 60 },
      { label: '选手姓名', prop: 'student_name' },
      { label: '商品名称', prop: 'live_commodity' },
      { label: '直播时长', prop: 'live_duration' },
      { label: '文件大小（M）', prop: 'live_video_size' },
      { label: '上传时间', prop: 'live_end_time' },
      { label: '操作', slots: 'table-x', width: 130 }
    ]
  }
})
const handleViewLive = function () {
  window.open(
    `https://saas-dml-pro.ezijing.com/one/live/test/view?experiment_id=${props.data.eid}&id=直播练习ID&record_id=直播记录ID&student_id=${props.data.sid}`
  )
}
</script>

<template>
  <el-dialog
    title="查看直播录像"
    :close-on-click-modal="false"
    width="700px"
    @update:modelValue="value => $emit('update:modelValue', value)"
  >
    <AppList v-bind="listOptions" ref="appList">
      <template #table-count="{ row }"> {{ row.checked_count }}/{{ row.need_check_count }} </template>
      <template #table-score="{ row }">
        <span :class="{ 'is-info': row.score_name !== '--' }">{{ row.score_name }}</span>
      </template>
      <template #table-x="{ row }">
        <el-button
          text
          type="primary"
          @click="handleViewLive"
          v-if="row.experiment_id !== '0' && row.experiment_id"
          >观看回放</el-button
        >
      </template>
    </AppList>
    <el-row justify="center">
      <el-button round auto-insert-space @click="$emit('update:modelValue', false)">关闭</el-button>
    </el-row>
  </el-dialog>
</template>

<style lang="scss" scoped>
.result {
  padding: 40px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  span {
    padding: 0 10px;
    font-size: 40px;
    color: var(--main-color);
  }
}
</style>
