<template>
  <div class="app-container">
    <!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="100px">
      <el-form-item label="优惠券类别" >
        <el-input v-model="queryParams.name" clearable @keyup.enter.native="handleQuery"></el-input>        
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="queryParams.state" placeholder="请选择状态" clearable @keyup.enter.native="handleQuery">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['coupon:category:query']">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>    -->

    <el-table v-loading="loading" :data="machineList">     
      <el-table-column label="机器编码" align="center">       
        <template slot-scope="scope">
          <a @click="handleLogDialog(scope.row)" style="color: blue">{{ scope.row.code }}</a>
        </template>     
      </el-table-column>
      <el-table-column label="机器型号" align="center" prop="model" />
      <el-table-column label="状态" align="center" prop="state" />
      <el-table-column label="绑定时间" align="center" prop="desc" />
      <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" />
      <el-table-column label="其他设置" align="center">
        <template slot-scope="scope">
          <a @click="handleOtherDialog(scope.row)" style="color: blue">查看</a>
        </template> 
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <!-- 机器日志对话框 -->
   <MachineDetailsLog ref="machineDetailsLog" ></MachineDetailsLog>
    <!-- 组件对话框 -->
   <MachineDetailsCom ref="machineDetailsCom" ></MachineDetailsCom>
    <!-- 其他组件对话框 -->
   <MachineDetailsOther ref="machineDetailsOther" ></MachineDetailsOther>
  </div>
</template>

<script>
import {getMachineList
} from "@/api/machine/machineDetails";
import MachineDetailsLog from './machineDetailsLog.vue';
import MachineDetailsCom from './machineDetailsCom.vue';
import MachineDetailsOther from './machineDetailsOther.vue';
export default {
  components: { MachineDetailsLog,MachineDetailsCom,MachineDetailsOther},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      machineList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,       
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      getMachineList(this.queryParams).then((response) => {
        if(response.code==0){
          this.machineList = response.data;
          this.total = response.data.length;
          this.loading = false;
        }       
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.name=null;
      this.queryParams.state=null;
      this.handleQuery();
    }, 
    //日志
    handleLogDialog(row){
      this.$refs.machineDetailsLog.handleLogDialog(row.id);
    },
    //组件
    handleComponentDialog(row){
      this.$refs.machineDetailsCom.handleComDiaLog(row);
    },
    //其他设置
    handleOtherDialog(row){
      this.$refs.machineDetailsOther.handleOthDiaLog(row);
    }
  }
};
</script>

