<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="modelList">     
      <el-table-column label="机器型号" align="center" prop="model_name"/>
      <el-table-column label="创建时间" align="center" prop="created_at" />
      <el-table-column label="组件管理" align="center">
        <template slot-scope="scope">
          <a @click="handleComponentDialog(scope.row)" style="color: blue">管理组件</a>
        </template> 
      </el-table-column>
      <el-table-column label="机器数量" align="center" prop="machine_count"/> 
      <el-table-column label="备注说明" align="center" prop="desc"/>       
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.limit"
      @pagination="getList" />    
    <!-- 组件对话框 -->
   <ModelCom ref="modelCom" ></ModelCom>
  </div>
</template>

<script>
import {getModelList} from "@/api/model/model";
import ModelCom from './modelCom.vue';
export default {
  components: {ModelCom },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      modelList: [],
      // 查询参数
      queryParams: {
        page: 1,
        limit: 10,       
      },
      modelList:[]
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      getModelList(this.queryParams).then((response) => {
        if(response.code==0){
          this.modelList = response.data;
          this.total = response.data.length;
          this.loading = false;
        }       
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.getList();
    }, 
    //组件
    handleComponentDialog(row){
      this.$refs.modelCom.handleModelComDialog(row.id);
    },


  }
};
</script>

