<style>

</style>
<template>
    <div class="AirTicketApp">
       <table class="singeRowTable" border="0" cellspacing="0" cellpadding="0" v-loading="loading">
           <tr>
               <th v-for="(item,index) in ColNameList" :key="index">{{item}}</th>
           </tr>
           <tr v-for="(item,index) in Rlist" :key="index">
               <td>{{item.BranchName}}</td>
               <td v-for="(cl,index) in item.CList" :key="index">{{cl.LossRatio}}
                   <el-button @click="Edit(item,cl)" style="padding:4px;margin-left:10px" type="primary" icon="el-icon-edit" circle></el-button>
               </td>
           </tr>
       </table>
       <el-dialog
        :title="$t('system.table_edit')"
        :visible.sync="dialogVisible"
        width="300px">
        <div>
            <el-form ref="form" :model="changeMsg" label-width="80px">
                <el-form-item :label="$t('system.table_company')">
                    <span>{{changeMsg.BranchName}}</span>
                </el-form-item>
                <el-form-item :label="$t('op.BL')" prop="LossRatio">
                    <el-input @keyup.native="checkInteger(changeMsg,'LossRatio')" v-model="changeMsg.Ratio"></el-input>
                </el-form-item>
            </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button size="small" @click="dialogVisible = false">{{$t('pub.cancelBtn')}}</el-button>
            <el-button type="danger" size="small" @click="Ok">{{$t('pub.sureBtn')}}</el-button>
        </span>
        </el-dialog>
    </div>
</template>
<script>
export default {
    data(){
        return{
           loading:false,
           ColNameList:[],
           Rlist:[],
           dialogVisible:false,
           changeMsg:{
               Ratio:0,
           },
           rules:{ 
            Ratio: [{ required: true, message: this.$t('objFill.v101.FinancialModule.qingsrbl'), trigger: "blur" }],
            },         
        }
    },created(){
        
    },methods:{
        Ok(){
            if(this.changeMsg.Ratio>=0 && this.changeMsg.Ratio<=100){
                this.apipost('ticket_post_SetAirTicketBranchRatio',this.changeMsg, res => {

                    if(res.data.resultCode == 1) {
                        this.getList();
                        this.dialogVisible=false;
                    } else {
                        this.$message.error(res.data.message);                        
                    }
                    this.loading = false;
            }, err => {})
            }else{
                this.Error(this.$t('objFill.v101.FinancialModule.qingsrzqdbl'))
            }
        },
        Edit(item,cl){
           this.dialogVisible=true;
           this.changeMsg.BranchName=item.BranchName;
           this.changeMsg.Ratio=cl.LossRatio;
           this.changeMsg.BranchId=cl.BranchId;
           this.changeMsg.LossType=cl.LossTypeCode;
           this.changeMsg.AirLossId=cl.LossConfigId;
           
           
        },
        getList(){
            this.loading = true;
            this.apipost('ticket_post_SetAirTicketLossManagement',{}, res => {              
                    this.loading = false;
                    if(res.data.resultCode == 1) {
                        this.ColNameList=res.data.data.ColNameList;
                        this.Rlist=res.data.data.Rlist;
                    } else {
                        this.$message.error(res.data.message);                        
                    }
                    this.loading = false;
            }, err => {})
        },
    
 
   
    },mounted(){
        this.getList();
    }
}
</script>
