<template>
    <section class="box-sjtj">
        <section class="content">
            <section class="totalbox">
                <MOSTY.Assort :title="'打叶复烤'" style="padding: 0;" />
                <section class="flex">
                    <section class="left-tj">
                        <Sjtj :info="pageData.defaultList1" :isShowTip="false" :isShowBottom="false" :width="235"
                            mb="6px" />
                    </section>
                </section>
            </section>
            <section class="totalbox">
                <MOSTY.Assort :title="'烟叶购销'" style="padding: 0;" />
                <section class="flex">
                    <section class="left-tj">
                        <Sjtj :info="pageData.defaultList2" :isShowTip="false" :isShowBottom="false" :width="235"
                            mb="6px" />
                    </section>
                </section>
            </section>
            <section class="totalbox">
                <MOSTY.Assort :title="'卷烟物流'" style="padding: 0;" />
                <section class="flex">
                    <section class="left-tj">
                        <Sjtj :info="pageData.defaultList3" :isShowTip="false" :isShowBottom="false" :width="235"
                            mb="6px" />
                    </section>
                </section>
            </section>
            <section class="totalbox">
                <MOSTY.Assort :title="'办公后勤'" style="padding: 0;" />
                <section class="flex">
                    <section class="left-tj">
                        <Sjtj :info="pageData.defaultList4" :isShowTip="false" :isShowBottom="false" :width="235"
                            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: () => { }
    }
});
const pageData = reactive({
    defaultList1: [
        { title: '总数', num: 0, dm: '1', icon: 'ccss/icon_01.png' },
        { title: '真空回潮设备', dm: '200401040000', num: 0, icon: 'ccss/icon_01.png' },
        { title: '制冷设备', dm: '200401120000', num: 0, icon: 'ccss/icon_02.png' },
        { title: '除尘设备', dm: '200401070000', num: 0, icon: 'ccss/icon_03.png' },
        { title: '生产性燃气设备', dm: '200401140000', num: 0, icon: 'ccss/icon_04.png' },
        { title: '其他', dm: '200401', num: 0, icon: 'ccss/icon_04.png' },
    ],
    defaultList2: [
        { title: '总数', dm: '2', num: 0, icon: 'ccss/icon_05.png' },
        { title: '打包机数', dm: '200402010000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '装卸机数', dm: '200402020000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '工业梯台', dm: '200402030000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '其他', dm: '200402', num: 0, icon: 'ccss/icon_04.png' },
    ],
    defaultList3: [
        { title: '总数', dm: '3', num: 0, icon: 'ccss/icon_05.png' },
        { title: '真空设备', dm: '200403100000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '制冷设备', dm: '200403110000', num: 0, icon: 'ccss/icon_06.png' },
        // { title: '烟叶购销', dm: '200403120000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '半自动条烟分拣线', dm: '200403050000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '异形烟分拣线', dm: '200403060000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '异标一体分拣线', dm: '200403070000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '其他', dm: '200403', num: 0, icon: 'ccss/icon_04.png' },
    ],
    defaultList4: [
        { title: '总数', dm: '4', num: 0, icon: 'ccss/icon_05.png' },
        { title: '新能源充电装置', dm: '200404010000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '中央空调', dm: '200404040000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '液化气瓶', dm: '200404050000', num: 0, icon: 'ccss/icon_06.png' },
        { title: '其他', dm: '200404', num: 0, icon: 'ccss/icon_04.png' },
    ],
})
onMounted(() => {
    getscsbsscount()
})
const getscsbsscount = () => {
    pageData.defaultList1 = [
        { title: '总数', num: 0, dm: '1', icon: 'ccss/icon_01.png' },
        { title: '真空回潮设备', dm: '200401040000', num: 0, icon: 'ccss/icon_01.png' },
        { title: '制冷设备', dm: '200401120000', num: 0, icon: 'ccss/icon_02.png' },
        { title: '除尘设备', dm: '200401070000', num: 0, icon: 'ccss/icon_03.png' },
        { title: '生产性燃气设备', dm: '200401140000', num: 0, icon: 'ccss/icon_04.png' },
        { title: '其他', dm: '200401', num: 0, icon: 'ccss/icon_04.png' },
    ],
        pageData.defaultList2 = [
            { title: '总数', dm: '2', num: 0, icon: 'ccss/icon_05.png' },
            { title: '打包机数', dm: '200402010000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '装卸机数', dm: '200402020000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '工业梯台', dm: '200402030000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '其他', dm: '200402', num: 0, icon: 'ccss/icon_04.png' },
        ],
        pageData.defaultList3 = [
            { title: '总数', dm: '3', num: 0, icon: 'ccss/icon_05.png' },
            { title: '真空设备', dm: '200403100000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '制冷设备', dm: '200403110000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '半自动条烟分拣线', dm: '200403050000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '异形烟分拣线', dm: '200403060000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '异标一体分拣线', dm: '200403070000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '其他', dm: '200403', num: 0, icon: 'ccss/icon_04.png' },
        ],
        pageData.defaultList4 = [
            { title: '总数', dm: '4', num: 0, icon: 'ccss/icon_05.png' },
            { title: '新能源充电装置', dm: '200404010000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '中央空调', dm: '200404040000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '液化气瓶', dm: '200404050000', num: 0, icon: 'ccss/icon_06.png' },
            { title: '其他', dm: '200404', num: 0, icon: 'ccss/icon_04.png' },
        ],
        postApi(props.obj, '/mosty-jcgl/sbglScsbss/countTbSbglScsbss').then(res => {
            if (res.length > 0) {
                res.forEach((item) => {
                    let _item1 = pageData.defaultList1.find(v => v.dm == item.dm)
                    let _item2 = pageData.defaultList2.find(v => v.dm == item.dm)
                    let _item3 = pageData.defaultList3.find(v => v.dm == item.dm)
                    let _item4 = pageData.defaultList4.find(v => v.dm == item.dm)
                    if (_item1) {
                        _item1.num = item.count || 0
                    }
                    if (_item2) {
                        _item2.num = item.count || 0
                    }
                    if (_item3) {
                        _item3.num = item.count || 0
                    }
                    if (_item4) {
                        _item4.num = item.count || 0
                    }
                });
                if (pageData.defaultList1[0].dm == '1') {
                    pageData.defaultList1.forEach(v => {
                        if (v.dm != '1') {
                            pageData.defaultList1[0].num += v.num
                        }
                    })
                }
                if (pageData.defaultList2[0].dm == '2') {
                    pageData.defaultList2.forEach(v => {
                        if (v.dm != '2') {
                            pageData.defaultList2[0].num += v.num
                        }
                    })
                }
                if (pageData.defaultList3[0].dm == '3') {
                    pageData.defaultList3.forEach(v => {
                        if (v.dm != '3') {
                            pageData.defaultList3[0].num += v.num
                        }
                    })
                }
                if (pageData.defaultList4[0].dm == '4') {
                    pageData.defaultList4.forEach(v => {
                        if (v.dm != '4') {
                            pageData.defaultList4[0].num += v.num
                        }
                    })
                }
            }
        })
}
const filtterNum = num => {
    return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
}
defineExpose({ getscsbsscount })
</script>

<style lang="scss" scoped>
.left-tj {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.box-sjtj {
    background-color: #fff;
    width: 100%;
    padding: 0 16px 7px 16px;
    box-sizing: border-box;

    .content {
        // display: flex;

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