瀏覽代碼

fix: 日期

lxf 20 分鐘之前
父節點
當前提交
4042d81d9a
共有 1 個文件被更改,包括 155 次插入 和 22 次删除
  1. 155 22
      src/components/popup/restorePlantingPopup.vue

+ 155 - 22
src/components/popup/restorePlantingPopup.vue

@@ -36,19 +36,23 @@
                     <img :src="sampleImage" alt="" />
                 </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"
-                    teleported
-                    popper-class="restore-planting-date-popper"
-                    style="width: 100%"
-                />
+                <div class="restore-planting-popup__date-wrap">
+                    <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"
+                        :prefix-icon="null"
+                        :disabled-date="disabledFutureDate"
+                        teleported
+                        popper-class="restore-planting-date-popper"
+                        style="width: 100%"
+                    />
+                </div>
             </div>
 
             <!-- 问题二:物候期选择 -->
@@ -240,7 +244,14 @@ const formatToday = () => {
     return `${y}-${m}-${day}`;
 };
 
-/** 日期选择器 YYYY.MM.DD → 接口 YYYY-MM-DD */
+/** 只能选今天及以前:返回 true 表示禁用(未来日期) */
+function disabledFutureDate(date) {
+    const endOfToday = new Date();
+    endOfToday.setHours(23, 59, 59, 999);
+    return date.getTime() > endOfToday.getTime();
+}
+
+/** 日期选择器值统一为 YYYY-MM-DD;兼容旧草稿里的 YYYY.MM.DD */
 const toApiDate = (value) => (value ? String(value).replace(/\./g, "-") : "");
 
 /** 拼接 CDN 图片地址 */
@@ -661,28 +672,58 @@ linear-gradient(180deg, rgba(255, 212, 137, 0.36) 0%, rgba(255, 212, 137, 0) 12%
         font-size: 10px;
     }
 
-    &__date-picker {
+    &__date-wrap {
         width: 100%;
 
+        // 从原生 wrap 穿透:class 挂在 el-date-picker 根上时,子选择器可能匹配不到
+        :deep(.el-date-editor),
+        :deep(.restore-planting-popup__date-picker) {
+            width: 100% !important;
+            height: 41px;
+        }
+
         :deep(.el-input__wrapper) {
-            height: 40px;
-            border-radius: 8px;
-            box-shadow: none !important;
-            background: #fff;
+            min-height: 41px;
+            border-radius: 10px;
+            box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset !important;
+            background: rgba(255, 255, 255, 0.04) !important;
+            background-color: rgba(255, 255, 255, 0.04) !important;
             padding: 0 12px;
+
+            &:hover {
+                box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset !important;
+            }
+
+            &.is-focused {
+                box-shadow: 0 0 0 1px rgba(255, 212, 137, 0.45) inset !important;
+            }
         }
 
         :deep(.el-input__inner) {
             font-size: 14px;
-            color: #333;
+            color: rgba(255, 255, 255, 0.9) !important;
+            -webkit-text-fill-color: rgba(255, 255, 255, 0.9);
+        }
+
+        :deep(.el-input__inner::placeholder) {
+            color: rgba(255, 255, 255, 0.35) !important;
+            -webkit-text-fill-color: rgba(255, 255, 255, 0.35);
         }
 
         :deep(.el-input__prefix),
-        :deep(.el-input__suffix) {
-            color: rgba(0, 0, 0, 0.35);
+        :deep(.el-input__suffix),
+        :deep(.el-input__icon),
+        :deep(.el-range__icon),
+        :deep(.el-input__prefix-inner),
+        :deep(.el-input__suffix-inner) {
+            color: rgba(255, 255, 255, 0.45) !important;
         }
     }
 
+    &__date-picker {
+        width: 100%;
+    }
+
     &__actions {
         margin-top: 12px;
         display: flex;
@@ -754,8 +795,100 @@ linear-gradient(180deg, rgba(255, 212, 137, 0.36) 0%, rgba(255, 212, 137, 0) 12%
 
 <!-- 日期面板 / 图片预览 / Message teleport 到 body,需高于弹窗 z-index: 20000 -->
 <style lang="scss">
+/* van-popup teleport 后 scoped 偶发打不穿 EP 输入框,这里再兜一层 */
+.restore-planting-popup__date-wrap {
+    .el-date-editor,
+    .restore-planting-popup__date-picker {
+        width: 100% !important;
+        height: 41px;
+    }
+
+    .el-input__wrapper {
+        min-height: 41px;
+        border-radius: 10px;
+        box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset !important;
+        background: rgba(255, 255, 255, 0.04) !important;
+        background-color: rgba(255, 255, 255, 0.04) !important;
+        padding: 0 12px;
+
+        &:hover {
+            box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset !important;
+        }
+
+        &.is-focused {
+            box-shadow: 0 0 0 1px rgba(255, 212, 137, 0.45) inset !important;
+        }
+    }
+
+    .el-input__inner {
+        font-size: 14px;
+        color: rgba(255, 255, 255, 0.9) !important;
+        -webkit-text-fill-color: rgba(255, 255, 255, 0.9);
+
+        &::placeholder {
+            color: rgba(255, 255, 255, 0.35) !important;
+            -webkit-text-fill-color: rgba(255, 255, 255, 0.35);
+        }
+    }
+
+    .el-input__prefix,
+    .el-input__suffix,
+    .el-input__icon {
+        color: rgba(255, 255, 255, 0.45) !important;
+    }
+}
+
 .restore-planting-date-popper {
     z-index: 30000 !important;
+    background: #1c1c1c !important;
+    border: 1px solid rgba(255, 255, 255, 0.12) !important;
+    border-radius: 10px !important;
+
+    .el-picker-panel,
+    .el-date-picker,
+    .el-picker-panel__body-wrapper,
+    .el-date-table th,
+    .el-picker-panel__icon-btn {
+        background: #1c1c1c;
+        color: rgba(255, 255, 255, 0.85);
+        border-color: rgba(255, 255, 255, 0.08);
+    }
+
+    .el-date-picker__header-label,
+    .el-picker-panel__icon-btn {
+        color: rgba(255, 255, 255, 0.85);
+
+        &:hover {
+            color: #e8c56a;
+        }
+    }
+
+    .el-date-table td .el-date-table-cell__text {
+        color: rgba(255, 255, 255, 0.85);
+    }
+
+    .el-date-table td.available:hover .el-date-table-cell__text,
+    .el-date-table td.current:not(.disabled) .el-date-table-cell__text {
+        background: rgba(232, 197, 106, 0.9);
+        color: #1a1208;
+    }
+
+    .el-date-table td.today .el-date-table-cell__text {
+        color: #e8c56a;
+    }
+
+    .el-date-table td.disabled .el-date-table-cell {
+        background-color: #171717;
+    }
+
+    .el-date-table td.disabled .el-date-table-cell__text {
+        color: rgba(255, 255, 255, 0.25);
+    }
+
+    .el-popper__arrow::before {
+        background: #1c1c1c !important;
+        border: 1px solid rgba(255, 255, 255, 0.12) !important;
+    }
 }
 
 .PhotoSlider__Wrapper {