<template>
  <div class="directorGuideList">
    <div class="el-card__header">
      <span>{{$t('objFill.v101.daoyouguanl')}}</span>
      <div style="display: flex;flex-direction: row;align-items: center">
        <el-button type="primary" class="el-button--small" @click="addRecharge">{{$t('pub.addBtn')}}</el-button>
        <el-button type="primary" @click="SetProduct(0)" style="margin-left:10px;" class="el-button--small">{{$t('fnc.qiyong')}}</el-button>
        <el-button type="primary" @click="SetProduct(1)" style="margin-left:10px;" class="el-button--small">{{$t('pub.fressSel')}}</el-button>
      </div>
    </div>
    <div class="content">
      <div style="display: flex;flex-direction: row;align-items: center">
        <div class="block" >
          <div class="searchInput" style="width:200px">
            <el-input style="display:inline-block;width:170px;height:30px"
                      :placeholder="$t('objFill.v101.qingshurdymc')"
                      v-model="msg.Name"
                      size="small"
                      @clear="getList"
                      @keyup.enter.native="getList"
                      clearable>
            </el-input>
            <span @click="getList" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
          </div>
          <div class="searchInput" style="width:200px">
            <el-input style="display:inline-block;width:170px;height:30px"
                      :placeholder="$t('objFill.v101.qingsrdyouid')"
                      v-model="searchId"
                      size="small"
                      @clear="getList"
                      @keyup.enter.native="getList"
                      type="number"
                      :min="0"
                      clearable>
            </el-input>
            <span @click="getList" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
          </div>
          <span>{{$t('admin.admin_status')}}:</span>
          <el-select class="w120" @change="msg.pageIndex=1,getList()" v-model="msg.IsEnable" size="small"
                     :placeholder="$t('pub.pleaseSel')">
            <el-option v-for="item in IsEnableList" :key="item.id" :label="item.name" :value="item.id">
            </el-option>
          </el-select>
          <span style="margin-left: 15px">{{$t('objFill.v101.zhuceshij')}}:</span>
          <el-date-picker v-model="dateList" @change="msg.pageIndex=1,getList()" size="small" type="datetimerange" :range-separator="$t('OrderList.zhi')"
                          value-format="yyyy-MM-dd HH:mm:ss" :start-placeholder="$t('OrderList.star')" :end-placeholder="$t('OrderList.end')">
          </el-date-picker>
        </div>

      </div>
    </div>
    <div class="content" style="margin-top: 0px">
      <div style="display: flex;flex-direction: row;align-items: center">
        <div class="block" >
          <span style="margin-left: 10px">{{$t('objFill.v101.gongzuonx')}}:</span>
          <el-input style="display:inline-block;width:100px;height:30px" :min="0" :placeholder="$t('pub.pleaseImport')" v-model="msg.StartWorkYears" size="small" type="number"></el-input>
          <span style="margin: 0 10px ;">~</span>
          <el-input style="display:inline-block;width:100px;height:30px" :min="0" :placeholder="$t('pub.pleaseImport')" v-model="msg.EndWorkYears" size="small" type="number"></el-input>

          <span style="margin-left: 20px">{{$t('salesModule.ScoreNUM')}}:</span>
          <el-input style="display:inline-block;width:100px;height:30px" :placeholder="$t('pub.pleaseImport')" v-model="msg.StartScore" size="small" type="number"></el-input>
          <span style="margin: 0 10px ;">~</span>
          <el-input style="display:inline-block;width:100px;height:30px" :placeholder="$t('pub.pleaseImport')" v-model="msg.EndScore" size="small" type="number"></el-input>
          <el-button type="primary" @click="getList()" size="small" style="margin-left: 5px">{{$t('pub.searchBtn')}}</el-button>
        </div>
      </div>
    </div>



    <div style="padding: 20px;background: #fff;">
      <el-table
        :data="tableData"
        header-cell-class-name="headClass"
        style="width: 100%"
        border
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" style="text-align:center;"></el-table-column>

        <el-table-column
          prop="ID"
          :label="$t('hotel.hotel_SerialNumber')"
          width="100">
        </el-table-column>

        <el-table-column
          prop="Name"
          :label="$t('objFill.v101.busManagement.daoyouxinxi')">
            <template slot-scope="scope">
              <div class="app-image" :style="{backgroundImage:'url(' + scope.row.GuidePhoto + ')',backgroundSize:'cover'}"></div>
              <div flex="dir:left cross:center">
                {{scope.row.Name}}
              </div>
            </template>
        </el-table-column>


        <el-table-column
          prop="WorkYears"
          :label="$t('objFill.v101.gongzuonx')"
          width="120">
        </el-table-column>
        <el-table-column
          prop="Score"
          :label="$t('salesModule.ScoreNUM')"
          width="120">
        </el-table-column>
        <el-table-column
          prop="SiteName"
          :label="$t('objFill.v101.zandiamc')">
        </el-table-column>
        <el-table-column
          prop="OrderNum"
          width="100"
          :label="$t('objFill.v101.FinancialModule.dindanshu')">
        </el-table-column>
        <el-table-column
          prop="GoodsNum"
          width="100"
          :label="$t('objFill.v101.shangpinshu')">
        </el-table-column>
        <el-table-column
          prop="CreateDateStr"
          width="170"
          :label="$t('objFill.v101.zhuceshij')">
        </el-table-column>
        <el-table-column
          prop="IsEnable"
          width="100"
          :label="$t('admin.admin_status')">
          <template slot-scope="scope">
            <span v-if="scope.row.IsEnable==0">{{$t('pub.normalSel')}}</span>
            <span v-if="scope.row.IsEnable==1">{{$t('pub.fressSel')}}</span>
          </template>

        </el-table-column>

        <el-table-column
          prop="Telephone"
          :label="$t('scen.sc_tel')">
        </el-table-column>
        <el-table-column
          prop="EmergencyPhone"
          :label="$t('objFill.jingjilxdh')">
        </el-table-column>


        <el-table-column
          fixed="right"
          :label="$t('system.table_operation')"
          width="180"
        >
          <template slot-scope="scope">

            <el-tooltip class="item" effect="dark" :content="$t('pub.edit')" placement="top" >
              <img src="../../../assets/img/setup/edit.png" alt="" class="imgstyle" @click="Edit(scope.row)">
            </el-tooltip>
