<template>
  <div>
    <div v-if="props.isOpen">
      <MOSTY.Assort :title="'消防类'" style="padding: 0" v-if="props.equipmentType === 0" />
      <BaseTag :items="pageData.countlist" :num="4" @getItem="cahngetype" v-if="props.equipmentType === 0" />
      <MOSTY.Assort :title="'安防类'" style="padding: 0" v-if="props.equipmentType === 1" />
      <BaseTag :items="pageData.countlist2" :num="4" @getItem="cahngetype" v-if="props.equipmentType === 1" />
    </div>
    <div class="tabox">
      <el-divider />
      <MOSTY.Search :searchArr="searchArr" @submit="onSearch" />
      <el-divider />
      <div class="button">
        <!-- isAuth && -->
        <el-button @click="addUserHander" v-if="props.obj.saveBtnShow">
          <el-icon>
            <Plus />
          </el-icon>
          <span>新增</span>
        </el-button>
        <MOSTY.ExportExcel :exportSheets="exportSheets" :exportInfo="exportInfo" @getSheets="getSheets"
          :ditData="{ D_BZ_SYZT, D_TB_JCYWLX }" />
        <el-button @click="handleewm" v-loading="exportLoadings" :disabled="pageData.tableData.length == 0"
          class="ml10">
          <el-icon>
            <Download />
          </el-icon>
          批量导出二维码
        </el-button>
      </div>
      <MOSTY.Table :table-columns="pageData.tableColumns" :tableData="pageData.tableData" :tableloading="tableloading"
        :isSelect="true" :isSort="true" :tableHeight="`calc(100vh - ${props.isOpen ? '780px' : '382px'})`">
        <template #sign="{ row }">
          <p style=" width: 12px; height: 12px;border-radius: 50%;margin: 0 auto"
            :style="{ 'background-color': row?.sign ? '#33CC00' : '#FC5F76' }"></p>
        </template>
        <template #sblx="{ row }">
          <dict-tag :options="D_TB_JCYWLX" :value="row.sblx" :tag="false" />
        </template>
        <template #responsibilitypersonname="{ row }">
          <span>{{ row.responsibilitypersonname ? row.responsibilitypersonname.replace(/（null）/g, "") : "" }}</span>
        </template>
        <template #state="{ row }">
          <dict-tag v-if="row.state" :options="D_BZ_SYZT" :value="row.state" :tag="false"
            :color="row.state == '01' ? 'green' : 'red'" />
          <span v-else>无</span>
        </template>
        <template #actions="{ row }">
          <!-- isAuth && -->
          <el-popconfirm confirm-button-text="是" cancel-button-text="否" icon-color="red" title="复制该条数据并进行数据编辑?"
            @confirm="handlcopy(row)" v-if='props.obj.saveBtnShow'>
            <template #reference>
              <span class="operecopy" size="small">
                <el-icon>
                  <CopyDocument />
                </el-icon>
                复制</span>
            </template>
          </el-popconfirm>
          <!-- isAuth &&  -->
          <span class="operedit" @click="handlexg(row)" v-if="props.obj.saveBtnShow">
            <el-icon>
              <EditPen />
            </el-icon>编辑</span>
          <!-- isAuth && -->
          <el-popconfirm v-if="props.obj.saveBtnShow" confirm-button-text="是" cancel-button-text="否" icon-color="red"
            title="确定要删除?" @confirm="handledelete(row)">
            <template #reference>
              <span class="operdel" size="small">
                <el-icon>
                  <Delete />
                </el-icon>
                删除</span>
            </template>
          </el-popconfirm>
          <span class="operesee" @click="handleSee(row)">
            <el-icon>
              <View />
            </el-icon>查看</span>
        </template>
      </MOSTY.Table>
      <div class="fenye">
        <MOSTY.Pages :pageConfiger="pageData.pageConfiger" @changeNo="handleCurrentChange"
          @changeSize="handleSizeChange" />
      </div>
    </div>
  </div>
  <!-- 安全设备设施 -->
  <div v-if="showdialogaqsbss" class="dialog-box">
    <aqsbssindex :equipmentType="props.equipmentType" :formData="formData" @saveSuccess="saveSuccess"
      :type="props.obj.type" />
  </div>
