//车辆管理
<template>
  <div class="container">
    
    <div class="center">
    <el-row style="padding-left:15px;">
      <el-col :span="12">
        <el-button class="bg-bottom" type="primary" size="small" @click="handleadd()">添加
        </el-button>
      </el-col>
      <el-col :span="12" class="bg-right"></el-col>
    </el-row>
      <div class="fromdata">
        <el-table :data="carData">
          <el-table-column type="index" label="序号">
            <template scope="scope">
              <span v-if="scope.$index < 9">0{{ scope.$index + 1 }}</span>
              <span v-else>{{ scope.$index + 1 }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="carNo" label="车牌号">
          </el-table-column>
          <el-table-column prop="address" label="操作">
            <template slot-scope="scope">
              <el-button @click="handledel(scope.row)" type="primary">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
        style="text-align:center" :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="deptBudgetTotal">
      </el-pagination>
    </div>
    <el-dialog
      title="添加车牌号"
      :visible.sync="show"
      width="30%"
      :before-close="handleClose">
      <el-input v-model="carNo" maxlength="7" placeholder="请输入车牌号"></el-input>
      <span slot="footer" class="dialog-footer">
        <el-button @click="show = false">取消</el-button>
        <el-button type="primary" @click="addcarNo">添加</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
  import WsUpload from '@/components/WsUpload'
  import {
    addcarInfo,
    getcarInfo,
    delcarInfo
  } from '@/model/personnelManagement/index'
  import {
    woekflowhandle
  } from '@/model/tasksport/index'
  export default {
    components: {
      WsUpload,
    },
    data() {
      return {
        value: '',
        carData: [],
        carNo:'',
        deptBudgetTotal: 0,
        currentPage: 1,
        pageSize: 10,
        show:false,
        recordList:[],
        compId:localStorage.getItem('ws-pf_compId'),
      }
    },
    activated() {
      this.getList()
    },
    methods: {
      handleadd(){
        this.show=true
      },
      handleClose(){
        this.show=false
      },
      handledel(row){
        delcarInfo({id:row.id,compId:localStorage.getItem('ws-pf_compId'),}).toPromise()
            .then((response) => {
              this.$message({
                message: '删除成功!',
                type: 'success',
              })
              this.getList()
            })
      },
      addcarNo(){
        addcarInfo({carNo:this.carNo,compId:localStorage.getItem('ws-pf_compId'),}).toPromise()
            .then((response) => {
              this.$message({
                message: '添加成功!',
                type: 'success',
              })
              this.show=false
              this.getList()
            })
      },
      typeChange(num) {
        if (num == 1) {
          this.searchType = 1
        } 
        else if (num == 2) {
          this.searchType = 2
        }else if(num == 3){
          this.searchType = 3
        }else{
          this.searchType = 4
        }
        this.currentPage = 1
        this.getList()
      },
      getList() {
        getcarInfo({
            currentPage: this.currentPage,
            pageSize: this.pageSize,
            compId: localStorage.getItem('ws-pf_compId'),
          })
          .toPromise()
          .then(response => {
            this.carData = response.records
           this.deptBudgetTotal = response.total
          })
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`)
        this.pageSize = val
        this.getList()
      },
      handleCurrentChange(val) {
        this.currentPage = val
        console.log(`当前页: ${val}`)
        this.getList()
      },
    },
  }
</script>
<style lang="scss" scoped>
  .container {
    background: #E8ECF6;
  }

  .center {
    margin: 0 auto;
    background: #ffffff;
    // height: calc(100vh - 13vh);
    border-radius: 4px;
    padding: 20px 0;

    /deep/.el-table td,
    /deep/.el-table th {
      text-align: center;
    }
  }

  .row_top {
    background: #F6F7FC;
    border-radius: 4px;
    margin-bottom: 10px;

    .bg-left {
      padding-left: 30px;
    }

    .bg-right {
      padding-right: 10px;
      text-align: right;
    }

    .title {
      position: relative;
    }

    .title::before {
      content: '';
      display: inline-block;
      width: 5px;
      height: 30px;
      background: #5473e8;
      position: absolute;
      left: 0;
    }
  }

  .datascreen {
    display: flex;

    .data_css {
      width: 40%;
    }

    .input_css {
      width: 50%;
      margin: 0 10px;
    }

    .find {
      margin-right: 10px;
    }
  }

  .fromdata {
    margin: 20px 15px;
    overflow-y: scroll;
    height: 546px;
  }
  .top_info{
    margin: 10px 0 0 10px;
    min-width: 712px;
    .info_css{
      margin-right: 20px;
    }
  }
  .bg-right{
    padding-top:15px;
  }
</style>
