<script setup>
import { reactive, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import{etaTrialInterence}from '@/api/modules/crmApi.js';
import mPage from '@/components/mPage.vue';

const route = useRoute()
const router = useRouter()

const detailData = ref([])
const quesitonTitle = ref(route.query.question)
const detailDataSearchP = reactive({
  CurrentIndex:1,
  PageSize:10,
  QuestionnaireId: route.query.quesionId||0,
})
const total = ref(0)
function getDetailList(){
  etaTrialInterence.getTextDetailList(detailDataSearchP).then(res=>{
    if(res.Ret == 200){
      detailData.value = res.Data.List || []
      total.value = res.Data.Paging.Totals || 0
    }
  })
}
getDetailList()

function pageChange(page_no){
  detailDataSearchP.CurrentIndex = page_no
  getDetailList()
}

function toQuestionnaireSurvey(){
  router.back()
}
</script>
<template>
  <div class="text-quesiton-container" id="text-quesiton-container">
    <div class="text-quesiton-header">
      <div class="text-header-left">
        {{ quesitonTitle }}<span style="white-space: nowrap">【填空题】</span>
      </div>
      <el-button
        type="primary"
        @click="toQuestionnaireSurvey"
        style="margin-left: 30px"
        >返回统计</el-button
      >
    </div>
    <div class="survey-detail-zone">
      <el-table :data="detailData" border>
        <el-table-column label="序号" prop="index" width="60">
          <template #default="{ $index }">
            {{
              (detailDataSearchP.CurrentIndex - 1) *
                detailDataSearchP.PageSize +
              1 +
              $index
            }}
          </template>
        </el-table-column>
        <el-table-column label="姓名" prop="UserName" width="85">
          <template #default="{ row }">
            {{ row.UserName }}
          </template>
        </el-table-column>
        <el-table-column label="文本内容" prop="Options">
          <template #default="{ row }">
            {{ row.Options }}
          </template>
        </el-table-column>
        <template #empty>
          <div class="table-noData">
            <img src="~@/assets/img/cus_m/nodata.png" />
            <span>暂无数据</span>
          </div>
        </template>
      </el-table>
      <!-- 页数选择器 -->
      <m-page
        :page_no="detailDataSearchP.CurrentIndex"
        :pageSize="detailDataSearchP.PageSize"
        :total="total"
        style="position: absolute; right: 60px; bottom: 50px"
        @handleCurrentChange="pageChange"
      />
    </div>
  </div>
</template>
<style lang="scss" scoped>
.text-quesiton-container {
  // height: auto;
  // min-height: 100%;
  .text-quesiton-header {
    background-color: white;
    padding: 20px 30px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    // flex-wrap: wrap;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    margin-bottom: 20px;
    .text-header-left {
      display: flex;
      align-items: center;
      color: #333333;
      font-size: 14px;
      span {
        color: #999999;
      }
    }
  }
  // 详细数据
  .survey-detail-zone {
    background-color: white;
    min-height: calc(100vh - 212px);
    box-sizing: border-box;
    padding: 30px 30px 80px;
    .table-noData {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      margin: 18vh 0;
      img {
        height: 110px;
        width: 136px;
      }
      span {
        font-weight: 400;
        font-size: 16px;
        color: #999999;
      }
    }
  }
}
</style>
