<!-- 视频分析 -->
<template>
  <div>
    <a-space class="header">
      <div class="input-box">
        <div class="silt-title">
          <span style="width: 70px; display: block">{{ '风险类型' }}</span>
          <a-select class="select-box" v-model:value="informationData.riskType" style="width: 190px" placeholder="请选择">
            <a-select-option v-for="item in riskTypeList" :key="item.value" :value="item.value">
              {{ item.name }}
            </a-select-option>
          </a-select>
        </div>
      </div>
      <div class="btnBox">
        <a-button style="margin-right: 16px" type="primary" @click="searchData">查询</a-button>
        <a-button style="margin-right: 16px" @click="reset">重置</a-button>
      </div>
    </a-space>
    <a-table :dataSource="dataSource" :row-key="(record) => record.key" :pagination="informationData"
      @change="onChangePage" :columns="columns">
      <template #bodyCell="{ column, record }"></template>
    </a-table>
  </div>
</template>
<script setup>
import reserveDataApi from '@/api/reserveData.info/reserveDataApi'
const columns = [
  {
    title: '序号',
    dataIndex: 'Index',
    align: 'center',
    customRender: ({ text, record, index }) => {
      return `${index + 1}`
    }
  },
  {
    title: '库区名称',
    dataIndex: 'orgName',
    align: 'center',
    key: 'orgName'
  },
  {
    title: '风险类型',
    dataIndex: 'riskType',
    align: 'center',
    key: 'riskType'
  },
  {
    title: '预警描述',
    dataIndex: 'warningDescription',
    align: 'center',
    key: 'warningDescription'
  },
  {
    title: '预警事件',
    dataIndex: 'warningEvent',
    align: 'center',
    key: 'warningEvent'
  },
  {
    title: '报警单位',
    dataIndex: 'alarmUnit',
    align: 'center',
    key: 'alarmUnit'
  },
  {
    title: '报警时间',
    dataIndex: 'alarmTime',
    align: 'center',
    key: 'alarmTime'
  },
  {
    title: '报警位置',
    dataIndex: 'alarmLocation',
    align: 'center',
    key: 'alarmLocation'
  },
  {
    title: '报警等级',
    dataIndex: 'alarmLevel',
    align: 'center',
    key: 'alarmLevel'
  },
  {
    title: '分析',
    dataIndex: '',
    align: 'center',
    key: '',
  }
]
const dataSource = ref([])
const riskTypeList = ref([
  {
    name: '抽烟检测',
    value: 1
  },
  {
    name: '未带安全帽',
    value: 2
  },
  {
    name: '摄像头遮挡',
    value: 3
  },
  {
    name: '姿态识别',
    value: 4
  },
])
const informationData = ref({
  riskType: undefined,
  current: 1,
  size: 10,
})
// 表格分页
const onChangePage = (ev) => {
  informationData.value = { ...ev }
  if (isShowName.value == '1') {
    informationData.value.riskType = undefined
  }
  onSearch()
}
// 列表分页
const onSearch = () => {
  const fd = { ...informationData.value }
  reserveDataApi.recognizetPage(fd).then((res) => {
    dataSource.value = []
    informationData.value.total = res.total
    dataSource.value = res.records
    dataSource.value.forEach(i => {
      switch (i.riskType) {
        case 1:
          i.riskType = '抽烟检测'
          break
        case 2:
          i.riskType = '未带安全帽'
          break
        case 3:
          i.riskType = '摄像头遮挡'
          break
        case 4:
          i.riskType = '姿态识别'
          break
        default:
          break
      }
    })
  })
}
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 = {
    riskType: undefined,
    current: 1,
    size: 10
  }
  onSearch()
}

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

.input-box {
  display: flex;
  width: 100%;
}

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

.title-box {
  width: 68px;
}

.inputBoxContent {
  width: 400px;
}

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

.btnBox {
  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;
}

.ant-space-item {
  width: 26%;
}

.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;
}

.ant-select-selector {
  display: none !important;
}

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