<style>
  .airTicketRules .query_box {
    font-size: 12px;
    padding: 29px 0;
    padding-right: 30px;
    display: flex;
    justify-content: space-between;
  }

  .airTicketRules .el-switch.is-checked .el-switch__core {
    border-color: #4bca81;
    background-color: #4bca81;
  }

  .airTicketRules .addCompany {
    width: 440px;
    max-height: 600px;
  }

  .airTicketRules .addCompany .el-dialog__body {
    height: 486px;
    overflow: auto;
  }

  .airTicketRules .query_box div label {
    display: inline-block;
    min-width: 80px;
    text-align: right;
    font-style: normal;
    margin: 0 20px 0 0;
  }

  input::-webkit-outer-spin-button,
  input::-webkit-inner-spin-button {
    -webkit-appearance: none;
  }

  input[type="number"] {
    -moz-appearance: textfield;
  }

  .airTicketRules .lineType {
    width: 51px;
    height: 24px;
    display: inline-block;
    text-align: center;
    line-height: 24px;
    border-radius: 4px;
    background-color: #ff9c00;
    color: #ffffff;
  }

  .airTicketRules .LMTable tr {
    height: 70px;
    text-align: center !important;
    background-color: #fff;
  }

  .comPanyNum {
    font-size: 14px;
    color: #333333;
    display: inline-block;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 5px;
    text-decoration: underline;
  }

  .comPanyNum:hover {
    color: #e95252;
  }

  .Linezhicai {
    color: #47bf8c;
  }

  .partCompany {
    padding: 0;
    box-shadow: 0px 1px 3px 0px #dedede;
  }

  .partCompany .popper__arrow::after {
    border-bottom-color: #ededed !important;
  }

  .partCompany table {
    padding: 10px 0 0 20px;
    background-color: #ededed;
    border-collapse: collapse;
    border: 1px solid #d2d2d2;
    font-size: 12px;
  }

  .partCompany table th {
    background-color: #ededed;
    padding: 5px;
  }

  .partCompany table td {
    background-color: #ffffff;
    padding: 9px 15px;
    color: #333333;
    border: 1px solid #d2d2d2;
  }

  .partCompany table td._d_name {
    background-color: #ededed;
  }

  .partCompany table ._color_666 {
    color: #666666;
  }

  .partCompany table tr._color_666 th {
    padding: 9px 15px;
  }

  .airTicketRules .LineName {
    display: inline-block;
    width: 120px;
    margin: 0 0 0 20px;
    text-align: left;
  }

  .airTicketRules .LM_Back {
    background-color: #f2f2f2;
  }

  .redType {
    color: #e95252;
  }

  .airTicketRules .tbDiv {
    overflow-y: auto;
  }

  .departListDiv {
    width: 100%;
    height: 200px;
    overflow-y: auto;
  }

  .airTicketRules .tbDiv::-webkit-scrollbar {
    width: 4px;
    height: 8px;
  }

  .airTicketRules .tbDiv::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    background: #ededed;
  }

  .airTicketRules .tbDiv::-webkit-scrollbar-thumb {
    border-radius: 4px;
    -webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
    background: #c9c9c9;
  }

  .departListDiv::-webkit-scrollbar {
    width: 4px;
    height: 8px;
  }

  .departListDiv::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    background: #ededed;
  }

  .departListDiv::-webkit-scrollbar-thumb {
    border-radius: 4px;
    -webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
    background: #c9c9c9;
  }

  .LMTable {
    width: 100%;
    font-size: 12px;
  }

  .airTicketRules .LMTable tr th {
    border-bottom: 1px solid #d1d1d1;
  }

  .airTicketRules .tbDiv .LMTable td {
    border-bottom: 1px solid #d1d1d1;
    border-right: 1px solid #d1d1d1;
    position: relative;
    text-align: center;
    padding: 5px;
    min-width: 250px;
  }

  .airTicketRules .tbDiv table {
    padding-right: 80px;
    margin-top: 10px;
    border-top: 1px solid #d1d1d1;
    border-left: 1px solid #d1d1d1;
    border-right: 1px solid #d1d1d1;
  }

  .upFentan {
    text-decoration: underline;
    cursor: pointer;
    position: absolute;
    right: 13px;
    top: 32%;
  }

  .subCountryList {
    width: 150px;
    text-align: left;
    display: inline-block;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    top: 3px;
  }

  .airTicketRules ._addLineTB tr {
    height: 40px !important;
  }

  .saveCompanyBtn {
    margin-top: 20px;
  }

  .setItem {
    cursor: pointer;
    text-decoration: underline;
    position: absolute;
    right: 13px;
    top: 32%;
  }

  .airTicketRules ._LMComdiv {
    float: left;
    width: 32%;
    text-align: left;
  }

  .airTicketRules .LineRank {
    width: 24px;
    height: 24px;
    background-color: #2aaef2;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    color: #fff;
    margin: 0 auto 5px;
  }

  .airTicketRules .joinDepart {
    display: inline-block;
    margin-right: 50px;
    text-align: left;
    float: left;
    width: 180px;
  }

  .airTicketRules .LM_Rank {
    text-align: center;
  }

  .airTicketRules ._LowDisMoney {
    width: 200px;
    float: left;
    text-align: left;
    margin: 0 0 0 20px;
  }

  .airTicketRules .LM_Btcontent {
    position: absolute;
    right: 100px;
    top: 10px;
    text-align: right;
    margin-left: 20px;
  }

  .airTicketRules .LM_ul li {
    /*height: 78px;*/
    margin: 20px 0 0px 0px;
    transition: linear all 0.5s;
    background-color: #fff;
    font-size: 12px;
    border: 1px solid #dddddd;
    overflow: hidden;
    position: relative;
    padding: 10px 0;
  }

  .airTicketRules .el-button-group .el-button {
    padding: 5px;
  }

  .airTicketRules .LM_ul>li:hover {
    box-shadow: 0px 0px 20px rgba(191, 191, 191, 1);
    transition: all linear 0.5s;
  }

  .airTicketRules .TFimgList {
    float: left;
    width: 170px;
    height: 100px;
    border-radius: 4px;
    position: relative;
    margin: 0 10px 10px 0;
    overflow: hidden;
  }

  .airTicketRules .TFimgList img {
    width: 100%;
    height: 100%;
  }

  .airTicketRules .TFIMGzhe {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    position: absolute;
    top: 0;
    text-align: center;
    line-height: 115px;
    border-radius: 4px;
    display: none;
  }

  .airTicketRules .TFimgList:hover .TFIMGzhe {
    display: block;
  }

