<template>
  <div class="directorCarList">
    <div class="el-card__header">
      <span>{{$t('objFill.v101.cheliangli')}}</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>
      </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.qingsrclmicss')"
                      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>

          <span style="margin-left:15px">{{$t('pub.Brand')}}:</span>
          <el-select class="w120" @change="msg.pageIndex=1,getList()" v-model="msg.CarBrandId" size="small" :placeholder="$t('pub.pleaseSel')">
            <el-option :label="$t('pub.unlimitedSel')" :value='0'></el-option>
            <el-option v-for="item in CarBrandList" :key="item.ID" :label="item.Name" :value="item.ID"></el-option>
          </el-select>
          <span style="margin-left:15px">{{$t('ground.fenlei')}}:</span>
          <el-select class="w120" @change="msg.pageIndex=1,getList()" v-model="msg.CarClass" size="small"  :placeholder="$t('pub.pleaseSel')">
            <el-option :label="$t('pub.unlimitedSel')" :value='0'></el-option>
            <el-option v-for="item in CarClassList" :key="item.Id" :label="item.Name" :value="item.Id"></el-option>
          </el-select>


        </div>

      </div>
    </div>


    <div style="padding: 20px;background: #fff;">
      <el-table
        :data="tableData"
        header-cell-class-name="headClass"
        style="width: 100%"
        border
      >

        <el-table-column
          prop="ID"
          label="ID"
          width="100">
        </el-table-column>

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

        <el-table-column
          prop="CarType"
          :label="$t('objFill.v101.administrative.xinghao')"
        >
        </el-table-column>
        <el-table-column
          prop="CarClassStr"
          :label="$t('ground.fenlei')"
          width="120">
        </el-table-column>
        <el-table-column
          prop="ColorList"
          :label="$t('objFill.v101.chelianyse')">
          <template slot-scope="scope">
            <el-button v-for="(x, index2) in scope.row.ColorList" :key="index2" size="mini" @click="showImg(x)">{{x.ColorName}}</el-button>
          </template>
        </el-table-column>
        <el-table-column
          prop="GoodsNum"
          width="100"
          :label="$t('objFill.v101.shangpinshu')">
        </el-table-column>
        <el-table-column
          prop="OrderNum"
          width="100"
          :label="$t('objFill.v101.FinancialModule.dindanshu')">
        </el-table-column>
        <el-table-column
          prop="GuestNum"
          width="100"
          :label="$t('objFill.v101.kechengrshu')">
        </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>
    <el-dialog :title="itemdata.ColorName+$t('MarketingActi.car')" :visible.sync="changeState" width="1240px">
        <div style="display: flex;flex-direction: row;flex-wrap: wrap;">
          <img v-for="(x, index) in itemdata.CarPic" :key="index" style="width:200px;height:200px;margin: 10px" :src="x" alt="">
        </div>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "directorCarList",
    data(){
      return{
        msg:{
          pageIndex:1,
          pageSize:20,
          Name:'',
          CarBrandId:0,
          CarClass:0,

        },
        changeState:false,
        dateList:[],
        CarClassList:[],
        CarBrandList:[],

        tableData:[],
        count:0,
        loading:false,
        itemdata:{},
        EnableMsg:{
          Ids:'',
          IsEnable:0,
        },
      }
    },
    created(){
      this.getDateList();
      this.getCarClassList()//获取车辆的分类
      this.getGuideCarBrandList()//获取车辆品牌
    },
    methods:{
      getDateList(){
        this.loading=true;
        this.lxymallapipost("/api/GuideCar/GetGuideCarPageList", 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);
          }

        })
      },
      getCarClassList(){
        this.lxymallapipost("/api/GuideCar/GetCarClassList", {}, res => {
          if(res.data.resultCode==1){
            this.CarClassList = res.data.data;
          }else {
            this.Info(res.data.message);
          }

        })
      },
      getGuideCarBrandList(){
        this.lxymallapipost("/api/GuideCar/GetGuideCarBrandList", {}, res => {
          if(res.data.resultCode==1){
            this.CarBrandList = res.data.data;
          }else {
            this.Info(res.data.message);
          }

        })
      },

      addRecharge(){
        this.$router.push('/addCar');

      },
      showImg(item){//显示图片
        this.changeState = true;

        this.itemdata = item
        this.itemdata.CarPic = JSON.parse(this.itemdata.CarPic)
      },
      Edit(row){
        this.$router.push({
          name: 'addCar',
          query: {
            ID:row.ID,
            blank: "y"
          }
        });
      },
      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);
              }
            },
          );
        });
      },




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

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

<style >
  @import './css/index.css';

  .directorCarList .el-card__header{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: #fff;

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