<template>
    <div class="rules">
        <on-line v-if="type == 'onLine' || !type" :dataList="dataList" />
        <off-line v-if="type == 'offLine' || !type" :dataList="dataList" />
        <vip-off-line v-if="type == 'vipOffLine' || !type" :dataList="dataList" />
    </div>
</template>

<script>
import { sysTenantConfig } from './api'
import setLoading from '@/utils/loading'
import OnLine from './components/onLine'
import OffLine from './components/offLine'
import vipOffLine from './components/vipOffLine'
export default {
    components: { OnLine, OffLine, vipOffLine },
    data() {
        let query = this.$route.query
        return {
            type: query.type || null,
            dataList: {}
        }
    },
    mounted() {
        let params = this.$route.query
        if(params.Authorization) {
            localStorage.setItem('Authorization', decodeURI(params.Authorization))
            localStorage.setItem('userInfo', decodeURI(params.Authorization))
        }
        document.title = '规则'
        this.__init()
    },
    methods: {
        async __init() {
            try {
                let offRes = await await sysTenantConfig({ group: "OFFLINE" })
                const offData = offRes.data || []
                offData.forEach(off => {
                    this.dataList[off.paramName] = off.paranValue
                });

                let onRes = await await sysTenantConfig({ group: "ONLINE" })
                const forwardRes = await sysTenantConfig({ group: "DAYA_BASIC" });
                const onData = onRes.data || []
                onData.forEach(on => {
                    this.dataList[on.paramName] = on.paranValue
                })
                const forwardData = forwardRes.data || []
                forwardData.forEach(forward => {
                    this.dataList[forward.paramName] = forward.paranValue
                })
                
            } catch(e) {}
        }
    }
}
</script>

<style lang="less" scoped>
.rules {
    background: #ffffff;
}
table {
    border: 0;
    font-size: 12px;
    border-color: #cccccc;
    th {
        text-align: center;
    }
    th, td {
        padding: 5px;
    }
    tr:nth-child(even) {
        background-color: #f1f1f1;
    }
}
table + table {
    margin-top: .15rem;
}
.r {
    color: red;
}
</style>