</template>
<script setup>
import * as MOSTY from "@/components/MyComponents/index"
import aqsbssindex from "@/components/dialog/aqsbssindex.vue"
import { reactive, ref, onMounted, nextTick, getCurrentInstance, watch } from "vue"
import { getApi, postApi } from "@/api/tobAcco_api.js"
import { ElMessage } from "element-plus"
import BaseTag from "@/views/dataReportWork/org/components/baseTag"
import { useStore } from "vuex"
import { getAuth, downloadewm } from "@/utils/tools.js"
import SecuritySheets from "./SecuritySheets.js"
import { singleObjectCheck } from "@/utils/tools.js"

const exportLoadings = ref(false)
const { proxy } = getCurrentInstance()
const {
  D_BZ_SYZT,
  D_TB_JCYWLX,
  D_BZ_SBLX
} = proxy.$dict("D_BZ_SYZT", "D_TB_JCYWLX", "D_BZ_SBLX")
const store = useStore()
const emits = defineEmits(["handleChange", "searchChange"])
const tableloading = ref(false)
const props = defineProps({
  obj: {
    default: null,
    type: Object
  },
  type: {
    default: "",
    type: String
  },
  tableHeight: {
    default: "40vh",
    type: String
  },
  equipmentType: {
    default: 0,
    type: Number
  },
  isOpen: Boolean
})
const total = ref(0)
const type = ref("")
const isAuth = ref(false)
const formData = ref({
  title: ""
})
const showdialogaqsbss = ref(false)
// 消防电源  消防水泵结合器  空气采样报警系统  红外对射报警系统 可燃气体探测报警系统  超音速干粉灭火系统
// 高压细水雾灭火系统 二氧化碳灭火系统  气溶胶灭火系统 水炮灭火系统 泡沫灭火系统  应急照明疏散指示系统
// 应急广播 停车场管理系统 电子巡更系统 电子围栏系统  门禁管理系统 安检门 场内道路管理系统
let fireControlPowerSupply = [
  "sblx",
  "name",
  "location",
  // "azsj",
  // "trsysj",
  "sitename",
  "buildingname",
  "partname",
  "responsibilitydeptname",
  "responsibilitypersonname"
]
// 消防水池  消防水箱
let firePool = [
  "sblx",
  "name",
  "location",
  // "azsj",
  // "trsysj",
  "rztj",
  "sitename",
  "buildingname",
  "partname",
  "responsibilitydeptname",
  "responsibilitypersonname"
]
// 消防水泵
let firePump = [
  "sblx",
  "name",
  "pumpsType",
  "pumpsNumber",
  "location",
  // "azsj",
  // "trsysj",
  "sitename",
  "buildingname",
  "partname",
  "responsibilitydeptname",
  "responsibilitypersonname"
]
// 感烟  感温报警系统
let alarmSystem = [
  "sblx",
  "name",
  "location",
  // "azsj",
  // "trsysj",
  "alarmHostsNumber",
  "thermalFireDetectorsNumber",
  "smokeFireDetectorsNumber",
  "manualAlarmButtonsNumber",
  "soundAndLightAlarmsNumber",
  "areaDisplaysNumber",
  "sitename",
  "buildingname",
  "partname",
  "responsibilitydeptname",
  "responsibilitypersonname"
]
// 电气火灾监控（智慧用电）报警系统
let electricalFireMonitoring = [
  "sblx",
  "name",
  "location",
  // "azsj",
  // "trsysj",
  "smokeFireDetectorsNumber",
  "sitename",
  "buildingname",
  "partname",
  "responsibilitydeptname",
  "responsibilitypersonname"
]
// 防火门  防火墙  防火卷帘
let fireproofDoor = [
  ...fireControlPowerSupply,
  "fireRating"
]
// 防火卷帘
let fireShutter = [
  "sblx",
  "name",
  // "azsj",
  // "trsysj",
  "fireRating",
  "sitename",
  "buildingname",
  "partname",
  "responsibilitydeptname",
  "responsibilitypersonname"
]
// 防排烟系统
let smokeControlAndExhaustSystem = [
  ...fireControlPowerSupply,
  "smokeExhaustType"
]
// 湿式自动喷水灭火系统  干式自动喷水灭火系统  预作用自动喷水灭火系统
let wetAutomatic = [
  "sblx",
  "name",
  "waterSprayType",
  "location",
  // "azsj",
  // "trsysj",
  "sprayPumpsNumber",
  "sprinklerHeadsNumber",
  "controlHostsNumber",
  "sitename",
  "buildingname",
  "partname",
  "responsibilitydeptname",
  "responsibilitypersonname"
]

