<!--
 * @Author: your name
 * @Date: 2021-09-13 17:52:31
 * @LastEditTime: 2021-09-26 14:23:00
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \hyyfClient\src\views\BioSafety\CarAdmin.vue
-->
<template>
  <div class="car-admin">
    <head-btns 
      :btnNames="btnNames" 
      :btnSelected="btnSelected"
      @btnSelected="getBtnSelected">
    </head-btns>

    <!-- 筛选条件 -->
    <query-conditions :formItems="formItems" :propFormData="propFormData" @getQueryParams="handleQuery"></query-conditions>

    <!-- 表格 -->
    <new-table :title="title" :listData="listData" :tableItems="tableItems" :shows="tableShows">
      <template v-slot:right>
        <template v-if="btnSelected === 1">
          <div>
            <el-button size="mini">黑名单</el-button>
          </div>
        </template>
        <template v-else-if="btnSelected === 2">
          <div>
            <!-- <el-button size="mini">黑名单</el-button> -->
          </div>
        </template>
        <template v-else>
          <div>
            <el-button size="mini">黑名单</el-button>
          </div>
        </template>
      </template>
    </new-table>
  </div>
</template>

<script>
import HeadBtns from 'components/bioSafety/Btns'
import QueryConditions from 'components/bioSafety/QueryConditions'
import NewTable from 'components/newTable/NewTable'

import { formItems, propFormData } from './carAdmin/queryCondition.config'
import { titles, tableItems, tableShows } from './carAdmin/table.config'

export default {
  name: "CarAdmin",
  components: {
    HeadBtns,
    QueryConditions,
    NewTable
  },
  data() {
    return {
      btnNames: [ // 按钮情况
        { id: 1, name: '车辆档案' },
        { id: 2, name: '车辆洗消' },
        { id: 3, name: '车辆烘干' }
      ],
      btnSelected: 1, // 选中的按钮
      formItems: [], // 传给 QueryCondition 组件的 formItems
      propFormData: {}, // 传给 QueryCondition 组件的 propFormData
      title: '', // 传给 BioTable 组件的 title
      listData: [], // 传给 BioTable 组件的表格展示的值 listData
      tableItems: [], // 传给 BioTable 组件的表格的列表 tableItems
      tableShows: {}
    }
  },
  mounted() {
    this.formItems = formItems[this.btnSelected - 1]
    this.propFormData = propFormData[this.btnSelected - 1]
    this.title = titles[this.btnSelected - 1]
    this.tableItems = tableItems[this.btnSelected - 1]
    this.tableShows = tableShows
  },
  methods: {
    getBtnSelected(id) {
      this.btnSelected = id
      this.formItems = formItems[id - 1]
      this.propFormData = propFormData[id - 1]
      this.title = titles[id - 1]
      this.tableItems = tableItems[id - 1]
    },
    // 获取查询条件
    handleQuery(params) {
      console.log(params)
    }
  },
}
</script>

<style scoped>
.car-admin {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 20px;
}
</style>
