<template>
  <div class="knowledge-7">
    <div class="query mg-b-8">
      <div class="query-items">
        <div class="query-item">
          <div class="lable">故障级别：</div>
          <div class="search-input">
            <el-select
              v-model="level"
              placeholder="请选择"
              popper-class="select"
            >
              <el-option
                v-for="item in levels"
                :key="item"
                :label="item"
                :value="item"
              >
              </el-option>
            </el-select>
          </div>
        </div>
        <div class="query-item">
          <div class="lable">报警类型：</div>
          <div class="search-input">
            <el-select
              v-model="warning"
              placeholder="请选择"
              popper-class="select"
            >
              <el-option
                v-for="item in warnings"
                :key="item"
                :label="item"
                :value="item"
              >
              </el-option>
            </el-select>
          </div>
        </div>
        <div class="query-item">
          <div class="lable">查询内容：</div>
          <div class="search-input">
            <el-input v-model="content" placeholder="请输入查询内容"></el-input>
          </div>
        </div>
      </div>
      <div class="query-actions">
        <button class="btn green" @click="onClickSearch">搜索</button>
      </div>
    </div>
    <div>
      <ComTable :data="tableData" height="85vh"></ComTable>
    </div>
  </div>
</template>

<script>
import ComTable from "@com/coms/table/table.vue";
import api from "@api/maintenance/expertKnowledge/index.js";

export default {
  components: { ComTable },
  data() {
    const that = this
    return {
      level: "",
      levels: ["5级","4级","3级","2级","1级"],
      warning: "",
      warnings: ["1类","2类","3类","4类","5类"],
      content: '',
      tableData: {
        column: [
          {
            name: "编码",
            field: "id",
            is_num: true,
            is_light: false,
          },
          {
            name: "名称",
            field: "name",
            is_num: false,
            is_light: false,
          },
          {
            name: "表达式",
            field: "expression",
            is_num: false,
            is_light: false,
          },
          {
            name: "级别",
            field: "rank",
            is_num: false,
            is_light: false,
          },
          {
            name: "报警类型",
            field: "category",
            is_num: false,
            is_light: false,
          },
          {
            name: "描述",
            field: "description",
            is_num: false,
            is_light: false,
          },
          {
            name: "范围",
            field: "modelid",
            is_num: false,
            is_light: false,
          },
          // {
          //   name: "操作",
          //   field: "",
          //   is_num: false,
          //   is_light: false,
          //   template() {
          //     return "<el-button type='text' style='cursor: pointer;'>查看</el-button>";
          //   },
          //   click(e, row) {
          //     that.getInformation(row);
          //   },
          // },
        ],
        data: [],
      },
    };
  },
  created() {
    this.level = this.levels[0];
    this.warning = this.warnings[0];
    this.requestWarnList();
  },
  methods: {
    // 搜索按钮
    onClickSearch() {
      this.requestWarnList();
    },
    // 查看详情
    getInformation(item){

    },
    requestWarnList() {
      api
        .earlyKnowledge({
          gzjb: this.level.substring(0,1),
          bjlx: this.warning.substring(0,1),
          cxnr: this.content,
          pageNum: 1,
          pageSize: 1000,
        })
        .then((res) => {
          if (res.code == 200) {
            this.tableData.data = res.data;
          }
        });

      // let that = this;
      // this.API.requestData({
      //   method: "GET",
      //   baseURL: "http://10.155.32.4:8034/",
      //   subUrl: "/experienceBase/yjzs",
      //   data: {
      //     gzjb: that.level.substring(0,1),
      //     bjlx: that.warning.substring(0,1),
      //     cxnr: that.content,
      //     pageNum: 1,
      //     pageSize: 1000,
      //   }, // 请求所携带参数，默认为空，可缺省
      //   success(res) {
      //     if (res.code == 200) {
      //       that.tableData.data = res.data;
      //     }
      //   },
      // });
    },
  },
};
</script>

<style lang="less" scope>
@titleGray: #9ca5a8;
@rowGray: #606769;
@darkBack: #536268;
.knowledge-7 {
  .query-item {
    width: 250px;
  }
}
</style>
