<script setup lang="ts">
import Table from "@/components/Table/index.vue";
const props = defineProps<{
  modelValue: boolean;
  data: Record<string, any>;
  stuData: Record<string, any>;
}>();
const emit = defineEmits(["update:modelValue"]);
const show = computed({
  get() {
    return props.modelValue;
  },
  set(val) {
    emit("update:modelValue", val);
  },
});
// const xbTable = ref({
//   loading: false,
//   columns: [
//     { type: "index", label: "序号" },
//     { prop: "stuName", label: "姓名" },
//   ],
//   tableData: [],
//   pagination: {
//     total: 0,
//     pageNum: 1,
//     pageSize: 10,
//   },
// });
const columns = ref(10);
function handleOpen() {
  // xbTable.value.tableData = props.data;
}
</script>
<template>
  <el-dialog
    title="查看"
    v-model="show"
    style="width: 1000px"
    top="10vh"
    close-on-click-modal
    @open="handleOpen"
  >
    <!-- <Table :xbTable="xbTable"></Table> -->
    <table v-if="props.data.length" class="watch-table">
      <tr
        v-for="(item, idx) in Math.ceil(props.data.length / columns)"
        :key="idx"
      >
        <template v-for="i in columns" :key="i">
          <td v-if="props.data[idx * columns + i - 1]?.stuName">
            <p>
              {{ props.data[idx * columns + i - 1]?.stuName }}
            </p>
            <p
              v-if="
                props.stuData.type === '选择题' &&
                props.stuData.answer.length === 1 &&
                props.stuData.answer !==
                  props.data[idx * columns + i - 1]?.submitAnswer
              "
              style="color: red"
            >
              {{ props.data[idx * columns + i - 1]?.submitAnswer }}
            </p>
          </td>
        </template>
      </tr>
    </table>
    <div style="text-align: center; height: 200px; line-height: 200px" v-else>
      暂无数据
    </div>
  </el-dialog>
</template>
<style scoped lang="scss">
.watch-table {
  tr {
    width: 100%;
    td {
      width: 100px;
      border: 1px solid #ccc;
      text-align: center;
      padding: 12px 0;
      font-size: 16px;
    }
  }
}
</style>
