copymirror-modal.vue 4.62 KB
<template>
    <section class="copymirror">
        <div class="copy-types">
            <span
                :class="selecteditem === item.key ? 'item selected' : 'item'"
                v-for="item in items"
                :key="item.key"
                @click="onSelect(item.key)"
            >
                <img :src="item.image" />
                <div class="text" v-text="$t(item.key)" />
            </span>
        </div>
        <div class="duplicate">
            <span v-text="$t('duplicateNumber')" />
            <span class="inputNumber">
                <el-input-number
                    v-model.number="duplicateNumber"
                    :precision="0"
                    :step="1"
                    controls-position="right"
                    :max="50"
                    :min="1"
                />
            </span>
        </div>
        <span class="button-big" v-text="$t('apply')" @click="onApply" />
    </section>
</template>
<script setup>
import { useCopyMirrorStore } from '@/views/stores/funtional-toolbar/useCopyMirrorStore';
import { storeToRefs } from 'pinia';

const store = useCopyMirrorStore();
const { items, selecteditem, duplicateNumber } = storeToRefs(store);
const { setSelectedItem, apply } = store;

const onSelect = (key) => {
    setSelectedItem(key);
};
const onApply = () => {
    apply();
};
</script>
<style lang="less" scoped>
.copymirror {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
    .copy-types {
        display: flex;
        flex-direction: row;
        -webkit-box-pack: justify;
        justify-content: space-between;
        .item {
            box-sizing: border-box;
            display: flex;
            cursor: pointer;
            background-color: #ffffff;
            padding: 8px 11px;
            border: 1px solid #cdd1d5;
            border-radius: 8px;
            border-image: initial;
            display: flex;
            flex-direction: column;
            //width: 140px;
            img {
                width: 36px;
                height: 36px;
                margin: auto;
                display: block;
            }
            .text {
                width: max-content;
                padding-top: 5px;
                margin: 0px;
                font-size: 14px;
                line-height: 22px;
                font-weight: 500;
                color: #333333;
                margin: auto;
                display: block;
                font-weight: 600;
            }
            &.selected {
                background-color: @color-button-selected-background;
                border-color: @color-button-main-selected-border;
            }
            &:hover{
                background-color: @color-button-hover-background;
            }
        }
    }

    .duplicate {
        margin-top: 12px;
        .inputNumber {
            width: fit-content;
            height: 34px;
            position: relative;
            box-sizing: content-box;
            border-radius: 4px;
            user-select: none;
            :deep(.el-input-number) {
                width: 100%;
                height: 32px;
                display: inline-block;
                text-align: right;
                outline: none;
                border-radius: 4px;
                font-size: 14px;
                font-weight: 400;
                line-height: 22px;
                letter-spacing: -0.3px;
                border: 0px;
                color: rgb(51, 51, 51);
                margin-top: 12px;
                .el-input__wrapper {
                    background-color: rgb(246, 247, 248);
                    padding-left: 0 !important;
                }
            }
            .el-input-number-unit[data-unit] {
                position: relative;
                --el-input-number-unit-offset-x: 35px;
            }

            .el-input-number-unit[data-unit]::after {
                content: attr(data-unit);
                height: 100%;
                display: flex;
                align-items: center;
                position: absolute;
                top: 0;
                right: var(--el-input-number-unit-offset-x);
                color: #606266;
                font-size: 12px;
            }
        }
    }
    .button-big {
        display: flex;
        width: 100%;
        -webkit-box-pack: center;
        justify-content: center;
        -webkit-box-align: center;
        align-items: center;
        padding: 0px;
        height: 46px;
        border-radius: 8px;
        cursor: pointer;
        margin: 0px;
        font-size: 14px;
        line-height: 20px;
        font-weight: 600;
        margin-top: 12px;
    }
}
</style>