// 七氟丙烷灭火系统
let fireExtinguishingSystem = [
  ...fireControlPowerSupply,
  "heptafluoropropaneType",
  "heptafluoropropaneCount",
  "controlHostsNumber",
  "heptafluoropropaneVaseCount"
]
// 室内消火栓  室外消火栓
let indoorFireHydrant = [
  ...fireControlPowerSupply,
  "waterSupplyMode",
  "pumpsNumber",
  "specificationModel",
  "hydrantsNumber"
]

// 防雷装置
let lightningProtectionDevice = [
  ...fireControlPowerSupply,
  "lightningProtectionType",
  "groundingBody",
  "lightningArrester",
  "detectionPoint"
]
// 视频监控系统
let videoMonitoringSystem = [
  ...fireControlPowerSupply,
  "monitoringType",
  "videoVcrCount",
  "videoCameraCount",
  "videoPlaybackTime"
]

// const isShowxf = ref(true)
const sbsslist = ref([])
const pageData = reactive({
  countlist: [
    {
      name: "消防电源",
      count: 0,
      dm: "20010101",
      icon: `aqss/icon_01.png`
    },
    {
      name: "消防供水系统",
      count: 0,
      dm: "20010102",
      icon: `aqss/icon_02.png`
    },
    {
      name: "火灾自动报警系统",
      count: 0,
      dm: "20010103",
      icon: `aqss/icon_03.png`
    },
    {
      name: "防火分隔",
      count: 0,
      dm: "20010104",
      icon: `aqss/icon_04.png`
    },
    {
      name: "自动灭火系统",
      count: 0,
      dm: "20010105",
      icon: `aqss/icon_05.png`
    },
    {
      name: "消火栓系统",
      count: 0,
      dm: "20010106",
      icon: `aqss/icon_06.png`
    },
    {
      name: "消防应急",
      count: 0,
      dm: "20010107",
      icon: `aqss/icon_07.png`
    },
    {
      name: "防雷装置",
      count: 0,
      dm: "20010108",
      icon: `aqss/icon_08.png`
    }
  ],
  countlist2: [
    {
      name: "视频监控系统",
      count: 0,
      dm: "20010201",
      icon: `aqss/icon_09.png`
    },
    {
      name: "停车场管理系统",
      count: 0,
      dm: "20010202",
      icon: `aqss/icon_10.png`
    },
    {
      name: "电子巡更系统",
      count: 0,
      dm: "20010203",
      icon: `aqss/icon_11.png`
    },
    {
      name: "电子围栏系统",
      count: 0,
      dm: "20010204",
      icon: `aqss/icon_12.png`
    },
    {
      name: "门禁管理系统",
      count: 0,
      dm: "20010205",
      icon: `aqss/icon_13.png`
    },
    {
      name: "安检门",
      count: 0,
      dm: "20010206",
      icon: `aqss/icon_01.png`
    },
    {
      name: "场内道路管理系统",
      count: 0,
      dm: "20010207",
      icon: `aqss/icon_03.png`
    }
  ],
  listQuery: {
    type: "0"
  },
  pageConfiger: {
    pageSize: 20,
    pageCurrent: 1,
    total: 0
  },
  tableColumns: [
    {
      title: "标记",
      prop: "sign",
      sortable: false,
      slot: true
    },
    {
      title: "单位",
      prop: "orgname"
    },
    {
      title: "安全设备设施名称",
      prop: "name"
    },
    {
      title: "安全设备设施类型",
      prop: "sblx",
      slot: true
    },
    {
      title: "内部编号",
      prop: "nbbh"
    },
    {
      title: "所属场所部位",
      prop: "sitename"
    },
    {
      title: "具体位置",
      prop: "location"
    },
    {
      title: "责任部门",
      prop: "responsibilitydeptname"
    },
    {
      title: "责任人",
      prop: "responsibilitypersonname",
      slot: true
    },
    {
      title: "状态",
      prop: "state",
      slot: true
    },
    {
      title: "操作",
      prop: "actions",
      fixed: "right",
      slot: true
    }
  ],
  tableData: []
})
const fromObj = ref({ type: "1" })
const exportInfo = reactive({
  name: "",
  loading: false,
  disabled: false
})
const exportSheets = reactive(SecuritySheets)
const searchArr = reactive([
  {
    showType: "input",
    prop: "keywords",
    width: "250px",
    placeholder: "请输入安全设备设施名称或内部编号"
  }, {
    showType: "zdlistTree",
    prop: "sblx",
    width: "250px",
    placeholder: "请选择设备类型",
    options: sbsslist
  }, {
    showType: "input",
    prop: "partname",
    width: "250px",
    placeholder: "请输入所属场所"
  }
])
const getaqsbsslb = () => {
  getApi({
    dm: "2001",
    zdbh: "D_TB_JCYWLX",
    level: 4
  }, "/mosty-base/sysDict/getJcyelxDictTree").then(res => {
    sbsslist.value = [res[0].itemList[props.equipmentType]]
  })
}
// 是否可以操作
const isAuthorize = async () => {
  isAuth.value = await getAuth()
}
onMounted(() => {
  nextTick(() => {
    if (props.equipmentType === 0) {
      pageData.tableColumns[2].title = '消防设备设施名称'
      pageData.tableColumns[3].title = '消防设备设施类型'
    } else if (props.equipmentType === 1) {
      pageData.tableColumns[2].title = '安防设备设施名称'
      pageData.tableColumns[3].title = '安防设备设施类型'
    }
  })
  getaqsbsslb()
  isAuthorize()
  fromObj.value.type = "1"
  pageData.listQuery.type = "1"
  if (props.type == "cs") {
    pageData.listQuery.siteid = props.obj.id
    fromObj.value.siteid = props.obj.id
    gettablist()
  } else if (props.type == "jzw") {
    pageData.listQuery.buildingid = props.obj.id
    fromObj.value.buildingid = props.obj.id
    gettablist()
  } else if (props.type == "lc") {
    pageData.listQuery.floorid = props.obj.id
    fromObj.value.floorid = props.obj.id
    gettablist()
  } else if (props.type == "bw") {
    pageData.listQuery.partid = props.obj.id
    fromObj.value.partid = props.obj.id
    gettablist()
  } else if (props.type == "aqsbss" || props.type == "afsbss" || props.type == "xfsbss") {
    watch(
      () => props.obj.orgid,
      (newValue) => {
        if (newValue) {
          pageData.listQuery.orgcode = newValue
          fromObj.value.orgcode = newValue
          fromObj.value.type = "0"
          pageData.listQuery.type = "0"
          gettablist()
        }

      },
      { deep: true, immediate: true }
    )
  }
})

