<template>
    <div class="work-item last-enter">
        <div class="work-line">
            <div class="line-box">
                <div class="line-dotted">
                    <div class="dotted-inset"></div>
                </div>
            </div>
        </div>
        <div class="work-info">
            <img class="done-img" src="@/assets/img/gallery/done.png" />
            <div class="card-item-title"><span class="dotted"></span>复核对比</div>
            <div class="recheck-content">
                <div class="sub-title">报价处方</div>
                <div class="over-img">
                    <!-- 图片列表 -->
                    <div class="carousel-wrapper" :style="carouselStyle">
                        <photo-provider :photo-closable="true">
                            <photo-consumer
                                class="carousel-item"
                                v-for="(photo, index) in treeImgList"
                                :key="index"
                                :src="base_img_url2 + photo.filename + resize"
                            >
                                <div class="img-two">
                                    <img :id="'img1' + index" :src="base_img_url2 + photo.filename + resize" />
                                    <img :id="'img2' + index" :src="base_img_url2 + photo.filename + resize" />
                                    <div class="tag tag-l">执行前</div>
                                    <div class="tag tag-r">执行后</div>
                                </div>
                            </photo-consumer>
                        </photo-provider>
                    </div>

                    <!-- 左右箭头 -->
                    <div @click="prev" class="arrow left-arrow">
                        <el-icon color="#F0D09C" size="20"><ArrowLeftBold /></el-icon>
                    </div>
                    <div @click="next" class="arrow right-arrow">
                        <el-icon color="#F0D09C" size="20"><ArrowRightBold /></el-icon>
                    </div>
                </div>

                <div class="compare-b">
                    <div class="sub-title">指标动态</div>
                    <div class="compare-chart">
                        <!-- <chart
                                        :key="'compare' + workItem.id"
                                        :indexName="workItem.indexName"
                                        :type="workItem.status !== 1 ? 'normal' : 'feature'"
                                        :chartData="workItem.indexChart"
                                    ></chart> -->

                        <chart :key="1" type="feature" :chartJson="indexJson"></chart>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, computed } from "vue";
import { base_img_url2, resize } from "@/api/config";
import chart from "./chart.vue";
const props = defineProps({
    progress: {
        type: Number,
        required: false,
    },
    indexJson: {},
});

const treeImgList = ref([
    {
        filename:
            "b68f2665-fd4c-4f54-a875-56ba882c85a1/cf9512f7-c55f-4cdc-ac68-3e58814fc378/DJI_202501201000_001_cf9512f7-c55f-4cdc-ac68-3e58814fc378/DJI_20250120100535_0012_Z_code-ws0y1mmqk4sp.jpeg",
    },
    {
        filename:
            "b68f2665-fd4c-4f54-a875-56ba882c85a1/cf9512f7-c55f-4cdc-ac68-3e58814fc378/DJI_202501201000_001_cf9512f7-c55f-4cdc-ac68-3e58814fc378/DJI_20250120100514_0011_Z_code-ws0y1mmqz3k2.jpeg",
    },
    {
        filename:
            "b68f2665-fd4c-4f54-a875-56ba882c85a1/cf9512f7-c55f-4cdc-ac68-3e58814fc378/DJI_202501201000_001_cf9512f7-c55f-4cdc-ac68-3e58814fc378/DJI_20250120100348_0006_Z_code-ws0y1mmnxuqb.jpeg",
    },
    {
        filename:
            "b68f2665-fd4c-4f54-a875-56ba882c85a1/cf9512f7-c55f-4cdc-ac68-3e58814fc378/DJI_202501201000_001_cf9512f7-c55f-4cdc-ac68-3e58814fc378/DJI_20250120100217_0001_Z_code-ws0y1mkyefed.jpeg",
    },
]);

const updateImagePosition = () => {
    carouselStyle.value.transform = `translateX(-${currentIndex.value * 100}%)`;
};
const currentIndex = ref(0);
// 计算轮播图样式
const carouselStyle = computed(() => {
    return {
        transform: `translateX(-${currentIndex.value * 100}%)`,
    };
});
// 下一张图片
const next = () => {
    // 图片总数
    const totalImages = treeImgList.value.length;
    currentIndex.value = (currentIndex.value + 1) % totalImages;
    updateImagePosition();
};

// 上一张图片
const prev = () => {
    // 图片总数
    const totalImages = treeImgList.value.length;
    currentIndex.value = (currentIndex.value - 1 + totalImages) % totalImages;
    updateImagePosition();
};
</script>

<style lang="scss" scoped>
@import "./boxClass.scss";

.recheck-content {
    padding-right: 10px;
    .sub-title {
        color: #2199f8;
    }
    .over-img {
        margin-top: 8px;
        width: 100%;
        overflow: hidden;
        transition: transform 0.5s ease;
        display: flex;
        position: relative;
        .carousel-container {
            flex: none;
            // transform: translateX(-100%);
            transition: transform 0.5s ease;
            &.hideMap {
                flex: none;
                transform: translateX(0);
                // transform: translateX(-100%);
            }
            position: relative;
            width: 100%;
            overflow: hidden;
            margin: 0 auto;
        }

        .carousel-wrapper {
            display: flex;
            transition: transform 0.5s ease;
            width: 100%;
            height: 100%;
        }

        .carousel-item {
            min-width: 100%;
            flex-shrink: 0;
            width: 100%;
            pointer-events: auto;
            position: relative;
            .img-two {
                display: flex;
                position: relative;
                .tag {
                    position: absolute;
                    bottom: 0;
                    background: rgba(0, 0, 0, 0.6);
                    color: #fff;
                    font-size: 10px;
                    padding: 2px 10px;
                }
                .tag-l {
                    left: 0;
                    border-radius: 0 5px 0 5px;
                }
                .tag-r {
                    right: 0;
                    border-radius: 5px 0 0 5px;
                }
            }
        }

        .carousel-item img {
            width: 50%;
            display: block;
        }

        .overlay {
            position: absolute;
            top: 0;
            right: 0;
            background: rgba(255, 255, 255, 0.3);
            width: 100%;
            height: 100%;
            transition: width 0.5s ease-in-out;
        }

        .percentage {
            position: absolute;
            bottom: 0;
            width: 100%;
        }

        .arrow {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            background: rgba(0, 0, 0, 0.5);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }

        .left-arrow {
            left: 16px;
        }

        .right-arrow {
            right: 16px;
        }
        ::v-deep {
            .el-carousel__arrow {
                background: rgba(0, 0, 0, 0.5);
            }
            .PhotoConsumer {
                width: 100%;
                height: 100%;
                img {
                    width: calc(50% - 4px);
                    height: 100%;
                    // height: 300px;
                    // max-height: 500px;
                    object-fit: scale-down;
                    border-radius: 5px;
                }
                img + img {
                    padding-left: 8px;
                }
            }
        }
    }
    .compare-b {
        padding: 12px 0 8px 0;
        .compare-chart {
            margin-top: 8px;
            background: #eaf4ff;
            border-radius: 5px;
            padding: 4px 0 8px 0;
            ::v-deep {
                .card-chart {
                    height: 160px;
                }
            }
        }
    }
}
</style>
