Browse Source

feat:添加执行人,修改参数获取

wangsisi 6 days ago
parent
commit
a6aaaaac83

BIN
src/assets/img/monitor/execute-icon.png


+ 44 - 15
src/components/pageComponents/FarmWorkPlanTimeline.vue

@@ -21,7 +21,11 @@
                             v-for="(fw, aIdx) in Array.isArray(r.farmWorkArrangeList) ? r.farmWorkArrangeList : []"
                             :key="`arrange-${uniqueTimestamp}-${idx}-${rIdx}-${aIdx}`"
                             class="arrange-card"
-                            :style="shouldShowIncompleteStatus(fw.farmWorkId) ? 'padding-bottom: 18px;' : 'padding-bottom: 10px'"
+                            :style="
+                                shouldShowIncompleteStatus(fw.farmWorkId)
+                                    ? 'padding-bottom: 18px;'
+                                    : 'padding-bottom: 10px'
+                            "
                             :class="getArrangeStatusClass(fw)"
                             @click="handleRowClick(fw)"
                         >
@@ -36,7 +40,10 @@
                             </div>
                             <div class="card-content">
                                 <span>{{ fw.interactionQuestion || "暂无提示" }}</span>
-                                <span v-if="!disableClick" :class="shouldShowIncompleteStatus(fw.farmWorkId) ? 'link-warning' : 'edit-link'" @click.stop="handleEdit(fw)"
+                                <span
+                                    v-if="!disableClick"
+                                    :class="shouldShowIncompleteStatus(fw.farmWorkId) ? 'link-warning' : 'edit-link'"
+                                    @click.stop="handleEdit(fw)"
                                     >点击编辑</span
                                 >
                             </div>
