Prechádzať zdrojové kódy

feat:添加编辑问题功能

wangsisi 3 dní pred
rodič
commit
5b6ee9bb56

+ 31 - 8
src/components/pageComponents/FarmWorkPlanTimeline.vue

@@ -15,6 +15,9 @@
                     <div class="time-text">起始时间</div>
                     <span>{{ p.startDate }}</span>
                 </div>
+                <div class="phenology-title" v-if="p.reproductiveList[0]?.phenologyName === getNextPhenologyName(idx, 0)">
+                    {{ p.reproductiveList[0]?.phenologyName }}
+                </div>
                 <div
                     v-for="(r, rIdx) in Array.isArray(p.reproductiveList) ? p.reproductiveList : []"
                     :key="`reproductive-${uniqueTimestamp}-${idx}-${rIdx}`"
@@ -66,13 +69,17 @@
                         </div>
                     </template>
                     <template v-else>
-                        <div class="phenology-name">{{ r.name }}</div>
-                        <div 
-                            class="phenology-name mr" 
-                            :style="r.phenologyName === getNextPhenologyName(idx, rIdx) ? 'padding: 6px 0;' : ''"
-                        >
-                            {{ r.phenologyName }}
-                        </div>
+                        <template v-if="r.phenologyName === getNextPhenologyName(idx, rIdx)">
+                            <div class="phenology-name">
+                                {{ r.name }}
+                            </div>
+                        </template>
+                        <template v-else>
+                            <div class="phenology-name">{{ r.name }}</div>
+                            <div class="phenology-name mr">
+                                {{ r.phenologyName }}
+                            </div>
+                        </template>
                     </template>
                 </div>
             </div>
@@ -467,7 +474,6 @@ const getFarmWorkPlan = () => {
                                     };
                                 })
                               : [];
-
                           return {
                               id: it.id ?? it.phenologyId ?? it.name ?? `${it.progress}-${it.progress2}`,
                               progress: Number(it.progress) || 0, // 起点 %
@@ -579,6 +585,10 @@ watch(
     }
 );
 
+defineExpose({
+    updateFarmWorkPlan,
+});
+
 // 使用 ResizeObserver 监听高度变化,确保在DOM完全渲染后获取准确高度
 const setupResizeObserver = () => {
     if (!timelineListRef.value || typeof ResizeObserver === "undefined") {
@@ -674,6 +684,19 @@ watch(
                 background: rgba(33, 153, 248, 0.1);
             }
         }
+        .phenology-title{
+            width: 20px;
+            height: 99%;
+            background: #2199f8;
+            color: #fff;
+            font-size: 12px;
+            position: absolute;
+            left: 35px;
+            z-index: 10;
+            text-align: center;
+            display: flex;
+            align-items: center;
+        }
         .reproductive-item {
             font-size: 12px;
             text-align: center;

+ 97 - 6
src/views/old_mini/home/subPages/warningDetail.vue

@@ -25,7 +25,7 @@
                 <div class="answer-text" v-if="pageParams.answer != null">
                     <span v-if="pageParams.answer == 0">答:暂未出现{{ pageParams.expectedRisk }}</span>
                     <template v-else>
-                        <div>答:{{pageParams.occurrenceTime}}已出现{{ pageParams.expectedRisk }}</div>
+                        <div>答:{{ pageParams.occurrenceTime }}已出现{{ pageParams.expectedRisk }}</div>
                         <div class="photo-img-wrap">
                             <photo-provider :photo-closable="true">
                                 <photo-consumer
@@ -43,7 +43,7 @@
                     </template>
                 </div>
                 <div v-else class="box-bottom" :style="{ justifyContent: !isLink ? 'center' : 'flex-end' }">
-                    <div class="edit-btn" v-if="!isLink">编辑问题</div>
+                    <div class="edit-btn" v-if="!isLink" @click="handleEditQuestion">编辑问题</div>
                     <template v-else>
                         <div class="edit-btn" @click="handleAnswerClick(0)">否</div>
                         <div class="edit-btn primary-btn" @click="handleAnswerClick(1)">是</div>
@@ -51,10 +51,6 @@
                 </div>
             </div>
 
-            <div class="article-text">
-                <span v-html="warningDetail.content"></span>
-            </div>
-
             <div class="photo-img-wrap-container" v-if="cropAlbum.length">
                 <div class="photo-img-wrap-title">
                     <div class="title-text">
@@ -79,6 +75,10 @@
                 </div>
             </div>
 
+            <div class="article-text">
+                <span v-html="warningDetail.content"></span>
+            </div>
+
             <div class="custom-bottom-fixed-btns" v-if="!isLink">
                 <div class="bottom-btn primary-btn" @click="showShareSheet = true">转发</div>
             </div>
@@ -86,6 +86,26 @@
     </div>
     <active-upload-popup ref="activeUploadPopupRef" @handleUploadSuccess="handleUploadSuccess"></active-upload-popup>
     <fn-share-sheet v-model:show="showShareSheet" :options="shareOptions" @select="handleShareSelect" />
+
+    <Popup v-model:show="showQuestionPopup" class="copy-plan-popup" round closeable :close-on-click-overlay="false">
+        <div class="copy-plan-content">
+            <div class="label">问题描述</div>
+            <el-input
+                v-model="interactionQuestion"
+                size="large"
+                placeholder="请输入问题描述"
+                type="textarea"
+                :rows="3"
+                maxlength="35"
+                show-word-limit
+                class="copy-plan-input"
+            />
+        </div>
+        <div class="copy-plan-footer">
+            <div class="btn btn-cancel" @click="showQuestionPopup = false">取消修改</div>
+            <div class="btn btn-confirm" @click="handleEdit">确认修改</div>
+        </div>
+    </Popup>
 </template>
 
 <script setup>
@@ -96,8 +116,38 @@ import FnShareSheet from "@/components/pageComponents/FnShareSheet.vue";
 import activeUploadPopup from "@/components/popup/activeUploadPopup.vue";
 import { useRoute, useRouter } from "vue-router";
 import { ElMessage } from "element-plus";
+import { Popup } from "vant";
 import wx from "weixin-js-sdk";
 
+const showQuestionPopup = ref(false);
+const handleEdit = () => {
+    VE_API.monitor
+        .updateFarmWorkArrange({
+            id:pageParams.value.arrangeId,
+            interactionQuestion: interactionQuestion.value,
+            // phenologyId:1,
+            // reproductiveId:1,
+            // interactionTime:1,
+        })
+        .then((res) => {
+            if (res.code === 0) {
+                ElMessage.success("修改成功");
+                showQuestionPopup.value = false;
+                getAnswer();
+                getWarningDetail();
+            } else {
+                ElMessage.error(res.message || "修改失败");
+            }
+        })
+        .catch(() => {
+            ElMessage.error("修改失败,请重试");
+        })
+        .finally(() => {
+            showQuestionPopup.value = false;
+        });
+};
+const interactionQuestion = ref("");
+
 const route = useRoute();
 const router = useRouter();
 const showShareSheet = ref(false);
@@ -147,6 +197,7 @@ const getAnswer = () => {
                 pageParams.value.expectedRisk = res.data.expectedRisk;
                 pageParams.value.imagePaths = res.data.imagePaths;
                 pageParams.value.occurrenceTime = res.data.occurrenceTime;
+                pageParams.value.questTitle = res.data.interactionQuestion;
             }
         });
 };
