<template>
  <div class="red-theme page_FProcessManagement">
    <div class="query-box" style="background: none;border: 0;">
      <ul>
          <li style="color: red;"></li>
          <li>
            <input type="button" class="hollowFixedBtn" value="新增" @click="AddMsg"/>
            <input type="button" class="normalBtn" style="position: absolute; right: 90px;" value="查询" @click="getList"/>
          </li>
      </ul>
    </div>
      <div
        class="cm_content"
        style="width: 100%;margin-bottom: 35px;margin-top: 6px;"
        v-for="(item,index ) in dataList "
        :key="index"
        v-loading="loading"
      >
        <table
          class="po_content singeRowTable"
          style="border:1px solid #E6E6E6;"
          cellspacing="0"
          cellpadding="0"
        >
          <tr>
            <th width="100" style="min-width: 100px;max-width: 100px;">方案名称</th>
            <th width="200" class="left-text-indent">线路</th>
            <th width="100">提成方式</th>
            <th width="100">单签提成比</th>
            <th width="100">团签奖励</th>
            <th width="100">团签助奖</th>
            <th width="100">单/落助人头奖</th>
            <th width="150" style="min-width: 150px;max-width: 150px;">修改时间</th>
            <th width="150" style="min-width: 150px;max-width: 150px;">操作</th>
          </tr>
          <tr>
            <td>
              <span>{{item.Name}}</span>
            </td>
            <td style="padding: 0 10px;" class="left-text-indent">
              {{item.LineName}}
            </td>
            <td style="padding: 0 10px;">
              {{item.SingleVisaWay==1?'人头奖励':item.SingleVisaWay==2?'利润比':'-'}}
            </td>
            <td>
              <span v-if="item.FSingleVisaMoney">总公司:</span>{{item.SingleVisaRate}}{{item.SingleVisaWay==1?'/人':item.SingleVisaWay==2?'%':'-'}}
              <div v-if="item.FSingleVisaMoney">分公司:{{item.FSingleVisaMoney}}/人</div>
            </td>
            <td>
              <span v-if="item.FTravelVisaMoney">总公司:</span> {{item.TravelVisaMoney}}/人
              <div v-if="item.FTravelVisaMoney">分公司:{{item.FTravelVisaMoney}}/人</div>
            </td>
            <td>{{item.TravelVisaZLMoney}}/人</td>
            <td>{{item.SingleZLMoney}}/人</td>
            <td style="padding: 0 10px;">
              <p>{{item.UpdateBy}}</p>
              <span>
                {{item.UpdateDate}}
              </span>
            </td>
            <td>
              <el-button @click="SetRules(item)" style="padding:4px" type="primary" icon="el-icon-edit" circle>
              </el-button>
              <el-button @click="Delete(item)" style="padding:4px" type="danger" icon="el-icon-delete" circle></el-button>
            </td>
          </tr>
        </table>

        <div style="width:100%;overflow-x: auto;">
          <table
            class="po_content singeRowTable"
            style="border:1px solid #E6E6E6;"
            cellspacing="0"
            cellpadding="0"
          >
            <tr>
              <td :rowspan="item.FProfitList&&item.FProfitList.length>0?4:2" width="150" style="min-width: 150px;">当月负责线路毛利金额<p>当月提成比例</p> </td>
              <th v-if="item.FProfitList&&item.FProfitList.length>0" width="80" class="opTitle" rowspan="2">总公司OP</th>
              <th style="min-width: 220px;"
                v-for="( son , sIndex ) in item.ProfitList"
                :key="sIndex"
              >{{ son.StartValue }} <span>{{son.EndValue && son.EndValue!=-1?'<=当月毛利润<':'<=当月毛利润'}}</span>
              <span v-if="son.EndValue && son.EndValue!=-1">{{ son.EndValue }}</span>
              </th>
            </tr>
            <tr>
              <td style="min-width: 220px;" v-for="( son , sIndex ) in item.ProfitList" :key="sIndex">  {{ son.Rate }}%</td>
            </tr>
            <template v-if="item.FProfitList&&item.FProfitList.length>0">
              <tr>
                <th width="80" class="opTitle" rowspan="2">分公司OP</th>
                <th style="min-width: 220px;"
                  v-for="( son , sIndex ) in item.FProfitList"
                  :key="sIndex"
                >{{ son.StartValue }} <span>{{son.EndValue && son.EndValue!=-1?'<=当月毛利润<':'<=当月毛利润'}}</span>
                <span v-if="son.EndValue && son.EndValue!=-1">{{ son.EndValue }}</span>
                </th>
              </tr>
              <tr>
                <td style="min-width: 220px;" v-for="( son , sIndex ) in item.FProfitList" :key="sIndex">  {{ son.Rate }}%</td>
              </tr>
            </template>
          </table>
          <table
          class="po_content singeRowTable"
          style="border:1px solid #E6E6E6;"
          cellspacing="0"
          cellpadding="0"
        >
          <tr>
            <td :rowspan="item.FExtraList&&item.FExtraList.length>0?4:2" width="150" style="min-width: 150px;">当月负责团数<p>当月奖励</p> </td>
            <th v-if="item.FExtraList&&item.FExtraList.length>0" width="80" class="opTitle" rowspan="2">总公司OP</th>
            <th style="min-width: 220px;"
              v-for="( son , sIndex ) in item.ExtraList"
              :key="sIndex"
            >{{ son.StartValue }} <span>{{son.EndValue && son.EndValue!=-1?'<=当月团数<':'<=当月团数'}}</span>
            <span v-if="son.EndValue && son.EndValue!=-1">{{ son.EndValue }}</span>
          </th>
          </tr>
          <tr>
            <td style="min-width: 220px;" v-for="( son , sIndex ) in item.ExtraList" :key="sIndex">  {{ son.Rate }}</td>
          </tr>
          <template v-if="item.FExtraList&&item.FExtraList.length>0">
            <tr>
              <th width="80" class="opTitle" rowspan="2">分公司OP</th>
              <th style="min-width: 220px;"
                v-for="( son , sIndex ) in item.FExtraList"
                :key="sIndex"
              >{{ son.StartValue }} <span>{{son.EndValue && son.EndValue!=-1?'<=当月团数<':'<=当月团数'}}</span>
              <span v-if="son.EndValue && son.EndValue!=-1">{{ son.EndValue }}</span>
              </th>
            </tr>
            <tr>
              <td style="min-width: 220px;" v-for="( son , sIndex ) in item.FExtraList" :key="sIndex">  {{ son.Rate }}</td>
            </tr>
          </template>
        </table>
        </div>
      </div>
      <div v-if="dataList.length==0"
        style="width: 100%;border:1px solid #E6E6E6;display: flex;align-items: center;justify-content: center;height: 60px;margin-top: 30px;"
      >暂无数据</div>
    <el-dialog :title="titleName" :visible.sync="ruleVisible" width="750px" @close="resetForm('form')">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <div class="titleOP">总公司OP提成</div>
        <div class="ImpressionTicketing-msgbox bottom0">
          <el-row>
            <el-col :span="8">
              <el-form-item label="规则名称" prop="Name">
                <el-input v-model="form.Name" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="单签提成" prop="SingleVisaWay">
                <el-select v-model="form.SingleVisaWay" size="mini">
                  <el-option v-for="(item,index) in typeList" :key="item.index" :label="item.name"
                      :value="item.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="form.SingleVisaWay">
              <el-form-item :label="form.SingleVisaWay==1?'单签人头奖':'单签提成比'" prop="SingleVisaRate"
              :rules="form.SingleVisaWay==1?rules.SingleVisaRate2:rules.SingleVisaRate">
                <div class="Impression-ratio-box">
                  <el-input type="Number" v-model="form.SingleVisaRate" clearable></el-input>
                  <span class="Impression-ratio-right">{{form.SingleVisaWay==1?'/人':'%'}}</span>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="团签奖励" prop="TravelVisaMoney">
                <div class="Impression-ratio-box">
                  <el-input type="Number" v-model="form.TravelVisaMoney" clearable></el-input>
                  <span class="Impression-ratio-right">/人</span>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="团签助奖" prop="TravelVisaZLMoney">
                <div class="Impression-ratio-box">
                  <el-input type="Number" v-model="form.TravelVisaZLMoney" clearable></el-input>
                  <span class="Impression-ratio-right">/人</span>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="titleName=='编辑规则'">
              <el-form-item label="国家" prop="CountryId">
                <el-select v-model="form.CountryId" class="w256" filterable>
                  <el-option label="欧洲" :value="0" :key="0"></el-option>
                  <el-option v-for="subItem in CountryList" :key="subItem.ID" :label="subItem.Name" :value="subItem.ID">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="单/落助人头奖" prop="SingleZLMoney">
                <div class="Impression-ratio-box">
                  <el-input type="Number" v-model="form.SingleZLMoney" clearable></el-input>
                  <span class="Impression-ratio-right">/人</span>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="16">
              <el-form-item label="线路" prop="LineIdList">
                <el-select class="multiple_input" filterable multiple collapse-tags
                style="width: 100%;" v-model="form.LineIdList" @change="getLineTeamList">
                  <el-option label='全线' :value='-1' :key='-1'></el-option>
                  <el-option v-for="item in LineList" :label='item.LineName'
                  :value='item.LineID' :key='item.LineID'>
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <el-form-item class="ImpressionTicketing-OuterFrame" label-width="0px">
          <p class="ImpressionTicketing-title">毛利当月提成比例</p>
          <div class="ImpressionTicketing-msgbox" v-for="(item,index) in form.ProfitList" :key="index">
            <div>
              <el-form-item
              :label="form.ProfitList.length>0?`开始值 ${index+1} `:` ` "
              :prop="`ProfitList.${index}.StartValue`"
              :rules="rules.StartValue"
              label-width="100px"
              label-position="left">
              <el-input onkeyup="this.value=this.value.replace(/[^\d.]/g,'');" :min="0" :max="99999999"
              v-model="item.StartValue" clearable></el-input>
              </el-form-item>
            </div>
            <div>
              <el-form-item
              :label="form.ProfitList.length>0?`结束值 ${index+1} `:` ` "
              :prop="`ProfitList.${index}.EndValue`"
              :rules="rules.EndValue"
              label-width="100px"
              label-position="left">
              <el-input-number type="number" :min="-1" :max="99999999"
              v-model="item.EndValue" clearable :controls="false"></el-input-number>
              </el-form-item>
            </div>
            <div>
              <el-form-item
              :label="form.ProfitList.length>0?`比例 ${index+1} `:` ` "
              :prop="`ProfitList.${index}.Rate`"
              :rules="rules.Rate2"
              label-width="100px"
              label-position="left">
                <div class="Impression-ratio-box">
                  <el-input onkeyup="this.value=this.value.replace(/[^\d.]/g,'');" :min="0" :max="99999999"
                v-model="item.Rate"></el-input>
                  <span class="Impression-ratio-right">%</span>
                </div>
              </el-form-item>
            </div>
            <div class="ImpressionTicketing-msg-but">
              <span @click="addRule(item,index,2)" v-if="index==0" class="el-icon-circle-plus-outline itc-outline"></span>
              <span @click="deleteRule(item,index,2)" v-else class="el-icon-delete itc-delete"></span>
            </div>
          </div>
        </el-form-item>
        <el-form-item class="ImpressionTicketing-OuterFrame" label-width="0px">
          <p class="ImpressionTicketing-title">团数当月奖励</p>
          <div class="ImpressionTicketing-msgbox"
          v-for="(item,index) in form.ExtraList" :key="index">
            <div>
              <el-form-item
              :label="form.ExtraList.length>0?`开始值 ${index+1} `:` ` "
              :prop="`ExtraList.${index}.StartValue`"
              :rules="rules.StartValue"
              label-width="100px"
              label-position="left">
              <el-input onkeyup="this.value=this.value.replace(/[^\d.]/g,'');" :min="0" :max="99999999"
              v-model="item.StartValue" clearable></el-input>
              </el-form-item>
            </div>
            <div>
              <el-form-item
              :label="form.ExtraList.length>0?`结束值 ${index+1} `:` ` "
              :prop="`ExtraList.${index}.EndValue`"
              :rules="rules.EndValue"
              label-width="100px"
              label-position="left">
              <el-input-number type="number" :min="-1" :max="99999999"
              v-model="item.EndValue" clearable :controls="false"></el-input-number>
              </el-form-item>
            </div>
            <div>
              <el-form-item
              :label="form.ExtraList.length>0?`奖励 ${index+1} `:` ` "
              :prop="`ExtraList.${index}.Rate`"
              :rules="rules.Rate"
              label-width="100px"
              label-position="left">
              <el-input onkeyup="this.value=this.value.replace(/[^\d.]/g,'');" :min="0" :max="99999999"
              v-model="item.Rate"></el-input>
              </el-form-item>
            </div>
            <div class="ImpressionTicketing-msg-but">
              <span @click="addRule(item,index,3)" v-if="index==0" class="el-icon-circle-plus-outline itc-outline"></span>
              <span @click="deleteRule(item,index,3)" v-else class="el-icon-delete itc-delete"></span>
            </div>
          </div>
        </el-form-item>
        <div style="text-align: right;padding: 10px 0 10px 0;border-top: 1px dashed #E6E6E6;">
          <span>是否启用 分公司阶梯提成</span>
          <el-switch
            v-model="form.IsEnableFBranch"
            @change="isSwitch"
            active-value=1
            inactive-value=0>
          </el-switch>
        </div>
        <div>
          <div class="titleOP">分公司OP提成</div>
          <div class="ImpressionTicketing-msgbox bottom0">
            <el-row>
              <el-col :span="8">
                <el-form-item label="单签人头奖" prop="FSingleVisaMoney"
                :rules="form.SingleVisaWay==1?rules.SingleVisaRate2:rules.SingleVisaRate">
                  <div class="Impression-ratio-box">
                    <el-input type="Number" v-model="form.FSingleVisaMoney" clearable></el-input>
                    <span class="Impression-ratio-right">/人</span>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="团签奖励" prop="FTravelVisaMoney">
                  <div class="Impression-ratio-box">
                    <el-input type="Number" v-model="form.FTravelVisaMoney" clearable></el-input>
                    <span class="Impression-ratio-right">/人</span>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-form-item v-if="form.IsEnableFBranch==1" class="ImpressionTicketing-OuterFrame" label-width="0px">
            <p class="ImpressionTicketing-title">毛利当月提成比例</p>
            <div class="ImpressionTicketing-msgbox" v-for="(item,index) in form.FProfitList" :key="index">
              <div>
                <el-form-item
                :label="form.ProfitList.length>0?`开始值 ${index+1} `:` ` "
                :prop="`FProfitList.${index}.StartValue`"
                :rules="rules.StartValue"
                label-width="100px"
                label-position="left">
                <el-input onkeyup="this.value=this.value.replace(/[^\d.]/g,'');" :min="0" :max="99999999"
                v-model="item.StartValue" clearable></el-input>
                </el-form-item>
              </div>
              <div>
                <el-form-item
                :label="form.ProfitList.length>0?`结束值 ${index+1} `:` ` "
                :prop="`FProfitList.${index}.EndValue`"
                :rules="rules.EndValue"
                label-width="100px"
                label-position="left">
                <el-input-number type="number" :min="-1" :max="99999999"
                v-model="item.EndValue" clearable :controls="false"></el-input-number>
                </el-form-item>
              </div>
              <div>
                <el-form-item
                :label="form.ProfitList.length>0?`比例 ${index+1} `:` ` "
                :prop="`FProfitList.${index}.Rate`"
                :rules="rules.Rate2"
                label-width="100px"
                label-position="left">
                  <div class="Impression-ratio-box">
                    <el-input onkeyup="this.value=this.value.replace(/[^\d.]/g,'');" :min="0" :max="99999999"
                  v-model="item.Rate"></el-input>
                    <span class="Impression-ratio-right">%</span>
                  </div>
                </el-form-item>
              </div>
              <div class="ImpressionTicketing-msg-but">
                <span @click="addRule(item,index,2,1)" v-if="index==0" class="el-icon-circle-plus-outline itc-outline"></span>
                <span @click="deleteRule(item,index,2,1)" v-else class="el-icon-delete itc-delete"></span>
              </div>
            </div>
          </el-form-item>
          <el-form-item class="ImpressionTicketing-OuterFrame" label-width="0px">
            <p class="ImpressionTicketing-title">团数当月奖励</p>
            <div class="ImpressionTicketing-msgbox"
            v-for="(item,index) in form.FExtraList" :key="index">
              <div>
                <el-form-item
                :label="form.ExtraList.length>0?`开始值 ${index+1} `:` ` "
                :prop="`FExtraList.${index}.StartValue`"
                :rules="rules.StartValue"
                label-width="100px"
                label-position="left">
                <el-input onkeyup="this.value=this.value.replace(/[^\d.]/g,'');" :min="0" :max="99999999"
                v-model="item.StartValue" clearable></el-input>
                </el-form-item>
              </div>
              <div>
                <el-form-item
                :label="form.ExtraList.length>0?`结束值 ${index+1} `:` ` "
                :prop="`FExtraList.${index}.EndValue`"
                :rules="rules.EndValue"
                label-width="100px"
                label-position="left">
                <el-input-number type="number" :min="-1" :max="99999999"
                v-model="item.EndValue" clearable :controls="false"></el-input-number>
                </el-form-item>
              </div>
              <div>
                <el-form-item
                :label="form.ExtraList.length>0?`奖励 ${index+1} `:` ` "
                :prop="`FExtraList.${index}.Rate`"
                :rules="rules.Rate"
                label-width="100px"
                label-position="left">
                <el-input onkeyup="this.value=this.value.replace(/[^\d.]/g,'');" :min="0" :max="99999999"
                v-model="item.Rate"></el-input>
                </el-form-item>
              </div>
              <div class="ImpressionTicketing-msg-but">
                <span @click="addRule(item,index,3,1)" v-if="index==0" class="el-icon-circle-plus-outline itc-outline"></span>
                <span @click="deleteRule(item,index,3,1)" v-else class="el-icon-delete itc-delete"></span>
              </div>
            </div>
          </el-form-item>
        </div>


      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="ruleVisible = false,resetForm('form')">取 消</el-button>
        <el-button size="small" type="danger" @click="RulesOk('form')" :loading="ruleLoading">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        CountryList: [],
        LineList: [],
        value:"",
        rules: {
          Name: [{
            required: true,
            message: '请输入规则名称',
            trigger: "blur"
          }],
          SingleVisaWay: [{
            required: true,
            message: '请选择提成方式',
            trigger: "change"
          }],
          SingleVisaRate: [{
            required: true,
            message: '请输入提成比例',
            trigger: "blur"
          }],
          SingleVisaRate2: [{
            required: true,
            message: '请输入人头奖金',
            trigger: "blur"
          }],
          TravelVisaMoney: [{
            required: true,
            message: '请输入人头奖励',
            trigger: "blur"
          }],
          TravelVisaZLMoney: [{
            required: true,
            message: '请输入签证奖励',
            trigger: 'blur'
          }],
          StartValue: [{
            required: true,
            message: "请输入开始值",
            trigger: "blur"
          }],
          EndValue: [{
            required: true,
            message: "请输入结束值",
            trigger: "blur"
          }],
          Rate: [{
            required: true,
            message: "请输入金额",
            trigger: "blur"
          }],
          Rate2: [{
            required: true,
            message: "请输入比例",
            trigger: "blur"
          }],
          LineIdList: [{
            required: true,
            message: '请选择线路',
            trigger: 'change'
          }],
          CountryId: [{
            required: true,
            message: '请选择国家',
            trigger: 'change'
          }],
          FSingleVisaMoney: [{
            required: true,
            message: '请输入分公司人头奖励',
            trigger: "blur"
          }],
          FTravelVisaMoney: [{
            required: true,
            message: '请输入分公司团签奖励',
            trigger: 'blur'
          }],
          SingleZLMoney: [{
            required: true,
            message: '请输入单项/落地散助理人头奖励',
            trigger: 'blur'
          }],
        },
        ProfitList:
          {
            StartValue:0,
            EndValue:null,
            Rate:null
          },
          ExtraList:
          {
            StartValue:0,
            EndValue:null,
            Rate:null
          },
        FProfitList:
          {
            StartValue:0,
            EndValue:null,
            Rate:null
          },
        FExtraList:
          {
            StartValue:0,
            EndValue:null,
            Rate:null
          },
        form:{
          Id:0,
          Name:'',
          SingleVisaWay: null,
          SingleVisaRate: 0,
          TravelVisaMoney: 0,
          TravelVisaZLMoney: 0,
          CountryId: null,
          LineIdList: [],
          LineIds: '',
          ProfitList:[
            {
              StartValue:0,
              EndValue:null,
              Rate:null
            }
          ],
          ExtraList:[
            {
              StartValue:0,
              EndValue:null,
              Rate:null
            }
          ],
          FProfitList: [
            {
              StartValue:0,
              EndValue:null,
              Rate:null
            }
          ],
          FExtraList: [
            {
              StartValue:0,
              EndValue:null,
              Rate:null
            }
          ],
          IsEnableFBranch: 0,
          FSingleVisaMoney: 0,
          FTravelVisaMoney: 0,
          SingleZLMoney: 0,
        },
        ruleLoading: false,
        ruleVisible:false,
        titleName:'提成规则',
        loading: false,
        dataList:[],
        typeList:[
            {name:'人头奖励',id:1},
            {name:'利润比',id:2}
          ]
      }
    },
    created() {},
    mounted() {
      this.getCountry()
      this.getLineList()
      this.getList()
    },
    methods: {
      // 初始化表单
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
      // 添加规则
      addRule(row,index,type,num){
       if(type==2){
        if(num){
          this.form.FProfitList.push(JSON.parse(JSON.stringify(this.FProfitList)))
        }else{
          this.form.ProfitList.push(JSON.parse(JSON.stringify(this.ProfitList)))
        }
        }else if(type==3){
          if(num){
            this.form.FExtraList.push(JSON.parse(JSON.stringify(this.FExtraList)))
          }else{
            this.form.ExtraList.push(JSON.parse(JSON.stringify(this.ExtraList)))
          }
        }
      },
      // 删除规则
      deleteRule(row,index,type,num){
        if(type==2){
          if(num){
            this.form.FProfitList.splice(index,1)
          }else{
            this.form.ProfitList.splice(index,1)
          }
        }else if(type==3){
          if(num){
            this.form.FExtraList.splice(index,1)
          }else{
            this.form.ExtraList.splice(index,1)
          }
        }
      },
      AddMsg(){//新增
        this.ruleVisible = true
        this.titleName = '提成规则'
        this.form.FExtraList = [JSON.parse(JSON.stringify(this.FExtraList))]
      },
      SetRules(item){//编辑
        this.titleName = '编辑规则'
        this.ruleVisible = true;
        item = JSON.parse(JSON.stringify(item))
        let arr = item.LineIds.split(',')
        let ids = []
        arr.forEach(item => {
          ids.push(Number(item))
        });
        this.form = {
          Id: item.Id,
          Name: item.Name,//规则名称
          LineIdList: ids,
          LineIds: item.LineIds,
          SingleVisaWay: item.SingleVisaWay,
          SingleVisaRate: item.SingleVisaRate,
          TravelVisaMoney: item.TravelVisaMoney,
          TravelVisaZLMoney: item.TravelVisaZLMoney,
          CountryId: item.CountryId>0||item.CountryId==0?item.CountryId:null,
          ProfitList: item.ProfitList,
          ExtraList: item.ExtraList,
          IsEnableFBranch: String(item.IsEnableFBranch),
          FProfitList: item.FProfitList&&item.FProfitList.length>0?item.FProfitList:item.IsEnableFBranch>0?[this.FProfitList]:[],
          FExtraList: item.FExtraList&&item.FExtraList.length>0?item.FExtraList:[this.FExtraList],
          FSingleVisaMoney: item.FSingleVisaMoney,
          FTravelVisaMoney: item.FTravelVisaMoney,
          SingleZLMoney: item.SingleZLMoney,
        }
      },
      Delete(item){//删除
        this.$confirm("是否删除? 删除后不可恢复", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          })
          .then(() => {
            this.apipost('commission_DelOPCommissionAwardRule', {
              RuleId: item.Id
            }, res => {
              if (res.data.resultCode == 1) {
                this.Success(res.data.message)
                this.getList()
              } else {
                this.Error(res.data.message)
              }
            })
          })
          .catch(() => {});
      },
      isSwitch(){
        this.form.FProfitList = []
        if(this.form.IsEnableFBranch){
          this.form.FProfitList.push(JSON.parse(JSON.stringify(this.FProfitList)))
        }
      },
      // 点击确定
      RulesOk(formName) {
        this.form.LineIds = this.form.LineIdList.join(',')
        // this.form.CountryId = this.form.CountryId||this.form.CountryId==0?this.form.CountryId:-1
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.ruleLoading = true
            this.apipost(
              'commission_SetOPCommissionAwardRule', this.form,
              res => {
                if (res.data.resultCode == 1) {
                  this.resetForm('form')
                  this.getList();
                  this.ruleVisible = false;
                  this.Success(res.data.message)
                } else {
                  this.Error(res.data.message)
                }
                this.ruleLoading = false
              },
              err => {}
            )
          }
        });
      },
      // 获取列表数据
      getList() {
        this.loading = true;
        this.apipost("commission_GetOPCommissionAwardRuleList", {}, res => {
          if (res.data.resultCode == 1) {
            this.dataList = res.data.data;
          }else{
            this.Error(res.data.message)
          }
          this.loading = false
        });
      },
      // 重置表单
      resetForm(formName) {
        this.ruleVisible = false;
        // 重置表单
        this.form = {
          Id:0,
          Name:'',
          CountryId: null,
          ProfitList:[
            {
              StartValue:0,
              EndValue:null,
              Rate:null
            }
          ],
          ExtraList:[
            {
              StartValue:0,
              EndValue:null,
              Rate:null
            }
          ],
          LineIdList:[],
          LineIds: '',
          SingleVisaWay: null,
          SingleVisaRate: 0,
          TravelVisaMoney: 0,
          TravelVisaZLMoney: 0,
        };
        this.$refs[formName].resetFields();
    },
    //获取系列列表
    getLineTeamList() {
        if (this.form.LineIdList.indexOf(-1) != -1) {
          this.form.LineIdList = [-1];
          return;
        }
    },
    //获取国家列表
    getCountry() {
        this.apipost(
          "dict_post_Destination_GetCountry", {},
          res => {
            if (res.data.resultCode == 1) {
              this.CountryList = res.data.data;
            }
          },
          err => {}
        );
      },
    // 线路
    getLineList() {
        this.apipost("line_post_GetAllList_V3", {
          IsShow: -1
        }, res => {
          if (res.data.resultCode == 1) {
            this.LineList = res.data.data;
          }
        });
      },
    }
  }