</style>
<template>
  <div class="flexOne airTicketRules">
    <div class="query-box">
      <ul>
        <li>
          <span>
            <em>{{$t('objFill.nianfen')}}</em>
            <el-select v-model="msg.YearStr" size="mini" class="_month_input">
              <el-option :key="DefaultValue" :label="$t('pub.pleaseSel')" :value="DefaultValue"></el-option>
              <el-option v-for="item in YearList" :key="item" :label="item" :value="item"></el-option>
            </el-select>
          </span>
        </li>
        <li>
          <span>
            <em>{{$t('ground.yuefen')}}</em>
            <el-select v-model="msg.MonthStr" size="mini" class="_month_input">
              <el-option :key="DefaultValue" :label="$t('pub.pleaseSel')" :value="DefaultValue"></el-option>
              <el-option v-for="item in MonthList" :key="item" :label="item" :value="item"></el-option>
            </el-select>
          </span>
        </li>
        <li>
          <input type="button" class="hollowFixedBtn" :value="$t('pub.searchBtn')"
            @click="resetPageIndex(),getList()" />
          <input type="button" class="normalBtn" :value="$t('pub.addBtn')"
            @click="isShowDIv=true,ClearInfo(),divTitle=$t('objFill.v101.xinzengticgz')" />
        </li>
      </ul>
    </div>
    <div class="commonContent">
      <table v-loading="loading" class="singeRowTable" border="0" cellspacing="0" cellpadding="0">
        <thead>
          <tr>
            <th>
              {{$t('hotel.hotel_SerialNumber')}}
            </th>
            <th>
              {{$t('salesModule.Time')}}
            </th>
            <th>
              {{$t('fnc.danjia')}}
            </th>
            <th>
              {{$t('active.cl_addPp')}}
            </th>
            <th>
              {{$t('fnc.cjshijian')}}
            </th>
            <th>
              {{$t('objFill.v101.administrative.xiugairen')}}
            </th>
            <th>
               {{$t('sm.xiugaishijian')}}
            </th>
            <th>
              {{$t('system.table_operation')}}
            </th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(item,index) in DataList">
            <td>
              {{item.ID}}
            </td>
            <td>
              {{item.YearStr}}-{{item.MonthStr}}
            </td>
            <td>
              {{item.UnitPrice}}
            </td>
            <td>
              {{item.CreateByName}}
            </td>
            <td>
              {{item.CreateTimeStr}}
            </td>
            <td>
              {{item.UpdateByName}}
            </td>
            <td>
              {{item.UpdateTimeStr}}
            </td>
            <td>
              <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'),GetAirticketRules(item.ID)"></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="DeleteAirticketRules(item.ID)"></el-button>
                </el-tooltip>
              </el-button-group>
            </td>
          </tr>
        </tbody>
        <tfoot>
          <tr>
            <td colspan="8">
              <el-pagination background @current-change="handleCurrentChange" :current-page.sync="msg.currentPage"
                layout="total,prev, pager, next, jumper" :page-size="msg.pageSize" :total="msg.total">
              </el-pagination>
            </td>
          </tr>
        </tfoot>
      </table>
    </div>
    <div class="combottomDiv" v-if="isShowDIv">
      <div class="combottomTitle">{{divTitle}}</div>
      <div class="">
        <el-form :model="addMsg" ref="addMsg" @submit.native.prevent label-width="130px">
          <template v-if="addMsg.ID==0">
            <el-col :span="5">
              <el-form-item :label="$t('objFill.v101.busManagement.kaishiyuef')">
                <el-date-picker v-model="addMsg.MonthRangeStart" type="month" value-format="yyyy-MM">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item :label="$t('objFill.v101.busManagement.jiehsuyf')">
                <el-date-picker v-model="addMsg.MonthRangeEnd" type="month" value-format="yyyy-MM">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </template>
          <template v-else>
            <el-col :span="5">
              <el-form-item :label="$t('pub.year')">
                <el-select v-model="addMsg.YearStr" size="mini" class="_month_input">
                  <el-option :key="DefaultValue" :label="$t('pub.pleaseSel')" :value="DefaultValue"></el-option>
                  <el-option v-for="item in YearList" :key="item" :label="item" :value="item"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item :label="$t('pub.month')">
                <el-select v-model="addMsg.MonthStr" size="mini" class="_month_input">
                  <el-option :key="DefaultValue" :label="$t('pub.pleaseSel')" :value="DefaultValue"></el-option>
                  <el-option v-for="item in MonthList" :key="item" :label="item" :value="item"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </template>

          <el-col :span="5">
            <el-form-item :label="$t('objFill.v101.LeaderManagement.danjiaren')">
              <el-input v-model="addMsg.UnitPrice" maxlength="5" @keyup.native="checkPrice(addMsg,'UnitPrice')">
              </el-input>
            </el-form-item>
          </el-col>
          <div class="LM_Btcontent">
            <input type="button" class="normalBtn" @click="SaveAirticketRules()" :value="$t('pub.saveBtn')" />
            <input type="button" class="hollowFixedBtn" @click="isShowDIv=false,ClearInfo()"
              :value="$t('pub.cancelBtn')" />
          </div>
        </el-form>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        msg: {
          pageIndex: 1,
          pageSize: 15,
          total: 0,
          currentPage: 1,
          MonthStr: 0, //月份
          YearStr: 0, //年份
        },
        addMsg: {
          ID: 0, //编号
          YearStr: 0, //年份
          MonthStr: 0, //月份
          UnitPrice: 0, //单价每人
          MonthRangeStart: "", //开始月份【2019-01到2019-12】
          MonthRangeEnd: "", //结束月份【2019-01到2019-12】
        },
        DefaultValue: 0, //默认值
        YearList: [],
        //月份
        MonthList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
        loading: false, //加载层
        isShowDIv: false, //是否显示新增、编辑的Div
        //数据列表
        DataList: [],
      };
    },
    methods: {
      getList() {
        this.loading = true;
        this.apipost(
          "AirTicketRules_get_GetPageList",
          this.msg,
          res => {
            this.loading = false;
            if (res.data.resultCode == 1) {
              this.DataList = res.data.data.pageData;
              this.msg.total = res.data.data.count;
            }
          },
          err => {}
        );
      },
      handleCurrentChange(val) {
        //翻页功能按钮
        this.msg.pageIndex = val;
        this.getList();
      },
      resetPageIndex() {
        //查询初始化页码
        this.msg.pageIndex = 1;
        this.msg.currentPage = 1;
      },
      //情况消息
      ClearInfo() {
        this.addMsg.ID = 0;
        this.addMsg.YearStr = 0;
        this.addMsg.MonthStr = 0;
        this.addMsg.UnitPrice = 0;
        this.addMsg.MonthRangeEnd="";
        this.addMsg.MonthRangeStart="";
      },
      //保存信息
      SaveAirticketRules() {
        if (this.addMsg.ID > 0) {
          if (this.addMsg.YearStr == 0) {
            this.Info(this.$t('objFill.v101.qiingxznfen'));
            return;
          }
          if (this.addMsg.MonthStr == 0) {
            this.Info(this.$t('objFill.v101.FinancialModule.qingxayf'));
            return;
          }
        } else {
          if (this.addMsg.MonthRangeStart == "") {
            this.Info(this.$t('objFill.v101.busManagement.qingxzksyf')+'!');
            return;
          }
          if (this.addMsg.MonthRangeEnd == "") {
            this.Info(this.$t('objFill.v101.busManagement.qingxzjsyf')+'!');
            return;
          }
        }
        if (this.addMsg.UnitPrice == 0) {
          this.Info(this.$t('objFill.v101.Rest.qingshurtcje')+'!');
          return;
        }
        this.apipost(
          "AirTicketRules_post_SetAirticketRule",
          this.addMsg,
          res => {
            if (res.data.resultCode == 1) {
              this.getList();
              this.ClearInfo();
              this.isShowDIv = false;
            }
          },
          err => {}
        );
      },
      //删除票务提成规则
      DeleteAirticketRules(Id) {
        var that = this;
        this.Confirm(that.$t('objFill.v101.shifcgzticschu'), function () {
          var msg = {
            ID: Id
          };
          that.apipost("AirTicketRules_post_RemoveAirticketRule", msg,
            res => {
              if (res.data.resultCode == 1) {
                that.Success(this.$t('tips.shanchuchenggong'));
                that.getList();
              } else {
                that.Error(res.data.data);
              }
            }, null);
        });
      },
      //根据编号获取票务提成规则
      GetAirticketRules(Id) {
        this.apipost(
          "AirTicketRules_get_GetAirticketRules", {
            ID: Id
          },
          res => {
            if (res.data.resultCode == 1) {
              this.addMsg.ID = res.data.data.ID;
              this.addMsg.YearStr = res.data.data.YearStr;
              this.addMsg.MonthStr = res.data.data.MonthStr;
              this.addMsg.UnitPrice = res.data.data.UnitPrice;
            }
          },
          err => {}
        );
      }
    },
    mounted() {
      this.getList();
    },
    created() {
      var CYear = new Date().getFullYear();
      let count = CYear - (CYear - 5);
      for (let i = 0; i <= count; i++) {
        this.YearList.push(CYear - i);
      }
    }
  };

</script>