<!-- 火灾预警 -->
<template>
  <div>
    <a-space class="header">
      <div class="inputBox">
        <span class="title-box">{{ '发生时间' }}</span>
        <a-date-picker style="width: 220px;margin-left: 12px;" :disabled="showLock"
          v-model:value="informationData['alarmTime']" value-format="YYYY-MM-DD HH:mm:ss" />
      </div>
      <div class="btnBox">
        <a-button style="margin-right: 16px" @click="searchData">查询</a-button>
        <a-button style="margin-right: 16px" @click="reset">重置</a-button>
      </div>
    </a-space>
    <a-table :dataSource="dataSource" @change="onChangePage" :row-key="(record) => record.id"
      :pagination="informationData" :columns="columns">
      <template #bodyCell="{ column, record }"></template>
    </a-table>
  </div>
</template>
<script setup name="fireEarlyWarning">
import safetyProductionApi from '@/api/security.info/riskLedgerApi.js'
const columns = [
  {
    title: '序号',
    dataIndex: 'Index',
    align: 'center',
    customRender: ({ text, record, index }) => {
      return `${index + 1}`
    }
  },
  {
    title: '报警单位',
    dataIndex: 'alarmUnit',
    align: 'center',
    key: 'alarmUnit'
  },
  {
    title: '报警类型',
    dataIndex: 'alarmType',
    align: 'center',
    key: 'alarmType'
  },
  {
    title: '报警时间',
    dataIndex: 'alarmTime',
    align: 'center',
    key: 'alarmTime'
  },
  {
    title: '报警位置',
    dataIndex: 'alarmLocation',
    align: 'center',
    key: 'alarmLocation'
  },
  {
    title: '报警等级',
    dataIndex: 'alarmLevel',
    align: 'center',
    key: 'alarmLevel'
  },
  {
    title: '报警人',
    dataIndex: 'alarmRaiser',
    align: 'center',
    key: 'alarmRaiser'
  },
  {
    title: '设备运行状态',
    dataIndex: 'equipmentStatus',
    align: 'center',
    key: 'equipmentStatus'
  }
]
const dataSource = ref([])
const informationData = ref({
  alarmTime: '',
  current: 1,
  size: 10
})
// 表格分页
const onChangePage = (ev) => {
  informationData.value = { ...ev }
  if (isShowName.value == '1') {
    informationData.value.alarmTime = ''
  }
  onSearch()
}
// 列表分页
const onSearch = () => {
  const fd = { ...informationData.value }
  safetyProductionApi.ssFireWarnPage(fd).then((res) => {
    dataSource.value = []
    dataSource.value = res.records
    informationData.value.total = res.total
  })
}
// 查询
const isShowName = ref('1')
const searchData = () => {
  informationData.value.current = 1
  if (informationData.value.total > 10) {
    isShowName.value = '2'
  } else {
    isShowName.value = '1'
  }
  onSearch()
}
// 重置
const reset = () => {
  informationData.value = {
    alarmTime: '',
    current: 1,
    size: 10
  }
  onSearch()
}

onMounted(() => {
  onSearch()
})
</script>
<style scoped>
.header {
  display: flex;
  padding: 20px;
  width: 100%;
}

.inputBox {
  display: flex;
}

.input-box-sle {
  width: 92%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 24px;
}

.select-box {
  margin-left: 12px;
}

.title-box {
  margin-left: 20px;
  line-height: 30px;
}

.inputBoxContent {
  width: 400px;
}

.silt-title {
  width: 280px;
  display: flex;
  align-items: center;
  margin-right: 32px;
}

.btnBox {
  width: 260px;
  margin-left: 20px;
  justify-content: start;
  display: flex;
}

.ant-input-group-addon {
  border: 0;
}

.ant-input,
.ant-btn {
  border-radius: 5px;
}

.ant-pagination {
  margin-top: 12px;
  float: right;
  margin-right: 16px;
}

.add-btn {
  background-color: rgba(112, 125, 233);
}

.check {
  background-color: rgba(112, 125, 233);
  color: #fff;
  margin-left: 8px;
}

.edit {
  background-color: rgba(222, 186, 80);
  color: #fff;
  margin-left: 8px;
}

.flow {
  background-color: #22ce8d;
  color: #fff;
  margin-left: 8px;
}

.delete {
  background-color: rgba(255, 70, 70);
  color: #fff;
  margin-left: 8px;
}

.audit {
  background-color: rgba(83, 184, 36);
  color: #fff;
  margin-left: 8px;
}

.ant-table-thead>tr>th {
  text-align: center;
}

.ant-table-tbody>tr>td {
  text-align: center;
}

::v-deep .ant-pagination-options {
  display: none !important;
}

::v-deep .ant-table-selection {
  display: none !important;
}
</style>