<style>
  .ShoppingReceipt {
    padding-top: 25px;
  }

  .ShoppingReceipt .singeRowTable_two td {
    border-top: 0;
    border-left: 0;
  }

  .ShoppingReceipt .singeRowTable_two tr:last-child td {
    border-bottom: 0;
  }

</style>
<template>
  <div class='flexOne ShoppingReceipt' v-loading="loading">
    <table border="0" cellspacing="1" cellpadding="0" class="singeRowTable"
      style="border: 1px solid rgb(230, 230, 230);background: #ccc;width: 900px">
      <tr>
        <th colspan="6" height="40">{{$t('ground.gwdyjhzd')}}</th>
      </tr>
      <tr>
        <td width="150px">{{$t('visa.v_tuanhao')}}</td>
        <td width="150px">{{TCID}}</td>
        <td width="150px">{{$t('ground.guideName')}}</td>
        <td width="150px">{{GuideName}}</td>
        <td width="150px">{{$t('pub.area')}}</td>
        <td width="150px">{{StartCityNames}}</td>
      </tr>
      <tr>
        <td colspan="3" width="450px">{{$t('ground.gwd')}}</td>
        <td width="150px">{{$t('ground.choiceShop')}}</td>
        <td colspan="2" width="300px">{{$t('ground.zczysx')}}</td>
      </tr>
      <tbody v-for="(item) in dataList">
        <tr v-for="(son,index) in item.ShopList">
          <td width="150px" v-if="index==0" :rowspan="item.ShopList.length">{{item.GoodsTypeStr}}</td>
          <td colspan="2" width="300px">
            {{son.ShopName}}
          </td>
          <td width="150px">
            <input type="checkbox" v-model="son.IsSelect" :disabled="son.SourceType===2">
          </td>
          <td colspan="2" width="300px" v-if="index==0" :rowspan="item.ShopList.length">
            <el-input v-model="son.PolicyAttention" type="textarea"></el-input>
          </td>
        </tr>
      </tbody>
    </table>
    <div style="padding: 20px 0 20px 20px;width: 900px;text-align: right">
      <input type="button" class="normalBtn" :value="$t('pub.saveBtn')" @click="saveFrom" />
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        dataList: [],
        tcIdList: '',
        loading: false,
        LeaderName: '',
        GuideName: '',
        StartCityNames: '',
        TCID: ''
      }
    },
    methods: {
      getData: function () {
        this.loading = true;
        this.apipost('dmcstatistics_post_GetDMCTravelPriceShop', {
          TCIDS: this.tcIdList
        }, res => {
          if (res.data.resultCode === 1) {
            this.dataList = res.data.data;
          } else {
            this.$message.error(res.data.message);
          }
          this.loading = false;
        }, null)
      },
      saveFrom: function () {
        let saveMsg = [];
        let _this = this;
        this.dataList.forEach(x => {
          x.ShopList.forEach(y => {
            if (y.IsSelect) {
              y.TCIDS = this.tcIdList;
              saveMsg.push(y)
            }
          })
        });
        if (saveMsg && saveMsg.length > 0) {
          this.loading = true;
          this.apipost('dmcstatistics_post_SaveDMCTravelPriceShop', saveMsg, res => {
            if (res.data.resultCode === 1) {
              this.$message.success(res.data.message);
              setTimeout(function () {
                _this.MsgBus.$emit('msg');
                _this.MsgBus.$emit('refresh');
              }, 500)
            } else {
              this.$message.error(res.data.message);
            }
            this.loading = false;
          }, null)
        } else {
          this.Info(this.$t('objFill.v101.qingxuanzhegwdi'));
        }

      }
    },
    mounted() {
      this.tcIdList = this.$route.query.TCID;
      this.TCID = this.$route.query.TCIDEN;
      this.LeaderName = this.$route.query.LeaderName;
      this.GuideName = this.$route.query.GuideName;
      this.StartCityNames = this.$route.query.StartCityNames;
      this.getData()
    }
  };
</script>