<template>
    <div class="service-price">
        <div class="service-form">
            <div class="service-form-title">服务报价</div>
            <el-form ref="formRef" :model="form" label-width="86px">
                <el-form-item label="人工服务" prop="manual" class="input-unit">
                    <el-input v-if="isEdit" v-model.number="form.manual" placeholder="请输入数字">
                        <template #append>元/亩</template>
                    </el-input>
                    <div v-else class="service-form-value">12<span class="unit">元/亩</span></div>
                </el-form-item>
                <el-form-item label="无人机服务" prop="drone" class="input-unit">
                    <el-input v-if="isEdit" v-model.number="form.drone" placeholder="请输入数字">
                        <template #append>元/亩</template>
                    </el-input>
                    <div v-else class="service-form-value">120<span class="unit">元/亩</span></div>
                </el-form-item>
            </el-form>
        </div>
        <div class="page-action" v-if="isEdit">
            <div class="btn-item cancel" @click="isEdit = false">取消</div>
            <div class="btn-right">
                <div class="btn-item primary" @click="isEdit = false">保存服务报价</div>
            </div>
        </div>
        <div class="page-action" v-else>
            <div class="btn-item primary center-btn" @click="isEdit = true">编辑服务报价</div>
        </div>
    </div>
</template>

<script setup>
import { ref, reactive } from "vue";

// 表单模型与选项
const formRef = ref();
const form = reactive({
    manual: "",
    drone: "",
});

const isEdit = ref(false);
</script>

<style lang="scss" scoped>
.service-price {
    width: 100%;
    height: 100%;

    .service-form {
        margin: 12px;
        padding: 12px 12px 2px 12px;
        background: #ffffff;
        border-radius: 8px;
        .service-form-title {
            font-size: 16px;
            color: #000000;
            margin-bottom: 10px;
        }
        .service-form-value {
            border: 1px solid rgba(24, 24, 24, 0.1);
            border-radius: 5px;
            padding: 0 10px;
            width: 100%;
            height: 30px;
            line-height: 30px;
            .unit {
                color: rgba(0, 0, 0, 0.3);
                padding-left: 8px;
            }
        }
        ::v-deep {
            .el-form-item__label {
                color: rgba(0, 0, 0, 0.4);
                font-size: 14px;
            }
            .el-form-item--default {
                margin-bottom: 16px;
            }
            .el-input__wrapper {
                box-shadow: none;
            }
            .el-input-group__append {
                padding: 0 10px;
                background: none;
                box-shadow: none;
                color: rgba(0, 0, 0, 0.3);
            }
            .input-unit {
                .el-input {
                    border: 1px solid rgba(24, 24, 24, 0.3);
                    border-radius: 5px;
                    height: 30px;
                    box-sizing: border-box;
                }
                .el-input__wrapper {
                    padding: 0 2px 0 10px;
                    height: 28px;
                    line-height: 28px;
                    min-height: 28px;
                }
                .el-input__inner {
                    --el-input-inner-height: 28px;
                    height: 28px;
                    line-height: 28px;
                    min-height: 28px;
                    color: #000000;
                    // --el-input-placeholder-color: rgba(33, 153, 248, 0.43);
                }
            }
        }
    }

    .page-action {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 12px 12px;
        background: #fff;
        box-shadow: 2px 2px 4.5px rgba(0, 0, 0, 0.4);
        display: flex;
        justify-content: space-between;
        align-items: center;
        .btn-item {
            height: 40px;
            line-height: 41px;
            border-radius: 20px;
            width: fit-content;
            padding: 0 20px;
            color: #666666;
            font-size: 14px;
            &.del {
                color: #ff943d;
                background: rgba(255, 148, 61, 0.1);
            }
            &.cancel {
                border: 1px solid rgba(153, 153, 153, 0.5);
            }
            &.primary {
                color: #fff;
                background: linear-gradient(#76c3ff, #2199f8);
            }
        }
        .center-btn {
            margin: 0 auto;
        }
        .btn-right {
            display: flex;
            gap: 10px;
        }
    }
}
</style>
