<template>
  <!-- <div class="synthesis-conf-container"> -->
  <el-dialog v-model="dialogVisible" title="配置" width="85vw" :before-close="close">
    <div class="synthesis-conf-content">
      <el-table :data="tableData" height="calc(100vh - 250px)" border @selection-change="selectionChange"
        :span-method="arraySpanMethod">
        <el-table-column type="index" width="55" label="序号" />
        <el-table-column prop="warningModule" label="预警模块" width="180"></el-table-column>
        <el-table-column prop="warningIndex" label="预警指标" width="180"></el-table-column>
        <el-table-column prop="indexRule" label="指标规则" width="300"></el-table-column>
        <el-table-column prop="thresholdDefaultConfig" label="阈值默认配置" width="150"></el-table-column>
        <el-table-column prop="threshold" label="阈值" width="100">
          <template #default="scope">
            <span>{{ scope.row.threshold }}%</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <template #footer>
      <!-- <el-button type="primary" @click="ok">保存</el-button> -->
      <el-button @click="close">关闭</el-button>
    </template>
  </el-dialog>
  <!-- </div> -->
</template>

<script setup>
import { ref } from 'vue';

const dialogVisible = ref(true);

const emit = defineEmits(['ok', 'close']);
const tableData = [
  {
    "warningModule": "综合管理",
    "warningIndex": "安全管理机构设置比率",
    "indexRule": "独立设置安全管理机构单位数量/应独立设置安全管理机构数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 85
  },
  {
    "warningModule": "综合管理",
    "warningIndex": "安全生产标准化达标率",
    "indexRule": "安全生产标准化达标单位数量/安全生产标准化应达标单位数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 80
  },
  {
    "warningModule": "综合管理",
    "warningIndex": "安全工程师岗位设置比率",
    "indexRule": "设置安全工程师岗位单位数量/应设置安全工程师岗位单位数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 85
  },
  {
    "warningModule": "安全管理队伍",
    "warningIndex": "安全工程师岗位聘任比率",
    "indexRule": "评聘安全工程师人数/专职安全管理人员数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 12
  },
  {
    "warningModule": "安全管理队伍",
    "warningIndex": "安全管理人员数占比",
    "indexRule": "专职安全管理人员数量/从业人员总数*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 1
  },
  {
    "warningModule": "",
    "warningIndex": "高层民用建筑可燃外墙保温材料性能占比",
    "indexRule": "高层民用建筑可燃外墙保温材料性能建筑数量/高层民用建筑总量*100%",
    "thresholdDefaultConfig": "高于（不含）",
    "threshold": 0
  },
  {
    "warningModule": "",
    "warningIndex": "高层民用建筑易燃外墙保温材料性能占比",
    "indexRule": "高层民用建筑易燃外墙保温材料性能建筑数量/高层民用建筑总量*100%",
    "thresholdDefaultConfig": "高于（不含）",
    "threshold": 0
  },
  {
    "warningModule": "",
    "warningIndex": "联合工房易燃外墙保温材料性能占比",
    "indexRule": "联合工房建筑易燃外墙保温材料性能建筑数量/联合工房建筑总量*100%",
    "thresholdDefaultConfig": "高于（不含）",
    "threshold": 0
  },
  {
    "warningModule": "",
    "warningIndex": "高层民用建筑消火栓系统设置比率",
    "indexRule": "高层民用建筑设置消火栓系统建筑数量/高层民用建筑总数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 0
  },
  {
    "warningModule": "",
    "warningIndex": "高层民用建筑火灾自动报警系统设置比率",
    "indexRule": "高层民用建筑设置火灾自动报警系统建筑数量/高层民用建筑总数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 0
  },
  {
    "warningModule": "",
    "warningIndex": "高层民用建筑自动灭火系统设置比率",
    "indexRule": "高层民用建筑设置自动灭火系统建筑数量/高层民用建筑总数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 0
  },
  {
    "warningModule": "",
    "warningIndex": "联合工房消火栓系统设置比率",
    "indexRule": "联合工房建筑设置消火栓系统建筑数量/联合工房建筑总数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 0
  },
  {
    "warningModule": "",
    "warningIndex": "联合工房火灾自动报警系统设置比率",
    "indexRule": "联合工房建筑设置火灾自动报警系统建筑数量/联合工房建筑总数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 0
  },
  {
    "warningModule": "仓储安全",
    "warningIndex": "仓储消防设施设置比率",
    "indexRule": "配置消火栓系统或火灾自动报警系统或自动灭火系统的（条件同分母）仓库数量/（占地面积大于1500平方米或者总建筑面积大于3000平方米的单层库或多层库的仓库数量+立体库的仓库数量）*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 23
  },
  {
    "warningModule": "职业健康和劳动保护",
    "warningIndex": "专职驾驶员体检率",
    "indexRule": "专职驾驶员特种作业人员体检数/驾驶员总数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 100
  },
  {
    "warningModule": "职业健康和劳动保护",
    "warningIndex": "电工体检率",
    "indexRule": "电工特种作业人员体检数/电工总人数*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 100
  },
  {
    "warningModule": "职业健康和劳动保护",
    "warningIndex": "压力容器操作工体检率",
    "indexRule": "压力容器操作工特种作业人员体检数/压力容器操作工总人数*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 100
  },
  {
    "warningModule": "相关方",
    "warningIndex": "安全协议签订率",
    "indexRule": "签订安全协议相关数量/重点相关方总数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 100
  },
  {
    "warningModule": "相关方",
    "warningIndex": "相关方资质符合率",
    "indexRule": "具备相应单位资质相关方数量/重点相关方总数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 100
  },
  {
    "warningModule": "道路交通",
    "warningIndex": "使用超过8年车辆占比",
    "indexRule": "使用超过8年车辆数量/机动车辆总数*100%",
    "thresholdDefaultConfig": "高于（不含）",
    "threshold": 27
  },
  {
    "warningModule": "道路交通",
    "warningIndex": "使用超过30万公里车辆占比",
    "indexRule": "使用超过30万公里车辆数量/机动车辆总数*100%",
    "thresholdDefaultConfig": "高于（不含）",
    "threshold": 27
  },
  {
    "warningModule": "风险管控",
    "warningIndex": "较大风险（橙区）现状风险单元数量（个）",
    "indexRule": "较大风险（橙区）现状风险单元数量（个）",
    "thresholdDefaultConfig": "高于（不含）",
    "threshold": 0
  },
  {
    "warningModule": "风险管控",
    "warningIndex": "重大风险（红区）现状风险单元数量（个）",
    "indexRule": "重大风险（红区）现状风险单元数量（个）",
    "thresholdDefaultConfig": "高于（不含）",
    "threshold": 0
  },
  {
    "warningModule": "隐患治理",
    "warningIndex": "隐患按期整改率",
    "indexRule": "在整改期限小于等于统计周期最后一自然日内，隐患状态为\"已完成\"的隐患数量/整改期限小于等于统计周期最后一自然日的隐患数量*100%",
    "thresholdDefaultConfig": "低于（不含）",
    "threshold": 90
  },
  {
    "warningModule": "隐患治理",
    "warningIndex": "重大隐患占比",
    "indexRule": "重大隐患数量/隐患总数*100%",
    "thresholdDefaultConfig": "高于（不含）",
    "threshold": 1
  },
  {
    "warningModule": "事故事件",
    "warningIndex": "交通事故万车死亡率",
    "indexRule": "事故类型为\"道路交通机动车辆伤害”的死亡人数/车辆总数*10000",
    "thresholdDefaultConfig": "高于（不含）",
    "threshold": 1.38
  },
  {
    "warningModule": "事故事件",
    "warningIndex": "千人生产安全事故死亡率",
    "indexRule": "事故类型为非\"道路交通机动车辆伤害”死亡人数/单位从业人数*1000",
    "thresholdDefaultConfig": "高于（不含）",
    "threshold": 0.01244
  }
];
const form = ref({});
const ok = () => {
  emit('ok');
};
/** 是否可选 */
const selectable = () => {
  return true;
}
const selectionChange = (selection) => {
  console.log('selectionChange', selection);
}

