<template>
  <div class="view-table-content">
    <div class="view-dataSpecies-right" style="width: 100%">
      <div class="view-dataType-table">
        <LTable ref="table" :defaultFetch="false" :fetch="fetch" :columns="columns" :dataSource="tableData" :options="options" :pagination="tableRequset"></LTable>
      </div>
    </div>
  </div>
</template>

<script>
import { getFalseAlarmResult } from '@/api/als/falseAlarmResult'
import { debounce } from '@/utils/index'
export default {
  name: 'FalseAlarmResult',
  components: {},
  props: {
    falseAlarmId: String
  },
  data() {
    // 这里存放数据
    return {
      aircaftModelIdList: [],
      currentNodeKey: null,
      currentNode: null,
      columns: [
        { prop: 'id', label: '编号' },
        {
          prop: 'falseAlarmId',
          label: '虚警抑制Id'
        },
        {
          prop: 'sortieNo',
          label: '架次号'
        },
        {
          prop: 'aircraftId',
          label: '机号'
        },
        {
          prop: 'code',
          label: '警告代码'
        },
        {
          prop: 'name',
          label: '警告名称'
        },
        {
          prop: 'describe',
          label: '警告描述'
        },
        {
          prop: 'status',
          label: '状态'
        },
        {
          button: true,
          label: '操作',
          width: '240px',
          group: [
            {
              name: '编辑',
              type: 'text',
              round: false,
              plain: false,
              onClick: (row, index, scope) => {
                _this.handUpdate(row)
              }
            },
            {
              name: '删除',
              type: 'text',
              round: false,
              plain: false,
              onClick: (row, index, scope) => {
                _this.remove([row])
              }
            }
          ]
        }
      ],
      options: {
        stripe: true, // 斑马纹
        mutiSelect: false, // 多选框
        index: false, // 显示序号， 多选则 mutiSelect
        loading: false, // 表格动画
        initTable: false, // 是否一挂载就加载数据
        border: true,
        height: 'calc(100vh - 300px)'
      },
      tableCheckItems: [],
      tableData: [],
      tableRequset: {
        total: 0,
        pageIndex: 1,
        pageSize: 10,
        searchValue: ''
      },
      debounceFn: debounce(this.fetch, 500),
      propsId: ''
    }
  },
  watch: {
    falseAlarmId: {
      handler(val) {
        this.propsId = this.falseAlarmId
        this.getFalseAlarmResultAPI({ falseAlarmId: this.propsId })
      }
    }
  },
  mounted() {
    this.propsId = this.falseAlarmId
    this.getFalseAlarmResultAPI({ falseAlarmId: this.falseAlarmId })
  },
  methods: {
    async getFalseAlarmResultAPI(params) {
      if (this.$refs.table) this.$refs.table.clearSelection()
      const { pageSize, pageIndex } = this.tableRequset
      const {
        data: { list, total }
      } = await getFalseAlarmResult({ pageSize, pageNum: pageIndex, ...params })
      this.tableData = list
      this.tableRequset.total = total
    },

    fetch() {
      this.getFalseAlarmResultAPI({ falseAlarmId: this.falseAlarmId })
    }
  }
}
</script>

<style lang="scss" scoped>
@import '../index.scss';
</style>
