<template>
  <section class="box-sjtj">
    <section class="content">
      <section v-if="equipmentType === 0" class="totalbox">
        <MOSTY.Assort :title="'消防器材分类'" style="padding: 0;" />
        <section class="flex">
          <section class="left-tj">
            <Sjtj :info="pageData.defaultLeftList" :isShowTip="false" :isShowBottom="false" :width="265" mb="6px" />
          </section>
        </section>
      </section>
      <section v-else class="totalbox">
        <MOSTY.Assort :title="'安防器材分类'" style="padding: 0;" />
        <section class="flex">
          <section class="left-tj">
            <Sjtj :info="pageData.defaultRightList" :isShowTip="false" :isShowBottom="false" :width="265" mb="6px" />
          </section>
        </section>
      </section>
    </section>
  </section>
</template>
<script setup>
import * as MOSTY from "@/components/MyComponents/index"
import Sjtj from '@/views/dataReportWork/aqjypx/components/sjtj.vue'
import { postApi } from "@/api/tobAcco_api.js";
import { reactive, onMounted } from "vue";
const props = defineProps({
  obj: {
    type: Object,
    default: () => { }
  },
  equipmentType: {
    default: 0,
    type: Number
  }
});
const pageData = reactive({
  defaultLeftList: [
    { title: '灭火器箱', num: 0, dm: '200201010000', icon: 'ccss/icon_01.png' },
    { title: '灭火器数量', num: 0, dm: '200201010100', icon: 'ccss/icon_01.png' },
    { title: '灭火毯数量', num: 0, dm: '20020102', icon: 'ccss/icon_02.png' },
    { title: '防烟面罩数量', num: 0, dm: '20020103', icon: 'ccss/icon_03.png' },
    { title: '其他消防器材数量', num: 0, dm: '20020104', icon: 'ccss/icon_04.png' }
  ],
  defaultRightList: [
    { title: '防爆器材数量', num: 0, dm: '20020201', icon: 'ccss/icon_05.png' },
    { title: '其他防暴器材数量', num: 0, dm: '20020202', icon: 'ccss/icon_06.png' }
  ],
})
onMounted(() => {
  getscsbsscount()
})
const getscsbsscount = () => {
  postApi(props.obj, '/mosty-jcgl/sbglAqqc/countTbSbglAqqc').then(res => {
    if (res.length > 0) {
      let leftList = res[1];
      let rightList = res[0]
      leftList.forEach((item) => {
        let _item = pageData.defaultLeftList.find(v => v.dm == item.dm)
        if (_item) {
          _item.num = item.count || 0
        }
      });
      rightList.forEach((item) => {
        let _item = pageData.defaultRightList.find(v => v.dm == item.dm)
        if (_item) {
          _item.num = item.count || 0
        }
      });
    }
  })
}
const filtterNum = num => {
  return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
}
defineExpose({ getscsbsscount })
</script>

<style lang="scss" scoped>
.box-sjtj {
  .content {
    .totalbox {
      flex: 1;
      // border-right: 1px solid #EBEEF5;
      padding-right: 8px;
      box-sizing: border-box;

      .flex {
        display: flex;
        align-items: center;
        justify-content: space-between;



        .right-tj {
          flex: 1;
          margin-left: 13px;
        }
      }
    }

    .center {
      flex: 1;
      // border-right: 1px solid #EBEEF5;
      padding-right: 8px;
      box-sizing: border-box;
      margin-left: 12px;

      .flex {
        display: flex;
        justify-content: space-between;

        .left-tj {
          flex: 1;
        }

        .right-tj {
          flex: 1;
          margin-left: 13px;
        }
      }
    }

    .right {
      flex: 1;
      margin-left: 12px;
    }
  }
}
</style>