shuhao 2 minggu lalu
induk
melakukan
64d38944fb

+ 13 - 0
.cursor/rules/farm-work-desc-integration.mdc

@@ -0,0 +1,13 @@
+---
+description: 农事调度模块接口与展示规范
+globs: "{src/views/warningHome/components/chart_components/chartList.vue,src/api/modules/warning.js}"
+alwaysApply: false
+---
+
+# 农事调度标题描述展示规则
+
+- 在 `chartList.vue` 的“农事调度规划”区域,必须展示农事 `title` 与 `description` 的文字内容,不再使用柱状图承载该区域内容。
+- 农事调度数据必须调用 `doc/openapi.json` 定义的接口:`GET /site/agri_common/farm_work_desc`,并携带 `speciesId` 查询参数。
+- 新接口统一在 `src/api/modules/warning.js` 中封装,遵循现有 `VE_API.warning` 的字段风格(`url` + `type`)。
+- 下拉选择作物后需同步刷新“物候进程分布”和“农事调度规划”两块内容,保证展示数据对应同一 `speciesId`。
+- 接口返回空或异常时,文字区域应回退为“暂无数据”,避免展示旧数据。

+ 1 - 1
src/api/config.js

@@ -3,7 +3,7 @@ let serverMock = "https://mock.apipark.cn/m1/4662471-4313509-default/"
 let pythonServe = VE_ENV.PYSERVER
 // let djiCloudBase = "http://127.0.0.1/";
 let djiCloudBase = "https://djiapi.sysuimars.com/";
-// let oneMapServer = "https://zytt-one-map-api.feiniaotech.com/";
+// let oneMapServer = "https://hainan-one-map-api.feiniaotech.com/";
 let oneMapServer = "http://127.0.0.1:84/";
 
 export const base_url = server + "site/";

+ 5 - 0
src/api/modules/warning.js

@@ -99,6 +99,11 @@ export default {
         url: config.one_map_url + "agri_chart_stat/stat_phenology_area_ratio_for_grain",
         type: "get",
     },