//	统计各类（场、建、楼、部）或单位下，安全设备设施
function getsbssscount() {
  postApi(fromObj.value, "/mosty-jcgl/sbglAqsbss/countTbSbglAqsbss").then(res => {
    let xflist = res[0]
    let aflist = res[1]
    for (let i = 0; i < pageData.countlist.length; i++) {
      const el = pageData.countlist[i]
      el.count = 0
      for (let j = 0; j < xflist.length; j++) {
        const li = xflist[j]
        if (li.dm == el.dm) {
          el.count = li.count
        }
      }
    }
    for (let i = 0; i < pageData.countlist2.length; i++) {
      const el2 = pageData.countlist2[i]
      el2.count = 0
      for (let j = 0; j < aflist.length; j++) {
        const li = aflist[j]
        if (li.dm == el2.dm) {
          el2.count = li.count
        }
      }
    }
  })
}

const getTreeItem = (treeData, id) => {
  for (let i in treeData) {
    if (treeData[i].dm === id) {
      return treeData[i]
    }
    if (treeData[i].itemList && treeData[i].itemList.length) {
      var res = getTreeItem(treeData[i].itemList, id)
      if (res) return res
    }
  }
}
const getSheets = go => {
  exportInfo.loading = true
  exportInfo.name = "安全设备设施"

  if (pageData.listQuery.sblx) exportInfo.name += "-" + getTreeItem(sbsslist.value, pageData.listQuery.sblx).zdmc

  exportSheets.forEach(item => {
    if (!item.title.includes(store.state.user.currentDeptName)) item.title = store.state.user.currentDeptName + item.title
    item.data = []
  })

  postApi({
    ...pageData.listQuery,
    pageSize: 10000,
    pageCurrent: 1
  }, "/mosty-jcgl/sbglAqsbss/queryTbSbglAqsbssAll").then(res => {
    if (!res) {
      exportInfo.loading = false
      return
    }
    res.forEach(list => {
      if (list.floorname) {
        list.sitename = list.sitename + "-" + list.buildingname + "-" + list.floorname + "-" + list.partname
      } else {
        list.sitename = list.sitename + "-" + list.buildingname + "-" + list.partname
      }
      list.pumpsType = list.pumpsType ? proxy.$getDictVal(list.pumpsType, D_BZ_SBLX) : ""
      exportSheets.forEach(item => {
        if (JSON.stringify(["200101020100", "200101020200"]) === JSON.stringify(item.sblx)) {
          //"消防水池", "消防水箱"
          if (["200101020100", "200101020200"].includes(list.sblx)) {
            item.data.push(list)
          }
        } else if (JSON.stringify(["200101070100", "200101070200"]) === JSON.stringify(item.sblx)) {
          //["应急照明疏散指示系统", "应急广播"]
          if (["200101070100", "200101070200"].includes(list.sblx)) {
            item.data.push(list)
          }
        } else if (JSON.stringify(["200101060100", "200101060200"]) === JSON.stringify(item.sblx)) {
          //["室外消火栓", "室内消火栓"]
          if (["200101060100", "200101060200"].includes(list.sblx)) {
            item.data.push(list)
          }
        } else if (JSON.stringify(["200101050101", "200101050102", "200101050103"]) === JSON.stringify(item.sblx)) {
          //["湿式自动喷水灭火系统", "干式自动喷水灭火系统", "预作用自动喷水灭火系统"]
          if (["200101050101", "200101050102", "200101050103"].includes(list.sblx)) {
            item.data.push(list)
          }
        } else {
          if (item.sblx === list.sblx) item.data.push(list)
        }
      })
    })
    exportInfo.loading = false
    go()
  })
}

