| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433 |
- <template>
- <popup
- v-model:show="showValue"
- round
- teleport="body"
- class="restore-planting-popup"
- :close-on-click-overlay="true"
- >
- <div class="popup-content">
- <img
- class="restore-planting-popup__decor"
- src="@/assets/img/agricultural/question.png"
- alt=""
- />
- <div class="restore-planting-popup__header">
- <div class="restore-planting-popup__title">
- <div>{{ t("agriFile.restoreFillQuestions") }}</div>
- <div>{{ t("agriFile.restorePlantingService") }}</div>
- </div>
- </div>
- <!-- 问题一:选择时间 -->
- <div v-if="questionType === 'time'" class="restore-planting-popup__card">
- <div class="restore-planting-popup__question">
- <template v-if="highlightWord && questionText.includes(highlightWord)">
- <span>{{ questionText.split(highlightWord)[0] }}</span>
- <span class="restore-planting-popup__keyword">{{ highlightWord }}</span>
- <span>{{ questionText.split(highlightWord).slice(1).join(highlightWord) }}</span>
- </template>
- <template v-else>{{ questionText }}</template>
- </div>
- <div class="restore-planting-popup__hint">{{ hintText }}</div>
- <div class="restore-planting-popup__photo">
- <img :src="sampleImage" alt="" />
- <!-- <div class="restore-planting-popup__bbox">
- <span>{{ stageTag }}</span>
- </div>
- <div class="restore-planting-popup__detect">{{ detectText }}</div> -->
- </div>
- <el-date-picker
- v-model="selectedDate"
- class="restore-planting-popup__date-picker"
- type="date"
- format="YYYY.MM.DD"
- value-format="YYYY.MM.DD"
- :placeholder="t('agriFile.selectTime')"
- :editable="false"
- :clearable="false"
- style="width: 100%"
- />
- </div>
- <!-- 问题二:物候期选择 -->
- <div v-else class="restore-planting-popup__card">
- <div class="restore-planting-popup__question">
- <template v-if="phenologyHighlight && phenologyQuestion.includes(phenologyHighlight)">
- <span>{{ phenologyQuestion.split(phenologyHighlight)[0] }}</span>
- <span class="restore-planting-popup__keyword">{{ phenologyHighlight }}</span>
- <span>{{ phenologyQuestion.split(phenologyHighlight).slice(1).join(phenologyHighlight) }}</span>
- </template>
- <template v-else>{{ phenologyQuestion }}</template>
- </div>
- <div class="restore-planting-popup__photo restore-planting-popup__photo--guide">
- <img :src="phenologyImage" alt="" />
- <div class="restore-planting-popup__guide-btn" @click="handleViewGuide">
- {{ t("agriFile.viewPatrolGuide") }}
- </div>
- </div>
- <div class="restore-planting-popup__options">
- <div
- v-for="item in phenologyOptions"
- :key="item.value"
- class="restore-planting-popup__option"
- :class="{ active: phenologyAnswer === item.value }"
- @click="phenologyAnswer = item.value"
- >
- <span>{{ item.label }}</span>
- <span v-if="phenologyAnswer === item.value" class="restore-planting-popup__option-check">
- <el-icon><Check /></el-icon>
- </span>
- </div>
- </div>
- </div>
- <div class="restore-planting-popup__actions">
- <div class="restore-planting-popup__btn restore-planting-popup__btn--ghost" @click="handleChangeQuestion">
- {{ t("agriFile.changeQuestion") }}
- </div>
- <div class="restore-planting-popup__btn restore-planting-popup__btn--primary" @click="handleConfirm">
- {{ questionType === 'time' ? t("agriFile.confirmNow") : t("agriFile.submitInfo") }}
- </div>
- </div>
- </div>
- </popup>
- </template>
- <script setup>
- import { computed, ref, watch } from "vue";
- import { Popup } from "vant";
- import { Check } from "@element-plus/icons-vue";
- import { useI18n } from "@/i18n";
- const { t } = useI18n();
- const props = defineProps({
- show: {
- type: Boolean,
- default: false,
- },
- questionText: {
- type: String,
- default: "还记得农场的 “来梢” 的时间吗?",
- },
- highlightWord: {
- type: String,
- default: "来梢",
- },
- hintText: {
- type: String,
- default: "时间误差 5-7 天无需担心,系统将结合作物生长模拟模型自动校准",
- },
- sampleImage: {
- type: String,
- default: require("@/assets/img/agricultural/baidian.png"),
- },
- stageTag: {
- type: String,
- default: "白点",
- },
- detectText: {
- type: String,
- default: "生育期检测:当前检测到白点期",
- },
- phenologyQuestion: {
- type: String,
- default: "您的农场是否进入到 某某物候期 ?",
- },
- phenologyHighlight: {
- type: String,
- default: "某某物候期",
- },
- phenologyImage: {
- type: String,
- default: require("@/assets/img/common/sd-1.jpg"),
- },
- });
- const emit = defineEmits(["update:show", "changeQuestion", "confirm", "viewGuide"]);
- const showValue = computed({
- get: () => props.show,
- set: (val) => emit("update:show", val),
- });
- const questionType = ref("time"); // time | phenology
- const selectedDate = ref("");
- const phenologyAnswer = ref("reached");
- const phenologyOptions = computed(() => [
- { value: "not_reached", label: t("agriFile.notReached") },
- { value: "reached", label: t("agriFile.reached") },
- { value: "passed", label: t("agriFile.passed") },
- ]);
- watch(
- () => props.show,
- (visible) => {
- if (visible) {
- questionType.value = "time";
- selectedDate.value = "";
- phenologyAnswer.value = "reached";
- }
- }
- );
- const handleChangeQuestion = () => {
- questionType.value = questionType.value === "time" ? "phenology" : "time";
- emit("changeQuestion", questionType.value);
- };
- const handleViewGuide = () => {
- emit("viewGuide");
- };
- const handleConfirm = () => {
- emit("confirm", {
- type: questionType.value,
- date: selectedDate.value,
- phenologyAnswer: phenologyAnswer.value,
- });
- showValue.value = false;
- };
- </script>
- <style scoped lang="scss">
- .restore-planting-popup {
- width: 86%;
- padding: 18px 14px 16px;
- box-sizing: border-box;
- background: linear-gradient(180deg, #d7ecff 0%, #ffffff 28%);
- overflow: visible;
-
- &__header {
- // position: relative;
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- // padding-right: 72px;
- // min-height: 64px;
- }
- &__title {
- font-size: 22px;
- line-height: 25px;
- color: #111;
- div {
- font-family: "PangMenZhengDao";
- }
- }
- .popup-content {
- position: relative;
- }
- &__decor {
- position: absolute;
- top: -8px;
- right: -4px;
- width: 78px;
- height: 78px;
- object-fit: contain;
- pointer-events: none;
- }
- &__card {
- margin-top: 12px;
- padding: 10px 12px 12px;
- border-radius: 12px;
- background: #eaf5ff;
- box-sizing: border-box;
- position: relative;
- z-index: 2;
- }
- &__question {
- font-size: 16px;
- line-height: 24px;
- color: #252525;
- font-weight: 500;
- }
- &__keyword {
- color: #2199f8;
- }
- &__hint {
- margin-top: 4px;
- font-size: 12px;
- line-height: 16px;
- color: #9E9E9E;
- }
- &__photo {
- position: relative;
- margin: 12px 0;
- border-radius: 8px;
- overflow: hidden;
- background: #dfeaf5;
- img {
- display: block;
- width: 100%;
- height: 148px;
- object-fit: cover;
- }
- &--guide img {
- height: 132px;
- }
- }
- &__bbox {
- position: absolute;
- top: 36%;
- left: 50%;
- width: 72px;
- height: 72px;
- transform: translate(-50%, -50%);
- border: 2px solid #2199f8;
- box-sizing: border-box;
- pointer-events: none;
- span {
- position: absolute;
- top: -18px;
- left: 50%;
- transform: translateX(-50%);
- padding: 0 4px;
- font-size: 12px;
- line-height: 16px;
- color: #2199f8;
- white-space: nowrap;
- background: rgba(255, 255, 255, 0.85);
- }
- }
- &__detect {
- position: absolute;
- left: 0;
- right: 0;
- bottom: 0;
- padding: 8px 10px;
- background: rgba(0, 0, 0, 0.55);
- color: #fff;
- font-size: 12px;
- line-height: 18px;
- }
- &__guide-btn {
- position: absolute;
- top: 8px;
- right: 8px;
- height: 28px;
- padding: 0 10px;
- border-radius: 14px;
- background: rgba(0, 0, 0, 0.55);
- color: #fff;
- font-size: 12px;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- &__options {
- margin-top: 12px;
- display: flex;
- gap: 8px;
- }
- &__option {
- position: relative;
- flex: 1;
- height: 36px;
- border-radius: 8px;
- background: #fff;
- border: 1px solid transparent;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 13px;
- color: #333;
- box-sizing: border-box;
- &.active {
- border-color: #2199f8;
- color: #2199f8;
- }
- }
- &__option-check {
- position: absolute;
- top: 0;
- right: 0;
- width: 16px;
- height: 16px;
- border-radius: 0 6px 0 6px;
- background: #2199f8;
- color: #fff;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 10px;
- }
- &__date-picker {
- width: 100%;
- :deep(.el-input__wrapper) {
- height: 40px;
- border-radius: 8px;
- box-shadow: none !important;
- background: #fff;
- padding: 0 12px;
- }
- :deep(.el-input__inner) {
- font-size: 14px;
- color: #333;
- }
- :deep(.el-input__prefix),
- :deep(.el-input__suffix) {
- color: rgba(0, 0, 0, 0.35);
- }
- }
- &__actions {
- margin-top: 12px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 12px;
- }
- &__btn {
- height: 40px;
- line-height: 40px;
- padding: 0 30px;
- border-radius: 20px;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 16px;
- font-weight: 500;
- box-sizing: border-box;
- &--ghost {
- background: rgba(236, 236, 236, 0.5);
- color: rgba(0, 0, 0, 0.6);
- }
- &--primary {
- background: linear-gradient(180deg, #76C3FF 0%, #2199F8 100%);
- color: #fff;
- }
- }
- }
- </style>
|