+    //按作物ID查询农事标题和描述
+    fetchFarmWorkDesc: {
+        url: config.one_map_url + "agri_common/farm_work_desc",
+        type: "get",
+    },
     //获取村界
     fetchVillageBoundary: {
         url: config.one_map_url + "village/list",

+ 77 - 57
src/views/warningHome/components/chart_components/chartList.vue

@@ -43,16 +43,26 @@
             </chart-box>
         </div>
         <div class="chart-item">
-            <chart-box :name="`三门坡镇非农化非粮化面积统计`">
+            <chart-box :name="`三门坡镇农事调度规划`">
+                <template #title-right>
+                  <el-select
+                      v-model="selectedPieItem"
+                      size="small"
+                      style="width: 100px"
+                      @change="handleSpeciesChange"
+                  >
+                    <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
+                  </el-select>
+                </template>
                 <div class="box-content">
-                    <div class="chart-dom">
-                        <bar-chart
-                            :key="`yield-${activeBaseTab}`"
-                            :chartData="yieldChartData"
-                            :yAxisFormatter="yAxisFormatter"
-                        ></bar-chart>
+                    <div class="farm-work-list">
+                        <div v-if="farmWorkList.length === 0" class="farm-work-empty">暂无数据</div>
+                        <div v-else class="farm-work-item" v-for="item in farmWorkList" :key="item.farmWorkId">
+                            <div class="farm-work-title">{{ item.title || "-" }}</div>
+                            <div class="farm-work-desc">{{ item.description || "-" }}</div>
+                        </div>
                     </div>
-                    <div class="box-bg">{{ yieldSummaryText }}</div>
+                    <div class="box-bg">{{ farmWorkSummaryText }}</div>
                 </div>
             </chart-box>
         </div>
@@ -119,23 +129,13 @@ const regionChartData = ref({
 // 区域占比摘要文字
 const regionSummaryText = ref("暂无数据");
 
-// 用地面积统计图表数据
-const yieldChartData = ref({
-    categories: [], // 类别名称数组
-    values: [], // 占比百分比数组
-});
-
-// 用地面积统计摘要文字
-const yieldSummaryText = ref("暂无数据");
-
-// y 轴格式化器(不显示百分比)
-const yAxisFormatter = "{value}";
+// 农事调度文本列表
+const farmWorkList = ref([]);
+const farmWorkSummaryText = ref("暂无数据");
 
 onMounted(() => {
     // 监听图例组件的变化事件
     eventBus.on("landUseLegend:change", handleLandUseLegendChange);
-    // 初始化时请求用地面积统计数据(statType=1)
-    fetchYieldChartData();
 });
 
 onUnmounted(() => {
@@ -156,7 +156,7 @@ const handleLandUseLegendChange = (data) => {
     };
     // 使用新的 nonGrain 重新获取饼图数据
     fetchStatRegionAreaRatio(data.nonGrain);
-    fetchStatPhenologyAreaRatioForGrain();
+    handleSpeciesChange();
 };
 
 const options = ref([]);
@@ -209,48 +209,28 @@ const fetchStatRegionAreaRatio = (nonGrain = null) => {
         });
 };
 
-// 获取用地面积统计图表数据(statType=1)
-const fetchYieldChartData = () => {
-    const params = { statType: 1 }; // 固定为 1
+const fetchFarmWorkDesc = () => {
+    if (!selectedPieItem.value) {
+        farmWorkList.value = [];
+        farmWorkSummaryText.value = "暂无数据";
+        return;
+    }
+
     VE_API.warning
-        .fetchStatAreaRatioByType(params)
+        .fetchFarmWorkDesc({ speciesId: selectedPieItem.value })
         .then((res) => {
             if (res.code === 0 && res.data && res.data.length > 0) {
-                // 计算总种植面积
-                const total = res.data.reduce((sum, item) => sum + (item.plantArea || 0), 0);
-
-                // 转换接口数据为柱状图格式
-                const categories = res.data.map((item) => item.name);
-                const values = res.data.map((item) => parseFloat(item.plantArea.toFixed(1)));
-
-                // 更新图表数据
-                yieldChartData.value = {
-                    categories,
-                    values,
-                };
-
-                // 生成摘要文字,显示每一项的数据
-                const summaryItems = res.data.map((item) => {
-                    return `${item.name}: ${item.plantArea.toFixed(1)}亩`;
-                });
-                yieldSummaryText.value = summaryItems.join(", ");
+                farmWorkList.value = res.data;
+                farmWorkSummaryText.value = `共${res.data.length}条农事调度`;
             } else {
-                // 接口返回空数据时,清空图表数据
-                yieldChartData.value = {
-                    categories: [],
-                    values: [],
-                };
-                yieldSummaryText.value = "暂无数据";
+                farmWorkList.value = [];
+                farmWorkSummaryText.value = "暂无数据";
             }
         })
         .catch((error) => {
-            console.error("获取用地面积统计数据失败:", error);
-            // 错误时清空数据
-            yieldChartData.value = {
-                categories: [],
-                values: [],
-            };
-            yieldSummaryText.value = "暂无数据";
+            console.error("获取农事调度描述失败:", error);
+            farmWorkList.value = [];
+            farmWorkSummaryText.value = "暂无数据";
         });
 };
 
@@ -307,6 +287,11 @@ const fetchStatPhenologyAreaRatioForGrain = () => {
             regionSummaryText.value = "暂无数据";
         });
 };
+
+const handleSpeciesChange = () => {
+    fetchStatPhenologyAreaRatioForGrain();
+    fetchFarmWorkDesc();
+};
 </script>
 
 <style lang="scss" scoped>
@@ -329,6 +314,41 @@ const fetchStatPhenologyAreaRatioForGrain = () => {
             height: calc(100% - 61px);
             width: 100%;
         }
+        .farm-work-list {
+            height: calc(100% - 61px);
+            width: 100%;
+            overflow-y: auto;
+            padding: 8px;
+            box-sizing: border-box;
+            color: #fff;
+            font-size: 12px;
+            line-height: 1.5;
+
+            .farm-work-empty {
+                color: rgba(255, 255, 255, 0.6);
+            }
+
+            .farm-work-item {
+                padding-bottom: 8px;
+                margin-bottom: 8px;
+                border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
+
+                &:last-child {
+                    margin-bottom: 0;
+                    border-bottom: none;
+                }
+            }
+
+            .farm-work-title {
+                font-weight: 600;
+                margin-bottom: 2px;
+            }
+
+            .farm-work-desc {
+                color: rgba(255, 255, 255, 0.8);
+                white-space: pre-wrap;
+            }
+        }
         .box-bg {
             border-radius: 2px 2px 0 0;
             font-size: 12px;