//获取安全器材类型
function cahngetype(val) {
  pageData.listQuery.sblx = val.dm
  gettablist()
}

//安全设备设施分页查询
function gettablist() {
  tableloading.value = true
  exportInfo.disabled = false
  if (!pageData.listQuery.sblx) {
    if (props.equipmentType === 0) {
      pageData.listQuery.sblx = '200101'
    } else {
      pageData.listQuery.sblx = '200102'
    }
  }
  let sign_map = new Map(
    [
      ["200101010000", fireControlPowerSupply],
      ["200101090000", fireControlPowerSupply],
      ["200101020100", firePool],
      ["200101020200", firePool],
      ["200101020300", firePump],
      ["200101020400", fireControlPowerSupply],
      ["200101020500", fireControlPowerSupply],
      ["200101030100", alarmSystem],
      ["200101030200", fireControlPowerSupply],
      ["200101030300", fireControlPowerSupply],
      ["200101030400", fireControlPowerSupply],
      ["200101030500", electricalFireMonitoring],
      ["200101040100", fireproofDoor],
      ["200101040200", fireproofDoor],
      ["200101040300", fireShutter],
      ["200101040400", smokeControlAndExhaustSystem],
      ["200101040500", fireControlPowerSupply],
      ["200101050101", fireControlPowerSupply],
      ["200101050102", fireControlPowerSupply],
      ["200101050103", fireControlPowerSupply],
      ["200101050104", fireControlPowerSupply],
      ["200101050105", fireControlPowerSupply],
      ["200101050106", fireControlPowerSupply],
      ["200101050201", fireControlPowerSupply],
      ["200101050202", fireControlPowerSupply],
      ["200101050203", fireControlPowerSupply], // 二氧化碳灭火系统
      ["200101050204", fireControlPowerSupply], // "七氟丙烷灭火系统"
      ["200101050600", fireControlPowerSupply], // "气溶胶灭火系统"
      ["200101050700", fireControlPowerSupply], // "水炮灭火系统"
      ["200101050800", fireControlPowerSupply], // 泡沫灭火
      ["200101060100", indoorFireHydrant], // "室内消火栓"
      ["200101060200", indoorFireHydrant], // "室外消火栓"
      ["200101070100", fireControlPowerSupply], // "应急照明疏散指示系统"
      ["200101070200", fireControlPowerSupply], // "应急广播"
      ["200101100100", fireControlPowerSupply], // "送风机"
      ["200101100200", fireControlPowerSupply], // "排风机"
      ["200101080100", fireControlPowerSupply], // "防烟系统"
      ["200101080200", fireControlPowerSupply], // "排烟系统"
      ["200101080000", lightningProtectionDevice], // 防雷装置
      ["200102020000", fireControlPowerSupply], // 停车管理系统
      ["200102030000", fireControlPowerSupply], // "电子巡更系统"
      ["200102040000", fireControlPowerSupply], // 电子围栏
      ["200102050000", fireControlPowerSupply], // "门禁管理系统"
      ["200102060000", fireControlPowerSupply], // 安检门
      ["200102070000", fireControlPowerSupply], // "场内道路管理系统"
      ["200102080000", fireControlPowerSupply], // "声波盾系统"
      ["200102090000", fireControlPowerSupply], // "入侵探测报警系统系统"
      ["200101050101", wetAutomatic], // 湿式自动喷水灭火系统
      ["200101050102", wetAutomatic],
      ["200101050103", wetAutomatic],
      ["200101050104", wetAutomatic],
      ["200101050105", wetAutomatic],
      ["200101050106", wetAutomatic],
      ["200101050201", wetAutomatic], // 超音速干粉灭火系统
      ["200101050202", wetAutomatic], // 超音速干粉灭火系统
      ["200101050203", wetAutomatic], // 超音速干粉灭火系统
      ["200101050204", wetAutomatic], // 超音速干粉灭火系统
      ["200102010000", videoMonitoringSystem], // 视频监控
      [null, fireControlPowerSupply]
    ])
  postApi({ ...pageData.pageConfiger, ...pageData.listQuery }, "/mosty-jcgl/sbglAqsbss/queryTbSbglAqsbss").then(async res => {
    if (res && res.records) {
      if (props.equipmentType === 0) {
        proxy.mittBus.emit('mittxfss', res.total)
      } else if (props.equipmentType === 1) {
        proxy.mittBus.emit('mittafss', res.total)
      }
      tableloading.value = false
      let table_Data = []
      // sblx
      for (let i = 0; i < res.records.length; i++) {
        if (typeof res.records[i].sblx === "string" && res.records[i].sblx.length !== 12) {
          res.records[i]["sign"] = false
          table_Data.push(res.records[i])
          continue
        }
        table_Data.push(await singleObjectCheck(res.records[i], sign_map.get(res.records[i].sblx)))
      }
      pageData.tableData = table_Data
      // console.log("页面数据")
      // console.log(pageData.tableData)
      pageData.tableData.forEach(list => {
        if (list.floorname) {
          list.sitename = list.sitename + "-" + list.buildingname + "-" + list.floorname + "-" + list.partname
        } else {
          list.sitename = list.sitename + "-" + list.buildingname + "-" + list.partname
        }
      })
      // total.value = res.total
      pageData.pageConfiger.total = res.total
      if (pageData.tableData.length === 0) exportInfo.disabled = true
    }
  })
}

