<template>
  <div class="knowledge-3">
    <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" style="margin-right: 1500px">
        <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";

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() {
      let that = this;
      this.API.requestData({
        method: "GET",
        baseURL: "http://10.155.32.4:8034/",
        subUrl: "/experienceBase/aqcszs",
        data: {
          name: that.content,
          pageNum: 1,
          pageSize: 1000,
        }, // 请求所携带参数，默认为空，可缺省
        success(res) {
          if (res.code == 200) {
            that.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,
              };
              that.tableData.data.push(obj);
            }
          }
        },
      });
    },
  },
};
</script>

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