<template>
  <section class="app-container">
    <el-row>
      <el-col :span="24">
        <el-form size="mini" :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
          <el-form-item label="故障名称">
            <el-input v-model="queryParams.faultName" placeholder="请输入故障名称" clearable style="width: 200px"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item>
            <el-button type="cyan" icon="el-icon-search" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <el-row class="mb8">
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center">
          </el-table-column>
          <el-table-column prop="signalCode" align="center" label="信号量">
          </el-table-column>
          <el-table-column prop="parentSignalCode" align="center" label="上级信号量">
          </el-table-column>
          <el-table-column prop="faultCode" align="center" label="故障编码">
          </el-table-column>
          <el-table-column prop="faultName" align="center" label="故障名称">
          </el-table-column>
          <el-table-column align="center" label="故障等级">
            <template slot-scope="scope">
              <section>{{scope.row.faultLevel | toChinaNum }}级</section>
            </template>
          </el-table-column>
          <el-table-column align="center" label="是否生成工单">
            <template slot-scope="scope">
              <section>{{scope.row.workIs | isToChina }}</section>
            </template>
          </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
          @pagination="getList" />
      </el-col>
    </el-row>
  </section>
</template>

<script>
import { list } from "@/api/fault/encrypt";
export default {
  name: "Encrypt",
  data () {
    return {
      // 表格数据
      tableData: [],
      // 总条数
      total: 0,
      // 显示搜索条件
      showSearch: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      },
    }
  },
  created () {
    this.getList()
  },
  methods: {
    // 获取故障编码列表
    getList () {
      list(this.queryParams).then((res) => {
        // debugger
        this.tableData = res.rows;
        this.total = res.total;
      });
    },

    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery () {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10
      };
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleSelectionChange () { }
  }
}
</script>

<style>
</style>