//新增
function addUserHander() {
  formData.value.type = props.type
  if (props.type == "cs") {
    formData.value.siteid = props.obj.id
    formData.value.sitename = props.obj.placename
  } else if (props.type == "jzw") {
    if (props.obj.type == "cq") {
      formData.value.publicarea = "1"
    }
    formData.value.siteid = props.obj.siteid
    formData.value.sitename = props.obj.sitename
    formData.value.buildingid = props.obj.id
    formData.value.buildingname = props.obj.buildingname
    formData.value.publicarea = props.obj.publicarea
  } else if (props.type == "lc") {
    formData.value.siteid = props.obj.siteid
    formData.value.sitename = props.obj.sitename
    formData.value.buildingid = props.obj.buildingid
    formData.value.buildingname = props.obj.buildingname
    formData.value.floorid = props.obj.id
    formData.value.floorname = props.obj.floorname
  } else if (props.type == "bw") {
    if (props.obj.type == "cq") {
      formData.value.sfcq = "1"
      formData.value.publicarea = "1"
    } else {
      if (props.obj.sfcq && props.obj.sfcq == "1") {
        formData.value.sfcq = "1"
        formData.value.publicarea = "1"
      } else {
        formData.value.sfcq = "2"
        formData.value.publicarea = "2"
      }
    }
    formData.value.siteid = props.obj.siteid
    formData.value.sitename = props.obj.sitename
    formData.value.buildingid = props.obj.buildingid
    formData.value.buildingname = props.obj.buildingname
    formData.value.floorid = props.obj.floorid
    formData.value.floorname = props.obj.floorname
    formData.value.partid = props.obj.id
    formData.value.partname = props.obj.partname
    formData.value.qtmc = props.obj.qtmc ? props.obj.qtmc : null
  }
  formData.value.title = "安全设备设施新增"
  formData.value.saveBtnShow = true
  formData.value={
    title:formData.value.title,
    saveBtnShow:formData.value.saveBtnShow,
    type:formData.value.type,
  }
  showdialogaqsbss.value = true
  tableloading.value = false
}
//复制
function handlcopy(row) {
  formData.value.type = props.type
  formData.value.qtmc = props.obj.qtmc ? props.obj.qtmc : null
  formData.value.title = "安全设备设施复制"
  formData.value.saveBtnShow = true
  formData.value.id = row.id
  formData.value.sblx = row.sblx
  showdialogaqsbss.value = true
}
//修改
function handlexg(row) {
  formData.value.type = props.type
  formData.value.qtmc = props.obj.qtmc ? props.obj.qtmc : null
  formData.value.title = "安全设备设施修改"
  formData.value.saveBtnShow = true
  formData.value.id = row.id
  formData.value.sblx = row.sblx
  showdialogaqsbss.value = true
}

