<template>
  <div class="domesticCommissionRule">
    <div class="query-box">
      <ul>
        <li>
          <span>
            <em>{{$t('fnc.gzmingcheng')}}</em>
            <el-input type="text" v-model="msg.RuleName" @keyup.native.enter="handleCurrentChange(1)">
            </el-input>
          </span>
        </li>
        <li>
          <span style="display: flex;align-items: center;">
            <em>{{$t('advmanager.v_line')}}</em>
            <el-select v-model="msg.LineId" size="mini" @change="handleCurrentChange(1)">
              <el-option :label="$t('pub.pleaseSel')" :value="0"></el-option>
              <el-option v-for="(item,index) in LineList" :key="item.index" :label="item.LineName" :value="item.LineID">
              </el-option>
            </el-select>
          </span>
        </li>


        <li>
          <input type="button" class="normalBtn" :value="$t('pub.addBtn')" @click="addNew">
        </li>
      </ul>
    </div>
    <div class="commonContent">
      <table v-loading="loading" class="singeRowTable" border="0" cellspacing="0" cellpadding="0">
        <thead>
          <tr>
            <th>{{$t('fnc.gzmingcheng')}}</th>
            <th>{{$t('advmanager.v_line')}}</th>
            <th>{{$t('sm.company')}}</th>
            <th>{{$t('objFill.v101.FinancialModule.xiaosoulx')}}</th>
            <!-- <th>{{$t('salesModule.Laiyuan')}}</th> -->
            <th>{{$t('objFill.tuanduilx')}}</th>
            <th>{{$t('advmanager.v_type')}}</th>
            <th>{{$t('objFill.v101.FinancialModule.jinebil')}}</th>
            <th>{{$t('objFill.v101.administrative.xiugairen')}}</th>
            <th>{{$t('sm.xiugaishijian')}}</th>
            <th>{{$t('system.table_operation')}}</th>
          </tr>
        </thead>
        <template v-for="(subItem,subIndex) in DataList">
          <tr v-for="(childItem,childIndex) in subItem.DetailList">
            <td v-if="childIndex==0" :rowspan="subItem.DetailList.length">{{subItem.RuleName}}</td>
            <td v-if="childIndex==0" :rowspan="subItem.DetailList.length">
              <span v-for="(x,y) in subItem.LineNameList"
                :key="y+'1'">{{x}}{{subItem.LineNameList.length==y+1?'':'、'}}</span>
            </td>
            <td v-if="childIndex==0" :rowspan="subItem.DetailList.length">{{subItem.BranchName}}</td>
            <td v-if="childIndex==0" :rowspan="subItem.DetailList.length">
              <span v-if="subItem.RuleType==1">{{$t('visaT.sale')}}</span>
              <span v-if="subItem.RuleType==2">OP</span>
              <span v-if="subItem.RuleType==3">{{$t('objFill.v101.FinancialModule.zidyry')}}</span>
            </td>
            <!-- <td >
              <span v-if="childItem.SourceType==1">{{$t('pub.normalSel')}}</span>
              <span v-if="childItem.SourceType==2">{{$t('objFill.v101.FinancialModule.feizhu')}}</span>
              <span v-if="childItem.SourceType==3">{{$t('objFill.v101.FinancialModule.xiaohs')}}</span>
            </td> -->
            <td>{{childItem.TravelType==1?$t('op.Onedaytour'):childItem.TravelType==2?$t('objFill.danxiang'):$t('Operation.Op_leaveCountry')}}</td>
            <td>
              <span v-if="childItem.CommissionType == 1">{{$t('objFill.v101.FinancialModule.rentou')}}</span>
              <span v-if="childItem.CommissionType == 2">{{$t('objFill.lirunbili')}}</span>
            </td>
            <td>
              <span>{{childItem.Money}} {{subItem.CurrencyName}}/{{$t('hotel.hotel_people')}}</span>
              <span v-if="childItem.CommissionType == 2">
                <div>{{$t('objFill.lirunbi')}}{{childItem.ProfitRate}}%</div>
                <div>{{$t('restaurant.res_profit')}}<={{$t('objFill.v101.FinancialModule.shi')}} {{childItem.Money}}{{$t('objFill.v101.FinancialModule.yuanren')}}</div> </span> </td>
            <td v-if="childIndex==0"
                    :rowspan="subItem.DetailList.length">{{subItem.UpdateBy}}</td>
            <td v-if="childIndex==0" :rowspan="subItem.DetailList.length">{{subItem.UpdateDate}}</td>
            <td v-if="childIndex==0" :rowspan="subItem.DetailList.length">
              <el-button-group size='mini'>
                <el-tooltip class="item" effect="dark" :content="$t('system.table_edit')" placement="top-start">
                  <el-button type="primary" icon="el-icon-edit"
                    @click="isShowDIv = true,divTitle=$t('objFill.v101.FinancialModule.xiugtcgz'),getEdit(subItem)">
                  </el-button>
                </el-tooltip>
                <el-tooltip class="item" effect="dark" :content="$t('system.table_delete')" placement="top-start">
                  <el-button type="danger" icon="el-icon-delete" @click="DeleteRules(subItem.Id)">
                  </el-button>
                </el-tooltip>
              </el-button-group>
            </td>


          </tr>
        </template>
        <tr v-if="DataList.length==0">
          <td colspan="10" align="center">{{$t('system.content_noData')}}</td>
        </tr>
        <tfoot>
          <tr>
            <td colspan="10">
              <el-pagination background @current-change="handleCurrentChange" :current-page.sync="msg.pageIndex"
                layout="total,prev, pager, next, jumper" :page-size="msg.pageSize" :total="total">
              </el-pagination>
            </td>
          </tr>
        </tfoot>


      </table>
    </div>
    <el-dialog :title="$t('objFill.v101.FinancialModule.guoneitcgz')" :visible.sync="ruleVisible" width="800px">
      <el-form ref="addMsg" :model="addMsg" :rules="rules" label-width="110px">
        <el-form-item :label="$t('fnc.gzmingcheng')" prop="RuleName">
          <el-input type="text" v-model="addMsg.RuleName"></el-input>
        </el-form-item>
        <el-form-item :label="$t('advmanager.v_line')" prop="LineshortIds">
          <el-select v-model="addMsg.LineshortIds" multiple :placeholder="$t('objFill.v101.FinancialModule.xuanzhexl')" style="width: 100%;">
            <el-option v-for="(item,index) in LineList" :key="index" :label="item.LineName" :value="item.LineID">
            </el-option>
          </el-select>
        </el-form-item>
        <el-row>
          <el-col :span="8">
            <el-form-item :label="$t('sm.company')" prop="BranchId">
              <el-select v-model="addMsg.BranchId" :placeholder="$t('objFill.v101.FinancialModule.xuanzhegs')" style="width: 100%;">
                <el-option v-for="item in companyList" :label='item.BName' :value='item.Id' :key='item.Id'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('objFill.v101.FinancialModule.jietuanshr')" prop="AuditEmpId">
              <el-select
                    v-model="addMsg.AuditEmpId"
                    filterable
                    remote
                    reserve-keyword
                    :placeholder="$t('objFill.v101.FinancialModule.sosuoshr')"
                    :remote-method="remoteMethod"
                    style="width: 100%;"
                    >
                    <el-option
                        v-for="item in searchList"
                        :key="item.empId"
                        :label="item.name"
                        :value="item.empId">
                        <span style="float: left">{{ item.name }}</span>
                        <span style="float: right; color: #8492a6; font-size: 13px">{{ item.postName }}</span>
                    </el-option>
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('hotel.hotel_Currency')" prop="CurrencyId">
              <el-select :placeholder="$t('objFill.v101.FinancialModule.xuanzhebz')"
                v-model="addMsg.CurrencyId" style="width: 100%;" @change="getCurrent(addMsg.CurrencyId)">
                <el-option v-for="item in allCurrencyList" :key="item.ID" :label="item.Name" :value="item.ID">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item :label="$t('system.query_type')" prop="RuleType">
          <el-radio v-model="addMsg.RuleType" label="1">{{$t('visaT.sale')}}</el-radio>
          <el-radio v-model="addMsg.RuleType" label="2" style="margin-right: 20px;">OP</el-radio>
          <!-- <el-radio v-model="addMsg.RuleType" label="3" style="margin-right: 20px;">{{$t('objFill.v101.FinancialModule.zidyry')}}</el-radio>
          <span style="font-size: 12px;color:red">(*{{$t('objFill.v101.FinancialModule.zhuzdyryjh')}})</span> -->
        </el-form-item>

        <el-form-item :label="$t('objFill.v101.FinancialModule.tichengblb')">
          <div style="width: 100%;border-bottom: 1px solid #e2e2e2;padding-bottom: 10px;margin-top: 10px;"
            v-for="(x,y) in addMsg.DetailList" :key='y'>
            <!-- <div style="display: flex;align-items: center;margin-top: 10px;">
              <el-form-item :label="$t('salesModule.Laiyuan')">
                <el-radio v-model="x.SourceType" label="1" @change='getSType(y)'>{{$t('pub.normalSel')}}</el-radio>
                <el-radio v-model="x.SourceType" label="2" :disabled="x.STdisabled" style="margin-right: 20px;" @change='getSType(y)'>{{$t('objFill.v101.FinancialModule.feizhu')}}</el-radio>
                <el-radio v-model="x.SourceType" label="3" :disabled="x.STdisabledXHS" style="margin-right: 20px;" @change='getSType(y)'>{{$t('objFill.v101.FinancialModule.xiaohs')}}</el-radio>
              </el-form-item>
              <el-button style="margin-left: 15px;padding: 6px;" type="danger" size="mini"  class="el-icon-delete" circle
                v-if="addMsg.DetailList.length>1" @click="addMsg.DetailList.splice(y,1),selectdis()">
              </el-button>
            </div> -->
            <div style="display: flex;align-items: center;">
              <!-- <span style="line-height: 34px;">团队类型：</span> -->
              <!-- <el-form-item v-if='x.SourceType==1 && addMsg.RuleType!=3' :prop="'DetailList.'+ y +'.TravelType'"
              :rules="productGroupRules.TravelType" :label="$t('objFill.v101.commissonBill.col.t3')">
                <el-select v-model="x.TravelType" style="width: 200px;" @change="selectdis($event, y),gettdName(x.Id,y)"
                  clearable>
                  <el-option v-for="item in TeamListArr" :key="item.Id" :label="item.Name" :disabled="item.disabled"
                    :value="item.Id"></el-option>
                </el-select>
              </el-form-item> -->
              <!-- <el-form-item :label="$t('fnc.ryxuanze')+'：'" v-if=" addMsg.RuleType==3" :prop="'DetailList.'+ y +'.Id'" :rules="productGroupRules2.Id">
                <el-select
                    v-model="x.Id"
                    filterable
                    remote
                    reserve-keyword
                    :placeholder="$t('pub.pleaseImport')"
                    :remote-method="remoteMethod"
                    @change="getpersonnel(y)"
                    >
                    <el-option
                        v-for="item in searchList"
                        :key="item.empId"
                        :label="item.name"
                        :value="item.empId">
                        <span style="float: left">{{ item.name }}</span>
                        <span style="float: right; color: #8492a6; font-size: 13px">{{ item.postName }}</span>
                    </el-option>
                </el-select>
            </el-form-item> -->
            </div>

            <!-- <div style="display: flex;align-items: center;margin-top: 10px;">
              <el-form-item :label="$t('system.query_type')">
                <el-radio v-model="x.CommissionType" label="1">{{$t('objFill.v101.FinancialModule.rentou')}}</el-radio>
                <el-radio v-model="x.CommissionType" label="2" style="margin-right: 20px;">{{$t('objFill.v101.FinancialModule.lirunbl')</el-radio>
              </el-form-item>
            </div> -->
            <div style="display: flex;align-items: center;margin-bottom: 10px;">
              <el-row>
                <el-col :span="12">
                  <el-form-item :prop="'DetailList.'+ y +'.TravelType'"
                  :rules="productGroupRules.TravelType" :label="$t('objFill.v101.commissonBill.col.t3')">
                    <el-select v-model="x.TravelType" style="width: 200px;" @change="selectdis($event, y),gettdName(x.Id,y)"
                      clearable>
                      <el-option v-for="item in TeamListArr" :key="item.Id" :label="item.Name" :disabled="item.disabled"
                        :value="item.Id"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :prop="'DetailList.'+ y +'.Money'" :rules="productGroupRules.Money"
                    :label="$t('objFill.v101.FinancialModule.rentouje')">
                    <el-input style="width: 200px;" type="Number" v-model="x.Money"
                      @keyup.native="checkPrice(x,'Money',true)"><template slot="append">{{CurrentNmae}}/{{$t('hotel.hotel_people')}}</template>
                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-form-item v-if="x.CommissionType==2" :prop="'DetailList.'+ y +'.ProfitRate'"
                :rules="productGroupRules.ProfitRate" :label="$t('objFill.v101.FinancialModule.lirunbl')">
                <el-input style="width: 170px;" type="Number" v-model="x.ProfitRate"
                  @keyup.native="checkPrice(x,'ProfitRate',true)">
                  <template slot="append">%</template>
                </el-input>
                <!-- <span style="margin-left: 15px;" >利润小于等于0：</span>
                                -->
              </el-form-item>
              <el-form-item v-if="x.CommissionType==2" :prop="'DetailList.'+ y +'.Money'" :rules="productGroupRules.Money"
                :label="$t('objFill.v101.FinancialModule.lirunshi')">
                <el-input style="width: 170px;" type="Number" v-model="x.Money"
                  @keyup.native="checkPrice(x,'Money',true)"><template slot="append">{{CurrentNmae}}/{{$t('hotel.hotel_people')}}</template>
                </el-input>
              </el-form-item>
              <div>
                <el-button style="margin-left: 15px;padding: 6px;" type="danger" size="mini"  class="el-icon-delete" circle
                v-if="addMsg.DetailList.length>1" @click="addMsg.DetailList.splice(y,1),selectdis()">
              </el-button>
              </div>
              <!-- <span v-if="x.CommissionType==1">人头金额：</span>
                            <span v-if="x.CommissionType==2">利润比例：</span>
                             -->

            </div>

          </div>
          <!-- v-if="TeamListArr.length>addMsg.DetailList.length || addMsg.RuleType==3" -->
          <el-button  size="mini" type="primary"
            class="el-icon-circle-plus-outline" circle @click="addDetailList"></el-button>

        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="ruleVisible = false">{{$t('pub.cancelBtn')}}</el-button>
        <el-button size="small" type="danger" @click="RulesOk('addMsg')">{{$t('pub.sureBtn')}}</el-button>
      </span>
    </el-dialog>



  </div>
</template>
<script>
  import Vue from "vue";
  const addobj = {
    Id: 0,
    RuleName: '',
    LineIds: '',
    LineshortIds: [],
    BranchId: '',
    RuleType: '1',
    CurrencyId:'',
    AuditEmpId: '',
    DetailList: [{
      TravelType: '',
      // Name: '',
      CommissionType: '1',
      Money: '0',
      // ProfitRate: '0',//提成比例
      // SourceType:'1',//来源
      // STdisabled:false,
      // STdisabledXHS:false
    }]
  }
  export default {
    data() {
      var checkVariable = (rule, value, callback) => {
        if (value == null || value.length == 0) {
          return callback(new Error(this.$t('objFill.v101.FinancialModule.ticblbnwk')));
        }
        let a = parseFloat(value);
        if (isNaN(a)) {
          callback(new Error(this.$t('objFill.v101.FinancialModule.ticblbxszs')));
        } else {
          callback();
        }
      };
      return {
        CurrentNmae: '',
        //所有币种
        allCurrencyList: [],
        companyList: [],
        getCompanyMsg: {
          RB_Group_Id: '0',
          Status: '0',
        },
        msg: {
          pageIndex: 1,
          pageSize: 10,
          RuleName: '',
          LineId: 0,
          BranchId: -1,
        },
        searchList:[],//人员
        loading: false, //加载层
        DataList: [],
        total: 0,
        TeamListArr: [
          {Name:'一日游',Id:1,disabled:false},
          {Name:'单项',Id:2,disabled:false},
          {Name:'出境',Id:3,disabled:false},
        ], //团队类型
        LineList: [], //线路
        ruleVisible: false, //弹窗的显示
        addMsg: Object.assign({}, addobj),
        rules: {
          RuleName: [{
            required: true,
            message: this.$t('rule.qsrgzmingcheng'),
            trigger: 'blur'
          }],
          LineshortIds: [{
            type: 'array',
            required: true,
            message: this.$t('objFill.v101.dmc.qingxzlx'),
            trigger: 'change'
          }],
          BranchId: [{
            required: true,
            message: this.$t('objFill.v101.activity.rul2.t4'),
            trigger: 'change'
          }],
          CurrencyId: [{
            required: true,
            message: this.$t('rule.qxzbzhong'),
            trigger: 'change'
          }],
          AuditEmpId: [{
            required: true,
            message: this.$t('objFill.v101.FinancialModule.qingxzjtshr'),
            trigger: 'change'
          }],
        },
        productGroupRules2:{
          Id: [{
            required: true,
            message: this.$t('objFill.v101.FinancialModule.qiingxzry'),
            trigger: 'change'
          }],
        },
        productGroupRules: {
          TravelType: [{
            required: true,
            message: this.$t('objFill.v101.FinancialModule.qingxztdlx'),
            trigger: 'change'
          }],
          Money: [{
            required: true,
            message: this.$t('objFill.v101.FinancialModule.bunengwk'),
            trigger: 'change'
          }],
          ProfitRate: [{
            required: true,
            message: this.$t('objFill.v101.FinancialModule.bunengwk'),
            trigger: 'change'
          }],
        }
      };
    },
    created() {
      let userInfo = this.getLocalStorage();
      this.getCompanyMsg.RB_Group_Id = userInfo.RB_Group_id; //集团

      this.getList()
      this.getTeamList()
      this.getLineList()
      this.getCompany()
      this.getAllCurrency()
    },
    methods: {
      //获取当前下拉选中币种
    getCurrent(currencyId) {
      this.allCurrencyList.forEach(x => {
        if (x.ID == currencyId) {
          this.CurrentNmae = x.Name;
        }
      });
    },
      //获取所有币种
      getAllCurrency() {
        this.apipost(
          "financeinfo_post_GetList",
          {},
          res => {
            if (res.data.resultCode == 1) {
              this.allCurrencyList = res.data.data;
            }
          },
          err => { }
        );
      },
      //获取公司
      getCompany() {
        this.apipost('admin_get_BranchGetList', this.getCompanyMsg, res => {
          if (res.data.resultCode == 1) {
            this.companyList = res.data.data;
          } else {}
        }, err => {})
      },
      handleCurrentChange(val) {
        //翻页功能按钮
        this.msg.pageIndex = val;
        this.getList();
      },
      getList() {
        this.loading = true;
        this.apipost(
          "sellcommission_GetTWCommissionRuleList",
          this.msg,
          res => {
            this.loading = false;
            if (res.data.resultCode == 1) {
              this.DataList = res.data.data.pageData;
              this.total = res.data.data.count;
            }
          },
          err => {}
        );
      },
      selectdis(val, index) { //团队类型下拉了不能再次选择
        this.TeamListArr.forEach((x, y) => {
          let ishow = false;
          this.addMsg.DetailList.map((j, ji) => {
            if (ishow == false) {
              if (x.Id == j.Id) {
                x.disabled = true;
                ishow = true;
                return;
              } else {
                x.disabled = false;
              }
            }
          });
        });
      },
      gettdName(id, index) { //获取团队类型名称
        this.TeamListArr.map(x => {
          if (x.Id == id) {
            this.addMsg.DetailList[index].Name = x.Name;
            return false
          }
        })
      },
      //获取线路列表
      getLineList() {
        this.apipost(
          "line_post_GetAllList", {},
          res => {
            if (res.data.resultCode == 1) {
              this.LineList = res.data.data;
            }
          }
        );
      },
      getTeamList() { //获取团队类型的列表
        this.apipost("travel_get_GetTravelPriceTeamTypeList", {}, res => {
            if (res.data.resultCode == 1) {
              // this.TeamListArr = res.data.data;
              // this.TeamListArr.forEach(x => {
              //   x.disabled = false
              // })
            } else {
              this.Error(res.data.message);
            }
          },
          err => {}
        );
      },
      getEdit(row) { //修改规则
        let data = JSON.parse(JSON.stringify(row))
        this.addMsg = Object.assign({}, addobj)
        this.addMsg.Id = data.Id;
        this.addMsg.RuleName = data.RuleName;
        this.addMsg.LineIds =  data.LineIds
        this.addMsg.LineshortIds = data.LineIds.split(',').map(Number);
        this.addMsg.DetailList = data.DetailList;
        this.addMsg.RuleType = data.RuleType.toString();
        this.addMsg.BranchId = data.BranchId
        this.addMsg.AuditEmpId = data.AuditEmpId
        this.addMsg.CurrencyId = data.CurrencyId
        this.CurrentNmae = data.CurrencyName
        this.remoteMethod(data.AuditEmpName)
        this.searchList=[]
        this.addMsg.DetailList.forEach(x => {
          x.CommissionType = x.CommissionType.toString()
          // x.SourceType = x.SourceType.toString()
          // if(this.addMsg.RuleType==3){
          //   this.searchList.push({empId:x.Id,name:x.Name,postName:''})
          // }
        })
        if(this.addMsg.RuleType!=3){
          this.isshowfeizhu()//检测是否有飞猪 如果有就不能选择第二个
        }
        this.selectdis()
        this.ruleVisible = true;


      },
      DeleteRules(ID) { //删除规则
        this.$confirm(this.$t('tips.shifoushanchu'), this.$t('tips.tips'), {
            confirmButtonText: this.$t('pub.sureBtn'),
            cancelButtonText: this.$t('pub.cancelBtn'),
            type: "warning"
          })
          .then(() => {
            this.apipost('sellcommission_DelTWCommissionRule', {
              RuleId: ID
            }, res => {
              if (res.data.resultCode == 1) {
                this.Success(res.data.message)
                this.getList()
              } else {
                this.Error(res.data.message)
              }
            })
          })
          .catch(() => {});
      },
      addNew() { //新增
        this.addMsg = {
          Id: 0,
          RuleName: '',
          LineIds: '',
          LineshortIds: [],
          RuleType:'1',
          CurrencyId:'',
          AuditEmpId: '',
          DetailList: [{
            TravelType: '',
            // Name: '',
            CommissionType: '1',
            Money: '0',
            // ProfitRate: '0',
            // SourceType:'1',
            // STdisabled:false,
            // STdisabledXHS:false,
          }]
        }
        this.selectdis()
        this.ruleVisible = true;
      },
      addDetailList() { //新增类型
        let isdisabled = false
        let isdisabledXHS = false
        for(let i = 0;i<this.addMsg.DetailList.length;i++){
          let x = this.addMsg.DetailList[i]
          // if(this.addMsg.RuleType!=3){
          //   if(x.SourceType==2||x.SourceType==3){
          //     if(x.SourceType==2) isdisabled=true
          //     if(x.SourceType==3) isdisabledXHS=true
          //     break
          //   }
          // }
        }
        let obj = {
          TravelType: '',
          CommissionType: '1',
          Money: '0',
        }
        this.addMsg.DetailList.push(obj)
      },
      RulesOk(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            let LineshortIds = JSON.parse(JSON.stringify(this.addMsg.LineshortIds))
            this.addMsg.LineIds = LineshortIds.join(',')
            this.apipost(
              'sellcommission_SetTWCommissionRule', this.addMsg,
              res => {
                if (res.data.resultCode == 1) {
                  this.getList();
                  this.ruleVisible = false;
                  this.Success(res.data.message)

                } else {
                  this.Error(res.data.message)
                }
              },
              err => {}
            )
          }
        });
      },
      isshowfeizhu(){
        let isfeizhu = false
        let isxiaohongshu = false
        for(let i = 0;i<this.addMsg.DetailList.length;i++){
          let x = this.addMsg.DetailList[i]
          if(x.SourceType==2){
            isfeizhu=true
          }
          if(x.SourceType==3){
            isxiaohongshu=true
          }
        }
        this.addMsg.DetailList.forEach(x=>{
          if(isfeizhu==true){
            if(x.SourceType==2){
              x.STdisabled = false;
              if(this.addMsg.RuleType!=3){
                x.Id=0;
                x.Name='飞猪'
              }

            }else{
              x.STdisabled = true
            }
          }else{
            x.STdisabled = false
          }
          if(isxiaohongshu==true){
            if(x.SourceType==3){
              x.STdisabledXHS = false;
              if(this.addMsg.RuleType!=3){
                x.Id=0;
                x.Name='小红书'
              }

            }else{
              x.STdisabledXHS = true
            }
          }else{
            x.STdisabledXHS = false
          }
        })
      },
      getSType(index){//选了飞猪之后 后面的不能选飞猪了
        if(this.addMsg.DetailList[index].SourceType==1 &&  this.addMsg.RuleType!=3){
          this.addMsg.DetailList[index].Id=''
          this.addMsg.DetailList[index].Name=''
        }
        if(this.addMsg.RuleType!=3){
          this.isshowfeizhu()//检测是否有飞猪 如果有就不能选择第二个
        }

        this.selectdis()
        this.$forceUpdate();
      },
      remoteMethod(query) {  //  转交人模糊查询
            if (query !== '') {
                this.apipost("admin_Get_Chat_All_SelectEmpName",{ EmName:query },res => {
                    if (res.data.resultCode == 1) {
                        this.searchList = res.data.data;
                    }
                },err => {});
            } else {
                this.searchList = [];
            }
        },
        getpersonnel(y){
          return
          for(let i = 0;i<this.searchList.length;i++){
            let x = this.searchList[i]
            if(x.empId  == this.addMsg.DetailList[y].Id){
              this.addMsg.DetailList[y].Name = x.name;
              break
            }
          }
        }

    },
    mounted() {

    }
  };

</script>
<style>
  /* .rule-box .el-select__tags{
    top: 100%;
  } */
  .domesticCommissionRule .query-box input {
    height: 34px !important;
  }

</style>
