abnormalTrack.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. <template>
  2. <div class="abnormal-track-page">
  3. <custom-header
  4. name="异常态势巡园要点"
  5. :isGoBack="!isFromShare"
  6. :showHome="isFromShare"
  7. @goback="handleBack"
  8. />
  9. <div class="abnormal-track-body" v-loading="loading" element-loading-background="rgba(15, 15, 15, 0.55)" element-loading-text="加载中...">
  10. <div class="abnormal-hero">
  11. <div class="abnormal-hero__share" @click="handleShare">
  12. <Icon name="share" color="rgba(255,255,255,0.85)" />
  13. <span>{{ t("agriFile.forward") }}</span>
  14. </div>
  15. <div class="abnormal-mask"></div>
  16. <div class="abnormal-top">
  17. <div class="abnormal-hero__tags">
  18. <span class="abnormal-hero__tag abnormal-hero__tag--level">
  19. <el-icon><WarningFilled /></el-icon>
  20. {{ level }}
  21. </span>
  22. <span class="abnormal-hero__tag abnormal-hero__tag--zone">{{ zoneName }}</span>
  23. </div>
  24. <div class="abnormal-hero__title">{{ theme }}</div>
  25. <div class="abnormal-hero__reason">{{ reason }}</div>
  26. </div>
  27. </div>
  28. <div class="abnormal-main">
  29. <!-- 农情研判 -->
  30. <div class="box-wrap stage-card analysis-card">
  31. <div class="work-info">
  32. <div class="section-title">
  33. <span class="title-bar"></span>
  34. {{ t("agriFile.agriAssessment") }}
  35. </div>
  36. <div class="analysis-card__desc">{{ assessmentDesc }}</div>
  37. <!-- <div class="analysis-card__stats">
  38. <div v-for="(item, index) in analysisStats" :key="index" class="analysis-card__stat">
  39. <div class="analysis-card__stat-value" :class="{ highlight: item.highlight }">
  40. <template v-if="item.unit">
  41. <span class="num">{{ item.value }}</span>
  42. <span class="unit">{{ item.unit }}</span>
  43. </template>
  44. <template v-else>{{ item.value }}</template>
  45. </div>
  46. <div class="analysis-card__stat-label">{{ item.label }}</div>
  47. </div>
  48. </div> -->
  49. </div>
  50. </div>
  51. <!-- 异常排查互动 -->
  52. <div class="interact-section-head">
  53. <span class="interact-section-head__text"> 异常排查互动 · 共 {{ interactList.length }} 项 </span>
  54. <span class="interact-section-head__line"></span>
  55. </div>
  56. <div v-for="(item, index) in interactList" :key="item.fw_code || index" class="abnormal-item">
  57. <div class="abnormal-item__wrap">
  58. <div class="abnormal-item__title">
  59. <img class="abnormal-item__icon" src="@/assets/img/agricultural/gaojin.png" alt="" />
  60. <span>{{ item.abnormal_type || t("agriFile.rootAbnormal") }}</span>
  61. </div>
  62. <div class="stage-card interact-card">
  63. <div class="work-info">
  64. <!-- 已答:问题 + 答案一句 + 修改;点修改后回到选项态 -->
  65. <div v-if="isAnsweredView(item, index)" class="interact-card__answered">
  66. <div class="interact-card__answered-text">
  67. <span class="interact-card__answered-problem">{{
  68. item.interact_problem
  69. }}:</span>
  70. <span class="interact-card__answered-value">{{
  71. resolveAnswerText(item)
  72. }}</span>
  73. </div>
  74. <div class="interact-card__edit" @click="startEdit(item, index)">
  75. 修改
  76. <el-icon class="interact-card__edit-icon"><Edit /></el-icon>
  77. </div>
  78. </div>
  79. <template v-else>
  80. <div class="interact-card__head">
  81. <div class="section-title interact-card__title">
  82. <span class="title-bar"></span>
  83. {{ t("agriFile.interactQuestion") }}
  84. </div>
  85. <div
  86. class="interact-card__submit"
  87. :class="{ disabled: selectedMap[item.fw_code || index] == null }"
  88. @click="handleSubmit(item, index)"
  89. >
  90. 确认提交
  91. </div>
  92. </div>
  93. <div class="interact-card__qa">
  94. <div class="interact-card__question">{{ item.interact_problem }}</div>
  95. <div class="interact-card__options">
  96. <div
  97. v-for="(opt, optIndex) in item.options"
  98. :key="`${item.fw_code || index}-${optIndex}`"
  99. class="interact-option"
  100. :class="{
  101. selected: selectedMap[item.fw_code || index] === optIndex,
  102. }"
  103. @click="selectedMap[item.fw_code || index] = optIndex"
  104. >
  105. <span class="interact-option__text">{{ opt }}</span>
  106. </div>
  107. </div>
  108. </div>
  109. </template>
  110. </div>
  111. </div>
  112. <!-- 巡园向导 -->
  113. <div class="guide-card">
  114. <div class="work-info">
  115. <div class="section-title">
  116. <img class="guide-icon" src="@/assets/img/farm/guide.png" alt="" />
  117. {{ t("agriFile.patrolGuide") }}
  118. </div>
  119. <div class="guide-card__img-box">
  120. <photo-provider :photo-closable="true">
  121. <photo-consumer :src="resolveGuideImage(item.pic_url)">
  122. <img :src="resolveGuideImage(item.pic_url)" alt="" />
  123. </photo-consumer>
  124. </photo-provider>
  125. </div>
  126. </div>
  127. <div class="guide-card__upload-wrap">
  128. <div class="guide-card__upload" @click="handleUploadClick">
  129. <img class="guide-card__upload-icon" src="@/assets/img/common/camera.png" alt="" />
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. <album-upload-popup v-model:show="showUploadPopup" @confirm="handleUploadConfirm" />
  138. <tip-popup
  139. v-model:show="showSuccessPopup"
  140. type="executeSuccess"
  141. text="您已上传成功"
  142. text2="诊断报告正在生成,请稍后..."
  143. hideBtn
  144. >
  145. <template #footer>
  146. <div class="bottom-btn-container">
  147. <div class="bottom-btn primary-btn" @click="handleComplete">完成</div>
  148. </div>
  149. </template>
  150. </tip-popup>
  151. <tip-popup
  152. v-model:show="showInteractSuccessPopup"
  153. type="executeSuccess"
  154. :text="interactSuccessText"
  155. :text2="interactSuccessText2"
  156. hideBtn
  157. >
  158. <template #footer>
  159. <div class="bottom-btn-container">
  160. <div class="bottom-btn secondary-btn" @click="handleInteractComplete">完成</div>
  161. <div class="bottom-btn primary-btn" @click="handleViewWorkDetail">查看详情</div>
  162. </div>
  163. </template>
  164. </tip-popup>
  165. </div>
  166. </template>
  167. <script setup>
  168. import { computed, nextTick, onActivated, reactive, ref } from "vue";
  169. import { useRoute, useRouter } from "vue-router";
  170. import { Icon } from "vant";
  171. import { ElMessage } from "element-plus";
  172. import { EditPen } from "@element-plus/icons-vue";
  173. import customHeader from "@/components/customHeader.vue";
  174. import albumUploadPopup from "../components/albumUploadPopup.vue";
  175. import tipPopup from "@/components/popup/tipPopup.vue";
  176. import { useI18n } from "@/i18n";
  177. import { base_img_url2 } from "@/api/config";
  178. import {
  179. ensureFarmContext,
  180. getSelectedFarmIdFromStorage,
  181. resolvePairedFarmZone,
  182. } from "@/utils/selectedFarm";
  183. import wx from "weixin-js-sdk";
  184. const { t } = useI18n();
  185. const route = useRoute();
  186. const router = useRouter();
  187. // ---------- 常量 ----------
  188. const DEFAULT_GUIDE_IMAGE = require("@/assets/img/agricultural/patrol-guide.png");
  189. /** 农情研判底部指标:接口未接好前写死 */
  190. const analysisStats = [
  191. { value: "126", unit: "mm", label: "累计降雨", highlight: false },
  192. { value: "92", unit: "%", label: "土壤含水率", highlight: false },
  193. { value: "52", unit: "h", label: "根部积水", highlight: true },
  194. ];
  195. // ---------- 页面状态 ----------
  196. const loading = ref(false);
  197. const submitting = ref(false);
  198. const showUploadPopup = ref(false);
  199. const showSuccessPopup = ref(false);
  200. const showInteractSuccessPopup = ref(false);
  201. /** 异常确认成功弹窗:文案与跳转参数来自接口 farmwork_brief */
  202. const interactSuccessBrief = ref({
  203. fw_name: "",
  204. suggest_execute_date: "",
  205. farm_id: null,
  206. zone_id: null,
  207. fw_code: "",
  208. });
  209. const needDraw = ref(true); // status≠1 时需先勾画种植范围
  210. const interactList = ref([]); // ab_it_info.interact_Info 映射后的列表
  211. const stressInfo = ref({}); // 胁迫等级等公共信息
  212. const selectedMap = reactive({}); // fw_code/index → 选项下标
  213. const editingMap = reactive({}); // fw_code/index → 已答后点「修改」进入选项态
  214. /** 与查询共用的提交上下文,保证 fw 答案与列表同源 */
  215. const queryContext = ref({
  216. farm_id: null,
  217. zone_id: null,
  218. calc_date: "",
  219. crop_type: "",
  220. });
  221. const interactSuccessText = computed(() => {
  222. const name = interactSuccessBrief.value.fw_name || "";
  223. return `系统已触发了 ${name}农事`;
  224. });
  225. const interactSuccessText2 = computed(() => {
  226. const date = interactSuccessBrief.value.suggest_execute_date || "";
  227. return `建议 ${date} 执行`;
  228. });
  229. // ---------- 工具函数 ----------
  230. function isTruthyFlag(value) {
  231. return value === 1 || value === "1" || value === true || value === "true";
  232. }
  233. function parseMaybeJson(value) {
  234. if (value == null || value === "") return null;
  235. if (typeof value === "object") return value;
  236. try {
  237. return JSON.parse(value);
  238. } catch {
  239. return null;
  240. }
  241. }
  242. /**
  243. * 分享链路:dev_login 把整份登录 query 塞进 miniJson,
  244. * 真正的页面参数在 miniJson.paramsPage(id / zoneId / farmId / fromShare / pageName)
  245. */
  246. function resolvePageParams() {
  247. const mini = parseMaybeJson(route.query.miniJson);
  248. if (mini) {
  249. const page = parseMaybeJson(mini.paramsPage) || {};
  250. return { ...mini, ...page };
  251. }
  252. const paramsPage = parseMaybeJson(route.query.paramsPage);
  253. if (paramsPage) {
  254. return { ...route.query, ...paramsPage };
  255. }
  256. return { ...(route.query || {}) };
  257. }
  258. // ---------- 计算属性 ----------
  259. const pageParams = computed(() => resolvePageParams());
  260. const zoneId = computed(
  261. () => pageParams.value.zoneId || pageParams.value.id || "",
  262. );
  263. const firstInteract = computed(() => interactList.value[0] || null);
  264. /** interaction_theme */
  265. const theme = computed(() => firstInteract.value?.interaction_title || t("agriFile.interactTheme"));
  266. /** interaction_title */
  267. const reason = computed(() => firstInteract.value?.interaction_theme || t("agriFile.interactReason"));
  268. /** 农情研判说明 */
  269. const assessmentDesc = computed(() => firstInteract.value?.interaction_reason || t("agriFile.agriAssessmentDesc"));
  270. const guideImage = computed(() => resolveGuideImage(firstInteract.value?.pic_url));
  271. /** stress_info.level */
  272. const level = computed(() => {
  273. const lv = stressInfo.value?.level;
  274. if (lv == null || lv === "") return t("agriFile.riskLevel2");
  275. return `${lv}级`;
  276. });
  277. const zoneName = computed(() => {
  278. const farm = getSelectedFarm();
  279. return farm.variety_name || farm.zone_name || t("agriFile.zoneOne");
  280. });
  281. /** 通过分享进入:无返回箭头 */
  282. const isFromShare = computed(() => isTruthyFlag(pageParams.value?.fromShare));
  283. function getSelectedFarm() {
  284. try {
  285. return JSON.parse(localStorage.getItem("selectedFarmData") || "{}");
  286. } catch {
  287. return {};
  288. }
  289. }
  290. function getSelectedFarmId() {
  291. const stored = localStorage.getItem("selectedFarmId");
  292. if (stored != null && stored !== "") return Number(stored);
  293. const farm = getSelectedFarm();
  294. const id = farm.farm_id ?? farm.id;
  295. return id != null && id !== "" ? Number(id) : null;
  296. }
  297. /** 农场品类编码,接口 crop_type */
  298. const resolveCropType = (farm = getSelectedFarm()) =>
  299. farm.category_code || farm.categorycode || farm.crop_code || farm.crop_type || "";
  300. function resolveImageUrl(path) {
  301. if (!path) return "";
  302. const text = String(path).trim();
  303. if (!text) return "";
  304. if (/^https?:\/\//i.test(text)) return text;
  305. return base_img_url2 + text.replace(/^\//, "");
  306. }
  307. function resolveGuideImage(picUrl) {
  308. return resolveImageUrl(picUrl) || DEFAULT_GUIDE_IMAGE;
  309. }
  310. /** interact_options 可能是 JSON 字符串 */
  311. function parseInteractOptions(value) {
  312. if (Array.isArray(value)) return value.map((name) => String(name));
  313. const parsed = parseMaybeJson(value);
  314. if (Array.isArray(parsed)) return parsed.map((name) => String(name));
  315. return [];
  316. }
  317. /** 已答文案:提交字段为 options,回显兼容 answer / interact_answer / 字符串 options */
  318. function resolveAnswerText(item) {
  319. const raw =
  320. item?.answerText ||
  321. item?.answer ||
  322. item?.interact_answer ||
  323. item?.fw_answer ||
  324. (typeof item?.options === "string" ? item.options : "");
  325. return raw != null && raw !== "" ? String(raw) : "";
  326. }
  327. function mapInteractItem(raw) {
  328. const optionsStr =
  329. typeof raw?.options === "string" && raw.options.trim() && !raw.options.trim().startsWith("[")
  330. ? raw.options
  331. : "";
  332. return {
  333. ...raw,
  334. options: parseInteractOptions(raw?.interact_options),
  335. answerText: String(raw?.answer ?? raw?.interact_answer ?? raw?.fw_answer ?? optionsStr ?? ""),
  336. };
  337. }
  338. function interactKey(item, index) {
  339. return item?.fw_code || index;
  340. }
  341. /** 已答且未进入修改态 */
  342. function isAnsweredView(item, index) {
  343. return Number(item?.is_answered) === 1 && !editingMap[interactKey(item, index)];
  344. }
  345. /** 点修改:回到选项,并尽量回填当前答案 */
  346. function startEdit(item, index) {
  347. const key = interactKey(item, index);
  348. editingMap[key] = true;
  349. const answer = resolveAnswerText(item);
  350. if (!answer || !Array.isArray(item?.options)) return;
  351. const optIndex = item.options.findIndex((opt) => opt === answer);
  352. if (optIndex >= 0) selectedMap[key] = optIndex;
  353. }
  354. const formatLocalDate = (date) => {
  355. const y = date.getFullYear();
  356. const m = String(date.getMonth() + 1).padStart(2, "0");
  357. const d = String(date.getDate()).padStart(2, "0");
  358. return `${y}-${m}-${d}`;
  359. };
  360. // ---------- 业务逻辑 ----------
  361. const fetchAbnormalInteract = async () => {
  362. const farm = getSelectedFarm();
  363. const { farmId, zoneId: zId } = await resolvePairedFarmZone(zoneId.value);
  364. const cropType = resolveCropType(farm);
  365. if (farmId == null || zId == null || zId === "" || !cropType) {
  366. interactList.value = [];
  367. stressInfo.value = {};
  368. return;
  369. }
  370. const params = {
  371. crop_type: cropType,
  372. farm_id: farmId,
  373. zone_id: zId,
  374. calc_date: formatLocalDate(new Date()),
  375. };
  376. queryContext.value = { ...params };
  377. loading.value = true;
  378. try {
  379. const res = await VE_API.questionnaire.getAbnormalInteract(params);
  380. if (res?.code !== 200) {
  381. interactList.value = [];
  382. stressInfo.value = {};
  383. return;
  384. }
  385. const data = res?.data || {};
  386. const abInfo = data.ab_it_info || {};
  387. const list = Array.isArray(abInfo.interact_Info) ? abInfo.interact_Info : [];
  388. interactList.value = list.map(mapInteractItem);
  389. stressInfo.value = abInfo.stress_info || data.stress_info || {};
  390. } catch (e) {
  391. console.warn("[abnormalTrack] getAbnormalInteract failed", e);
  392. interactList.value = [];
  393. stressInfo.value = {};
  394. } finally {
  395. loading.value = false;
  396. }
  397. };
  398. /** status=1 有范围无需勾画;status=0 无范围需要勾画 */
  399. const fetchZoneRangeStatus = async () => {
  400. const { farmId, zoneId: zId } = await resolvePairedFarmZone(zoneId.value);
  401. if (farmId == null || farmId === "" || zId == null || zId === "") {
  402. needDraw.value = true;
  403. return;
  404. }
  405. try {
  406. const res = await VE_API.questionnaire.checkZoneRange({
  407. farm_id: farmId,
  408. zone_id: zId,
  409. });
  410. needDraw.value = Number(res?.data?.status) !== 1;
  411. } catch (e) {
  412. console.warn("[abnormalTrack] checkZoneRange failed", e);
  413. needDraw.value = true;
  414. }
  415. };
  416. // ---------- 事件处理 / 生命周期 ----------
  417. const handleShare = () => {
  418. const shareFarmId =
  419. pageParams.value.farmId ||
  420. pageParams.value.farm_id ||
  421. getSelectedFarmIdFromStorage();
  422. const query = {
  423. askInfo: { title: "转发巡园要点", content: "是否分享给好友" },
  424. shareText: reason.value || "速长窗口不追肥?后期发育慢人一步,直接掉队!",
  425. targetUrl: "abnormal_track",
  426. paramsPage: JSON.stringify({
  427. id: pageParams.value.id || zoneId.value,
  428. zoneId: zoneId.value,
  429. ...(shareFarmId ? { farmId: shareFarmId } : {}),
  430. fromShare: 1,
  431. ...(pageParams.value.pageName
  432. ? { pageName: pageParams.value.pageName }
  433. : {}),
  434. }),
  435. imageUrl: "https://birdseye-img.sysuimars.com/farm-h5/abnormal_cover.png",
  436. };
  437. wx.miniProgram.navigateTo({
  438. url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
  439. });
  440. };
  441. /** 需勾画则先画范围;否则直接上传(同 growthTrack) */
  442. const handleUploadClick = () => {
  443. if (needDraw.value) {
  444. router.push({
  445. path: "/add_zone",
  446. query: {
  447. type: "farm",
  448. targetUrl: "/abnormal_track",
  449. ...(zoneId.value ? { trackId: zoneId.value } : {}),
  450. },
  451. });
  452. return;
  453. }
  454. showUploadPopup.value = true;
  455. };
  456. const handleUploadConfirm = async ({ images } = {}) => {
  457. const imageList = (Array.isArray(images) ? images : [])
  458. .filter(Boolean)
  459. .map((url) => resolveImageUrl(url));
  460. if (!imageList.length) {
  461. ElMessage.warning("请先上传照片");
  462. return;
  463. }
  464. const { farmId, zoneId: pairedZoneId } = await resolvePairedFarmZone(zoneId.value);
  465. if (farmId == null || pairedZoneId == null || pairedZoneId === "") {
  466. ElMessage.warning("当前农场与分区不匹配,请返回后重试");
  467. return;
  468. }
  469. try {
  470. const res = await VE_API.pheno.uploadAbnormalPhoto({
  471. farm_id: farmId,
  472. zone_id: pairedZoneId,
  473. images: imageList,
  474. });
  475. if (res?.code === 200) {
  476. showSuccessPopup.value = true;
  477. return;
  478. }
  479. ElMessage.error(res?.msg || "上传失败,请稍后再试");
  480. } catch {
  481. ElMessage.error("上传失败,请稍后再试");
  482. }
  483. };
  484. const handleComplete = () => {
  485. showSuccessPopup.value = false;
  486. router.replace("/agri_file");
  487. };
  488. const handleInteractComplete = () => {
  489. showInteractSuccessPopup.value = false;
  490. };
  491. const handleViewWorkDetail = () => {
  492. const { farm_id, zone_id, fw_code } = interactSuccessBrief.value;
  493. showInteractSuccessPopup.value = false;
  494. if (farm_id == null || zone_id == null || !fw_code) {
  495. ElMessage.warning("农事信息不完整,无法查看详情");
  496. return;
  497. }
  498. router.push({
  499. path: "/work_detail",
  500. query: {
  501. farm_id,
  502. zone_id,
  503. fw_code,
  504. },
  505. });
  506. };
  507. const handleSubmit = async (item, index) => {
  508. const key = interactKey(item, index);
  509. const optIndex = selectedMap[key];
  510. if (optIndex == null) {
  511. ElMessage.warning(t("agriFile.pleaseSelectOption"));
  512. return;
  513. }
  514. const optionText = item?.options?.[optIndex];
  515. if (!optionText || !item?.fw_code) {
  516. ElMessage.warning(t("agriFile.pleaseSelectOption"));
  517. return;
  518. }
  519. if (submitting.value) return;
  520. submitting.value = true;
  521. try {
  522. const res = await VE_API.questionnaire.confirmAbnormalInteract({
  523. ...queryContext.value,
  524. fw_code: item.fw_code,
  525. options: String(optionText),
  526. });
  527. if (res?.code === 200) {
  528. const data = res?.data || {};
  529. const brief = data.farmwork_brief || {};
  530. interactSuccessBrief.value = {
  531. fw_name: brief.fw_name || "",
  532. suggest_execute_date: brief.suggest_execute_date || "",
  533. farm_id: data.farm_id ?? queryContext.value.farm_id,
  534. zone_id: data.zone_id ?? queryContext.value.zone_id,
  535. fw_code: brief.fw_code || data.fw_code || "",
  536. };
  537. editingMap[key] = false;
  538. await fetchAbnormalInteract();
  539. showInteractSuccessPopup.value = true;
  540. return;
  541. }
  542. ElMessage.error(res?.msg || "提交失败,请稍后再试");
  543. } catch (e) {
  544. console.warn("[abnormalTrack] confirmAbnormalInteract failed", e);
  545. ElMessage.error("提交失败,请稍后再试");
  546. } finally {
  547. submitting.value = false;
  548. }
  549. };
  550. const handleBack = () => {
  551. router.back();
  552. };
  553. /** keep-alive 离开再进:清掉「修改」态,按接口已答态回到「已答 + 修改」 */
  554. function resetEditingState() {
  555. Object.keys(editingMap).forEach((k) => delete editingMap[k]);
  556. }
  557. onActivated(async () => {
  558. resetEditingState();
  559. // 分享进页可能落在接收方当前选中农场,先按 farmId / zoneId 切回分享上下文
  560. await ensureFarmContext({
  561. farmId: pageParams.value.farmId || pageParams.value.farm_id,
  562. zoneId: zoneId.value,
  563. });
  564. fetchZoneRangeStatus();
  565. fetchAbnormalInteract();
  566. if (route.query.showUpload !== "1") return;
  567. nextTick(() => {
  568. showUploadPopup.value = true;
  569. const { showUpload, ...restQuery } = route.query;
  570. router.replace({ path: route.path, query: restQuery });
  571. });
  572. });
  573. </script>
  574. <style lang="scss" scoped>
  575. .abnormal-track-page {
  576. display: flex;
  577. flex-direction: column;
  578. width: 100%;
  579. height: 100vh;
  580. overflow: hidden;
  581. background: #0b0b0b;
  582. color: #fff;
  583. .abnormal-track-body {
  584. flex: 1;
  585. overflow-y: auto;
  586. -webkit-overflow-scrolling: touch;
  587. padding-bottom: 10px;
  588. box-sizing: border-box;
  589. }
  590. .abnormal-hero {
  591. position: relative;
  592. padding: 86px 70px 0px 12px;
  593. box-sizing: border-box;
  594. z-index: 2;
  595. min-height: 240px;
  596. background: linear-gradient(
  597. 180deg,
  598. rgba(11, 11, 11, 0) 8.51%,
  599. rgba(11, 11, 11, 0.416) 42.95%,
  600. rgba(11, 11, 11, 0.468) 56.49%,
  601. rgba(11, 11, 11, 0.52) 80.47%
  602. ),
  603. url("@/assets/img/agricultural/detail-bg.png") right bottom / cover no-repeat;
  604. .abnormal-mask {
  605. position: absolute;
  606. bottom: 0;
  607. left: 0;
  608. width: 100%;
  609. height: 107px;
  610. background: linear-gradient(
  611. 180deg,
  612. rgba(11, 11, 11, 0) 8.47%,
  613. rgba(11, 11, 11, 0.8) 26.93%,
  614. rgba(11, 11, 11, 0.9) 37.74%,
  615. #0b0b0b 56.89%
  616. );
  617. }
  618. .abnormal-top {
  619. position: relative;
  620. z-index: 2;
  621. padding-bottom: 40px;
  622. }
  623. &__share {
  624. position: absolute;
  625. top: 16px;
  626. right: 16px;
  627. z-index: 2;
  628. display: inline-flex;
  629. align-items: center;
  630. gap: 4px;
  631. height: 28px;
  632. padding: 0 12px;
  633. border-radius: 14px;
  634. background: rgba(0, 0, 0, 0.45);
  635. border: 1px solid rgba(255, 255, 255, 0.12);
  636. color: rgba(255, 255, 255, 0.85);
  637. font-size: 12px;
  638. }
  639. &__tags {
  640. display: flex;
  641. align-items: center;
  642. flex-wrap: wrap;
  643. gap: 8px;
  644. margin-bottom: 12px;
  645. padding-right: 88px;
  646. }
  647. &__tag {
  648. display: inline-flex;
  649. align-items: center;
  650. gap: 3px;
  651. height: 20px;
  652. padding: 0 7px;
  653. border-radius: 24px;
  654. font-size: 12px;
  655. line-height: 20px;
  656. box-sizing: border-box;
  657. border: 1px solid rgba(138, 106, 46, 1);
  658. }
  659. &__tag--level {
  660. background: linear-gradient(90deg, #7e2321 0%, #350302 100%);
  661. color: #ff7d7b;
  662. border-color: rgba(201, 53, 50, 0.41);
  663. }
  664. &__tag--zone {
  665. color: #e8c27a;
  666. background: #2a2418;
  667. }
  668. &__title {
  669. font-family: "PangMenZhengDao", sans-serif;
  670. font-size: 26px;
  671. line-height: 34px;
  672. background: linear-gradient(180deg, #ffffff 0%, #fecd76 100%);
  673. -webkit-background-clip: text;
  674. background-clip: text;
  675. color: transparent;
  676. margin-bottom: 6px;
  677. }
  678. &__reason {
  679. font-size: 12px;
  680. line-height: 22px;
  681. padding: 4px;
  682. border-radius: 4px;
  683. background: linear-gradient(90deg, rgba(255, 212, 137, 0.1) 0%, rgba(255, 212, 137, 0) 100%);
  684. color: rgba(255, 255, 255, 1);
  685. }
  686. }
  687. .abnormal-main {
  688. position: relative;
  689. z-index: 3;
  690. margin-top: -38px;
  691. padding: 0 12px 12px;
  692. box-sizing: border-box;
  693. }
  694. .box-wrap {
  695. padding: 1px;
  696. border-radius: 12px;
  697. background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 72.15%);
  698. .work-info {
  699. background: linear-gradient(180deg, #1a191d 0%, #121216 100%);
  700. border-radius: 12px;
  701. padding: 12px 13px;
  702. box-sizing: border-box;
  703. }
  704. }
  705. .stage-card + .stage-card {
  706. margin-top: 12px;
  707. }
  708. .section-title {
  709. display: flex;
  710. align-items: center;
  711. gap: 10px;
  712. font-size: 16px;
  713. font-weight: 500;
  714. color: #f2e9d8;
  715. margin-bottom: 10px;
  716. &.interact-card__title {
  717. font-size: 14px;
  718. }
  719. .title-bar {
  720. width: 4px;
  721. height: 16px;
  722. border-radius: 2px;
  723. background: #ffd489;
  724. flex-shrink: 0;
  725. }
  726. }
  727. .analysis-card {
  728. .analysis-card__desc {
  729. font-size: 14px;
  730. line-height: 22px;
  731. color: rgba(255, 255, 255, 0.6);
  732. margin-bottom: 10px;
  733. }
  734. .analysis-card__stats {
  735. display: flex;
  736. align-items: stretch;
  737. background: rgba(255, 255, 255, 0.05);
  738. border-radius: 10px;
  739. padding: 8px 0 6px;
  740. }
  741. .analysis-card__stat {
  742. flex: 1;
  743. min-width: 0;
  744. text-align: center;
  745. position: relative;
  746. & + .analysis-card__stat::before {
  747. content: "";
  748. position: absolute;
  749. left: 0;
  750. top: 50%;
  751. transform: translateY(-50%);
  752. width: 1px;
  753. height: 32px;
  754. background: rgba(255, 255, 255, 0.06);
  755. }
  756. }
  757. .analysis-card__stat-value {
  758. font-size: 22px;
  759. line-height: 27px;
  760. color: #fff;
  761. margin-bottom: 2px;
  762. height: 27px;
  763. &.highlight {
  764. color: #ff9f5a;
  765. }
  766. .num {
  767. font-size: 22px;
  768. font-weight: 600;
  769. }
  770. .unit {
  771. color: rgba(255, 255, 255, 0.5);
  772. margin-left: 1px;
  773. font-size: 12px;
  774. }
  775. }
  776. .analysis-card__stat-label {
  777. font-size: 12px;
  778. line-height: 18px;
  779. color: rgba(255, 255, 255, 0.5);
  780. }
  781. }
  782. .interact-section-head {
  783. display: flex;
  784. align-items: center;
  785. gap: 10px;
  786. margin: 16px 0 12px;
  787. &__text {
  788. flex-shrink: 0;
  789. font-size: 12px;
  790. line-height: 18px;
  791. color: #727272;
  792. }
  793. &__line {
  794. flex: 1;
  795. height: 1px;
  796. background: rgba(255, 255, 255, 0.08);
  797. }
  798. }
  799. .abnormal-item {
  800. padding: 1px;
  801. border-radius: 12px;
  802. background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 25%),
  803. linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 25%);
  804. &__wrap {
  805. padding: 11px 13px;
  806. border-radius: 12px;
  807. background: linear-gradient(180deg, #1A191D 0%, #121216 100%);
  808. }
  809. & + .abnormal-item {
  810. margin-top: 16px;
  811. }
  812. &__title {
  813. display: flex;
  814. align-items: center;
  815. gap: 10px;
  816. margin-bottom: 12px;
  817. font-size: 16px;
  818. font-weight: 500;
  819. color: #FFD489;
  820. }
  821. &__icon {
  822. width: 18px;
  823. height: 23px;
  824. object-fit: contain;
  825. }
  826. }
  827. .interact-card {
  828. padding: 10px 12px;
  829. border-radius: 12px;
  830. border: 1px solid rgba(255, 241, 217, 0.2);
  831. background: linear-gradient(180deg, #1A191D 0%, #121216 100%);
  832. &__head {
  833. display: flex;
  834. align-items: center;
  835. justify-content: space-between;
  836. gap: 8px;
  837. margin-bottom: 12px;
  838. .section-title {
  839. margin-bottom: 0;
  840. }
  841. }
  842. &__submit {
  843. flex-shrink: 0;
  844. height: 27px;
  845. padding: 0 15px;
  846. border-radius: 24px;
  847. background: rgba(255, 212, 137, 0.1);
  848. border: 1px solid rgba(255, 212, 137, 0.4);
  849. color: #FFD489;
  850. font-size: 12px;
  851. line-height: 27px;
  852. text-align: center;
  853. box-sizing: border-box;
  854. &.disabled {
  855. opacity: 0.35;
  856. }
  857. }
  858. &__question {
  859. font-size: 16px;
  860. font-family: "PangMenZhengDao";
  861. line-height: 20px;
  862. color: #FFD489;
  863. margin-bottom: 12px;
  864. }
  865. &__answered {
  866. display: flex;
  867. align-items: center;
  868. justify-content: space-between;
  869. gap: 6px;
  870. }
  871. &__answered-text {
  872. flex: 1;
  873. min-width: 0;
  874. font-size: 14px;
  875. line-height: 22px;
  876. word-break: break-all;
  877. }
  878. &__answered-problem {
  879. color: rgba(255, 255, 255, 0.85);
  880. }
  881. &__answered-value {
  882. padding-left: 4px;
  883. color: #ffd489;
  884. }
  885. &__edit {
  886. flex-shrink: 0;
  887. display: inline-flex;
  888. align-items: center;
  889. gap: 4px;
  890. height: 22px;
  891. padding: 0 10px;
  892. border-radius: 12px;
  893. background: rgba(255, 212, 137, 0.1);
  894. color: #ffd489;
  895. font-size: 12px;
  896. line-height: 22px;
  897. box-sizing: border-box;
  898. }
  899. &__edit-icon {
  900. font-size: 12px;
  901. color: #ffd489;
  902. }
  903. &__options {
  904. display: flex;
  905. gap: 12px;
  906. }
  907. .interact-option {
  908. position: relative;
  909. flex: 1;
  910. min-width: 0;
  911. min-height: 41px;
  912. display: flex;
  913. align-items: center;
  914. justify-content: center;
  915. border-radius: 8px;
  916. background: rgba(255, 255, 255, 0.05);
  917. border: 1px solid rgba(255, 255, 255, 0.12);
  918. box-sizing: border-box;
  919. cursor: pointer;
  920. &__text {
  921. display: block;
  922. padding: 0 6px;
  923. overflow: hidden;
  924. text-overflow: ellipsis;
  925. white-space: nowrap;
  926. font-size: 14px;
  927. color: rgba(255, 255, 255, 0.7);
  928. }
  929. &.selected {
  930. border-color: rgba(255, 255, 255, 0.5);
  931. background: rgba(255, 255, 255, 0.1);
  932. .interact-option__text {
  933. color: #fff;
  934. }
  935. }
  936. }
  937. }
  938. .guide-card {
  939. position: relative;
  940. margin-top: 12px;
  941. background: rgba(75, 74, 70, 0.2);
  942. border-radius: 10px;
  943. padding: 10px;
  944. &__img {
  945. display: block;
  946. width: 100%;
  947. border-radius: 8px;
  948. }
  949. .guide-card__img-box {
  950. img {
  951. display: block;
  952. width: 100%;
  953. }
  954. }
  955. .section-title {
  956. gap: 6px;
  957. font-size: 14px;
  958. color: rgba(255, 255, 255, 0.6);
  959. }
  960. .guide-icon {
  961. width: 14px;
  962. height: 14px;
  963. object-fit: contain;
  964. filter: grayscale(100%);
  965. -webkit-filter: grayscale(100%);
  966. }
  967. }
  968. .guide-card__upload-wrap {
  969. position: absolute;
  970. right: 25px;
  971. bottom: 27px;
  972. z-index: 10;
  973. }
  974. .guide-card__upload {
  975. display: flex;
  976. align-items: center;
  977. justify-content: center;
  978. width: 52px;
  979. height: 52px;
  980. border-radius: 50%;
  981. background: linear-gradient(90deg, #ffebc9 0%, #ffca6d 100%);
  982. }
  983. .guide-card__upload-icon {
  984. width: 18px;
  985. height: 16px;
  986. object-fit: contain;
  987. }
  988. }
  989. .bottom-btn-container {
  990. display: flex;
  991. justify-content: space-between;
  992. gap: 12px;
  993. width: 100%;
  994. .bottom-btn {
  995. flex: 1;
  996. padding: 0 25px;
  997. border-radius: 8px;
  998. font-size: 16px;
  999. height: 44px;
  1000. line-height: 44px;
  1001. box-sizing: border-box;
  1002. text-align: center;
  1003. &.secondary-btn {
  1004. color: rgba(255, 255, 255, 0.6);
  1005. border: 1px solid rgba(255, 255, 255, 0.12);
  1006. background: transparent;
  1007. }
  1008. &.primary-btn {
  1009. background: linear-gradient(90deg, #FFEBC9 0%, #FFCA6D 100%);
  1010. color: #1A1408;
  1011. }
  1012. }
  1013. }
  1014. </style>