<style>
    .SnotSet,.TotalShouSun{
        color:#E95252;
    }
    .totalShouSan{
        position: absolute;
        left:20px;
        font-size:14px;
        top:15px;
    }
    .cmShouLastTd{
        padding:10px 0;
        position:relative;
        text-align:right;
        padding:20px 20px 20px 0;
    }
    .totalRemarkSpan{
        position: absolute;
        left:20px;
        top:40px;
        font-size:12px;
        color:#E95252;
    }
    .comShouSunTable{
        width: 100%;
        border-collapse: collapse;
    }
    .comShouSunTable tr{
        height:40px;
    }
    .comShouSunTable tr td{
        font-size: 12px;
        border: 1px solid #e5e5e5;
        background-color: #fff;
        text-align: center;
    }
</style>

<template>
    <div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="comShouSunTable">
            <tr>
                <td colspan="4">
                    {{$t('ground.opszssrs')}}：
                    <template v-if="Type==1">
                        <el-input class="w180" :placeholder="$t('pub.pleaseImport')" @keyup.native="checkInteger(dataList,'OpSetLossPeople')" v-model="dataList.OpSetLossPeople" type="text" ></el-input>
                    </template>
                    <template v-else>{{dataList.OpSetLossPeople}}</template>
                </td>
            </tr>
            <tr>
                <td>
                    {{$t('ground.pwssjne')}}
                </td>
                <td>
                    {{$t('ground.qzssjine')}}
                </td>
                <td>
                    {{$t('ground.djshousunjine')}}
                </td>
                <td>
                   {{$t('ground.opbuchongjine')}}
                </td>
            </tr>
            <tr>
                <td>
                    <template v-if="Type==2">
                        <el-input class="w135" v-model="dataList.LossTicketMoney" @keyup.native="checkPrice(dataList,'LossTicketMoney',true),getTotalSun(dataList)" :placeholder="$t('pub.pleaseImport')" type="text" ></el-input>
                    </template>
                    <template v-else>
                        <span v-if="dataList.TicketIsSet==1">{{dataList.LossTicketMoney}}</span>
                        <span class="SnotSet" v-else>{{$t('ground.weishezhi')}}</span>
                    </template>
                </td>
                <td>
                    <template v-if="Type==3">
                        <el-input class="w135" v-model="dataList.LossVisaMoney" @keyup.native="checkPrice(dataList,'LossVisaMoney',true),getTotalSun(dataList)" :placeholder="$t('pub.pleaseImport')" type="text" ></el-input>
                    </template>
                    <template v-else>
                        <span v-if="dataList.VisaIsSet==1">{{dataList.LossVisaMoney}}</span>
                        <span class="SnotSet" v-else>{{$t('ground.opbuchongjine')}}{{$t('ground.weishezhi')}}</span>
                    </template>
                </td>
                <td>
                    <template v-if="Type==4">
                        <el-input class="w135" v-model="dataList.LossDiJieMoney" @keyup.native="checkPrice(dataList,'LossDiJieMoney',true),getTotalSun(dataList)" :placeholder="$t('pub.pleaseImport')" type="text" ></el-input>
                    </template>
                    <template v-else>
                        <span v-if="dataList.DiJieIsSet==1">{{dataList.LossDiJieMoney}}</span>
                        <span class="SnotSet" v-else>{{$t('ground.weishezhi')}}</span>
                    </template>
                </td>
                <td>
                    <template v-if="Type==1">
                        <el-input class="w135" v-model="dataList.LossOPMoney" @keyup.native="checkPrice(dataList,'LossOPMoney',true),getTotalSun(dataList)" :placeholder="$t('pub.pleaseImport')" type="text" ></el-input>
                    </template>
                    <template v-else>
                        <span v-if="dataList.OPIsSet==1">{{dataList.LossOPMoney}}</span>
                        <span class="SnotSet" v-else>{{$t('ground.weishezhi')}}</span>
                    </template>
                </td>
            </tr>
            <tfoot>
                <tr>
                    <td class="cmShouLastTd" colspan="4" style="text-align:right">
                        <span class="totalShouSan">
                            {{$t('ground.shousunzonge')}}：<span class="TotalShouSun">{{totalSun}}</span>
                        </span>
                        <span class="totalRemarkSpan">
                            {{$t('ground.quanbujineshezhi')}}
                        </span>
                        <div style="margin-top:43px;text-align:left;padding-left:20px;color:red;">
                            <span v-if="MiniAppUserId>0&&MyIsChargeLossOrders==1">
                                {{$t('objFill.zhuxcxystslxgly')}}
                            </span>
                            <span v-if="MiniAppUserId>0&&MyIsChargeLossOrders==0">
                                {{$t('objFill.zhubchzdcjtkdjqhs')}}
                            </span>
                        </div>
                        <input type="button" class="normalBtn" @click="closeDialog()" :value="$t('pub.cancelBtn')" />
                        <input type="button" class="normalBtn" v-if="getShow()"  @click="setShouSun()" :value="$t('pub.saveBtn')" />
                    </td>
                </tr>
            </tfoot>
        </table>
    </div>
</template>
<script>
  export default {
    props: ["Type", "SetShouSunGuestNum","MiniAppUserId","MyIsChargeLossOrders"],
    data() {
      return {
          dataList:[],
          OrderId:0,
          totalSun:0
      };
    },
    methods: {
      getShouSunList(OrderId) {
        this.OrderId=OrderId;
        let msg = {
            OrderId:OrderId
        }
        this.apipost("sellorder_post_GetTravelSetLossMoneyInfo",msg,res => {
            if (res.data.resultCode == 1) {
                this.dataList = res.data.data;
                // this.dataList.OpSetLossPeople = this.SetShouSunGuestNum
                this.getTotalSun(this.dataList);
            } else {
                this.Error(res.data.message);
            }
        },
        err => {}
        );
      },
      //计算收损总额
      getTotalSun(dataList){
          if(dataList!=undefined){
            this.totalSun = parseFloat(dataList.LossOPMoney)+parseFloat(dataList.LossTicketMoney)
            +parseFloat(dataList.LossVisaMoney)+parseFloat(dataList.LossDiJieMoney);
          }
      },
      //关闭窗口
      closeDialog() {
        this.$emit("closeShouSun");
      },
      //判断是否显示确定按钮
      getShow(){
          if(this.MiniAppUserId>0&&this.MyIsChargeLossOrders==1){
              return false
          }else{
              return true
          }
      },
      //保存
      setShouSun(){
        let msg={
            OrderId:this.OrderId,
            Type:this.Type,
            PeopleNum:this.dataList.OpSetLossPeople,
            LossMoney:0
        }
        switch(this.Type){
            case 1:
                msg.LossMoney=this.dataList.LossOPMoney
                break;
            case 2:
                msg.LossMoney=this.dataList.LossTicketMoney
                break;
            case 3:
                msg.LossMoney=this.dataList.LossVisaMoney
                break;
            case 4:
                msg.LossMoney=this.dataList.LossDiJieMoney
                break;
        }
        this.apipost("sellorder_post_SetOrderRevenueLossNew",msg,res => {
            if (res.data.resultCode == 1) {
                this.Success(res.data.message);
                this.closeDialog();
                this.$emit("getList");
                this.MsgBus.$emit('comMsgTips')
            } else {
                this.Error(res.data.message);
            }
        },
        err => {}
        );
      }
    },
    mounted() {

    }
  };
</script>

