Pārlūkot izejas kodu

feat:提交确认信息接口

wangsisi 2 nedēļas atpakaļ
vecāks
revīzija
abb6fdbb15

+ 4 - 2
src/components/pageComponents/GrowthStageTimeline.vue

@@ -122,6 +122,7 @@ import {
  * @property {string[]} [tags] 绿色标签,如 ['最佳给肥点']
  * @property {string} periodTitle 生育期大标题
  * @property {string} periodSubtitle 生育期描述小字
+ * @property {string} [phenophase_code] 物候期编码,由接口/父组件写入
  */
 
 const props = defineProps({
@@ -474,8 +475,9 @@ function emitScrollSettledIfPending() {
     clearScrollSettledTimers();
     const idx = activeIndex.value;
     const stage = normalizedStages.value[idx];
-    emit("change", idx, stage);
-    emit("scrollSettled", idx, stage);
+    const phenophaseCode = stage?.phenophase_code;
+    emit("change", idx, stage, phenophaseCode);
+    emit("scrollSettled", idx, stage, phenophaseCode);
 }
 
 function armScrollSettledAfterHandle() {

+ 22 - 8
src/views/old_mini/recordDetails/index.vue

@@ -302,23 +302,35 @@ const beforeReadUpload = (file) => {
 };
 
 const curStage = ref({});
-
-function onStageScrollSettled(index, stage) {
+const curCode = ref('')
+function onStageScrollSettled(index, stage, code) {
     if (stage) curStage.value = stage;
+    curCode.value = code ?? stage?.phenophase_code ?? "";
+}
+
+/** 从节点文案如「60%展开」中取出百分数,转为 0~1,如 60% -> 0.6 */
+function labelPercentToProgress(label) {
+    if (typeof label !== "string" || !label.trim()) return 0;
+    const m = label.match(/(\d+(?:\.\d+)?)\s*%/);
+    if (!m) return 0;
+    return Number(m[1]) / 100;
 }
 
 const hanldeSubmit = () =>{
     const farmData = JSON.parse(localStorage.getItem('selectedFarmData'))
-    const time = new Date().toLocaleDateString()
+    const time = new Date().toISOString()
     const params = {
         farm_id:farmData.farm_id,
         farm_variety:farmData.farm_variety,
-        current_code:'',
-        new_start_date: time,
-        progress:''
+        current_code:curCode.value,
+        new_start_date: time.slice(0,10),
+        progress: labelPercentToProgress(curStage.value.label),
     }
-    console.log(params)
-    // VE_API.monitor.farmPhenologyAdjust(params)
+    VE_API.monitor.farmPhenologyAdjust(params).then(res =>{
+        if(res.code === 200){
+            ElMessage.success('确认成功')
+        }
+    })
 }
 
 const afterReadUpload = async (data) => {
@@ -437,6 +449,7 @@ function syncCurStageFromModel() {
     }
     const stage = stages[i];
     if (stage) curStage.value = stage;
+    curCode.value = stage?.phenophase_code ?? "";
 }
 
 watch([growthStages, growthStageIndex], syncCurStageFromModel, { immediate: true });
@@ -498,6 +511,7 @@ const getFindPhenologyInfo = async () => {
                     tags: Array.isArray(t.tags) ? t.tags : [],
                     periodTitle: item.phenophase_name ?? '',
                     periodSubtitle: item.phenophase_discribe ?? '',
+                    phenophase_code: item.phenophase_code ?? item.phenophaseCode ?? '',
                 });
             }
         }