Преглед изворни кода

fix: 图片展示原图限时

lxf пре 3 дана
родитељ
комит
0f225f3e68
2 измењених фајлова са 35 додато и 9 уклоњено
  1. 23 7
      src/views/old_mini/interaction/index.vue
  2. 12 2
      src/views/old_mini/interactionList/index.vue

+ 23 - 7
src/views/old_mini/interaction/index.vue

@@ -55,10 +55,17 @@
                     <div class="field-row" v-if="region.phenologyId">
                     <div class="field-row" v-if="region.phenologyId">
                         <div class="field-label">{{ getPhenologyLabel(crop, region.phenologyId) }}</div>
                         <div class="field-label">{{ getPhenologyLabel(crop, region.phenologyId) }}</div>
                         <div class="field-value">
                         <div class="field-value">
-                            <el-date-picker :editable="false" style="width: 100%" v-model="region.phenologyStartDate"
-                                class="date-picker" type="date" placeholder="选择时间" format="YYYY-MM-DD"
+                            <el-date-picker
+                                :editable="false"
+                                style="width: 100%"
+                                v-model="region.phenologyStartDate"
+                                class="date-picker"
+                                type="date"
+                                placeholder="选择时间"
+                                format="YYYY-MM-DD"
                                 value-format="YYYY-MM-DD"
                                 value-format="YYYY-MM-DD"
-                                :disabled-date="disabledFutureDate" />
+                                :disabled-date="(time) => disabledFutureDate(time, crop, region)"
+                            />
                         </div>
                         </div>
                     </div>
                     </div>
                 </div>
                 </div>
@@ -215,13 +222,22 @@ const handlePhenologyChange = (crop, region) => {
     region.phenologyStartDate = getStartDate(crop, region.phenologyId);
     region.phenologyStartDate = getStartDate(crop, region.phenologyId);
 };
 };
 
 
-// 禁用今天之后的日期;最早只能选到前 3 个月
-const disabledFutureDate = (time) => {
+// 禁用今天之后的日期;最早只能选到「该物候期默认开始时间」的前 3 个月
+// 如果没有物候期开始时间,则基于今天往前 3 个月
+const disabledFutureDate = (time, crop, region) => {
     const today = new Date();
     const today = new Date();
     today.setHours(0, 0, 0, 0);
     today.setHours(0, 0, 0, 0);
 
 
-    // 三个月前的同一天(简单按 3 个月回退)
-    const threeMonthsAgo = new Date(today);
+    // 基准开始时间:物候期默认开始日期
+    const baseStartStr = getStartDate(crop, region.phenologyId);
+    const baseStart = baseStartStr ? new Date(baseStartStr) : null;
+
+    // 选择基准日期:有物候期开始时间则用它,否则用今天
+    const base = !baseStart || isNaN(baseStart.getTime()) ? new Date(today) : new Date(baseStart);
+    base.setHours(0, 0, 0, 0);
+
+    // 三个月前的同一天(基于 base)
+    const threeMonthsAgo = new Date(base);
     threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3);
     threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3);
 
 
     const t = time.getTime();
     const t = time.getTime();

+ 12 - 2
src/views/old_mini/interactionList/index.vue

@@ -68,12 +68,22 @@
                         <div class="reason-text">上传照片({{ item.imagePaths.length }}张)</div>
                         <div class="reason-text">上传照片({{ item.imagePaths.length }}张)</div>
                         <!-- 图片展示 -->
                         <!-- 图片展示 -->
                         <div class="uploaded-images">
                         <div class="uploaded-images">
-                            <div class="uploaded-img-wrap" v-for="(image, imgIndex) in item.imagePaths" :key="image"
+                            <!-- <div class="uploaded-img-wrap" v-for="(image, imgIndex) in item.imagePaths" :key="image"
                                 @click="showExample(item, imgIndex, { hideLabel: true })">
                                 @click="showExample(item, imgIndex, { hideLabel: true })">
                                 <img class="uploaded-img" :src="base_img_url2 + image" alt="" />
                                 <img class="uploaded-img" :src="base_img_url2 + image" alt="" />
                                 <span v-show="item.questionStatus === 3" class="uploaded-img-remove"
                                 <span v-show="item.questionStatus === 3" class="uploaded-img-remove"
                                     @click.stop="removeUploadedImage(item, imgIndex)">×</span>
                                     @click.stop="removeUploadedImage(item, imgIndex)">×</span>
-                            </div>
+                            </div> -->
+
+                            <photo-provider :photo-closable="true">
+                                <photo-consumer v-for="(image, imgIndex) in item.imagePaths" :key="imgIndex" :src="base_img_url2 + image">
+                                <div class="uploaded-img-wrap">
+                                    <img :src="base_img_url2 + image" class="uploaded-img">
+                                    <span v-show="item.questionStatus === 3" class="uploaded-img-remove"
+                                        @click.stop="removeUploadedImage(item, imgIndex)">×</span>
+                                </div>
+                                </photo-consumer>
+                            </photo-provider>
                         </div>
                         </div>
                         <uploader v-show="item.questionStatus === 3" class="upload-wrap continue-upload-btn"
                         <uploader v-show="item.questionStatus === 3" class="upload-wrap continue-upload-btn"
                             @click="handleUploadClick(item)" multiple :max-count="10" :after-read="afterReadUpload">
                             @click="handleUploadClick(item)" multiple :max-count="10" :after-read="afterReadUpload">