//查看
function handleSee(row) {
  formData.value.type = props.type
  formData.value.qtmc = props.obj.qtmc ? props.obj.qtmc : null
  formData.value.title = "安全设备设施详情"
  formData.value.saveBtnShow = false
  formData.value.id = row.id
  formData.value.sblx = row.sblx
  showdialogaqsbss.value = true
}

//注销
function handledelete(row) {
  getApi({ id: row.id }, `/mosty-jcgl/sbglAqsbss/deleteTbSbglAqsbssOne`).then(res => {
    ElMessage.success("删除成功")
    emits("searchChange", "aqsbss")
    if (props.equipmentType === 0) {
      emits("searchChange", "xfsbss")
    } else if (props.equipmentType === 1) {
      emits("searchChange", "afsbss")
    }
    getsbssscount()
    gettablist()
  })
}

function saveSuccess(obj) {
  // formData.value = {}
  showdialogaqsbss.value = false
  gettablist()
  // pageData.listQuery.sblx = null
  getsbssscount()
  emits("searchChange", "aqsbss")
  if (props.equipmentType === 0) {
    emits("searchChange", "xfsbss")
  } else if (props.equipmentType === 1) {
    emits("searchChange", "afsbss")
  }
}

//查询
function onSearch(obj) {
  pageData.listQuery.keywords = obj.keywords
  pageData.listQuery.sblx = obj.sblx
  pageData.listQuery.partname = obj.partname
  pageData.pageConfiger.pageCurrent = 1
  gettablist()
}

//页码发生变化
const handleCurrentChange = val => {
  // pageData.listQuery.pageCurrent = val
  pageData.pageConfiger.pageCurrent = val
  gettablist()
}
//查询条数发生变化
const handleSizeChange = val => {
  // pageData.listQuery.pageSize = val
  pageData.pageConfiger.pageSize = val
  gettablist()
}

//批量导出二维码
function handleewm() {
  let url = "/mosty-api/mosty-jcgl/sbglAqsbss/exportQrcodeZip?orgcode=" + pageData.listQuery.orgcode +
    (pageData.listQuery.keywords ? "&keywords" + pageData.listQuery.keywords : "") +
    (pageData.listQuery.partname ? "&partname" + pageData.listQuery.partname : "") +
    (pageData.listQuery.sblx ? "&sblx" + pageData.listQuery.sblx : "")
  downloadewm(url, "安全设备设施二维码")

}
</script>

<style lang="scss" scoped>
::v-deep .el-divider--horizontal {
  margin: 12px 0;
}

.el-pagination {
  justify-content: end !important;
}

.headBox {
  width: 100%;
  margin-bottom: 10px;
}

.top_ul {
  display: flex;
  justify-content: start;
  flex-wrap: wrap;

  >li {
    width: 11%;
    height: 83px;
    margin: 4px 0.75%;
  }
}

.button {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
}
</style>
