<template>
  <div class="knowledge-2">
    <div class="query mg-b-8">
      <div class="query-items">
        <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() {
    return {
      content: "",
      tableData: {
        column: [
          {
            name: "序号",
            field: "id",
            is_num: true,
            is_light: false,
          },
          {
            name: "按错内容",
            field: "safecontent",
            is_num: false,
            is_light: false,
          },
          {
            name: "故障按错内容描述",
            field: "describe",
            is_num: false,
            is_light: false,
          },
          {
            name: "负责人",
            field: "principal",
            is_num: false,
            is_light: false,
          },
          {
            name: "添加时间",
            field: "addtime",
            is_num: false,
            is_light: false,
          },
          {
            name: "类型",
            field: "type",
            is_num: false,
            is_light: false,
          },
          {
            name: "其他",
            field: "other",
            is_num: false,
            is_light: false,
          },
        ],
        data: [],
      },
    };
  },
  created() {
    this.requestSafeList();
  },
  methods: {
    // 搜索按钮
    onClickSearch() {
      this.requestSafeList();
    },
    // 获取按错内容
    requestSafeList() {
      api.safeMeasureKnowledge({
        name: this.content,
        pageNum: 1,
        pageSize: 1000,
      }).then(res =>{
        if (res.code == 200) {
            this.tableData.data = [];
            let data = res.data;
            for (var i = 0; i < data.length; i++) {
              let obj = {
                id: i + 1,
                safecontent: data[i].safecontent,
                describe: data[i].describe,
                principal: data[i].principal,
                addtime: new Date(data[i].addtime).formatDate("yyyy-MM-dd"),
                type: data[i].type,
                other: data[i].other,
              };
              this.tableData.data.push(obj);
            }
          }
      })
    },
  },
};
</script>

<style lang="less" scope>
@titleGray: #9ca5a8;
@rowGray: #606769;
@darkBack: #536268;
.knowledge-2 {
  .el-select {
    width: 200px;
  }
  .el-input {
    width: 200px;
  }
}
</style>
