<template>
    <div class="formula-list">
        <!-- <div class="title">
            <slot></slot>
        </div> -->
        <!-- 计费参数 -->
        <div class="flex title">
            <div class="flex calculator-title">
                计算符
            </div>
            <div class="list-warp-parameter">
                <div v-for="item in getMpsParametersList" :key="item.key" :title="item.value" class="item" @click="choice(item)">
                    {{ item.value }}
                </div>
            </div>
        </div>
        <div class="list-warp">
            <div class="item-type">
                <div v-for="item in expenseType.EexpenseOne" :key="item.key" :title="item.value" class="item" :style="{ '--bg': bg ? bg : '#81d3f8' }"
                    @click="choice(item)">
                    {{ item.value }}
                </div>
            </div>
        </div>
        <div class="list-warp">
            <div class="item-symbol">
                <div v-for="item in expenseType.EexpenseTwo" :key="item.key" :title="item.value" class="item" :style="{ '--bg': bg ? bg : '#81d3f8' }"
                    @click="choice(item)">
                    {{ item.value }}
                </div>
            </div>
            <div class="item-number">
                <div v-for="item in expenseType.EexpenseThree" :key="item.key" :title="item.value" class="item" :style="{ '--bg': bg ? bg : '#81d3f8' }"
                    @click="choice(item)">
                    {{ item.value }}
                </div>
            </div>
        </div>
    </div>
</template>
<script lang="ts" setup>
import type { ListIitem } from '@/api/base/BaseDataModel';
import { EexpenseOject, EexpenseType } from '../types';
import { computed } from 'vue';
import { isArrayLength } from '@/utils/is';

const props = defineProps<{ expenseType: EexpenseOject, mpsParametersList: ListIitem[], bg?: string}>()
const emit = defineEmits(['choice'])
// 获取计费参数
const getMpsParametersList = computed<EexpenseType[]>(() => {
    if (isArrayLength(props.mpsParametersList)) {
        const list = props.mpsParametersList.map(item => ({ key: `{${item.value}}`, value: item.label }))
        return list
    }
    return []
})
// 选择符号
const choice = (params) => emit('choice',params)
</script>

<style lang="scss" scoped>
.formula-list {
    margin-top: 8px;
    .title {
        border-bottom: 1px solid #f2f2f2;
        font-size: 16px;
        font-weight: bold;
    }
    .calculator-title {
        flex-basis: 205px;
        align-items: center;
    }
    .list-warp-parameter {
        flex-basis: 720px;
        display: grid;
        width: 720px;
        margin-bottom: 15px;
        grid-row-gap: 15px;
        grid-column-gap: 15px;
        grid-template-columns: repeat(auto-fill, 105px);
        .item {
            background: #409eff;
            background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #409eff), color-stop(1, #3681cf));
            font-size: 14px;
            height: 32px;
            line-height: 32px;
            width: 105px;
            text-align: center;
            color: #fff;
            cursor: pointer;
            user-select: none;
        }
    }
    .list-warp {
        // display: flex;
        display: grid;
        // grid-template-columns: 200px 300px 300px;
        grid-template-columns: 360px 360px;
        justify-content: center;
        margin: 0 auto;
        margin-bottom: 15px;

        .item-type {
            display: grid;
            grid-row-gap: 15px;
            grid-column-gap: 15px;
            grid-auto-flow: column;
            // grid-template-columns: 85px 85px;
            // grid-template-rows: 32px 32px;
        }

        .item-symbol {
            display: grid;
            grid-row-gap: 15px;
            grid-column-gap: 15px;
            grid-template-columns: repeat(auto-fill, 105px);
        }

        .item-number {
            display: grid;
            grid-row-gap: 15px;
            grid-column-gap: 15px;
            grid-template-columns: repeat(auto-fill, 105px);
        }

        .item {
            // background-color: var(--bg);
            background: #006e62;
            background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #00544b), color-stop(1, #006e62));
            font-size: 16px;
            height: 32px;
            line-height: 32px;
            // min-width: 80px;
            width: 105px;
            text-align: center;
            color: #fff;
            cursor: pointer;
            user-select: none;

            &.active {
                background-color: #67c23a;
                color: #fff;
            }
        }
    }
}
</style>