<style scoped>
  .busSign {
    font-size: 40px;
    margin-top: 10px;
    margin-bottom: 10px;
    width: 95%;
    margin: 0 auto;
    overflow-y: scroll;
  }

  /* 自定义评分组件的样式 */
  .busSign .custom-rate .el-rate__item {
    font-size: 38px;
    /* 调整星星的大小 */
  }

  /deep/.busSign .custom-rate .el-rate__icon {
    font-size: 60px;
  }

  /deep/.busSign .custom-rate .el-rate__text {
    font-size: 38px;
  }

  /deep/.busSign .el-textarea .el-textarea__inner {
    font-size: 36px;
    min-height: 200px;
  }

  /deep/.busSign .el-radio-group .el-radio__label {
    font-size: 36px;
  }

  /deep/.busSign .el-radio-group .el-radio__input {
    line-height: 3;
  }

  /deep/.busSign .el-radio-group .el-radio__inner {
    width: 40px;
    height: 40px;
    line-height: 40px;
  }

  /deep/.busSign .el-checkbox .el-checkbox__inner {
    width: 40px;
    height: 40px;
  }

  /deep/.busSign .el-checkbox .el-checkbox__label {
    font-size: 36px;
    /* 设置文字大小 */
  }

  /* 如果需要调整选中对勾的大小 */
  /deep/.busSign .el-checkbox .el-checkbox__input .el-checkbox__inner::after {
    width: 20px;
    /* 设置对勾的宽度 */
    height: 20px;
    /* 设置对勾的高度 */
    line-height: 20px;
    /* 设置对勾内文本的行高 */
  }

  /deep/.busSign .el-checkbox .el-checkbox__input.is-checked .el-checkbox__inner::after {
    transform: rotate(50deg) scaleY(1.3);
  }

</style>


<template>
  <div class="busSign">
    <el-row>
      <el-col :span="24" style="text-align:center;margin-top:10px;">
        <span style="font-weight:bold;">{{$t('objFill.v101.ganxie')}}{{qMsg.SurName}}{{qMsg.Sex==1?$t('objFill.v101.xiansheng'):$t('objFill.v101.nvshi')}}{{$t('objFill.v101.chanyuyijdc')}}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">{{$t('leader.leader_Leader')}}:<template v-if="priceInfo&&priceInfo.LeaderName&&priceInfo.LeaderName!=''">
          {{priceInfo.LeaderName}}</template> </el-col>
      <el-col :span="12">{{$t('leader.leader_Guide')}}:<template v-if="priceInfo&&priceInfo.GuideName&&priceInfo.GuideName!=''">
          {{priceInfo.GuideName}}</template></el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <span>{{$t('fnc.tuanqi')}}:<template v-if="priceInfo&&priceInfo.StartDateStr&&priceInfo.StartDateStr!=''">
            {{priceInfo.StartDateStr}}</template>
          <template v-if="priceInfo&&priceInfo.EndDateStr&&priceInfo.EndDateStr!=''">
            -{{priceInfo.EndDateStr}}</template></span>
      </el-col>
    </el-row>
    <template v-for="(item,index) in dataList ">
      <el-row :key="`t_`+index">
        <el-col :span="24">
          <span>{{index+1}}、{{item.Title}}</span>
        </el-col>
      </el-row>
      <el-row :key="`s_`+index">
        <el-col :span="24" style="min-height:100px;margin-top:10px;margin-bottom:10px;">
          <template v-if="item.SurveyType === 1">
            <el-rate v-model="item.ScoreNum" show-text :texts="texts" class="custom-rate">
            </el-rate>
          </template>
          <template v-if="item.SurveyType === 2">
            <el-radio-group v-model="item.ScoreNum">
              <el-radio v-for="(radio, rIndex) in item.SurveyOptionsList" :label="radio.ID" :key="rIndex">
                {{radio.OptionsName}}</el-radio>
            </el-radio-group>
          </template>
          <template v-if="item.SurveyType === 3">
            <el-checkbox v-for="(radio, rIndex) in item.SurveyOptionsList" v-model="radio.IsCheckS" :label="radio.ID"
              :key="rIndex">
              {{radio.OptionsName}}</el-checkbox>
          </template>
          <template v-if="item.SurveyType === 4">
            <el-input type="textarea" :rows="2" :placeholder="$t('fnc.qsrneirong')" v-model="item.TextContent">
            </el-input>
          </template>
        </el-col>
      </el-row>
    </template>
    <el-row style="margin-bottom:100px;">
      <el-col :span="24" style="text-align:center;">
        <el-button type="primary" style="width:50%;height:80px;font-size:36px;" @click="saveGuestSurvey"
          :loading="saveLoading">{{$t('fnc.tijiao')}}</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        qMsg: {
          TCID: 21633,
        },
        dataList: [],
        priceInfo: {},
        texts: [
          this.$t('objFill.pingfens')[0],
          this.$t('objFill.pingfens')[1],
          this.$t('objFill.pingfens')[2],
          this.$t('objFill.pingfens')[3],
          this.$t('objFill.pingfens')[4]
        ],
        saveLoading: false,
      };
    },
    created() {
      if (this.$route.query.TCID) {
        this.qMsg.TCID = this.$route.query.TCID;
      }

    },
    mounted() {
      this.getPriceInfo();
      this.GetSurveyShowList();
    },
    methods: {
      getPriceInfo() {
        this.apipost('miniProgram_post_GetBasePrice', {
          tcid: this.qMsg.TCID
        }, res => {
          if (res.data.resultCode === 1) {
            let data = res.data.data
            this.priceInfo = data;
          }
        }, null)
      },
      GetSurveyShowList: function () {
        let data = {
          IsShow: 1,
          SurveyType: -1
        }
        this.apipost('survey_post_GetBusSurveyShowList', data, res => {
          if (res.data.resultCode === 1) {
            let data = res.data.data
            data.map(item => {
              if (item.SurveyType === 2) {
                item.SurveyOptionsList.map((cItem, cIndex) => {
                  cItem.IsCheckS = false
                })
              }
              if (item.SurveyType === 3) {
                item.SurveyOptionsList.map((cItem, cIndex) => {
                  cItem.IsCheckS = false
                })
              }
              if (item.SurveyType === 1) {
                item.ScoreNum = 5;
              }
            })
            this.dataList = data;
          }
        }, null)
      },
      //提交意见调查
      saveGuestSurvey() {
        this.saveLoading = true;
        var postMsg = [];
        if (this.dataList && this.dataList.length > 0) {
          this.dataList.forEach(item => {
            item.TCID = this.qMsg.TCID;
            if (item.SurveyType === 2 || item.SurveyType === 3) {
              item.SurveyOptionsList.forEach(y => {
                //单选
                if (item.SurveyType == 2) {
                  if (item.ScoreNum == y.ID) {
                    y.IsCheck = "1";
                  }
                }
                //多选
                if (item.SurveyType == 3) {
                  y.IsCheck = "0";
                  if (y.IsCheckS) {
                    y.IsCheck = "1";
                  }
                }
              })
              item.ScoreNum = 0;
            }
            postMsg.push(item);
          })
        }
        var newMsg = {
          busDetailsList: postMsg
        }
        this.apipost("survey_post_SetBusSurvey", newMsg, res => {
          this.saveLoading = false;
          if (res.data.resultCode == 1) {
            this.Success(res.data.message);
          } else {
            this.Error(res.data.message);
          }
        });
      }
    }
  }

</script>