|
@@ -0,0 +1,147 @@
|
|
|
+<template>
|
|
|
+ <div class="time-step-select">
|
|
|
+ <div class="left-icon" @click="handleLeft"></div>
|
|
|
+ <div class="center-box">
|
|
|
+ <div
|
|
|
+ class="center-content line-box-id-only"
|
|
|
+ :style="{ transform: `translateX(${-translateXNum}px)` }"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ class="center-box-item line-box-item-id-only"
|
|
|
+ v-for="(item, index) in timeList"
|
|
|
+ @click="handleSelect(item)"
|
|
|
+ :class="{ hasActive: checkValue == item.value }"
|
|
|
+ >
|
|
|
+ <div class="box-icon"></div>
|
|
|
+ <div class="title">{{ item.name }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="right-icon" @click="handleRight"></div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import { ref, defineProps, computed, defineEmits } from "vue";
|
|
|
+const translateXNum = ref(0);
|
|
|
+const props = defineProps({
|
|
|
+ timeList: {
|
|
|
+ type: Array,
|
|
|
+ default: () => [],
|
|
|
+ },
|
|
|
+});
|
|
|
+const emit = defineEmits("update:modelValue");
|
|
|
+const checkValue = ref();
|
|
|
+const handleSelect = (item) => {
|
|
|
+ checkValue.value = item.value;
|
|
|
+};
|
|
|
+
|
|
|
+const handleLeft = () => {
|
|
|
+ const numWidth =
|
|
|
+ document.getElementsByClassName("line-box-item-id-only")[0].clientWidth;
|
|
|
+ if (translateXNum.value <= 0) {
|
|
|
+ translateXNum.value = 0;
|
|
|
+ } else {
|
|
|
+ translateXNum.value -= numWidth;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const handleRight = () => {
|
|
|
+ const boxWidth =
|
|
|
+ document.getElementsByClassName("line-box-id-only")[0].scrollWidth;
|
|
|
+ const boxShowWidth =
|
|
|
+ document.getElementsByClassName("line-box-id-only")[0].clientWidth;
|
|
|
+ const numWidth = document.getElementsByClassName("line-box-item-id-only")[0]
|
|
|
+ .clientWidth;
|
|
|
+ console.log(document.getElementsByClassName("line-box-id-only"));
|
|
|
+ if (translateXNum.value >= boxWidth - boxShowWidth) {
|
|
|
+ // translateXNum.value = boxWidth - numWidth;
|
|
|
+ } else {
|
|
|
+ translateXNum.value += numWidth;
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.time-step-select {
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ margin-bottom: 25px;
|
|
|
+ background-color: #042f74bb;
|
|
|
+ padding: 10px 20px;
|
|
|
+ border-radius: 5px;
|
|
|
+ .left-icon,
|
|
|
+ .right-icon {
|
|
|
+ width: 22px;
|
|
|
+ height: 30px;
|
|
|
+ }
|
|
|
+ .left-icon {
|
|
|
+ cursor: pointer;
|
|
|
+
|
|
|
+ background-image: url("../../assets/img/箭头1.png");
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .center-box {
|
|
|
+ width: calc(100% - 80px);
|
|
|
+ overflow: hidden;
|
|
|
+ background-image: url("../../../assets/img/时间轴.png");
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+ .center-content {
|
|
|
+ display: flex;
|
|
|
+ width: 100%;
|
|
|
+ transition: transform 0.4s;
|
|
|
+ }
|
|
|
+ .center-box-item {
|
|
|
+ position: relative;
|
|
|
+ width: 70px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ flex-grow: 0;
|
|
|
+ padding-bottom: 20px;
|
|
|
+ cursor: pointer;
|
|
|
+
|
|
|
+ .box-icon {
|
|
|
+ position: absolute;
|
|
|
+ top: 3px;
|
|
|
+ left: 50%;
|
|
|
+ transform: translateX(-50%);
|
|
|
+ width: 15px;
|
|
|
+ height: 15px;
|
|
|
+ background-image: url("../../assets/img/普通点.png");
|
|
|
+ background-size: 100% 100%;
|
|
|
+ z-index: 9;
|
|
|
+ }
|
|
|
+ &.hasActive {
|
|
|
+ // background-image: url('../../assets/images/0211/时间轴选中节点.png');
|
|
|
+ // background-repeat: no-repeat;
|
|
|
+ // background-size: 100% 100%;
|
|
|
+ .box-icon {
|
|
|
+ top: -5px;
|
|
|
+ width: 30px;
|
|
|
+ height: 30px;
|
|
|
+ background-image: url("../../assets/img/选中点.png");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ &::after {
|
|
|
+ content: "";
|
|
|
+ position: absolute;
|
|
|
+ top: 10px;
|
|
|
+ width: 100%;
|
|
|
+ border-bottom: 1px dashed #cccccc6c;
|
|
|
+ }
|
|
|
+ .title {
|
|
|
+ position: relative;
|
|
|
+ top: 20px;
|
|
|
+ text-align: center;
|
|
|
+ font-family: DIN;
|
|
|
+ font-weight: 500;
|
|
|
+ font-size: 16px;
|
|
|
+ color: #9daac7;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .right-icon {
|
|
|
+ cursor: pointer;
|
|
|
+ background-image: url("../../assets/img/箭头2.png");
|
|
|
+ background-size: 100% 100%;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|