index.vue 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468
  1. <template>
  2. <div class="work-detail">
  3. <custom-header
  4. v-if="!miniJson?.hideDraw"
  5. :name="$t('workDetail.title')"
  6. :isGoBack="!isFromShare"
  7. :isClose="isFromShare"
  8. :showClose="false"
  9. @goback="handleBack"
  10. />
  11. <div class="work-detail-content">
  12. <!-- 顶部状态 -->
  13. <div class="content-status" :class="{'done-status': statusVal === 'completed'}">
  14. <div class="status-l">
  15. <div class="status-title">
  16. <span class="status-title-text">08.18 {{ farmData.fw_name }}</span>
  17. <div class="status-title-tags">
  18. <span
  19. v-if="farmData.isNormal"
  20. class="status-sub small-tag"
  21. :style="statusTagStyle[farmData?.farm_work_type]"
  22. >标准类</span>
  23. <span
  24. v-if="farmData.isAbnormal"
  25. class="status-sub small-tag isAbnormal"
  26. :style="statusTagStyle[farmData?.farm_work_type]"
  27. >异常类</span>
  28. <span
  29. v-if="farmData.isWeather"
  30. class="status-sub small-tag isWeather"
  31. :style="statusTagStyle[farmData?.farm_work_type]"
  32. >气象类</span>
  33. <span
  34. v-if="farmData.isHighRisk"
  35. class="status-sub small-tag isHighRisk"
  36. :style="statusTagStyle[farmData?.farm_work_type]"
  37. >高风险</span>
  38. </div>
  39. </div>
  40. <div class="status-hint-card" v-if="farmData.cornerTip">
  41. <div class="status-hint-text">{{ farmData.cornerTip }}</div>
  42. </div>
  43. <div class="status-sub-wrap" :style="getFarmWorkTypeColorStyle(farmData)" v-else>
  44. <div v-if="statusVal !== 'completed'" class="status-sub" :style="statusTagStyle[farmData?.farm_work_type]">{{ farmWorkTypeObj[farmData?.farm_work_type] }}</div>
  45. <div v-if="statusVal === 'completed'" class="status-sub done-status__text">
  46. <el-icon size="14" class="done-status__icon"><SuccessFilled /></el-icon>
  47. 已完成
  48. </div>
  49. <!-- <div class="status-sub">
  50. {{ farmData.best_time }}
  51. </div> -->
  52. </div>
  53. </div>
  54. <!-- <div class="status-r">
  55. <img class="status-r__icon" src="@/assets/img/home/user-icon-fill.png" alt="">
  56. 外包农事
  57. </div> -->
  58. </div>
  59. <div class="work-wrap" :class="{ 'from-share': isFromShare }">
  60. <!-- 农事组信息 -->
  61. <div class="group-info group-box" v-if="farmData.fw_explain_simple">
  62. <div class="group-name">
  63. <div class="group-title">农情研判:</div>
  64. {{ farmData.fw_explain_simple }}
  65. </div>
  66. </div>
  67. <div class="box-wrap stage-card">
  68. <div class="work-info">
  69. <div class="execution-area-card" @click="handleViewArea">
  70. <div class="execution-area-card__header">
  71. <span class="title">{{ $t('agriRecordDetail.executionArea') }}</span>
  72. <span class="code">{{ farmData.crop_category_name }}</span>
  73. </div>
  74. <div class="map-container" ref="mapContainer"></div>
  75. </div>
  76. <!-- <div class="area-list">
  77. <div v-for="(zone, zoneIndex) in farmZones"
  78. :key="`${zone.zone_name || 'zone'}-${zoneIndex}`" class="area-item">
  79. <div class="area-l">
  80. {{ zone.zone_name }}
  81. <span> {{ zone.execute_time }}</span>
  82. <span class="area-tag" :style="backgroundFarmWorkStatus(farmData.work_status)">{{
  83. workStatusObj[farmData.work_status] }}</span>
  84. </div>
  85. <div class="area-r" @click="handleExecute(farmData?.work_status, farmData?.farm_work_type)" :style="{background:farmData?.work_status === 6 ? '#37C11B' : '#2199F8'}">{{ farmData?.work_status === 6 ? '溯源认证' : '我已完成' }}</div>
  86. </div>
  87. </div> -->
  88. <!-- <div class="ecological-plant-card">
  89. <div class="ecological-plant-text">
  90. <div class="ecological-plant-line">
  91. 生态种植方式:{{ ecologicalPlantingMethodText }}
  92. </div>
  93. <div class="ecological-plant-line ecological-plant-line--sub">
  94. 来自于 {{ ecologicalExecutorOrg }}
  95. </div>
  96. </div>
  97. <div class="ecological-plant-gallery">
  98. <img v-for="(src, idx) in ecologicalPlantThumbUrls" :key="idx"
  99. class="ecological-plant-thumb" :src="src" alt="" />
  100. </div>
  101. </div> -->
  102. </div>
  103. </div>
  104. <div class="box-wrap stage-card">
  105. <div class="work-info">
  106. <div class="info-item">
  107. <div class="info-title"><span class="title-block"></span>{{ $t('workDetail.prescription') }}
  108. </div>
  109. <div class="info-value">{{ farmData.fw_precrip }}</div>
  110. </div>
  111. <div class="info-item">
  112. <div class="info-title"><span class="title-block"></span>{{ $t('workDetail.executeParameters')
  113. }}</div>
  114. <div class="info-value">{{ farmData.fw_params }}</div>
  115. </div>
  116. <div class="info-item">
  117. <div class="info-title"><span class="title-block"></span>{{ $t('workDetail.notes') }}</div>
  118. <div class="info-value">{{ farmData.fw_atten }}</div>
  119. </div>
  120. </div>
  121. </div>
  122. <!-- <div class="warning-info">
  123. <div class="warning-l">
  124. <div class="warning-title">
  125. <el-icon size="16" color="#FF953D"><WarningFilled /></el-icon>
  126. 存在继发危害需巡园
  127. </div>
  128. <div class="warning-text">{{ $t('文案文案文案文案文案') }}</div>
  129. </div>
  130. <div class="warning-r">{{ $t('异常记录') }}</div>
  131. </div> -->
  132. <!-- 底部按钮 -->
  133. <!-- <div class="fixed-btn-wrap execute-action">
  134. <div class="action-item second" v-if="!miniJson?.hideDraw" @click="handleConvert">{{ $t('转发给执行人员') }}</div>
  135. </div> -->
  136. <!-- <div class="action-item primary" @click="handleExecute">{{ $t('溯源认证') }}</div> -->
  137. </div>
  138. </div>
  139. <div v-if="statusVal !== 'completed' && farmData.isAbnormal" class="warning-info" :class="{ 'from-share': isFromShare }">
  140. <div class="warning-l">
  141. <div class="warning-title">
  142. <el-icon size="16" color="#FF953D"><WarningFilled /></el-icon>
  143. 发现异常后机动执行
  144. </div>
  145. <div class="warning-text">为您匹配最佳农事方案</div>
  146. </div>
  147. <div class="warning-r" @click="goGrowthTrack">巡园要点</div>
  148. </div>
  149. <div class="footer-btn" v-if="statusVal !== 'completed'" :class="{'done-btn': statusVal === 'completed'}">
  150. <!-- <div class="secondary-btn" @click="handleShare">转发</div> -->
  151. <div class="primary-btn" @click="handleComplete">我已完成</div>
  152. </div>
  153. <ExecutePopup ref="executePopupRef" @executeSuccess="getDetail" />
  154. <upload-tips v-model:show="showUploadTipsPopup" />
  155. </div>
  156. </template>
  157. <script setup>
  158. import { ElMessage, ElMessageBox } from "element-plus";
  159. import { WarningFilled } from "@element-plus/icons-vue";
  160. import wx from "weixin-js-sdk";
  161. import customHeader from "@/components/customHeader.vue";
  162. import { ref, computed, watch, onMounted, onActivated, onDeactivated, onBeforeUnmount, nextTick } from "vue";
  163. import { useI18n } from "@/i18n";
  164. import { useRouter } from "vue-router";
  165. import { formatDate } from "@/common/commonFun";
  166. import ExecutePopup from "./components/executePopup.vue";
  167. import { base_img_url2 } from "@/api/config";
  168. import UploadTips from "@/components/popup/uploadTips.vue";
  169. import { useRoute } from "vue-router";
  170. import AreaMap from "./components/areaMap.js";
  171. import WKT from "ol/format/WKT.js";
  172. import { time } from "echarts";
  173. const route = useRoute();
  174. const { locale } = useI18n();
  175. const showUploadTipsPopup = ref(false);
  176. const router = useRouter();
  177. // const info = JSON.parse(localStorage.getItem("localUserInfo") || "{}");
  178. const statusVal = computed(() => pageParams.value?.statusVal ?? null);
  179. function isTruthyFlag(value) {
  180. return value === 1 || value === "1" || value === true || value === "true";
  181. }
  182. function parseMaybeJson(value) {
  183. if (value == null || value === "") return null;
  184. if (typeof value === "object") return value;
  185. try {
  186. return JSON.parse(value);
  187. } catch {
  188. return null;
  189. }
  190. }
  191. /**
  192. * 分享链路:dev_login 会把整份登录 query 塞进 miniJson,
  193. * 真正的页面参数在 miniJson.paramsPage 里(如 id、fromShare)
  194. */
  195. function resolvePageParams() {
  196. const mini = parseMaybeJson(route.query.miniJson);
  197. if (mini) {
  198. const page = parseMaybeJson(mini.paramsPage) || {};
  199. return { ...mini, ...page };
  200. }
  201. const paramsPage = parseMaybeJson(route.query.paramsPage);
  202. if (paramsPage) {
  203. return { ...route.query, ...paramsPage };
  204. }
  205. return { ...(route.query || {}) };
  206. }
  207. const pageParams = computed(() => resolvePageParams());
  208. const workId = computed(() => pageParams.value?.id ?? null);
  209. /** 通过分享进入:无返回箭头、无底部转发 */
  210. const isFromShare = computed(() => isTruthyFlag(pageParams.value?.fromShare));
  211. const syncMiniJsonFromRoute = () => {
  212. miniJson.value = resolvePageParams();
  213. };
  214. /** 接口根级与 detail 合并后的详情(pesticideList、prescriptionList) */
  215. const detail = ref({
  216. farmId: null,
  217. farmWorkLibId: null,
  218. farmWorkName: "",
  219. flowStatus: null,
  220. purpose: "",
  221. speciesId: null,
  222. speciesName: "",
  223. executeDate: null,
  224. intervelTime: null,
  225. remark: "",
  226. pesticideList: [],
  227. prescriptionList: [],
  228. confirmPicture: [],
  229. executeEvidence: [],
  230. expertName: "",
  231. expertPrescription: "",
  232. id: null,
  233. postId: null,
  234. post: null,
  235. expertNameFromFarmBasicInfo: "",
  236. rangeWkt: null,
  237. });
  238. /** 凭证图片统一为 { filename } */
  239. const normalizeCropAlbum = (album) => {
  240. if (!album || !Array.isArray(album)) return [];
  241. return album
  242. .map((x) => {
  243. if (!x) return null;
  244. if (typeof x === "string") return { filename: x };
  245. if (x.filename) return x;
  246. return null;
  247. })
  248. .filter(Boolean);
  249. };
  250. const maybeShowUploadTips = () => {
  251. if (detail.value?.flowStatus !== 1) return;
  252. const shown = localStorage.getItem('upload_tips');
  253. if (shown === "1") return;
  254. localStorage.setItem('upload_tips', "1");
  255. showUploadTipsPopup.value = true;
  256. };
  257. onMounted(() => {
  258. maybeShowUploadTips();
  259. });
  260. const miniJson = ref(null);
  261. const farmData = ref({});
  262. /** 列表页带入的 agronomy_detail 缓存 */
  263. const WORK_AGRONOMY_DETAIL_KEY = "WORK_AGRONOMY_DETAIL";
  264. function readWorkAgronomyPayload() {
  265. try {
  266. return JSON.parse(sessionStorage.getItem(WORK_AGRONOMY_DETAIL_KEY) || "null");
  267. } catch {
  268. return null;
  269. }
  270. }
  271. /** 列表带入:agronomy_detail 原样 + 列表上的类型/状态标签 */
  272. function applyAgronomyDetailPayload(payload) {
  273. if (!payload || typeof payload !== "object") return false;
  274. const detail =
  275. payload.agronomy_detail && typeof payload.agronomy_detail === "object"
  276. ? payload.agronomy_detail
  277. : payload.fw_name || payload.fw_explain_simple
  278. ? payload
  279. : null;
  280. if (!detail) return false;
  281. const workType = payload.work_type;
  282. const isWeather = workType === "weather_warning" || workType === "warning";
  283. farmData.value = {
  284. ...detail,
  285. work_id: payload.work_id ?? detail.id,
  286. work_type: workType,
  287. work_status: payload.work_status,
  288. status: payload.status,
  289. // 与列表卡片标签一致
  290. isNormal: payload.isNormal ?? (!isWeather && workType === "standard"),
  291. isAbnormal: payload.isAbnormal ?? false,
  292. isWeather: payload.isWeather ?? isWeather,
  293. isHighRisk: payload.isHighRisk ?? isWeather,
  294. cornerTip: payload.cornerTip || "",
  295. };
  296. return true;
  297. }
  298. const wktFmt = new WKT();
  299. const MAP_CENTER_FALLBACK = "POINT(113.1093017627431 22.57454083668)";
  300. const farmZones = computed(() => {
  301. const zones = farmData.value?.zones;
  302. if (!Array.isArray(zones)) return [];
  303. return zones.filter(
  304. (z) => z && typeof z.zone_geometry === "string" && z.zone_geometry.trim()
  305. );
  306. });
  307. /** 从地块 WKT 取首坐标作为初始中心,initZones 会 fit 到全部地块 */
  308. function wktCenterPointFromZones(zones) {
  309. const list = Array.isArray(zones) ? zones : [];
  310. for (const zone of list) {
  311. const wkt = zone?.zone_geometry;
  312. if (!wkt || typeof wkt !== "string") continue;
  313. try {
  314. const c = wktFmt.readGeometry(wkt.trim()).getFirstCoordinate();
  315. return `POINT(${c[0]} ${c[1]})`;
  316. } catch {
  317. /* try next zone */
  318. }
  319. }
  320. return MAP_CENTER_FALLBACK;
  321. }
  322. function destroyWorkDetailMap() {
  323. areaMap.destroyMap();
  324. }
  325. function initWorkDetailMap() {
  326. nextTick(() => {
  327. if (!mapContainer.value) return;
  328. const zones = farmZones.value;
  329. areaMap.destroyMap();
  330. areaMap.initMap(wktCenterPointFromZones(zones), mapContainer.value);
  331. areaMap.initZones(zones);
  332. });
  333. }
  334. onDeactivated(() => {
  335. destroyWorkDetailMap();
  336. });
  337. onBeforeUnmount(() => {
  338. destroyWorkDetailMap();
  339. });
  340. onActivated(() => {
  341. syncMiniJsonFromRoute();
  342. getDetail();
  343. });
  344. const workStatusObj = {
  345. 0: "时间待校准",
  346. 1: "触发待巡园",
  347. 2: "待执行",
  348. 3: "未激活",
  349. 4: "已认证",
  350. 5: "已失效",
  351. 6: "已执行",
  352. }
  353. const farmWorkTypeObj = {
  354. 1: "标准农事",
  355. 2: "机动农事",
  356. 3: "气象预警农事",
  357. 4: "气象恢复农事",
  358. 5: "异常农事",
  359. 6: "标准施肥类",
  360. 7: "标准防治类",
  361. 8: "标准调节类",
  362. }
  363. const backgroundFarmWorkStatus = (status) => {
  364. let background = 'rgba(33, 153, 248, 0.1)';
  365. let color = '#2199F8';
  366. if (status === 6 || status === 4) {
  367. background = 'rgba(55, 193, 27, 0.1)';
  368. color = '#37C11B';
  369. } else if (status === 3 || status === 5) {
  370. background = 'rgba(98, 98, 98, 0.1)';
  371. color = '#626262';
  372. }
  373. return {
  374. background,
  375. color,
  376. }
  377. }
  378. const getDetail = () => {
  379. const payload = readWorkAgronomyPayload();
  380. const payloadId = payload?.work_id != null ? String(payload.work_id) : "";
  381. const id = workId.value;
  382. // 优先使用列表带入的 agronomy_detail
  383. if (payload?.agronomy_detail && (!id || !payloadId || payloadId === String(id))) {
  384. applyAgronomyDetailPayload(payload);
  385. initWorkDetailMap();
  386. return;
  387. }
  388. if (id == null || id === "") return;
  389. VE_API.monitor.getWorkDetail({ id }).then((res) => {
  390. if (res.code === 200 && res.data.length) {
  391. farmData.value = res.data[0];
  392. initWorkDetailMap();
  393. }
  394. });
  395. };
  396. const handleExecute = (status, type) => {
  397. const popupType = type === 5 ? 'bc' : (status === 6 ? 'sy' : 'wc')
  398. executePopupRef.value.openPopup(popupType);
  399. };
  400. /** 完成农事用手机号:优先录入信息 */
  401. function resolveUserTel() {
  402. try {
  403. const entry = JSON.parse(localStorage.getItem("ENTRY_FARM_DATA") || "null");
  404. if (entry?.phone) return String(entry.phone).trim();
  405. } catch {
  406. // ignore
  407. }
  408. try {
  409. const userInfo = JSON.parse(localStorage.getItem("localUserInfo") || "{}");
  410. return String(userInfo.tel || userInfo.phone || userInfo.mobile || "").trim();
  411. } catch {
  412. return "";
  413. }
  414. }
  415. const handleComplete = async () => {
  416. const tel = resolveUserTel();
  417. const id = farmData.value?.work_id ?? workId.value;
  418. if (!tel) {
  419. ElMessage.error("缺少手机号,无法完成农事");
  420. return;
  421. }
  422. if (id == null || id === "") {
  423. ElMessage.error("缺少农事信息,无法完成");
  424. return;
  425. }
  426. try {
  427. await ElMessageBox.confirm("确认将该农事标记为已完成?", "提示", {
  428. confirmButtonText: "确认",
  429. cancelButtonText: "取消",
  430. type: "warning",
  431. });
  432. } catch {
  433. return;
  434. }
  435. try {
  436. const raw = await VE_API.questionnaire.updateWorkStatus({
  437. work_type: farmData.value?.work_type || "standard",
  438. work_id: id,
  439. tel,
  440. });
  441. const res = Array.isArray(raw) ? raw[0] : raw;
  442. const code = Number(res?.code);
  443. if (!(code === 200 || code === 0 || code === 1)) {
  444. ElMessage.error(res?.message || res?.msg || "完成农事失败");
  445. return;
  446. }
  447. ElMessage.success("农事已完成");
  448. router.back();
  449. } catch {
  450. ElMessage.error("完成农事失败,请稍后再试");
  451. }
  452. };
  453. watch(locale, () => {
  454. getDetail();
  455. });
  456. // 执行方式 Tab 配置
  457. const executionTabs = [
  458. { label: "植保机", value: 1 },
  459. { label: "人工手持", value: 2 },
  460. { label: "地面机械", value: 3 }
  461. ];
  462. // 每一段农事的当前执行方式(索引 -> 执行方式),默认 1:植保机
  463. const stageExecutionMethods = ref({});
  464. const executePopupRef = ref(null);
  465. const hasTextValue = (val) => {
  466. if (val === null || val === undefined) return false;
  467. return String(val).trim() !== "";
  468. };
  469. const hasValidParamForMethod = (item, methodValue) => {
  470. if (!item?.params || !Array.isArray(item.params)) return false;
  471. const methodParam = item.params.find(
  472. (param) => Number(param.executionMethod) === Number(methodValue)
  473. );
  474. if (!methodParam) return false;
  475. return hasTextValue(methodParam.ratio) || hasTextValue(methodParam.remark);
  476. };
  477. const getAvailableExecutionTabs = (prescription) => {
  478. const list = prescription?.pesticideList;
  479. if (!Array.isArray(list) || !list.length) return [];
  480. return executionTabs.filter((tab) =>
  481. list.some((item) => hasValidParamForMethod(item, tab.value))
  482. );
  483. };
  484. const statusTagStyle = {
  485. 3: {
  486. color: '#FF953D',
  487. },
  488. 4: {
  489. color: '#FF953D',
  490. },
  491. 5: {
  492. color: '#FF6A6A',
  493. },
  494. };
  495. const getFarmWorkTypeColorStyle = (farmData) => {
  496. const type = Number(farmData?.farm_work_type);
  497. const status = Number(farmData?.work_status);
  498. let color = '#2199F8';
  499. if (status === 2) {
  500. if(type === 3 || type === 4) {
  501. color = '#FF943D';
  502. } else if(type === 5) {
  503. color = '#FF6A6A';
  504. } else {
  505. color = '#2199F8';
  506. }
  507. }else if (status === 3) {
  508. color = 'rgba(62, 61, 61, 0.8)';
  509. }
  510. return {
  511. color,
  512. };
  513. };
  514. /**
  515. * 展示用「分段」列表:detail.pesticideList 或 prescriptionList 推导
  516. */
  517. const stageList = computed(() => {
  518. const d = detail.value;
  519. if (!d) return [];
  520. // if (Array.isArray(d.pesticideList) && d.pesticideList.length) {
  521. return [
  522. {
  523. ...d,
  524. pesticideList: d.pesticideList,
  525. cropAlbum: normalizeCropAlbum(
  526. d.confirmPicture?.length
  527. ? d.confirmPicture
  528. : d.executeEvidence
  529. ),
  530. },
  531. ];
  532. // }
  533. // return [];
  534. });
  535. const handleViewArea = () => {
  536. router.push({
  537. path: "/view_area",
  538. query: {
  539. subjectId: localStorage.getItem('selectedFarmId'),
  540. varietyId: 2,
  541. },
  542. });
  543. }
  544. const goGrowthTrack = () => {
  545. router.push({
  546. path: "/growth_track",
  547. query: {
  548. id: farmData.value?.id || workId.value || route.query.id,
  549. type: farmData.value?.type || "growth",
  550. },
  551. });
  552. };
  553. const handleBack = () => {
  554. router.back();
  555. };
  556. const handleShare = () => {
  557. const query = {
  558. askInfo: { title: "转发农事", content: "是否分享给好友" },
  559. shareText:
  560. ((farmData.value?.work_name ||
  561. detail.value?.farmWorkName) + ' 已触发,请在最佳农时内及时执行') ||
  562. "农事详情",
  563. targetUrl: "work_detail",
  564. paramsPage: JSON.stringify({
  565. id: farmData.value?.id || workId.value || route.query.id,
  566. fromShare: 1,
  567. }),
  568. imageUrl: "https://birdseye-img.sysuimars.com/birdseye-look-mini/work_img.png",
  569. };
  570. wx.miniProgram.navigateTo({
  571. url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
  572. });
  573. };
  574. const handleConvert = () => {
  575. const query = {
  576. askInfo: { title: "农事执行", content: "是否分享该农事给好友" },
  577. shareText: `${detail.value.farmWorkName}农事 已触发,请在最佳农时内执行`,
  578. targetUrl: `work_detail`,
  579. paramsPage: JSON.stringify({ ...miniJson.value, hideDraw: true }),
  580. imageUrl: 'https://birdseye-img.sysuimars.com/birdseye-look-mini/work_img.png',
  581. };
  582. wx.miniProgram.navigateTo({
  583. url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
  584. });
  585. };
  586. // 获取当前段的执行方式
  587. const getStageExecutionMethod = (stageIndex) => {
  588. const stage = stageList.value?.[stageIndex];
  589. const availableTabs = getAvailableExecutionTabs(stage);
  590. if (!availableTabs.length) return 1;
  591. const val = stageExecutionMethods.value[stageIndex];
  592. const isValidSelected = availableTabs.some(
  593. (tab) => Number(tab.value) === Number(val)
  594. );
  595. return isValidSelected ? val : availableTabs[0].value;
  596. };
  597. // 根据当前执行方式,获取对应的参数(配比、单亩用量、备注)
  598. const getPesticideParam = (item, stageIndex) => {
  599. if (!item?.params || !Array.isArray(item.params)) return null;
  600. const currentMethod = getStageExecutionMethod(stageIndex);
  601. return (
  602. item.params.find((param) => param.executionMethod === currentMethod) || null
  603. );
  604. };
  605. // 地图
  606. const mapContainer = ref(null);
  607. const areaMap = new AreaMap();
  608. </script>
  609. <style scoped lang="scss">
  610. .work-detail {
  611. height: 100vh;
  612. background: #f2f3f5;
  613. display: flex;
  614. flex-direction: column;
  615. .work-detail-content {
  616. flex: 1;
  617. overflow: auto;
  618. }
  619. .footer-btn {
  620. height: 70px;
  621. background: #fff;
  622. box-shadow: 2px 2px 4.5px 0px rgba(0, 0, 0, 0.4);
  623. display: flex;
  624. align-items: flex-start;
  625. padding: 10px 12px 0 12px;
  626. justify-content: center;
  627. box-sizing: border-box;
  628. &.done-btn {
  629. justify-content: center;
  630. }
  631. .secondary-btn {
  632. padding: 0 38px;
  633. height: 40px;
  634. border-radius: 20px;
  635. line-height: 40px;
  636. color: #000000;
  637. background: #F6F6F6;
  638. text-align: center;
  639. }
  640. .primary-btn {
  641. padding: 0 24px;
  642. height: 40px;
  643. border-radius: 20px;
  644. line-height: 40px;
  645. background: #2199F8;
  646. color: #fff;
  647. }
  648. }
  649. }
  650. .content-status {
  651. position: relative;
  652. padding: 12px;
  653. color: #fff;
  654. z-index: 1;
  655. min-height: 92px;
  656. box-sizing: border-box;
  657. display: flex;
  658. align-items: center;
  659. &::after {
  660. content: "";
  661. z-index: -1;
  662. position: absolute;
  663. left: 0;
  664. top: 0;
  665. height: 140px;
  666. background: #2199F8;
  667. width: 100%;
  668. }
  669. &.done-status {
  670. &::after {
  671. background: #4ABF32;
  672. }
  673. }
  674. .status-l {
  675. flex: 1;
  676. min-width: 0;
  677. .status-title {
  678. font-size: 21px;
  679. display: flex;
  680. align-items: flex-start;
  681. gap: 9px;
  682. .status-title-text {
  683. flex: 1;
  684. min-width: 0;
  685. line-height: 1.3;
  686. word-break: break-word;
  687. }
  688. .status-title-tags {
  689. flex-shrink: 0;
  690. display: flex;
  691. flex-direction: row;
  692. align-items: center;
  693. gap: 4px;
  694. }
  695. .status-tag {
  696. font-size: 12px;
  697. color: #2199F8;
  698. background: #fff;
  699. border-radius: 2px;
  700. padding: 2px 5px;
  701. min-width: fit-content;
  702. }
  703. }
  704. .status-sub-wrap {
  705. margin-top: 8px;
  706. display: flex;
  707. align-items: center;
  708. gap: 10px;
  709. }
  710. .status-sub {
  711. font-size: 14px;
  712. padding: 2px 8px;
  713. background: #fff;
  714. color: #2199F8;
  715. width: fit-content;
  716. border-radius: 2px;
  717. &.small-tag {
  718. padding: 0 5px;
  719. height: 22px;
  720. line-height: 22px;
  721. font-size: 12px;
  722. white-space: nowrap;
  723. flex-shrink: 0;
  724. &.isAbnormal {
  725. color: #FF6A6A;
  726. }
  727. &.isWeather {
  728. color: #FDA202;
  729. }
  730. &.isHighRisk {
  731. color: #FFFFFF;
  732. background: #FF6A6A;
  733. }
  734. }
  735. .done-status__icon {
  736. color: #959595;
  737. }
  738. &.done-status__text {
  739. display: flex;
  740. align-items: center;
  741. gap: 4px;
  742. color: #959595;
  743. }
  744. }
  745. .status-hint-card {
  746. margin-top: 10px;
  747. display: inline-block;
  748. width: fit-content;
  749. max-width: 100%;
  750. background: #fff;
  751. border-radius: 2px;
  752. padding: 5px 8px;
  753. box-sizing: border-box;
  754. .status-hint-text {
  755. font-size: 12px;
  756. color: #626262;
  757. white-space: nowrap;
  758. }
  759. .status-hint-question {
  760. margin-top: 8px;
  761. background: #2199f8;
  762. border-radius: 4px;
  763. padding: 6px 8px;
  764. display: flex;
  765. align-items: center;
  766. gap: 6px;
  767. color: #fff;
  768. .status-hint-link-icon {
  769. flex-shrink: 0;
  770. font-size: 14px;
  771. }
  772. .status-hint-question-text {
  773. flex: 1;
  774. min-width: 0;
  775. font-size: 12px;
  776. text-decoration: underline;
  777. overflow: hidden;
  778. text-overflow: ellipsis;
  779. white-space: nowrap;
  780. }
  781. }
  782. }
  783. }
  784. .status-r {
  785. flex: none;
  786. display: flex;
  787. flex-direction: column;
  788. justify-content: center;
  789. align-items: center;
  790. gap: 2px;
  791. padding: 6px;
  792. border-radius: 5px;
  793. background: rgba(255, 255, 255, 0.2);
  794. border: 1px solid rgba(255, 255, 255, 0.6);
  795. backdrop-filter: blur(4px);
  796. color: #fff;
  797. font-size: 12px;
  798. .status-r__icon {
  799. width: 14px;
  800. height: 14px;
  801. filter: brightness(0) invert(1);
  802. }
  803. }
  804. }
  805. .work-wrap {
  806. position: relative;
  807. top: 0;
  808. padding: 0 12px 62px;
  809. z-index: 2;
  810. // &.has-bottom {
  811. // margin-bottom: 88px;
  812. // }
  813. // &.warning-info-show {
  814. // // margin-bottom: 168px;
  815. // margin-bottom: 88px;
  816. // }
  817. &.from-share {
  818. padding-bottom: 82px;
  819. }
  820. }
  821. .box-wrap {
  822. .work-info {
  823. background: #ffffff;
  824. border-radius: 8px;
  825. padding: 10px 10px;
  826. box-shadow: 0 2px 8px rgba(15, 35, 52, 0.06);
  827. }
  828. .photo-box {
  829. margin-top: 10px;
  830. padding: 11px 10px;
  831. font-size: 14px;
  832. .tips-text {
  833. color: #FA7406;
  834. padding: 5px 10px;
  835. border: 1px solid #FF953D;
  836. border-radius: 5px;
  837. margin-bottom: 10px;
  838. background: #fff;
  839. }
  840. .photo-title {
  841. color: #000;
  842. padding-bottom: 9px;
  843. }
  844. .photo-sub-title {
  845. padding-bottom: 9px;
  846. color: #767676;
  847. }
  848. }
  849. }
  850. .group-info {
  851. margin-bottom: 10px;
  852. background: #ffffff;
  853. border-radius: 8px;
  854. padding: 14px 10px 10px 10px;
  855. box-shadow: 0 2px 8px rgba(15, 35, 52, 0.06);
  856. &.group-box {
  857. padding: 10px;
  858. .group-name {
  859. font-size: 14px;
  860. color: #9C9C9C;
  861. .group-title {
  862. font-family: "PangMenZhengDao";
  863. font-size: 16px;
  864. color: #4F4F4F;
  865. padding-bottom: 4px;
  866. }
  867. .group-name-text {
  868. color: #000;
  869. }
  870. }
  871. }
  872. .group-name {
  873. font-size: 14px;
  874. color: rgba(0, 0, 0, 0.2);
  875. .group-name-text {
  876. color: #767676;
  877. }
  878. }
  879. .group-sub {
  880. margin-top: 6px;
  881. font-size: 12px;
  882. color: rgba(0, 0, 0, 0.45);
  883. line-height: 1.5;
  884. }
  885. }
  886. .stage-card+.stage-card {
  887. margin-top: 12px;
  888. }
  889. .info-item+.info-item {
  890. margin-top: 10px;
  891. }
  892. .info-item {
  893. .info-title {
  894. display: flex;
  895. align-items: center;
  896. gap: 4px;
  897. color: #2199F8;
  898. font-weight: 500;
  899. .title-block {
  900. width: 6px;
  901. height: 6px;
  902. background: #2199F8;
  903. border-radius: 1px;
  904. transform: rotate(45deg);
  905. }
  906. }
  907. .info-value {
  908. padding-top: 4px;
  909. color: #ACACAC;
  910. line-height: 21px;
  911. white-space: pre-line;
  912. }
  913. .blod-text {
  914. font-weight: 500;
  915. }
  916. }
  917. .execution-area-card {
  918. .execution-area-card__header {
  919. display: flex;
  920. align-items: center;
  921. justify-content: space-between;
  922. .title {
  923. font-size: 16px;
  924. }
  925. .code {
  926. color: #565656;
  927. }
  928. }
  929. .map-container {
  930. width: 100%;
  931. height: 166px;
  932. margin: 12px 0 0;
  933. border-radius: 8px;
  934. overflow: hidden;
  935. clip-path: inset(0 round 8px);
  936. }
  937. }
  938. .area-list {
  939. margin-top: 10px;
  940. .area-item+.area-item {
  941. margin-top: 6px;
  942. }
  943. .area-item {
  944. display: flex;
  945. align-items: center;
  946. justify-content: space-between;
  947. padding: 10px;
  948. border: 1px solid rgba(0, 0, 0, 0.1);
  949. border-radius: 6px;
  950. .area-l {
  951. display: flex;
  952. align-items: center;
  953. gap: 5px;
  954. .area-tag {
  955. background: rgba(98, 98, 98, 0.1);
  956. color: #626262;
  957. height: 22px;
  958. line-height: 22px;
  959. padding: 0 5px;
  960. border-radius: 2px;
  961. font-size: 12px;
  962. margin-left: 5px;
  963. display: inline-block;
  964. }
  965. }
  966. .area-r {
  967. background: #2199F8;
  968. color: #fff;
  969. font-size: 12px;
  970. font-weight: 500;
  971. cursor: pointer;
  972. height: 28px;
  973. line-height: 28px;
  974. padding: 0 10px;
  975. border-radius: 20px;
  976. }
  977. }
  978. }
  979. .ecological-plant-card {
  980. margin-top: 10px;
  981. border-radius: 8px;
  982. text-align: left;
  983. }
  984. .ecological-plant-text {
  985. color: #666666;
  986. font-size: 14px;
  987. line-height: 1.45;
  988. }
  989. .ecological-plant-line--sub {
  990. margin-top: 6px;
  991. }
  992. .ecological-plant-gallery {
  993. display: flex;
  994. gap: 12px;
  995. }
  996. .ecological-plant-thumb {
  997. width: 80px;
  998. height: 80px;
  999. object-fit: cover;
  1000. border-radius: 8px;
  1001. display: block;
  1002. }
  1003. .stage-card {
  1004. .stage-header {
  1005. padding-bottom: 12px;
  1006. display: flex;
  1007. align-items: center;
  1008. gap: 5px;
  1009. .stage-title {
  1010. font-size: 16px;
  1011. color: #000;
  1012. }
  1013. .title-tag {
  1014. width: fit-content;
  1015. font-size: 12px;
  1016. height: 26px;
  1017. line-height: 26px;
  1018. color: #2199F8;
  1019. background: rgba(33, 153, 248, 0.1);
  1020. border-radius: 20px;
  1021. padding: 0 8px;
  1022. }
  1023. .tag-0 {
  1024. color: #FF953D;
  1025. background: rgba(255, 149, 61, 0.1);
  1026. }
  1027. }
  1028. .stage-info {
  1029. padding: 8px 0 2px;
  1030. border-top: 1px solid #f5f5f5;
  1031. }
  1032. }
  1033. .form-item {
  1034. display: flex;
  1035. font-size: 14px;
  1036. color: #767676;
  1037. margin-top: 4px;
  1038. .area-btn {
  1039. border: 1px solid rgba(0, 0, 0, 0.1);
  1040. padding: 0 10px;
  1041. color: #767676;
  1042. }
  1043. .area-btn-right {
  1044. padding-right: 4px;
  1045. display: inline-flex;
  1046. align-items: center;
  1047. gap: 4px;
  1048. }
  1049. .item-name {
  1050. padding-right: 26px;
  1051. color: rgba(0, 0, 0, 0.2);
  1052. }
  1053. .item-text {
  1054. flex: 1;
  1055. line-height: 21px;
  1056. &.light-text {
  1057. color: #2199F8;
  1058. }
  1059. }
  1060. .area-text {
  1061. display: inline-flex;
  1062. align-items: center;
  1063. gap: 10px;
  1064. }
  1065. }
  1066. .light-text {
  1067. color: #2199F8;
  1068. }
  1069. .stage-tabs {
  1070. display: inline-flex;
  1071. gap: 8px;
  1072. margin-top: 8px;
  1073. .tab-pill {
  1074. padding: 0 8px;
  1075. font-size: 14px;
  1076. text-align: center;
  1077. border-radius: 2px;
  1078. height: 28px;
  1079. line-height: 28px;
  1080. color: #767676;
  1081. background: rgba(171, 171, 171, 0.1);
  1082. &.active {
  1083. background: rgba(33, 153, 248, 0.1);
  1084. color: #2199F8;
  1085. }
  1086. }
  1087. }
  1088. .prescription-wrap {
  1089. margin-top: 10px;
  1090. overflow: hidden;
  1091. .prescription-title {
  1092. padding: 8px 10px;
  1093. font-size: 13px;
  1094. font-weight: 500;
  1095. border-bottom: 1px solid rgba(225, 225, 225, 0.6);
  1096. }
  1097. }
  1098. .prescription-table {
  1099. font-size: 12px;
  1100. text-align: center;
  1101. border-radius: 6px;
  1102. border: 1px solid rgba(225, 225, 225, 0.6);
  1103. .table-header {
  1104. display: flex;
  1105. background: rgba(171, 171, 171, 0.1);
  1106. padding: 9px 6px;
  1107. color: #767676;
  1108. }
  1109. .table-row {
  1110. display: flex;
  1111. padding: 12px 6px;
  1112. border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  1113. color: rgba(0, 0, 0, 0.76);
  1114. &:last-child {
  1115. border-bottom: none;
  1116. }
  1117. }
  1118. .col {
  1119. display: flex;
  1120. align-items: center;
  1121. justify-content: center;
  1122. padding: 0 2px;
  1123. }
  1124. .col-type {
  1125. width: 56px;
  1126. }
  1127. .col-name {
  1128. flex: 1;
  1129. }
  1130. .col-ratio {
  1131. width: 64px;
  1132. }
  1133. .col-dose {
  1134. width: 64px;
  1135. }
  1136. }
  1137. .prescription-remark {
  1138. margin-top: 8px;
  1139. padding: 7px 10px;
  1140. border-radius: 6px;
  1141. color: #767676;
  1142. background: rgba(171, 171, 171, 0.1);
  1143. line-height: 21px;
  1144. }
  1145. .photo-img-wrap {
  1146. display: flex;
  1147. flex-wrap: wrap;
  1148. gap: 10px;
  1149. ::v-deep {
  1150. .PhotoConsumer {
  1151. width: 31%;
  1152. height: 92px;
  1153. }
  1154. }
  1155. .photo-img {
  1156. width: 100%;
  1157. height: 100%;
  1158. position: relative;
  1159. box-sizing: border-box;
  1160. border: 2px solid transparent;
  1161. border-radius: 8px;
  1162. overflow: hidden;
  1163. .fail-icon {
  1164. position: absolute;
  1165. top: 0;
  1166. left: 0;
  1167. width: 100%;
  1168. height: 100%;
  1169. background: rgba(0, 0, 0, 0.6);
  1170. border-radius: 8px;
  1171. display: flex;
  1172. align-items: center;
  1173. justify-content: center;
  1174. flex-direction: column;
  1175. gap: 4px;
  1176. .fail-icon-text {
  1177. color: #FF943D;
  1178. font-size: 12px;
  1179. }
  1180. }
  1181. img {
  1182. width: 100%;
  1183. height: 100%;
  1184. border-radius: 8px;
  1185. object-fit: cover;
  1186. }
  1187. }
  1188. }
  1189. .execute-action {
  1190. display: flex;
  1191. align-items: center;
  1192. justify-content: center;
  1193. // justify-content: space-between;
  1194. gap: 16px;
  1195. .action-item {
  1196. padding: 0 26px;
  1197. height: 40px;
  1198. line-height: 40px;
  1199. border-radius: 26px;
  1200. box-sizing: border-box;
  1201. font-size: 14px;
  1202. &.second {
  1203. background: #ffffff;
  1204. border: 0.5px solid rgba(153, 153, 153, 0.5);
  1205. color: #999999;
  1206. }
  1207. &.primary {
  1208. background: linear-gradient(180deg, #8ACBFF 0%, #2199F8 100%);
  1209. color: #ffffff;
  1210. }
  1211. }
  1212. &.no-share {
  1213. justify-content: center;
  1214. }
  1215. }
  1216. .warning-info {
  1217. position: fixed;
  1218. z-index: 2;
  1219. bottom: 80px;
  1220. left: 10px;
  1221. width: calc(100% - 20px);
  1222. background: linear-gradient(180deg, #FFDFC5 -13%, #FFFFFF 39%);
  1223. border-radius: 8px;
  1224. padding: 14px 10px;
  1225. box-sizing: border-box;
  1226. display: flex;
  1227. align-items: center;
  1228. justify-content: space-between;
  1229. gap: 12px;
  1230. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.1);
  1231. &.from-share {
  1232. bottom: 50px;
  1233. }
  1234. .warning-l {
  1235. min-width: 0;
  1236. flex: 1;
  1237. .warning-title {
  1238. display: inline-flex;
  1239. align-items: center;
  1240. gap: 6px;
  1241. font-size: 16px;
  1242. font-weight: 500;
  1243. line-height: 20px;
  1244. color: #FF953D;
  1245. }
  1246. .warning-text {
  1247. margin-top: 2px;
  1248. color: rgba(0, 0, 0, 0.4);
  1249. font-size: 12px;
  1250. line-height: 16px;
  1251. }
  1252. }
  1253. .warning-r {
  1254. flex-shrink: 0;
  1255. background: #FF953D;
  1256. color: #fff;
  1257. font-size: 12px;
  1258. cursor: pointer;
  1259. padding: 0 16px;
  1260. height: 32px;
  1261. line-height: 32px;
  1262. border-radius: 20px;
  1263. white-space: nowrap;
  1264. }
  1265. }
  1266. .fixed-btn-wrap {
  1267. display: flex;
  1268. justify-content: center;
  1269. // justify-content: space-between;
  1270. &.center-btn {
  1271. justify-content: center;
  1272. }
  1273. position: fixed;
  1274. bottom: 0px;
  1275. left: 0;
  1276. right: 0;
  1277. background: #fff;
  1278. padding: 10px 12px 36px 12px;
  1279. box-sizing: border-box;
  1280. // box-shadow: 0 -2px 8px rgba(15, 35, 52, 0.06);
  1281. box-shadow: 2px 2px 4.5px 0px #00000066;
  1282. .fixed-btn {
  1283. min-width: 110px;
  1284. height: 40px;
  1285. line-height: 40px;
  1286. text-align: center;
  1287. border-radius: 20px;
  1288. background: linear-gradient(180deg, #70bffe, #2199f8);
  1289. color: #ffffff;
  1290. font-size: 14px;
  1291. }
  1292. }
  1293. .map-popup {
  1294. width: 92%;
  1295. // max-width: 420px;
  1296. border-radius: 8px;
  1297. padding: 12px;
  1298. box-sizing: border-box;
  1299. }
  1300. </style>