</script>
<style scoped>
  .hollowFixedBtn{
    position: absolute;
    top: 0;
    right: 20px;
  }
  ._nav li{float: left;font-size: 14px;color: #666666;padding: 15px 10px;background-color: #F1F1F1;cursor: pointer;position: relative;}
  ._nav li._active{background-color:#FFFFFF;color: #333333 }
  ._nav li._active::after{content: "";width: 20px;height: 3px;background-color: #E95252;display: inline-block;position: absolute;bottom: 0;left: 38%;}
  .ImpressionTicketing-OuterFrame{
    padding: 10px 20px 20px 20px;
    box-shadow: 0 1px 8px rgb(0 0 0 / 20%), 0 3px 4px rgb(0 0 0 / 14%), 0 3px 3px -2px rgb(0 0 0 / 12%);
  }
  .ImpressionTicketing-msgbox{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    margin-bottom: 20px;
  }
  .ImpressionTicketing-msgbox.bottom0{
    margin-bottom: 0;
  }
  .ImpressionTicketing-msgbox div{
    flex: 1;
  }
  .ImpressionTicketing-msgbox div.ImpressionTicketing-msg-but{
    flex: 0 0 auto;
  }
  .itc-delete{
    color: #E95252;
    font-size: 16px;
    cursor: pointer;
    display: inline-block;
    padding: 10px;
  }
  .itc-outline{
    color: #409EFF;
    font-size: 16px;
    cursor: pointer;
    display: inline-block;
    padding: 10px;
  }
  .ImpressionTicketing-title{
    padding: 0;
  }
  .left-text-indent{
    text-align: left;
    text-indent: 20px
  }
  /deep/.el-input-number{
    width: inherit;
  }
  /deep/.el-input-number .el-input__inner{
    text-align: left;
    height: 34px;
  }
  .Impression-ratio-box{
    display: flex;
    justify-content: space-between;
  }
  .Impression-ratio-right{
    font-size: 13px;
    margin-left: 5px;
  }
  /deep/.line-heigh .el-input-number{
    line-height: 32px;
  }
  .titleOP{
    font-size: 16px;
    padding: 0 0 10px 0;
    font-weight: bold;
  }
  .opTitle{
    min-width:80px;background: #fff;border-top: 1px solid #E6E6E6;border-right: 1px solid #E6E6E6;
  }
</style>