<!--            <el-tooltip class="item" effect="dark" :content="$t('system.table_delete')" placement="top" >-->
<!--              <img src="../../../assets/img/setup/del.png" alt="" class="imgstyle" @click="delete_b(scope.row)">-->
<!--            </el-tooltip>-->
          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align:right"
                     background
                     @current-change="handleCurrentChange"
                     :page-size="msg.pageSize"
                     layout="prev, pager, next"
                     :current-page.sync="msg.pageIndex"
                     :total="count">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  export default {
    name: "directorGuideList",
    data(){
      return{
        msg:{
          pageIndex:1,
          pageSize:20,
          Name:'',
          ID:'',
          StartWorkYears:'',
          EndWorkYears:'',
          IsEnable:-1,
          StartTime:'',
          EndTime:'',
          StartScore:'',
          EndScore:'',
        },
        dateList:[],
        IsEnableList:[
          {id:-1,name: this.$t('pub.unlimitedSel')},
          {id:0,name:this.$t('pub.normalSel')},
          {id:1,name:this.$t('pub.fressSel')},
        ],
        tableData:[],
        count:0,
        loading:false,
        EnableMsg:{
          Ids:'',
          IsEnable:0,
        },
        searchId:'', //输入框ID
      }
    },
    created(){
      this.getDateList();

    },
    methods:{
      getDateList(){
        this.loading=true;
        if(this.searchId==''){
          this.msg.ID=0
        }else{
          this.msg.ID = parseInt(this.searchId);
        }
        if (this.dateList && this.dateList.length > 0) {
          this.msg.StartTime = this.dateList[0];
          this.msg.EndTime = this.dateList[1];
        } else {
          this.msg.StartTime = '';
          this.msg.EndTime = '';
        }
        if(parseInt(this.msg.StartWorkYears) > parseInt(this.msg.EndWorkYears)){
          this.Error(this.$t('objFill.v101.gongznxyddg'))
          return false
        }
        if(parseInt(this.msg.StartScore) > parseInt(this.msg.EndScore)){
          this.Error(this.$t('objFill.v101.pinfyddgao'))
          return false
        }
        this.lxymallapipost("/api/GuideCar/GetGuidePageListRepository", this.msg, res => {
          this.loading=false;
          if(res.data.resultCode==1){
            this.tableData = res.data.data.pageData;
            this.count = res.data.data.count;
          }else {
            this.Info(res.data.message);
          }

        })
      },
      addRecharge(){
        this.$router.push('/addGuide');

      },

      Edit(row){
        this.$router.push({
          name: 'addGuide',
          query: {
            ID:row.ID
          }
        });
      },
      delete_b(row){
        let that=this;
        that.Confirm(that.$t('tips.shifoushanchu'), function () {
          that.lxymallapipost(
            "/api/GuideCar/DelGuideCarSiteInfo",
            {Id:row.ID},
            res => {
              if (res.data.resultCode == 1) {
                that.Success(res.data.message);
                that.getDateList();
              } else {
                that.Error(res.data.message);
              }
            },
          );
        });
      },

      enableGuideCar(){
        this.lxymallapipost("/api/GuideCar/EnableGuideCarGuideInfo", this.EnableMsg, res => {
          if(res.data.resultCode==1){
            this.Success(res.data.message)
            this.getList()
          }
        })
      },
      //点击启用和冻结导游
      SetProduct(type){
        this.EnableMsg.IsEnable = type;
        if(this.EnableMsg.Ids.length==0){
          this.Info(this.$t('objFill.v101.qingxzdaoy'));
          return
        }
        this.EnableMsg.Ids = this.EnableMsg.Ids.join(",");
        this.enableGuideCar()
      },
      //勾选导游
      handleSelectionChange(val){
        var selectRow = JSON.parse(JSON.stringify(val));
        let array= [];
        selectRow.forEach(x => {
          let obj = {}
          obj = x.ID;
          array.push(obj)
        });
        this.EnableMsg.Ids = array
      },

      getList(){
        this.msg.pageIndex = 1
        this.getDateList()
      },

      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getDateList();
      },
    },
  }
</script>

<style >
  @import './css/index.css';
  .directorGuideList .el-card__header{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: #fff;

  }
  .directorGuideList .el-button--small{
    padding: 9px 15px;
  }
  .directorGuideList .content .searchInput{
    border: 1px solid #DCDFE6;
    border-radius: 4px;
    /*margin-left: 10px;*/
  }
  .directorGuideList .content .searchInput .el-input__inner{
    border:none;outline:none;
    height: 30px;
    line-height: 30px;
  }
  .directorGuideList .content .searchInput{
    line-height: normal;
    display: inline-table;
    border-collapse: separate;
    border-spacing: 0;
    width:250px;
  }
  .directorGuideList .content{
    background: #fff;
    margin-top:10px;
    padding: 15px;
    box-sizing: border-box;
  }
  .directorGuideList .el-tag{
    margin-right: 5px;
  }
  .directorGuideList .app-image{
    background-position: center center;
    width: 50px;
    height: 50px;
    border-radius:0%;
    float: left;
    margin-right: 8px;
  }
  .directorGuideList span{
    font-size: 13px;
    font-weight: normal;
}
</style>