WebApp【公共组件库】@前端(For Git Submodule)
‘chensiAb’
7 days ago a44eddf956e7042b64428044f057c76ddf2ac791
layout/numerical/CNumerical.vue
@@ -7,11 +7,23 @@
    <view class="c-numerical at-row at-row--wrap">
        <view
            class="at-col"
            v-for="(item,index) in values"
            v-for="(item,index) in values2"
            :key="index"
            :class="'at-col-' + valueFlex[index]"
            :class="'at-col-' + valueFlex[index] + ' ' + (!!item.onClick?'on-clickable':'')"
            @tap="evt => item.onClick && item.onClick(item)"
        >
            <view class="c-numerical-value">{{item.value}}</view>
            <view
                class="c-numerical-value"
                :class="item.textType?('m-text-'+item.textType):''"
            >
                <text class="c-numerical-interger">{{item.integer}}</text>
                <text
                    class="c-numerical-decimal"
                    :class="item.integer.length>4?'small':''"
                    v-if="item.decimal.length>0"
                >.{{item.decimal}}</text>
                <text class="c-numerical-more">&#187;</text>
            </view>
            <view class="c-numerical-title">{{item.title}}</view>
        </view>
    </view>
@@ -26,19 +38,36 @@
    name: 'CNumerical',
    components: {},
    props: {
        values: Array,
        // 数值集合,格式为:[{title, value, textType, onClick}]
        values: {
            type: Array,
            default: () => [],
        },
    },
    computed: {
        values2() {
            return (
                this.values.map(item => ({
                    ...item,
                    integer: (item.value + '').split('.')[0] || '',
                    decimal: (item.value + '').split('.')[1] || '',
                })) || []
            );
        },
        valueFlex() {
            return this.values.map((item, index) => {
                const surplus = this.values.length % 3;
                if (surplus === 0) {
                    return 4;
                } else if (surplus === 1) {
                    if (index === this.values.length - 1) {
                    if (this.values.length === 1) {
                        return 12;
                    } else {
                        return 4;
                        if (index >= this.values.length - 4) {
                            return 6;
                        } else {
                            return 4;
                        }
                    }
                } else if (surplus === 2) {
                    if (index >= this.values.length - 2) {