@@ -252,6 +303,11 @@ const getFarmPhoto = async () => {
 const handleSeeMore = () => {
     router.push(`/farm_photo?farmId=${pageParams.value.farmId}`);
 };
+
+const handleEditQuestion = () => {
+    interactionQuestion.value = pageParams.value.questTitle;
+    showQuestionPopup.value = true;
+};
 </script>
 
 <style scoped lang="scss">
@@ -412,4 +468,39 @@ const handleSeeMore = () => {
         }
     }
 }
+
+.copy-plan-popup {
+    width: 100%;
+    padding: 50px 12px 20px 12px;
+    .copy-plan-content {
+        display: flex;
+        gap: 12px;
+        .label {
+            font-size: 16px;
+            font-weight: 500;
+        }
+        .copy-plan-input {
+            width: calc(100% - 80px);
+        }
+    }
+    .copy-plan-footer {
+        display: flex;
+        gap: 12px;
+        margin-top: 20px;
+        .btn {
+            flex: 1;
+            color: #666666;
+            border: 1px solid #999999;
+            border-radius: 25px;
+            padding: 10px 0;
+            font-size: 16px;
+            text-align: center;
+            &.btn-confirm {
+                color: #fff;
+                border: 1px solid #2199f8;
+                background: #2199f8;
+            }
+        }
+    }
+}
 </style>

+ 1 - 1
src/views/old_mini/mine/pages/register.vue

@@ -189,7 +189,7 @@ const onSubmit = () => {
             ElMessage.success('注册成功,待审核')
             router.push('/mine')
         }else{
-            ElMessage.success('注册失败')
+            ElMessage.error(res.msg)
         }
     })
 };

+ 4 - 0
src/views/old_mini/monitor/subPages/plan.vue

@@ -53,6 +53,7 @@
                     :disableClick="!hasPlanPermission || active === tabs[0]?.id"
                     :isStandard="active === tabs[0]?.id"
                     :schemeId="route.query.schemeId || active"
+                    ref="farmWorkPlanTimelineRef"
                 />
             </div>
         </div>
@@ -125,6 +126,7 @@
                         value-format="YYYY-MM-DD"
                         v-model="item.startDate"
                         :clearable="false"
+                        :editable="false"
                         type="date"
                         placeholder="选择日期"
                         @change="(date) => handleStartDateChange(date, index)"
@@ -400,6 +402,7 @@ const handleStartDateChange = (date, currentIndex) => {
 /**
  * 确认物候期设置
  */
+const farmWorkPlanTimelineRef = ref(null);
 const handleConfirmPhenologySetting = async () => {
     const params = {
         farmId: route.query.farmId,
@@ -414,6 +417,7 @@ const handleConfirmPhenologySetting = async () => {
         ElMessage.success("设置成功");
         showPhenologySetting.value = false;
         getFarmWorkPlanForPhenology();
+        farmWorkPlanTimelineRef.value.updateFarmWorkPlan();
     }
 };
 // 取消复制方案