<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="NFIDReaderList"
      @selection-change="handleSelectionChange"
    >
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <!-- <el-table-column label="ID" align="center" prop="id" width="80" /> -->
      <el-table-column label="设备序列号" align="center" prop="deviceSerial" />
      <el-table-column label="设备名称" align="center" prop="deviceName" />
      <el-table-column label="设备点位" align="center" prop="deviceSpot">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.deviceSpot=='bind'">吊钩绑定</el-tag>
          <el-tag v-if="scope.row.deviceSpot=='weight'">白条称重</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="最近通信时间" align="center" prop="lastActiveTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastActiveTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.status=='0'">离线</el-tag>
          <el-tag v-if="scope.row.status=='1'">在线</el-tag>
          <el-tag type="danger" v-if="scope.row.status=='2'">异常</el-tag>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {
  listNFIDReader,
  listAllNFIDReader
} from "@/api/app/NFIDReader";
export default {
  name: "NFIDReader",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 设备表格数据
      NFIDReaderList: [],
      regionOptions: [],
      // 弹出层标题
      title: "",
      isView:false,
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,

      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {

      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询设备列表 */
    getList() {
      this.loading = true;
      listNFIDReader(this.queryParams).then((response) => {
        this.NFIDReaderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
