<template>
  <div class="resultPageList">
    <div class="el-card__header">
      <span>问卷调查列表</span>

    </div>
    <div class="content">
      <div style="display: flex;flex-direction: row;align-items: center">
        <div class="block">
          <div class="searchInput" style="width:250px">
            <el-input style="display:inline-block;width:225px;height:30px"
                      placeholder="请输入昵称搜索"
                      v-model="msg.AliasName"
                      size="small"
                      @clear="getList"
                      @keyup.enter.native="getList"
                      clearable>
            </el-input>
            <span @click="getList" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
          </div>
          <span>填写时间：</span>
          <el-date-picker v-model="dateList" @change="getList()" size="small" type="datetimerange"
                          range-separator="至" value-format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期">
          </el-date-picker>

        </div>
      </div>

    </div>


    <div style="padding: 20px;background: #fff;">
      <el-table
        :data="tableData"
        header-cell-class-name="headClass"
        style="width: 100%"
        border
      >

        <el-table-column
          prop="ID"
          label="ID"
          width="100">
        </el-table-column>

        <el-table-column
          prop="ActiveSurveyName"
          label="活动名称">

        </el-table-column>
        <el-table-column
          prop="AliasName"
          label="信息">
          <template slot-scope="scope">
            <div class="app-image" :style="{backgroundImage:'url(' + scope.row.Photo + ')',backgroundSize:'cover'}"></div>
            <div flex="dir:left cross:center">
              {{scope.row.AliasName}}
            </div>
          </template>

        </el-table-column>



        <el-table-column
          label="创建时间"
          prop="CreateDateStr">
        </el-table-column>

        <el-table-column
          fixed="right"
          label="操作"
          width="180"
        >
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="详情" placement="top" >
              <img src="../../assets/img/userman/detail.png" alt="" class="imgstyle" @click="grant(scope.row)">
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align:right"
                     background
                     @current-change="handleCurrentChange"
                     :page-size="msg.pageSize"
                     layout="prev, pager, next"
                     :current-page.sync="msg.pageIndex"
                     :total="count">
      </el-pagination>
    </div>
    <el-dialog title="用户问卷调查详情" :visible.sync="dialogVisible" width="600px">
      <div class="wjstyle" v-if="xqdata!=null">
        <div class="row" style="font-size: 16px;margin-bottom: 10px">
          <img :src="xqdata.obj.Photo" alt="" style="width: 50px;height: 50px;margin-right: 10px">
          {{xqdata.obj.Name}}
        </div>
        <div>创建时间：{{xqdata.obj.CreateDateStr}}</div>
        <div style="font-size: 16px;margin: 10px 0 ;font-weight: bold">用户调查表</div>
        <div v-for="(item,index) in xqdata.surverList" :key="index">
            <div >{{index+1}}、{{item.Title}}</div>
            <div v-if="item.SurveyType==4" style="margin: 10px 0;">
              <el-input
                v-if="item.FormType==2"
                type="textarea"
                placeholder="请输入内容"
                v-model="item.TextContent"
                :rows="3"
                size="small"
                :disabled="true">
              </el-input>
              <el-input
                v-if="item.FormType==1"
                type="text"
                placeholder="请输入内容"
                v-model="item.TextContent"
                size="small"
                :disabled="true">
              </el-input>
            </div>
<!--          单选-->
          <div v-if="item.SurveyType==2|| item.SurveyType==3" style="margin: 10px 0;">
            <el-checkbox v-model="x.IsCheck==0?true:false" disabled v-for="(x,y) in item.SurveyOptionsList" :key="y" >{{x.OptionsName}}</el-checkbox>

          </div>
          <div v-if="item.SurveyType==1" style="margin: 10px 0;">
            <el-rate
              v-model="item.ScoreNum"
              disabled
              show-score
              text-color="#ff9900"
              score-template="{value}分">
            </el-rate>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "resultPageList",
    data(){
      return{
        msg:{
          pageIndex:1,
          pageSize:20,
          AliasName:'',
          StartDate:'',
          EndDate:'',
        },
        tableData:[],
        count:0,
        loading:false,
        dateList:[],
        dialogVisible:false,
        xqdata:null,
      }
    },
    created(){
      this.getDateList();
    },
    methods:{
      getDateList(){
        this.loading=true;
        if (this.dateList && this.dateList.length > 0) {
          this.msg.StartDate = this.dateList[0];
          this.msg.EndDate = this.dateList[1];
        } else {
          this.msg.StartDate = '';
          this.msg.EndDate = '';
        }
        this.apipost("/api/Survey/GetResultPageList", this.msg, res => {
          this.loading=false;
          if(res.data.resultCode==1){
            this.tableData = res.data.data.pageData;
            this.count = res.data.data.count;
          }else {
            this.Info(res.data.message);
          }
        })
      },

      getList(){
        this.msg.pageIndex = 1
        this.getDateList()
      },

      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getDateList();
      },
      grant(row){
        this.apipost("/api/Survey/GetGuestSurveyDetails", {SurveyID:row.ID}, res => {
          if(res.data.resultCode==1){
            this.xqdata = res.data.data;
            this.dialogVisible =true
          }else {
            this.Info(res.data.message);
          }

        })
      }
    },
  }
</script>

<style >
  .resultPageList .el-card__header{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: #fff;

  }
  .resultPageList .el-button--small{
    padding: 9px 15px;
  }
  .resultPageList .content .searchInput{
    border: 1px solid #DCDFE6;
    border-radius: 4px;
    margin-left: 20px;
  }
  .resultPageList .content .searchInput .el-input__inner{
    border:none;outline:none;
    height: 30px;
    line-height: 30px;
  }
  .resultPageList .content .searchInput{
    line-height: normal;
    display: inline-table;
    border-collapse: separate;
    border-spacing: 0;
    width:250px;
  }
  .resultPageList .content{
    background: #fff;
    margin-top:10px;
    padding: 15px;
    box-sizing: border-box;
  }
  .resultPageList .app-image{
    background-position: center center;
    width: 50px;
    height: 50px;
    border-radius:0%;
    float: left;
    margin-right: 8px;
  }
  .resultPageList .wjstyle{
    width: 100%;

  ;
  }
</style>
