transform-modal.vue 7.38 KB
<template>
    <section>
        <div class="translation">
            <span class="title" v-text="$t('translation')" />
            <div class="item" v-for="([key], index) in Object.entries(translationItems)" :key="index">
                <span v-text="$t(`${key}Axis`)" />
                <span class="inputNumber">
                    <el-input-number
                        v-model.number="translationItems[key]"
                        :precision="2"
                        :step="0.1"
                        controls-position="right"
                        @change="
                            (currentValue, oldValue) => {
                                transformFromModal(currentValue, oldValue, key, 'translate');
                            }
                        "
                        class="el-input-number-unit"
                        data-unit="mm"
                        :max="500"
                        :min="-500"
                    />
                </span>
            </div>
            <!--  <span class="reset" @click="onReset('translate')" v-text="$t('reset')" /> -->
        </div>
        <div class="rotation">
            <span class="title" v-text="$t('rotation')" />
            <div class="item" v-for="([key], index) in Object.entries(rotationItems)" :key="index">
                <span v-text="$t(`${key}Axis`)" />
                <span class="rotate-constant">
                    <span class="rotate45" @click="onRotate(key, 45)">+45°</span>
                    <span class="rotate45" @click="onRotate(key, -45)">-45°</span>
                </span>
                <span class="inputNumber">
                    <el-input-number
                        v-model.number="rotationItems[key]"
                        :precision="0"
                        controls-position="right"
                        :step="1"
                        @change="
                            (currentValue, oldValue) => {
                                transformFromModal(currentValue, oldValue, key, 'rotate');
                            }
                        "
                        class="el-input-number-unit"
                        data-unit="°"
                    />
                </span>
            </div>
            <!--
            <div class="checkbox">
                <el-checkbox v-model="rotateAroundCenterChecked" :label="$t('rotateAroundCenter')" />
                <el-checkbox v-model="sticktToBaseChecked" :label="$t('stickToBase')" />
            </div>
            -->
            <span class="button-big" @click="onReset('rotate')" v-text="$t('reset')" />
        </div>
    </section>
</template>

<script setup>
import { useTransformStore } from '@/views/stores/useTransformStore';
import { storeToRefs } from 'pinia';

const store = useTransformStore();
const { translationItems, rotationItems, sticktToBaseChecked, rotateAroundCenterChecked } = storeToRefs(store);
const { setReset, setRotate, transformFromModal } = store;

const onReset = (key) => {
    setReset(key);
};

const onRotate = (key, angle) => {
    setRotate(key, angle);
};
</script>
<style lang="less">
.translation,
.rotation {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;

    .title {
        margin: 0px;
        font-size: 14px;
        line-height: 22px;
        font-weight: 600;
        color: #333333;
    }
    .item {
        display: flex;
        flex-direction: row;
        -webkit-box-align: center;
        align-items: center;
        -webkit-box-pack: justify;
        justify-content: space-between;
        height: 34px;
        span {
            margin: 0px;
            font-size: 14px;
            line-height: 22px;
            font-weight: 500;
            color: #333333;
        }
        .inputNumber {
            width: fit-content;
            height: 34px;
            position: relative;
            box-sizing: content-box;
            border-radius: 4px;
            user-select: none;
            .el-input-number {
                width: 120px;
                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);
                .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;
            }
        }
    }
    span {
        &.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;
        }
        &.rotate-constant {
            display: flex;
            -webkit-box-pack: center;
            justify-content: center;
            -webkit-box-align: center;
            align-items: center;
            padding: 0px;
            .rotate45 {
                display: flex;
                -webkit-box-pack: center;
                justify-content: center;
                -webkit-box-align: center;
                align-items: center;
                padding: 0px;
                border: 1px solid rgb(205, 209, 213);
                background-color: rgb(255, 255, 255);
                border-radius: 8px;
                cursor: pointer;
                margin: 0px;
                font-size: 14px;
                line-height: 32px;
                height: 32px;
                width: 50px;
                margin-left: 5px;
                &:hover {
                    background-color: @color-button-hover-background;
                }
                &:active {
                    background-color: @color-button-active-background;
                }
            }
        }
    }
    .checkbox {
        display: flex;
        flex-direction: column;
        padding-top: 10px;
    }
}

.rotation {
    .el-input-number-unit[data-unit] {
        position: relative;
        --el-input-number-unit-offset-x: 53px !important;
    }
}

.el-input-number.is-controls-right .el-input-number__increase {
    border-left: unset !important;
    border-bottom: unset !important;

    .el-icon-arrow-up:before {
        content: '\E78F';
        font-size: 15px;
        color: #868686;
    }
}
.el-input-number.is-controls-right .el-input-number__decrease {
    border-left: unset !important;
    border-bottom: unset !important;

    .el-icon-arrow-down:before {
        content: '\E790';
        font-size: 15px;
        color: #868686;
    }
}
</style>