@@ -146,18 +153,33 @@ const safeParseDate = (val) => {
 const batchValidateData = ref({});
 const allTrue = ref(false);
 const invalidIds = ref([]);
+const invalidArr = ref([]);
 // 验证农事卡片药肥报价信息是否完整
-const batchValidatePesticideFertilizerQuotes = (ids) => {
+const batchValidatePesticideFertilizerQuotes = (ids, items) => {
     if (props.isStandard) {
         return;
     }
     VE_API.monitor
         .batchValidatePesticideFertilizerQuotes({ ids, schemeId: props.schemeId })
-        .then(({ data,code }) => {
+        .then(({ data, code }) => {
             if (code === 0) {
                 batchValidateData.value = data || {};
                 allTrue.value = Object.values(data).every((value) => value === true);
                 invalidIds.value = Object.keys(data).filter((key) => data[key] !== true);
+
+                // 清空之前的arrangeIds
+                invalidArr.value = [];
+                // 遍历items,判断farmWorkId是否在invalidIds中,如果对应上了就把item.id push进去
+                items.forEach((item) => {
+                    // 判断item.farmWorkId是否在invalidIds数组中(需要转换为字符串进行比较)
+                    const farmWorkIdStr = String(item.farmWorkId);
+                    if (invalidIds.value.includes(farmWorkIdStr)) {
+                        invalidArr.value.push({
+                            arrangeId: item.id,
+                            farmWorkId: item.farmWorkId,
+                        });
+                    }
+                });
             }
         })
         .catch(() => {});
@@ -167,17 +189,18 @@ const batchValidatePesticideFertilizerQuotes = (ids) => {
 // 如果batchValidateData中对应的farmWorkId验证结果为true(已完善),则不显示
 // 如果验证结果为false(未完善)或不存在,则显示
 const shouldShowIncompleteStatus = (farmWorkId) => {
-    if (!farmWorkId || !batchValidateData.value || typeof batchValidateData.value !== 'object') {
+    if (!farmWorkId || !batchValidateData.value || typeof batchValidateData.value !== "object") {
         // 如果没有验证数据,默认不显示
         return false;
     }
 
     // 从对象中直接获取验证结果,支持字符串和数字类型的key
-    const isValid = batchValidateData.value[farmWorkId] !== undefined 
-        ? batchValidateData.value[farmWorkId]
-        : batchValidateData.value[String(farmWorkId)] !== undefined
-        ? batchValidateData.value[String(farmWorkId)]
-        : undefined;
+    const isValid =
+        batchValidateData.value[farmWorkId] !== undefined
+            ? batchValidateData.value[farmWorkId]
+            : batchValidateData.value[String(farmWorkId)] !== undefined
+            ? batchValidateData.value[String(farmWorkId)]
+            : undefined;
 
     // 如果找到了验证结果
     if (isValid !== undefined) {
@@ -340,6 +363,7 @@ const getArrangeStatusClass = (fw) => {
 const handleRowClick = (item) => {
     item.isEdit = shouldShowIncompleteStatus(item.farmWorkId);
     item.invalidIds = invalidIds.value;
+    item.invalidArr = invalidArr.value;
     emits("row-click", item);
 };
 
@@ -418,7 +442,8 @@ const getFarmWorkPlan = () => {
                             requestAnimationFrame(() => {
                                 // 测量timeline-list的实际渲染高度
                                 if (timelineListRef.value) {
-                                    const height = timelineListRef.value.offsetHeight || timelineListRef.value.clientHeight;
+                                    const height =
+                                        timelineListRef.value.offsetHeight || timelineListRef.value.clientHeight;
                                     if (height > 0) {
                                         timelineListHeight.value = height;
 
@@ -435,7 +460,9 @@ const getFarmWorkPlan = () => {
                                     // 如果测量失败,延迟一下再尝试滚动
                                     setTimeout(() => {
                                         if (timelineListRef.value) {
-                                            const height = timelineListRef.value.offsetHeight || timelineListRef.value.clientHeight;
+                                            const height =
+                                                timelineListRef.value.offsetHeight ||
+                                                timelineListRef.value.clientHeight;
                                             if (height > 0) {
                                                 timelineListHeight.value = height;
                                             }
@@ -454,6 +481,7 @@ const getFarmWorkPlan = () => {
 
                 // 收集所有farmWorkId
                 const farmWorkIds = [];
+                const farmWorks = [];
                 phenologyList.value.forEach((phenology) => {
                     if (Array.isArray(phenology.reproductiveList)) {
                         phenology.reproductiveList.forEach((reproductive) => {
@@ -461,6 +489,7 @@ const getFarmWorkPlan = () => {
                                 reproductive.farmWorkArrangeList.forEach((farmWork) => {
                                     if (farmWork.farmWorkId && farmWork.isFollow !== 0) {
                                         farmWorkIds.push(farmWork.farmWorkId);
+                                        farmWorks.push(farmWork);
                                     }
                                 });
                             }
@@ -470,7 +499,7 @@ const getFarmWorkPlan = () => {
 
                 // 调用验证方法,传入所有ids
                 if (farmWorkIds.length > 0) {
-                    batchValidatePesticideFertilizerQuotes(farmWorkIds);
+                    batchValidatePesticideFertilizerQuotes(farmWorkIds, farmWorks);
                 }
             }
         })
@@ -507,7 +536,7 @@ watch(
 
 // 使用 ResizeObserver 监听高度变化,确保在DOM完全渲染后获取准确高度
 const setupResizeObserver = () => {
-    if (!timelineListRef.value || typeof ResizeObserver === 'undefined') {
+    if (!timelineListRef.value || typeof ResizeObserver === "undefined") {
         return;
     }
 
@@ -653,7 +682,7 @@ watch(
                             color: #2199f8;
                             margin-left: 5px;
                         }
-                        .link-warning{
+                        .link-warning {
                             color: #ff953d;
                             margin-left: 5px;
                         }

+ 1 - 1
src/views/old_mini/modify_work/reviewWork.vue

@@ -63,7 +63,7 @@
                             </div>
                         </div>
                         <div class="subject-item">
-                            <img class="subject-img" :src="workItem.expertIcon" alt="" />
+                            <img class="subject-img" :src="workItem.executorIcon" alt="" />
                             <div class="subject-tag">
                                 {{ workItem.executeName }}
                             </div>

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

@@ -279,7 +279,6 @@ const getPhenologyList = async () => {
 };
 
 const farmWorkIds = ref([]);
-const arrangeIds = ref([]);
 // 获取农事规划数据以获取 containerSpaceTimeId
 const getFarmWorkPlanForPhenology = async () => {
     try {
@@ -294,7 +293,6 @@ const getFarmWorkPlanForPhenology = async () => {
 
             // 收集所有farmWorkId
             farmWorkIds.value = [];
-            arrangeIds.value = [];
             data.phenologyList.forEach((phenology) => {
                 if (Array.isArray(phenology.reproductiveList)) {
                     phenology.reproductiveList.forEach((reproductive) => {
@@ -302,7 +300,6 @@ const getFarmWorkPlanForPhenology = async () => {
                             reproductive.farmWorkArrangeList.forEach((farmWork) => {
                                 if (farmWork.farmWorkId && farmWork.isFollow !== 0) {
                                     farmWorkIds.value.push(farmWork.farmWorkId);
-                                    arrangeIds.value.push(farmWork.id);
                                 }
                             });
                         }
@@ -461,7 +458,6 @@ const handleSubmitPlan = async () => {
 const savePlanPageInfo = () => {
     sessionStorage.setItem("specieValue", specieValue.value);
     sessionStorage.setItem("active", active.value);
-    sessionStorage.setItem("arrangeIds", JSON.stringify(arrangeIds.value));
     sessionStorage.setItem("currentTabIndex", currentTabIndex.value);
 };
 
@@ -491,6 +487,7 @@ const handleRowClick = (item) => {
     curFarmObj.value = item;
     savePlanPageInfo();
     sessionStorage.setItem("farmWorkIds", JSON.stringify(item.invalidIds));
+    console.log('item.invalidArr', item.invalidArr);
     const enabled = tabs.value[currentTabIndex.value]?.enabled;
     router.push({
         path: "/modify",

+ 30 - 3
src/views/old_mini/task_condition/components/task.vue

@@ -49,6 +49,10 @@
                         :ref="(el) => setTaskItemRef(el, index)"
                     >
                         <template #footer>
+                            <div class="execute-wrap">
+                                <img class="execute-icon" src="@/assets/img/monitor/execute-icon.png" alt="">
+                                <span>{{ item.executorName }}</span>
+                            </div>
                             <div class="item-footer" v-if="activeIndex === 2">
                                 <div class="footer-l farm-name-text van-ellipsis">
                                     来自<span class="name-text">{{ item.farmName || "--" }}</span>
@@ -72,10 +76,10 @@
                             <div v-else-if="activeIndex === 0" class="item-footer">
                                 <div class="footer-l" @click="toDetail(item)">查看详情</div>
                                 <div class="footer-r" v-if="item.expectedExecuteDate">
-                                    <div class="btn primary" @click="showUploadExecutePopup(item)">上传照片</div>
+                                    <div class="btn primary primary-text" @click="showUploadExecutePopup(item)">{{ agriculturalRole === 1 ? "提醒执行" : "上传照片" }}</div>
                                 </div>
                                 <div class="footer-r" v-else>
-                                    <div class="btn warning" @click="selectExecuteTime(item)">确认执行时间</div>
+                                    <div class="btn warning" @click="selectExecuteTime(item)">{{ agriculturalRole === 1 ? "提醒确认执行时间" : "确认执行时间" }}</div>
                                 </div>
                             </div>
                         </template>
@@ -229,9 +233,11 @@ function initTaskCounts() {
 }
 const mapPoint = ref(null);
 
+const agriculturalRole = ref(null);
 onMounted(() => {
     mapPoint.value = store.state.home.miniUserLocationPoint;
-
+    const userInfo = JSON.parse(localStorage.getItem("localUserInfo"));
+    agriculturalRole.value = userInfo.agriculturalRole;
     // 初始化时获取所有状态的数量
     initTaskCounts();
     // 加载当前选中状态的数据列表
@@ -561,6 +567,22 @@ function handleForward(item) {
         margin-top: 10px;
     }
 
+    .execute-wrap{
+        background: rgba(153, 153, 153, 0.1);
+        border: 1px solid rgba(153, 153, 153, 0.2);
+        border-radius: 2px;
+        padding: 6px 10px;
+        color: #999999;
+        display: flex;
+        align-items: center;
+        gap: 5px;
+        margin-top: 10px;
+        .execute-icon{
+            width: 14px;
+            height: 14px;
+        }
+    }
+
     .item-footer {
         margin-top: 10px;
         padding-top: 11px;
@@ -630,6 +652,11 @@ function handleForward(item) {
                     color: #2199f8;
                     border: 1px solid #2199f8;
                 }
+                &.primary-text {
+                    background: rgba(33, 153, 248, 0.1);
+                    color: #2199F8;
+                    border: 1px solid #2199F8;
+                }
             }
             .btn + .btn {
                 margin-left: 8px;