|
@@ -36,7 +36,7 @@
|
|
|
{{ t("agriFile.agriAssessment") }}
|
|
{{ t("agriFile.agriAssessment") }}
|
|
|
</div>
|
|
</div>
|
|
|
<div class="analysis-card__desc">{{ assessmentDesc }}</div>
|
|
<div class="analysis-card__desc">{{ assessmentDesc }}</div>
|
|
|
- <div class="analysis-card__stats">
|
|
|
|
|
|
|
+ <!-- <div class="analysis-card__stats">
|
|
|
<div v-for="(item, index) in analysisStats" :key="index" class="analysis-card__stat">
|
|
<div v-for="(item, index) in analysisStats" :key="index" class="analysis-card__stat">
|
|
|
<div class="analysis-card__stat-value" :class="{ highlight: item.highlight }">
|
|
<div class="analysis-card__stat-value" :class="{ highlight: item.highlight }">
|
|
|
<template v-if="item.unit">
|
|
<template v-if="item.unit">
|
|
@@ -47,7 +47,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="analysis-card__stat-label">{{ item.label }}</div>
|
|
<div class="analysis-card__stat-label">{{ item.label }}</div>
|
|
|
</div>
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
|
+ </div> -->
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -66,35 +66,52 @@
|
|
|
|
|
|
|
|
<div class="stage-card interact-card">
|
|
<div class="stage-card interact-card">
|
|
|
<div class="work-info">
|
|
<div class="work-info">
|
|
|
- <div class="interact-card__head">
|
|
|
|
|
- <div class="section-title interact-card__title">
|
|
|
|
|
- <span class="title-bar"></span>
|
|
|
|
|
- {{ t("agriFile.interactQuestion") }}
|
|
|
|
|
|
|
+ <!-- 已答:问题 + 答案一句 + 修改;点修改后回到选项态 -->
|
|
|
|
|
+ <div v-if="isAnsweredView(item, index)" class="interact-card__answered">
|
|
|
|
|
+ <div class="interact-card__answered-text">
|
|
|
|
|
+ <span class="interact-card__answered-problem">{{
|
|
|
|
|
+ item.interact_problem
|
|
|
|
|
+ }}:</span>
|
|
|
|
|
+ <span class="interact-card__answered-value">{{
|
|
|
|
|
+ resolveAnswerText(item)
|
|
|
|
|
+ }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
- <div
|
|
|
|
|
- class="interact-card__submit"
|
|
|
|
|
- :class="{ disabled: selectedMap[item.fw_code || index] == null }"
|
|
|
|
|
- @click="handleSubmit(item, index)"
|
|
|
|
|
- >
|
|
|
|
|
- 确认提交
|
|
|
|
|
|
|
+ <div class="interact-card__edit" @click="startEdit(item, index)">
|
|
|
|
|
+ 修改
|
|
|
|
|
+ <el-icon class="interact-card__edit-icon"><Edit /></el-icon>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <div class="interact-card__qa">
|
|
|
|
|
- <div class="interact-card__question">{{ item.interact_problem }}</div>
|
|
|
|
|
- <div class="interact-card__options">
|
|
|
|
|
|
|
+ <template v-else>
|
|
|
|
|
+ <div class="interact-card__head">
|
|
|
|
|
+ <div class="section-title interact-card__title">
|
|
|
|
|
+ <span class="title-bar"></span>
|
|
|
|
|
+ {{ t("agriFile.interactQuestion") }}
|
|
|
|
|
+ </div>
|
|
|
<div
|
|
<div
|
|
|
- v-for="(opt, optIndex) in item.options"
|
|
|
|
|
- :key="`${item.fw_code || index}-${optIndex}`"
|
|
|
|
|
- class="interact-option"
|
|
|
|
|
- :class="{
|
|
|
|
|
- selected: selectedMap[item.fw_code || index] === optIndex,
|
|
|
|
|
- }"
|
|
|
|
|
- @click="selectedMap[item.fw_code || index] = optIndex"
|
|
|
|
|
|
|
+ class="interact-card__submit"
|
|
|
|
|
+ :class="{ disabled: selectedMap[item.fw_code || index] == null }"
|
|
|
|
|
+ @click="handleSubmit(item, index)"
|
|
|
>
|
|
>
|
|
|
- <span class="interact-option__text">{{ opt }}</span>
|
|
|
|
|
|
|
+ 确认提交
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
|
+ <div class="interact-card__qa">
|
|
|
|
|
+ <div class="interact-card__question">{{ item.interact_problem }}</div>
|
|
|
|
|
+ <div class="interact-card__options">
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-for="(opt, optIndex) in item.options"
|
|
|
|
|
+ :key="`${item.fw_code || index}-${optIndex}`"
|
|
|
|
|
+ class="interact-option"
|
|
|
|
|
+ :class="{
|
|
|
|
|
+ selected: selectedMap[item.fw_code || index] === optIndex,
|
|
|
|
|
+ }"
|
|
|
|
|
+ @click="selectedMap[item.fw_code || index] = optIndex"
|
|
|
|
|
+ >
|
|
|
|
|
+ <span class="interact-option__text">{{ opt }}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<!-- 巡园向导 -->
|
|
<!-- 巡园向导 -->
|
|
@@ -243,6 +260,7 @@ import { computed, nextTick, onActivated, reactive, ref } from "vue";
|
|
|
import { useRoute, useRouter } from "vue-router";
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
import { Icon } from "vant";
|
|
import { Icon } from "vant";
|
|
|
import { ElMessage } from "element-plus";
|
|
import { ElMessage } from "element-plus";
|
|
|
|
|
+import { Edit } from "@element-plus/icons-vue";
|
|
|
import customHeader from "@/components/customHeader.vue";
|
|
import customHeader from "@/components/customHeader.vue";
|
|
|
import albumUploadPopup from "../components/albumUploadPopup.vue";
|
|
import albumUploadPopup from "../components/albumUploadPopup.vue";
|
|
|
import tipPopup from "@/components/popup/tipPopup.vue";
|
|
import tipPopup from "@/components/popup/tipPopup.vue";
|
|
@@ -276,6 +294,7 @@ const soilSections = ref([]); // 土壤条件判断(质地/酸碱/墒情/氮
|
|
|
const sectionSelected = reactive({}); // section.key → 选中值(多选为数组)
|
|
const sectionSelected = reactive({}); // section.key → 选中值(多选为数组)
|
|
|
const stressInfo = ref({}); // 胁迫等级等公共信息
|
|
const stressInfo = ref({}); // 胁迫等级等公共信息
|
|
|
const selectedMap = reactive({}); // fw_code/index → 选项下标
|
|
const selectedMap = reactive({}); // fw_code/index → 选项下标
|
|
|
|
|
+const editingMap = reactive({}); // fw_code/index → 已答后点「修改」进入选项态
|
|
|
/** 与查询共用的提交上下文,保证 fw 答案与列表同源 */
|
|
/** 与查询共用的提交上下文,保证 fw 答案与列表同源 */
|
|
|
const queryContext = ref({
|
|
const queryContext = ref({
|
|
|
farm_id: null,
|
|
farm_id: null,
|
|
@@ -373,13 +392,48 @@ function parseInteractOptions(value) {
|
|
|
return [];
|
|
return [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/** 已答文案:提交字段为 options,回显兼容 answer / interact_answer / 字符串 options */
|
|
|
|
|
+function resolveAnswerText(item) {
|
|
|
|
|
+ const raw =
|
|
|
|
|
+ item?.answerText ||
|
|
|
|
|
+ item?.answer ||
|
|
|
|
|
+ item?.interact_answer ||
|
|
|
|
|
+ item?.fw_answer ||
|
|
|
|
|
+ (typeof item?.options === "string" ? item.options : "");
|
|
|
|
|
+ return raw != null && raw !== "" ? String(raw) : "";
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function mapInteractItem(raw) {
|
|
function mapInteractItem(raw) {
|
|
|
|
|
+ const optionsStr =
|
|
|
|
|
+ typeof raw?.options === "string" && raw.options.trim() && !raw.options.trim().startsWith("[")
|
|
|
|
|
+ ? raw.options
|
|
|
|
|
+ : "";
|
|
|
return {
|
|
return {
|
|
|
...raw,
|
|
...raw,
|
|
|
options: parseInteractOptions(raw?.interact_options),
|
|
options: parseInteractOptions(raw?.interact_options),
|
|
|
|
|
+ answerText: String(raw?.answer ?? raw?.interact_answer ?? raw?.fw_answer ?? optionsStr ?? ""),
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function interactKey(item, index) {
|
|
|
|
|
+ return item?.fw_code || index;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 已答且未进入修改态 */
|
|
|
|
|
+function isAnsweredView(item, index) {
|
|
|
|
|
+ return Number(item?.is_answered) === 1 && !editingMap[interactKey(item, index)];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 点修改:回到选项,并尽量回填当前答案 */
|
|
|
|
|
+function startEdit(item, index) {
|
|
|
|
|
+ const key = interactKey(item, index);
|
|
|
|
|
+ editingMap[key] = true;
|
|
|
|
|
+ const answer = resolveAnswerText(item);
|
|
|
|
|
+ if (!answer || !Array.isArray(item?.options)) return;
|
|
|
|
|
+ const optIndex = item.options.findIndex((opt) => opt === answer);
|
|
|
|
|
+ if (optIndex >= 0) selectedMap[key] = optIndex;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const formatLocalDate = (date) => {
|
|
const formatLocalDate = (date) => {
|
|
|
const y = date.getFullYear();
|
|
const y = date.getFullYear();
|
|
|
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
@@ -522,7 +576,7 @@ const handleComplete = () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleSubmit = async (item, index) => {
|
|
const handleSubmit = async (item, index) => {
|
|
|
- const key = item?.fw_code || index;
|
|
|
|
|
|
|
+ const key = interactKey(item, index);
|
|
|
const optIndex = selectedMap[key];
|
|
const optIndex = selectedMap[key];
|
|
|
if (optIndex == null) {
|
|
if (optIndex == null) {
|
|
|
ElMessage.warning(t("agriFile.pleaseSelectOption"));
|
|
ElMessage.warning(t("agriFile.pleaseSelectOption"));
|
|
@@ -543,6 +597,7 @@ const handleSubmit = async (item, index) => {
|
|
|
});
|
|
});
|
|
|
if (res?.code === 200) {
|
|
if (res?.code === 200) {
|
|
|
ElMessage.success(t("agriFile.submitSuccess"));
|
|
ElMessage.success(t("agriFile.submitSuccess"));
|
|
|
|
|
+ editingMap[key] = false;
|
|
|
await fetchSoilRootInteract();
|
|
await fetchSoilRootInteract();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -1001,6 +1056,50 @@ onActivated(() => {
|
|
|
margin-bottom: 12px;
|
|
margin-bottom: 12px;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ &__answered {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ gap: 6px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &__answered-text {
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+ min-width: 0;
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ line-height: 22px;
|
|
|
|
|
+ word-break: break-all;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &__answered-problem {
|
|
|
|
|
+ color: rgba(255, 255, 255, 0.85);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &__answered-value {
|
|
|
|
|
+ padding-left: 4px;
|
|
|
|
|
+ color: #ffd489;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &__edit {
|
|
|
|
|
+ flex-shrink: 0;
|
|
|
|
|
+ display: inline-flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ gap: 4px;
|
|
|
|
|
+ height: 22px;
|
|
|
|
|
+ padding: 0 10px;
|
|
|
|
|
+ border-radius: 12px;
|
|
|
|
|
+ background: rgba(255, 212, 137, 0.1);
|
|
|
|
|
+ color: #ffd489;
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ line-height: 22px;
|
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &__edit-icon {
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ color: #ffd489;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
&__options {
|
|
&__options {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
gap: 12px;
|
|
gap: 12px;
|