const arraySpanMethod = ({ row, column, rowIndex, columnIndex }) => {
  // 第一列，，向下合并
  if (columnIndex === 1) {
    // 综合管理 合并3个 。对比excel序号少2个(因为列表序号从0开始，而excel序号从2开始)
    if (rowIndex === 0) return [3, 1]
    if (rowIndex > 0 && rowIndex < 3) return [0, 0]
    // 安全管理队伍 合并2个
    if (rowIndex === 3) return [2, 1]
    if (rowIndex > 3 && rowIndex < 5) return [0, 0]
    // 无名菜单 （建筑） 合并 8个
    if (rowIndex === 5) return [8, 1]
    if (rowIndex > 5 && rowIndex < 13) return [0, 0]
    // 仓储安全 合并 1个
    if (rowIndex === 13) return [1, 1]
    // 职业健康和劳动保护 合并 3个
    if (rowIndex === 14) return [3, 1]
    if (rowIndex > 14 && rowIndex < 17) return [0, 0]
    // 相关方 合并 2个
    if (rowIndex === 17) return [2, 1]
    if (rowIndex > 17 && rowIndex < 19) return [0, 0]
    // 道路交通 合并 2个
    if (rowIndex === 19) return [2, 1]
    if (rowIndex > 19 && rowIndex < 21) return [0, 0]
    // 风险管控 合并 2个
    if (rowIndex === 21) return [2, 1]
    if (rowIndex > 21 && rowIndex < 23) return [0, 0]
    // 隐患治理 合并 2个
    if (rowIndex === 23) return [2, 1]
    if (rowIndex > 23 && rowIndex < 25) return [0, 0]
    // 事故事件 合并 2个
    if (rowIndex === 25) return [2, 1]
    if (rowIndex > 25 && rowIndex < 27) return [0, 0]
  }

  return [1, 1]
}
const close = () => {
  emit('close');
};
// /** 设置table数据 */
// const setTable = ()=>{
// 	tableData.value = []
// }

</script>

<style lang="scss" scoped>
// .synthesis-conf-container {
// 	width: 100%;
// 	height: 100%;
// }</style>