ArchivesFarmTimeLine.vue 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507
  1. <template>
  2. <div class="timeline-container" ref="timelineContainerRef">
  3. <div class="timeline-list" ref="timelineListRef">
  4. <empty v-if="isEmpty" image="https://birdseye-img.sysuimars.com/birdseye-look-mini/custom-empty-image.png"
  5. image-size="80" description="暂无数据" class="empty-state" />
  6. <template v-else>
  7. <!-- <div class="timeline-middle-line"></div>
  8. <div v-for="(t, tIdx) in phenologyStartDates" :key="`term-${uniqueTimestamp}-${tIdx}`"
  9. class="timeline-term" :style="getTermStyle(t, tIdx)">
  10. <span class="term-name">{{ formatDate(t.startDate) }}</span>
  11. </div> -->
  12. <div v-for="(p, idx) in phenologyList" :key="`phenology-${uniqueTimestamp}-${idx}`"
  13. class="phenology-bar">
  14. <div class="phenology-title"
  15. :class="{ 'phenology-red': !shouldShowBlue(p), 'phenology-blue': shouldShowBlue(p) }"
  16. v-if="shouldShowPhenologyBarTitle(idx)">
  17. {{ p.phenologyName }}
  18. </div>
  19. <div v-for="(r, rIdx) in Array.isArray(p.reproductiveList) ? p.reproductiveList : []"
  20. :key="`reproductive-${uniqueTimestamp}-${idx}-${rIdx}`" class="reproductive-item">
  21. <div class="arranges">
  22. <div v-for="(fw, aIdx) in Array.isArray(r.farmWorkArrangeList) ? r.farmWorkArrangeList : []"
  23. :key="`arrange-${uniqueTimestamp}-${idx}-${rIdx}-${aIdx}`" class="arrange-card" :class="[
  24. getArrangeStatusClass(fw),
  25. {
  26. 'last-card':
  27. aIdx === r.farmWorkArrangeList.length - 1 &&
  28. rIdx !== r.farmWorkArrangeList.length - 1,
  29. },
  30. // 右侧农事卡片跟随物候期颜色:未来节气对应的农事卡片置灰
  31. { 'future-card': !shouldShowBlue(p) },
  32. ]" @click="handleRowClick(fw)">
  33. <div class="card-content">
  34. <div class="card-left"
  35. :style="{ width: fw.sourceDataJson && fw.sourceDataJson.resFilename ? 'calc(100% - 45px)' : '100%' }"
  36. v-if="pageType === 'agri_plan'">
  37. <div class="left-info">
  38. <div class="left-date">{{ formatDate(fw.createTime) }}</div>
  39. <div class="text" @click.stop="handleStatusDetail(fw)">
  40. <span class="van-ellipsis">{{ fw.title }}</span>
  41. <!-- <el-icon v-if="shouldShowBlue(p)">
  42. <ArrowRight />
  43. </el-icon> -->
  44. </div>
  45. <!-- <div class="text green van-ellipsis" v-if="fw?.sourceType === 7">
  46. 执行者:{{ fw.sourceDataJson.executorName }}
  47. </div> -->
  48. </div>
  49. <div class="title-text van-ellipsis"
  50. v-if="shouldShowBlue(p) && fw.sourceType != 4">{{ fw.content }}</div>
  51. </div>
  52. <div class="card-left agri-record-card" v-else>
  53. <div class="left-info">
  54. <div class="left-date">{{ formatDate(fw.recommendDate) }}</div>
  55. <div class="text van-ellipsis" @click.stop="handleStatusDetail(fw)">
  56. <span class="text-name">{{ fw.farmWorkName }}</span>
  57. <el-icon class="text-icon">
  58. <ArrowRight />
  59. </el-icon>
  60. </div>
  61. </div>
  62. <div class="title-wrap van-ellipsis" v-if="fw.flowStatus != null && fw.flowStatus != 0">
  63. <div class="title-text">{{ flowStatusStr[fw.flowStatus] }}</div>
  64. <div class="title-text blue-tag" v-if="fw?.executionLimitDays >= 0">限时溯源</div>
  65. </div>
  66. </div>
  67. <div class="card-right"
  68. v-if="fw.sourceDataJson && fw.sourceDataJson.resFilename && fw.sourceDataJson.resFilename.length > 0"
  69. @click.stop="handleImageClick(fw)">
  70. <img v-if="fw.sourceType === 7"
  71. :src="base_img_url2 + fw.sourceDataJson?.executeImageUrls?.[0]" alt="" />
  72. <img v-else :src="base_img_url2 + fw.sourceDataJson?.resFilename?.[0]?.filename"
  73. alt="" />
  74. <div class="num" v-if="fw?.sourceDataJson?.imageIds">
  75. {{ fw?.sourceDataJson?.imageIds?.length ||
  76. fw?.sourceDataJson?.executeImageUrls?.length || 0 }}
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <template v-if="r.name === p.phenologyName">
  83. <div class="phenology-name text-blue"
  84. :class="{ 'phenology-red': !shouldShowBlue(p), 'phenology-blue': shouldShowBlue(p) }"
  85. :style="r.phenologyName === getNextPhenologyName(idx, rIdx) ? 'padding: 6px 0;' : ''">
  86. {{ r.name }}
  87. </div>
  88. </template>
  89. <template v-else>
  90. <template v-if="p.phenologyName === getNextPhenologyName(idx, rIdx)">
  91. <div class="phenology-name"
  92. :class="{ 'text-red': !shouldShowBlue(p), 'text-blue': shouldShowBlue(p) }">
  93. {{ r.name }}
  94. </div>
  95. </template>
  96. <template v-else>
  97. <div class="phenology-name"
  98. :class="{ 'text-red': !shouldShowBlue(p), 'text-blue': shouldShowBlue(p) }">
  99. {{ r.name }}
  100. </div>
  101. <div class="phenology-name mr" :class="{
  102. 'phenology-red': !shouldShowBlue(p),
  103. 'phenology-blue': shouldShowBlue(p),
  104. }">
  105. {{ p.phenologyName }}
  106. </div>
  107. </template>
  108. </template>
  109. </div>
  110. </div>
  111. </template>
  112. </div>
  113. </div>
  114. </template>
  115. <script setup>
  116. import { ref, nextTick, watch, onMounted, onUnmounted, onActivated, onDeactivated, computed } from "vue";
  117. import { useRouter, useRoute, onBeforeRouteLeave } from "vue-router";
  118. import { ElMessage } from "element-plus";
  119. import { Empty, showImagePreview } from "vant";
  120. import { base_img_url2 } from "@/api/config";
  121. const router = useRouter();
  122. const route = useRoute();
  123. const props = defineProps({
  124. // 农场 ID,用于请求农事规划数据
  125. farmId: {
  126. type: [String, Number],
  127. default: null,
  128. },
  129. // 是否禁用所有点击事件(用于只读展示)
  130. disableClick: {
  131. type: Boolean,
  132. default: false,
  133. },
  134. // 是否是标准农事
  135. isStandard: {
  136. type: Boolean,
  137. default: false,
  138. },
  139. // 方案ID
  140. schemeId: {
  141. type: [Number, String],
  142. default: null,
  143. },
  144. // 类型:agri_record / agri_plan
  145. pageType: {
  146. type: String,
  147. default: "agri_plan",
  148. },
  149. // 区域ID
  150. regionId: {
  151. type: [Number, String],
  152. default: null,
  153. },
  154. // 容器ID
  155. containerId: {
  156. type: [Number, String],
  157. default: null,
  158. },
  159. // 类型ID
  160. typeId: {
  161. type: [Number, String],
  162. default: null,
  163. },
  164. });
  165. const farmWorkType = {
  166. 0: "预警农事",
  167. 1: "标准农事",
  168. 2: "建议农事",
  169. 3: "自建农事",
  170. };
  171. const emits = defineEmits(["row-click"]);
  172. const solarTerms = ref([]);
  173. const phenologyList = ref([]);
  174. // 从物候期列表中提取起始时间,用于时间轴显示
  175. const phenologyStartDates = computed(() => {
  176. if (!phenologyList.value || phenologyList.value.length === 0) {
  177. return [];
  178. }
  179. // 从每个物候期中提取起始时间,并去重排序
  180. const startDatesMap = new Map();
  181. phenologyList.value.forEach((phenology) => {
  182. if (phenology.startDate) {
  183. const dateKey = phenology.startDate;
  184. // 如果该日期还没有添加过,或者需要更新信息
  185. if (!startDatesMap.has(dateKey)) {
  186. startDatesMap.set(dateKey, {
  187. startDate: phenology.startDate,
  188. id: phenology.id || `phenology-${dateKey}`,
  189. });
  190. }
  191. }
  192. });
  193. // 转换为数组并按时间排序
  194. const result = Array.from(startDatesMap.values()).sort((a, b) => {
  195. const timeA = safeParseDate(a.startDate);
  196. const timeB = safeParseDate(b.startDate);
  197. if (isNaN(timeA) || isNaN(timeB)) return 0;
  198. return timeA - timeB;
  199. });
  200. return result;
  201. });
  202. const timelineContainerRef = ref(null);
  203. const timelineListRef = ref(null);
  204. const getTimelineScrollKey = () =>
  205. `timelineScrollTop:${props.pageType}:${props.farmId ?? "none"}:${props.regionId ?? "none"}:${props.containerId ?? "none"}:${route.path}`;
  206. const saveTimelineScrollTop = () => {
  207. if (!timelineContainerRef.value) return;
  208. const scrollTop = timelineContainerRef.value.scrollTop || 0;
  209. sessionStorage.setItem(getTimelineScrollKey(), scrollTop.toString());
  210. };
  211. const restoreTimelineScrollTop = () => {
  212. if (!timelineContainerRef.value) return false;
  213. const savedScrollTop = sessionStorage.getItem(getTimelineScrollKey());
  214. if (savedScrollTop == null) return false;
  215. const scrollTop = Number(savedScrollTop);
  216. if (Number.isNaN(scrollTop)) return false;
  217. const maxScrollTop = Math.max(
  218. 0,
  219. (timelineContainerRef.value.scrollHeight || 0) - (timelineContainerRef.value.clientHeight || 0)
  220. );
  221. timelineContainerRef.value.scrollTop = Math.min(scrollTop, maxScrollTop);
  222. return true;
  223. };
  224. const restoreTimelineScrollTopWithRetry = (retryCount = 4) => {
  225. const restored = restoreTimelineScrollTop();
  226. if (restored || retryCount <= 0) return restored;
  227. setTimeout(() => {
  228. restoreTimelineScrollTopWithRetry(retryCount - 1);
  229. }, 60);
  230. return false;
  231. };
  232. // 标记是否为首次加载
  233. const isInitialLoad = ref(true);
  234. // 存储timeline-list的实际渲染高度
  235. const timelineListHeight = ref(0);
  236. // 生成唯一的时间戳,用于确保key的唯一性
  237. const uniqueTimestamp = ref(Date.now());
  238. // ResizeObserver 实例,用于监听高度变化
  239. let resizeObserver = null;
  240. // 标记是否为空数据
  241. const isEmpty = ref(false);
  242. // 标记是否正在请求数据,防止重复请求
  243. const isRequesting = ref(false);
  244. // 记录上一次请求的 farmId,避免相同 farmId 重复请求
  245. const lastRequestedFarmId = ref(null);
  246. // 获取当前季节
  247. const getCurrentSeason = () => {
  248. const month = new Date().getMonth() + 1; // 1-12
  249. if (month >= 1 && month <= 5) {
  250. return "spring"; // 春季:3-5月
  251. } else if (month >= 6 && month <= 8) {
  252. return "summer"; // 夏季:6-8月
  253. } else if (month >= 9 && month <= 10) {
  254. return "autumn"; // 秋季:9-10月
  255. } else {
  256. return "winter"; // 冬季:11-2月
  257. }
  258. };
  259. // 安全解析时间到时间戳(ms)
  260. /** 解析 sourceData JSON,避免大整数(如雪花 ID)被 JSON.parse 精度丢失(>2^53 会变成 500 结尾等) */
  261. const parseSourceDataSafe = (str) => {
  262. if (!str) return null;
  263. try {
  264. const fixed = str.replace(/"imageIds"\s*:\s*\[([^\]]*)\]/g, (_, arr) => {
  265. const quoted = arr.split(",").map((s) => {
  266. const t = s.trim().replace(/^["']|["']$/g, "");
  267. return /^\d+$/.test(t) ? `"${t}"` : s.trim();
  268. }).join(",");
  269. return `"imageIds":[${quoted}]`;
  270. });
  271. return JSON.parse(fixed);
  272. } catch {
  273. return null;
  274. }
  275. };
  276. const safeParseDate = (val) => {
  277. if (!val) return NaN;
  278. if (val instanceof Date) return val.getTime();
  279. if (typeof val === "number") return val;
  280. if (typeof val === "string") {
  281. // 兼容 "YYYY-MM-DD HH:mm:ss" -> Safari
  282. const s = val.replace(/-/g, "/").replace("T", " ");
  283. const d = new Date(s);
  284. return isNaN(d.getTime()) ? NaN : d.getTime();
  285. }
  286. return NaN;
  287. };
  288. const batchValidateData = ref({});
  289. const allTrue = ref(false);
  290. const invalidIds = ref([]);
  291. const invalidArr = ref([]);
  292. // 验证农事卡片药肥报价信息是否完整
  293. const batchValidatePesticideFertilizerQuotes = (ids, items) => {
  294. if (props.isStandard) {
  295. return;
  296. }
  297. VE_API.monitor
  298. .batchValidatePesticideFertilizerQuotes({ ids, schemeId: props.schemeId })
  299. .then(({ data, code }) => {
  300. if (code === 0) {
  301. batchValidateData.value = data || {};
  302. allTrue.value = Object.values(data).every((value) => value === true);
  303. invalidIds.value = Object.keys(data).filter((key) => data[key] !== true);
  304. // 清空之前的arrangeIds
  305. invalidArr.value = [];
  306. // 遍历items,判断farmWorkId是否在invalidIds中,如果对应上了就把item.id push进去
  307. items.forEach((item) => {
  308. // 判断item.farmWorkId是否在invalidIds数组中(需要转换为字符串进行比较)
  309. const farmWorkIdStr = String(item.farmWorkId);
  310. if (invalidIds.value.includes(farmWorkIdStr)) {
  311. invalidArr.value.push({
  312. arrangeId: item.id,
  313. farmWorkId: item.farmWorkId,
  314. });
  315. }
  316. });
  317. }
  318. })
  319. .catch(() => { });
  320. };
  321. // 获取图片 URL 列表
  322. const fetchImageUrls = async (params) => {
  323. try {
  324. const res = await VE_API.ali.getTreeImageList(params);
  325. if (res.code === 0 && Array.isArray(res.data)) {
  326. return res.data.map((item) => {
  327. if (item.filename) {
  328. return {
  329. ...item,
  330. cloudFilename: item.filename, // 兼容组件
  331. };
  332. }
  333. return null;
  334. }).filter(item => item !== null);
  335. }
  336. return [];
  337. } catch (error) {
  338. console.error("获取图片列表失败:", error);
  339. return [];
  340. }
  341. };
  342. // 与 albumCarouselItem.getPhotoSrc 一致:拼 CDN 前缀;无水印预览用 Vant ImagePreview
  343. const resolveFarmWorkImagePath = (photo) => {
  344. if (photo == null) return "";
  345. if (typeof photo === "string") return photo;
  346. return photo.cloudFilename || photo.filename || "";
  347. };
  348. const buildFarmWorkPreviewUrls = (fw) => {
  349. const sd = fw?.sourceDataJson;
  350. if (!sd) return [];
  351. const toFullUrl = (path) => {
  352. if (!path) return "";
  353. if (/^https?:\/\//i.test(path)) return path;
  354. return base_img_url2 + path;
  355. };
  356. if (fw.sourceType === 7) {
  357. const arr = sd.executeImageUrls || [];
  358. return arr.map((p) => toFullUrl(resolveFarmWorkImagePath(p))).filter(Boolean);
  359. }
  360. const arr = sd.resFilename || [];
  361. return arr.map((p) => toFullUrl(resolveFarmWorkImagePath(p))).filter(Boolean);
  362. };
  363. const handleImageClick = (fw) => {
  364. const images = buildFarmWorkPreviewUrls(fw);
  365. if (!images.length) return;
  366. showImagePreview({
  367. images,
  368. startPosition: 0,
  369. closeable: true,
  370. showIndex: true,
  371. });
  372. };
  373. // 顶部物候标题:相邻两段 phenologyName 相同时只显示一次(保留第一段)
  374. const shouldShowPhenologyBarTitle = (idx) => {
  375. const list = phenologyList.value;
  376. if (!list?.length || idx < 0 || idx >= list.length) return false;
  377. if (idx === 0) return true;
  378. return list[idx]?.phenologyName !== list[idx - 1]?.phenologyName;
  379. };
  380. // 获取下一个reproductive-item的phenologyName
  381. const getNextPhenologyName = (currentPhenologyIdx, currentReproductiveIdx) => {
  382. const currentPhenology = phenologyList.value[currentPhenologyIdx];
  383. if (!currentPhenology || !Array.isArray(currentPhenology.reproductiveList)) {
  384. return null;
  385. }
  386. // 如果当前reproductive-item不是最后一个,获取同一个物候期的下一个
  387. if (currentReproductiveIdx < currentPhenology.reproductiveList.length - 1) {
  388. const nextReproductive = currentPhenology.reproductiveList[currentReproductiveIdx + 1];
  389. return nextReproductive?.phenologyName || null;
  390. }
  391. // 如果当前reproductive-item是最后一个,获取下一个物候期的第一个reproductive-item
  392. if (currentPhenologyIdx < phenologyList.value.length - 1) {
  393. const nextPhenology = phenologyList.value[currentPhenologyIdx + 1];
  394. if (
  395. nextPhenology &&
  396. Array.isArray(nextPhenology.reproductiveList) &&
  397. nextPhenology.reproductiveList.length > 0
  398. ) {
  399. const firstReproductive = nextPhenology.reproductiveList[0];
  400. return firstReproductive?.phenologyName || null;
  401. }
  402. }
  403. return null;
  404. };
  405. // 计算物候期需要的实际高度(基于农事数量)
  406. const getPhenologyRequiredHeight = (item) => {
  407. // 统计该物候期内的农事数量
  408. let farmWorkCount = 0;
  409. if (Array.isArray(item.reproductiveList)) {
  410. item.reproductiveList.forEach((reproductive) => {
  411. if (Array.isArray(reproductive.farmWorkArrangeList)) {
  412. farmWorkCount += reproductive.farmWorkArrangeList.length;
  413. }
  414. });
  415. }
  416. // 如果没有农事,给一个最小高度
  417. if (farmWorkCount === 0) {
  418. return 50; // 最小50px
  419. }
  420. // 每个农事卡片的高度(根据实际内容,卡片高度可能因内容而异)
  421. // 卡片包含:padding(8px*2) + header(约25px) + content margin(4px+2px) + content(约25-30px) = 约72-77px
  422. // 考虑到内容可能换行,实际高度可能更高,设置为120px更安全,避免卡片重叠
  423. const farmWorkCardHeight = 120; // 卡片高度估算,确保能容纳内容且不重叠
  424. // 卡片之间的间距(与CSS中的gap保持一致)
  425. const cardGap = 12;
  426. // 计算总高度:卡片数量 * 卡片高度 + (卡片数量 - 1) * 间距
  427. // 如果有多个卡片,需要加上它们之间的间距
  428. const totalHeight = farmWorkCount * farmWorkCardHeight + (farmWorkCount > 1 ? (farmWorkCount - 1) * cardGap : 0);
  429. // 返回精确的总高度,只保留最小高度限制,不添加额外余量
  430. return Math.max(totalHeight, 50); // 最小50px,精确匹配农事卡片高度
  431. };
  432. // 计算所有物候期的累积位置和总高度
  433. const calculatePhenologyPositions = () => {
  434. let currentTop = 10; // 起始位置,留出顶部间距
  435. const positions = new Map();
  436. // 按progress排序物候期,确保按时间顺序排列
  437. const sortedPhenologyList = [...phenologyList.value].sort((a, b) => {
  438. const aProgress = Math.min(Number(a?.progress) || 0, Number(a?.progress2) || 0);
  439. const bProgress = Math.min(Number(b?.progress) || 0, Number(b?.progress2) || 0);
  440. return aProgress - bProgress;
  441. });
  442. sortedPhenologyList.forEach((phenology) => {
  443. const height = getPhenologyRequiredHeight(phenology);
  444. // 使用与数据生成时相同的ID生成逻辑
  445. const itemId =
  446. phenology.id ?? phenology.phenologyId ?? phenology.name ?? `${phenology.progress}-${phenology.progress2}`;
  447. positions.set(itemId, {
  448. top: currentTop,
  449. height: height,
  450. });
  451. currentTop += height; // 紧挨着下一个物候期,不留间距
  452. });
  453. return {
  454. positions,
  455. totalHeight: currentTop, // 总高度 = 最后一个物候期的底部位置,不添加额外间距
  456. };
  457. };
  458. // 计算所有农事的总高度(基于物候期紧挨排列)
  459. const calculateTotalHeightByFarmWorks = () => {
  460. const { totalHeight } = calculatePhenologyPositions();
  461. // 如果有物候期数据,直接使用计算出的总高度
  462. // totalHeight 已经包含了从 10 开始的起始位置和所有物候期的高度
  463. if (totalHeight > 10) {
  464. // 确保总高度至少能容纳所有物候期起始时间(每个至少50px)
  465. const baseHeight = (phenologyStartDates.value?.length || 0) * 50;
  466. // 返回物候期总高度和基础高度的较大值,确保物候期起始时间能正常显示
  467. return Math.max(totalHeight, baseHeight);
  468. }
  469. // 如果没有物候期数据,返回基础高度
  470. const baseHeight = (phenologyStartDates.value?.length || 0) * 50;
  471. return baseHeight || 100; // 至少返回100px,避免为0
  472. };
  473. const getTermStyle = (t, index) => {
  474. // 优先使用实际测量的timeline-list高度,如果没有测量到则使用计算值作为后备
  475. const totalHeight = timelineListHeight.value > 0 ? timelineListHeight.value : calculateTotalHeightByFarmWorks();
  476. // 获取物候期起始时间总数(使用新数组)
  477. const termCount = phenologyStartDates.value?.length || 1;
  478. // 等分高度:总高度 / 物候期起始时间数量
  479. const termHeight = totalHeight / termCount;
  480. // 计算top位置:索引 * 每个物候期起始时间的高度
  481. const top = index * termHeight;
  482. return {
  483. position: "absolute",
  484. top: `${top}px`,
  485. left: 0,
  486. width: "35px",
  487. height: `${termHeight}px`, // 高度等分,使用实际测量的高度
  488. display: "flex",
  489. alignItems: "center",
  490. };
  491. };
  492. // 点击季节 → 滚动到对应节气(立春/立夏/立秋/立冬)
  493. const handleSeasonClick = (seasonValue) => {
  494. const mapping = {
  495. spring: "立春",
  496. summer: "立夏",
  497. autumn: "立秋",
  498. winter: "立冬",
  499. };
  500. const targetName = mapping[seasonValue];
  501. if (!targetName) return;
  502. // 查找对应的节气
  503. const targetIndex = solarTerms.value.findIndex((t) => (t?.displayName || "") === targetName);
  504. if (targetIndex === -1) return;
  505. // 计算目标节气的top位置
  506. const totalHeight = timelineListHeight.value > 0 ? timelineListHeight.value : calculateTotalHeightByFarmWorks();
  507. const termCount = solarTerms.value?.length || 1;
  508. const termHeight = totalHeight / termCount;
  509. const targetTop = targetIndex * termHeight;
  510. // 滚动到目标位置
  511. const wrap = timelineContainerRef.value;
  512. if (!wrap) return;
  513. const viewH = wrap.clientHeight || 0;
  514. const maxScroll = Math.max(0, wrap.scrollHeight - viewH);
  515. // 将目标位置稍微靠上(使用 0.1 视口高度做偏移)
  516. let scrollTop = Math.max(0, targetTop - viewH * 0.1);
  517. if (scrollTop > maxScroll) scrollTop = maxScroll;
  518. wrap.scrollTo({ top: scrollTop, behavior: "smooth" });
  519. };
  520. // 农事状态样式映射
  521. const getArrangeStatusClass = (fw) => {
  522. const t = props.pageType === 'agri_record' ? fw?.flowStatus : fw?.sourceType;
  523. if (props.pageType === 'agri_record') {
  524. if (t == null || t == 0) return "status-default";
  525. if (t == 3) return "status-warning-bg";
  526. if (t == 5) return "status-normal";
  527. return "status-act";
  528. } else {
  529. if (t == 10) return "status-complete";
  530. if (t == 11) return "status-warning";
  531. return "status-normal";
  532. }
  533. };
  534. const handleRowClick = (item) => {
  535. // 跳转前记录当前滚动位置
  536. saveTimelineScrollTop();
  537. emits("row-click", item);
  538. };
  539. // 获取农事规划数据
  540. const getFarmWorkPlan = () => {
  541. if (!props.farmId) return;
  542. // 如果正在请求,或者 regionId 与上次请求的相同,直接返回,防止重复请求
  543. if (isRequesting.value || lastRequestedFarmId.value === props.regionId) return;
  544. // 设置请求标志和记录 regionId
  545. isRequesting.value = true;
  546. lastRequestedFarmId.value = props.regionId;
  547. // 更新时间戳,确保key变化,触发DOM重新渲染
  548. uniqueTimestamp.value = Date.now();
  549. // 重置测量高度,等待重新测量
  550. timelineListHeight.value = 0;
  551. // 重置空数据状态
  552. isEmpty.value = false;
  553. let savedScrollTop = 0;
  554. if (!isInitialLoad.value && timelineContainerRef.value) {
  555. savedScrollTop = timelineContainerRef.value.scrollTop || 0;
  556. }
  557. const apiFunc = props.pageType === 'agri_record' ? VE_API.monitor.getFarmWorkPlan : VE_API.monitor.getArchivesList;
  558. const params = {
  559. farmId: props.farmId,
  560. regionId: props.regionId,
  561. }
  562. if (props.pageType === 'agri_record') {
  563. params.containerId = props.containerId;
  564. }
  565. apiFunc(params)
  566. .then(async ({ data, code }) => {
  567. if (code === 0) {
  568. const list = Array.isArray(data?.solarTermsList) ? data.solarTermsList : [];
  569. const filtered = list
  570. .filter((t) => t && t.type === 1)
  571. .map((t) => ({
  572. id:
  573. t.id ??
  574. t.solarTermsId ??
  575. t.termId ??
  576. `${t.name || t.solarTermsName || t.termName || "term"}-${t.createDate || ""}`,
  577. displayName: t.name || t.solarTermsName || t.termName || "节气",
  578. createDate: t.createDate || null,
  579. progress: Number(t.progress) || 0,
  580. }));
  581. solarTerms.value = filtered;
  582. // 物候期数据
  583. const processedPhenologyList = Array.isArray(data?.phenologyList)
  584. ? await Promise.all(
  585. data.phenologyList.map(async (it) => {
  586. const reproductiveList = Array.isArray(it.reproductiveList)
  587. ? await Promise.all(
  588. it.reproductiveList.map(async (r) => {
  589. const farmWorkArrangeList = Array.isArray(r.broadcastList || r.interactionFarmWorkList)
  590. ? await Promise.all(
  591. (r.broadcastList || r.interactionFarmWorkList).map(async (fw) => {
  592. const sourceDataJson = parseSourceDataSafe(fw.sourceData);
  593. // 如果有 imageIds,获取图片 URL
  594. if (
  595. sourceDataJson &&
  596. sourceDataJson.imageIds &&
  597. Array.isArray(sourceDataJson.imageIds) &&
  598. sourceDataJson.imageIds.length > 0
  599. ) {
  600. const resFilenameList = await fetchImageUrls(
  601. {
  602. imageIds: sourceDataJson.imageIds,
  603. page: 1,
  604. limit: 100,
  605. }
  606. );
  607. sourceDataJson.resFilename = resFilenameList;
  608. // 调用 findSuitabilityByPoint 接口获取天气适宜性信息
  609. if (fw.farmId && fw.createTime) {
  610. try {
  611. const dateStr = formatDateForAPI(fw.createTime);
  612. if (dateStr) {
  613. const suitabilityRes = await VE_API.ali.findSuitabilityByPoint({
  614. farmId: fw.farmId,
  615. date: dateStr,
  616. });
  617. if (suitabilityRes && suitabilityRes.code === 0 && suitabilityRes.data) {
  618. // 将返回的数据合并到 sourceDataJson
  619. sourceDataJson.suitability = suitabilityRes.data;
  620. }
  621. }
  622. } catch (error) {
  623. console.error("获取天气适宜性信息失败:", error);
  624. }
  625. }
  626. }
  627. return {
  628. ...fw,
  629. phenologyName: r.phenologyName,
  630. sourceDataJson,
  631. containerSpaceTimeId: it.containerSpaceTimeId,
  632. };
  633. })
  634. )
  635. : [];
  636. return {
  637. ...r,
  638. farmWorkArrangeList,
  639. };
  640. })
  641. )
  642. : [];
  643. return {
  644. id: it.id ?? it.phenologyId ?? it.name ?? `${it.progress}-${it.progress2}`,
  645. progress: Number(it.progress) || 0, // 起点 %
  646. progress2: Number(it.progress2) || 0, // 终点 %
  647. phenologyName: it.phenologyName,
  648. startDate: it.startDate,
  649. startTimeMs: safeParseDate(
  650. it.startDate || it.beginDate || it.startTime || it.start || it.start_at
  651. ),
  652. reproductiveList,
  653. };
  654. })
  655. )
  656. : [];
  657. phenologyList.value = processedPhenologyList;
  658. // 使用多次 nextTick 和 requestAnimationFrame 确保DOM完全渲染
  659. nextTick(() => {
  660. requestAnimationFrame(() => {
  661. nextTick(() => {
  662. requestAnimationFrame(() => {
  663. // 测量timeline-list的实际渲染高度
  664. if (timelineListRef.value) {
  665. const height =
  666. timelineListRef.value.offsetHeight || timelineListRef.value.clientHeight;
  667. if (height > 0) {
  668. timelineListHeight.value = height;
  669. }
  670. }
  671. const hasRestoredScrollTop = restoreTimelineScrollTopWithRetry();
  672. if (isInitialLoad.value) {
  673. if (hasRestoredScrollTop) {
  674. isInitialLoad.value = false;
  675. } else {
  676. // 如果测量失败,延迟一下再尝试滚动
  677. setTimeout(() => {
  678. if (timelineListRef.value) {
  679. const height =
  680. timelineListRef.value.offsetHeight ||
  681. timelineListRef.value.clientHeight;
  682. if (height > 0) {
  683. timelineListHeight.value = height;
  684. }
  685. }
  686. if (!restoreTimelineScrollTopWithRetry()) {
  687. const currentSeason = getCurrentSeason();
  688. handleSeasonClick(currentSeason);
  689. }
  690. isInitialLoad.value = false;
  691. }, 200);
  692. }
  693. } else {
  694. if (!hasRestoredScrollTop && timelineContainerRef.value && savedScrollTop > 0) {
  695. timelineContainerRef.value.scrollTop = savedScrollTop;
  696. }
  697. }
  698. });
  699. });
  700. });
  701. });
  702. // 收集所有farmWorkId
  703. const farmWorkIds = [];
  704. const farmWorks = [];
  705. phenologyList.value.forEach((phenology) => {
  706. if (Array.isArray(phenology.reproductiveList)) {
  707. phenology.reproductiveList.forEach((reproductive) => {
  708. if (Array.isArray(reproductive.farmWorkArrangeList)) {
  709. reproductive.farmWorkArrangeList.forEach((farmWork) => {
  710. if (farmWork.farmWorkId && farmWork.isFollow !== 0) {
  711. farmWorkIds.push(farmWork.farmWorkId);
  712. farmWorks.push(farmWork);
  713. }
  714. });
  715. }
  716. });
  717. }
  718. });
  719. // 调用验证方法,传入所有ids
  720. if (farmWorkIds.length > 0) {
  721. batchValidatePesticideFertilizerQuotes(farmWorkIds, farmWorks);
  722. }
  723. // 判断是否为空数据:没有节气或没有物候期数据
  724. if (solarTerms.value.length === 0 && phenologyList.value.length === 0) {
  725. isEmpty.value = true;
  726. } else {
  727. isEmpty.value = false;
  728. }
  729. } else {
  730. // 接口返回错误码,显示暂无数据
  731. isEmpty.value = true;
  732. solarTerms.value = [];
  733. phenologyList.value = [];
  734. }
  735. })
  736. .catch((error) => {
  737. console.error("获取农事规划数据失败:", error);
  738. ElMessage.error("获取农事规划数据失败");
  739. // 接口报错,显示暂无数据
  740. isEmpty.value = true;
  741. solarTerms.value = [];
  742. phenologyList.value = [];
  743. })
  744. .finally(() => {
  745. // 请求完成,重置请求标志
  746. isRequesting.value = false;
  747. });
  748. };
  749. const updateFarmWorkPlan = () => {
  750. solarTerms.value = [];
  751. phenologyList.value = [];
  752. isEmpty.value = false;
  753. getFarmWorkPlan();
  754. };
  755. watch(
  756. () => props.regionId,
  757. (val, oldVal) => {
  758. // 如果 farmId 没有值,则不触发
  759. if (!val) return;
  760. // 如果 farmId 变化了,重置上次请求的 farmId,允许请求新数据
  761. if (val !== oldVal) {
  762. lastRequestedFarmId.value = null;
  763. }
  764. // getFarmWorkPlan 内部已经有防重复请求的检查,这里直接调用即可
  765. isInitialLoad.value = true;
  766. updateFarmWorkPlan();
  767. },
  768. { immediate: true }
  769. );
  770. const handleStatusDetail = (fw) => {
  771. // 跳转前记录当前滚动位置
  772. saveTimelineScrollTop();
  773. if (props.pageType === 'agri_plan') {
  774. if (fw?.sourceData && fw?.id) {
  775. router.push({
  776. path: "/agricultural_detail",
  777. query: {
  778. farmId: props.farmId,
  779. regionId: props.regionId,
  780. date: fw?.createTime?.slice(0, 10),
  781. content: fw?.content
  782. },
  783. });
  784. }
  785. } else {
  786. router.push({
  787. path: "/work_detail",
  788. query: {
  789. miniJson: JSON.stringify({
  790. paramsPage: JSON.stringify({
  791. farmId: props.farmId,
  792. farmWorkLibId: fw?.farmWorkLibId,
  793. recordId: fw?.farmWorkRecordId,
  794. typeId: props.typeId
  795. }),
  796. }),
  797. },
  798. });
  799. }
  800. };
  801. // 格式化日期为 MM-DD 格式
  802. const formatDate = (dateStr) => {
  803. if (!dateStr) return "--";
  804. const date = new Date(dateStr);
  805. if (Number.isNaN(date.getTime())) return dateStr;
  806. const m = `${date.getMonth() + 1}`.padStart(2, "0");
  807. const d = `${date.getDate()}`.padStart(2, "0");
  808. return `${m}-${d}`;
  809. };
  810. // 格式化日期为 YYYY-MM-DD 格式(用于接口调用)
  811. const formatDateForAPI = (dateStr) => {
  812. if (!dateStr) return null;
  813. const date = new Date(dateStr);
  814. if (Number.isNaN(date.getTime())) return null;
  815. const y = date.getFullYear();
  816. const m = `${date.getMonth() + 1}`.padStart(2, "0");
  817. const d = `${date.getDate()}`.padStart(2, "0");
  818. return `${y}-${m}-${d}`;
  819. };
  820. // 获取下一个即将到来的节气(当前节气)的 progress
  821. const getNextTermProgress = () => {
  822. if (!solarTerms.value || solarTerms.value.length === 0) return Infinity;
  823. const now = new Date();
  824. now.setHours(0, 0, 0, 0);
  825. let nextTermProgress = Infinity;
  826. // 找到当前日期之后的下一个节气(当前节气)
  827. solarTerms.value.forEach((term) => {
  828. const termDate = safeParseDate(term.createDate);
  829. if (!isNaN(termDate)) {
  830. const termDateObj = new Date(termDate);
  831. termDateObj.setHours(0, 0, 0, 0);
  832. // 找到大于等于当前日期的第一个节气
  833. if (termDateObj >= now) {
  834. const termProgress = Number(term.progress) || 0;
  835. if (termProgress < nextTermProgress) {
  836. nextTermProgress = termProgress;
  837. }
  838. }
  839. }
  840. });
  841. // 如果没有找到未来的节气,说明所有节气都已过,返回 Infinity(所有物候期都显示蓝色)
  842. return nextTermProgress === Infinity ? Infinity : nextTermProgress;
  843. };
  844. // 根据物候期的 progress 判断它所属节气的 progress
  845. const getPhenologyTermProgress = (phenologyProgress) => {
  846. if (!solarTerms.value || solarTerms.value.length === 0) return -1;
  847. const progress = Number(phenologyProgress) || 0;
  848. // 找到物候期所属的节气(progress 最接近且小于等于的节气)
  849. let matchedTermProgress = -1;
  850. solarTerms.value.forEach((term) => {
  851. const termProgress = Number(term.progress) || 0;
  852. if (progress >= termProgress && termProgress > matchedTermProgress) {
  853. matchedTermProgress = termProgress;
  854. }
  855. });
  856. // 如果物候期的 progress 小于所有节气,返回第一个节气的 progress
  857. if (matchedTermProgress === -1 && solarTerms.value.length > 0) {
  858. const firstTermProgress = Number(solarTerms.value[0].progress) || 0;
  859. return firstTermProgress;
  860. }
  861. return matchedTermProgress;
  862. };
  863. const flowStatusStr = {
  864. '3': '待认证',
  865. '-1': '已过期',
  866. '5': '已认证',
  867. }
  868. // 判断物候期是否应该显示蓝色(已过或当前节气的物候期)
  869. const shouldShowBlue = (phenology) => {
  870. // 农事记录页兼容:只要该物候期下存在待认证农事,左侧生育期/物候期均高亮为蓝色
  871. if (props.pageType === "agri_record") {
  872. const hasPendingAuth = (Array.isArray(phenology?.reproductiveList) ? phenology.reproductiveList : []).some((reproductive) =>
  873. (Array.isArray(reproductive?.farmWorkArrangeList) ? reproductive.farmWorkArrangeList : []).some((fw) => Number(fw?.flowStatus) === 3)
  874. );
  875. if (hasPendingAuth) {
  876. return true;
  877. }
  878. }
  879. // 优先使用物候期真实日期判断:未来日期不应显示蓝色
  880. const phenologyTimeMs =
  881. Number(phenology?.startTimeMs) ||
  882. safeParseDate(phenology?.startDate || phenology?.beginDate || phenology?.startTime || phenology?.start || phenology?.start_at);
  883. if (!Number.isNaN(phenologyTimeMs) && phenologyTimeMs > 0) {
  884. const today = new Date();
  885. today.setHours(0, 0, 0, 0);
  886. return phenologyTimeMs <= today.getTime();
  887. }
  888. // 日期缺失时,回退到 progress 规则(兼容老数据)
  889. // 获取下一个即将到来的节气(当前节气)的 progress
  890. const nextTermProgress = getNextTermProgress();
  891. // 如果所有节气都已过(nextTermProgress === Infinity),所有物候期都显示蓝色
  892. if (nextTermProgress === Infinity) {
  893. return true;
  894. }
  895. // 根据物候期的 progress 判断它属于哪个节气
  896. const phenologyProgress = Math.min(Number(phenology?.progress) || 0, Number(phenology?.progress2) || 0);
  897. const phenologyTermProgress = getPhenologyTermProgress(phenologyProgress);
  898. // 找到下一个节气的完整信息,用于判断物候期是否属于当前节气
  899. let nextTerm = null;
  900. solarTerms.value.forEach((term) => {
  901. const termProgress = Number(term.progress) || 0;
  902. if (termProgress === nextTermProgress) {
  903. nextTerm = term;
  904. }
  905. });
  906. // 如果物候期所属的节气的 progress < 下一个节气的 progress,显示蓝色
  907. // 如果物候期所属的节气的 progress === 下一个节气的 progress,也显示蓝色(当前节气)
  908. // 也就是说,只有属于当前节气或之前节气的物候期才显示蓝色
  909. if (phenologyTermProgress === -1) {
  910. return false;
  911. }
  912. // 如果物候期正好属于下一个节气,需要判断它的 progress 是否在下一个节气的范围内
  913. if (phenologyTermProgress === nextTermProgress && nextTerm) {
  914. // 如果物候期的 progress 小于等于下一个节气的 progress,说明它属于当前节气,显示蓝色
  915. return phenologyProgress <= nextTermProgress;
  916. }
  917. // 如果物候期所属的节气的 progress < 下一个节气的 progress,显示蓝色
  918. return phenologyTermProgress < nextTermProgress;
  919. };
  920. defineExpose({
  921. updateFarmWorkPlan,
  922. });
  923. // 使用 ResizeObserver 监听高度变化,确保在DOM完全渲染后获取准确高度
  924. const setupResizeObserver = () => {
  925. if (!timelineListRef.value || typeof ResizeObserver === "undefined") {
  926. return;
  927. }
  928. // 如果已经存在观察者,先断开
  929. if (resizeObserver) {
  930. resizeObserver.disconnect();
  931. }
  932. // 创建新的观察者
  933. resizeObserver = new ResizeObserver((entries) => {
  934. for (const entry of entries) {
  935. const height = entry.contentRect.height;
  936. if (height > 0 && height !== timelineListHeight.value) {
  937. timelineListHeight.value = height;
  938. }
  939. }
  940. });
  941. // 开始观察
  942. resizeObserver.observe(timelineListRef.value);
  943. };
  944. // 组件挂载后设置 ResizeObserver
  945. onMounted(() => {
  946. nextTick(() => {
  947. requestAnimationFrame(() => {
  948. setupResizeObserver();
  949. restoreTimelineScrollTopWithRetry();
  950. });
  951. });
  952. });
  953. // 组件卸载前清理 ResizeObserver
  954. onUnmounted(() => {
  955. saveTimelineScrollTop();
  956. if (resizeObserver) {
  957. resizeObserver.disconnect();
  958. resizeObserver = null;
  959. }
  960. });
  961. onActivated(() => {
  962. nextTick(() => {
  963. requestAnimationFrame(() => {
  964. restoreTimelineScrollTopWithRetry();
  965. });
  966. });
  967. });
  968. onDeactivated(() => {
  969. saveTimelineScrollTop();
  970. });
  971. onBeforeRouteLeave(() => {
  972. saveTimelineScrollTop();
  973. });
  974. // 在数据更新后重新设置 ResizeObserver
  975. watch(
  976. () => phenologyList.value.length,
  977. () => {
  978. nextTick(() => {
  979. requestAnimationFrame(() => {
  980. setupResizeObserver();
  981. });
  982. });
  983. }
  984. );
  985. </script>
  986. <style scoped lang="scss">
  987. .timeline-container {
  988. height: 100%;
  989. overflow: auto;
  990. position: relative;
  991. box-sizing: border-box;
  992. .timeline-list {
  993. position: relative;
  994. }
  995. .timeline-middle-line {
  996. position: absolute;
  997. left: 13px;
  998. /* 位于节气文字列中间(列宽约30px) */
  999. top: 0;
  1000. bottom: 0;
  1001. width: 2px;
  1002. background: #e8e8e8;
  1003. z-index: 1;
  1004. }
  1005. .phenology-bar {
  1006. align-items: stretch;
  1007. justify-content: center;
  1008. box-sizing: border-box;
  1009. position: relative;
  1010. .phenology-title {
  1011. width: 18px;
  1012. height: 99.5%;
  1013. color: #fff;
  1014. font-size: 12px;
  1015. position: absolute;
  1016. // left: 39px;
  1017. left: -1px;
  1018. z-index: 10;
  1019. text-align: center;
  1020. display: flex;
  1021. align-items: center;
  1022. &.phenology-blue {
  1023. background: #2199f8;
  1024. }
  1025. &.phenology-red {
  1026. background: #f1f1f1;
  1027. color: #808080;
  1028. }
  1029. }
  1030. .reproductive-item {
  1031. font-size: 12px;
  1032. text-align: center;
  1033. word-break: break-all;
  1034. writing-mode: vertical-rl;
  1035. text-orientation: upright;
  1036. letter-spacing: 3px;
  1037. width: 100%;
  1038. line-height: 23px;
  1039. color: inherit;
  1040. position: relative;
  1041. .phenology-name {
  1042. width: 18px;
  1043. line-height: 16px;
  1044. height: 100%;
  1045. color: #fff;
  1046. padding: 4px 0;
  1047. font-size: 12px;
  1048. box-sizing: border-box;
  1049. &.mr {
  1050. margin-right: 3px;
  1051. }
  1052. &.single {
  1053. width: 39px;
  1054. line-height: 39px;
  1055. // z-index: 10;
  1056. // position: relative;
  1057. }
  1058. &.phenology-blue {
  1059. background: #2199f8;
  1060. }
  1061. &.phenology-red {
  1062. background: #f1f1f1;
  1063. color: #808080;
  1064. }
  1065. &.text-blue {
  1066. background: rgba(33, 153, 248, 0.15);
  1067. color: #2199f8;
  1068. border: 1px solid #2199f8;
  1069. line-height: 16px;
  1070. box-sizing: border-box;
  1071. }
  1072. &.text-red {
  1073. background: rgba(128, 128, 128, 0.15);
  1074. color: #808080;
  1075. border: 1px solid rgba(128, 128, 128, 0.35);
  1076. line-height: 16px;
  1077. box-sizing: border-box;
  1078. }
  1079. }
  1080. .arranges {
  1081. display: flex;
  1082. max-width: calc(100vw - 88px);
  1083. min-width: calc(100vw - 78px);
  1084. gap: 5px;
  1085. letter-spacing: 0px;
  1086. // min-height: 90px;
  1087. .arrange-card {
  1088. width: 95%;
  1089. border: 0.5px solid #2199f8;
  1090. border-radius: 8px;
  1091. background: #fff;
  1092. box-sizing: border-box;
  1093. position: relative;
  1094. padding: 8px 15px 8px 10px;
  1095. writing-mode: horizontal-tb;
  1096. margin-bottom: 10px;
  1097. // &.last-card {
  1098. // margin-bottom: 0;
  1099. // }
  1100. .card-content {
  1101. color: #242424;
  1102. display: flex;
  1103. justify-content: space-between;
  1104. align-items: center;
  1105. font-size: 14px;
  1106. .card-left {
  1107. width: calc(100% - 45px);
  1108. .left-info {
  1109. display: flex;
  1110. align-items: center;
  1111. gap: 6px;
  1112. .left-date {
  1113. color: #2199f8;
  1114. border: 1px solid #2199f8;
  1115. padding: 1px 0;
  1116. border-radius: 2px;
  1117. font-size: 12px;
  1118. width: 45px;
  1119. box-sizing: border-box;
  1120. }
  1121. .text {
  1122. display: flex;
  1123. align-items: center;
  1124. gap: 2px;
  1125. width: calc(100% - 50px);
  1126. }
  1127. }
  1128. .title-text {
  1129. margin-top: 5px;
  1130. width: fit-content;
  1131. max-width: 100%;
  1132. text-align: left;
  1133. color: #2199F8;
  1134. padding: 0 6px;
  1135. border-radius: 2px;
  1136. font-size: 12px;
  1137. box-sizing: border-box;
  1138. background: rgba(33, 153, 248, 0.1);
  1139. }
  1140. &.agri-record-card {
  1141. .title-wrap {
  1142. display: flex;
  1143. align-items: flex-end;
  1144. gap: 6px;
  1145. .expert-info {
  1146. display: flex;
  1147. align-items: center;
  1148. gap: 2px;
  1149. font-size: 12px;
  1150. color: #B7B7B7;
  1151. }
  1152. .blue-tag{
  1153. color: #2199F8;
  1154. background: rgba(33, 153, 248, 0.1);
  1155. }
  1156. }
  1157. }
  1158. }
  1159. .card-right {
  1160. display: flex;
  1161. align-items: center;
  1162. position: relative;
  1163. img {
  1164. width: 45px;
  1165. height: 45px;
  1166. border-radius: 4px;
  1167. object-fit: cover;
  1168. }
  1169. .num {
  1170. position: absolute;
  1171. width: 18px;
  1172. height: 18px;
  1173. box-sizing: border-box;
  1174. top: -4px;
  1175. right: -6px;
  1176. background: #BFBFBF;
  1177. color: #fff;
  1178. font-size: 12px;
  1179. border-radius: 50%;
  1180. display: flex;
  1181. align-items: center;
  1182. justify-content: center;
  1183. }
  1184. }
  1185. }
  1186. &::before {
  1187. content: "";
  1188. position: absolute;
  1189. left: -5px;
  1190. top: 50%;
  1191. transform: translateY(-50%);
  1192. width: 0;
  1193. height: 0;
  1194. border-top: 5px solid transparent;
  1195. border-bottom: 5px solid transparent;
  1196. border-right: 5px solid #2199f8;
  1197. }
  1198. }
  1199. .arrange-card.normal-style {
  1200. opacity: 0.3;
  1201. }
  1202. .arrange-card.status-normal {
  1203. border-color: #2199f8;
  1204. &::before {
  1205. border-right-color: #2199f8;
  1206. }
  1207. }
  1208. .arrange-card.status-warning {
  1209. border-color: #FF4E4E;
  1210. .card-left {
  1211. .left-info {
  1212. .left-date {
  1213. color: #FF4E4E;
  1214. border-color: #FF4E4E;
  1215. }
  1216. }
  1217. .title-text {
  1218. color: #FF4E4E;
  1219. background: rgba(255, 78, 78, 0.1);
  1220. }
  1221. }
  1222. &::before {
  1223. border-right-color: #FF4E4E;
  1224. }
  1225. }
  1226. .arrange-card.status-complete {
  1227. border-color: #FF943D;
  1228. .card-left {
  1229. .left-info {
  1230. .left-date {
  1231. color: #FF943D;
  1232. border-color: #FF943D;
  1233. }
  1234. }
  1235. .title-text {
  1236. color: #FF943D;
  1237. background: rgba(255, 149, 61, 0.1);
  1238. }
  1239. }
  1240. &::before {
  1241. border-right-color: #FF943D;
  1242. }
  1243. }
  1244. .arrange-card.status-warning-bg {
  1245. border-color: #FF943D;
  1246. .card-left {
  1247. .left-info {
  1248. .left-date {
  1249. color: #FF943D;
  1250. border-color: #FF943D;
  1251. }
  1252. }
  1253. .title-text {
  1254. color: #fff;
  1255. background: #FF943D;;
  1256. }
  1257. }
  1258. &::before {
  1259. border-right-color: #FF943D;
  1260. }
  1261. }
  1262. .arrange-card.status-act {
  1263. border-color: #FF953D;
  1264. .card-left {
  1265. .left-info {
  1266. .left-date {
  1267. color: #FF953D;
  1268. border-color: #FF953D;
  1269. }
  1270. }
  1271. .title-text {
  1272. color: #fff;
  1273. background: #FF953D;
  1274. }
  1275. }
  1276. &::before {
  1277. border-right-color: #FF953D;
  1278. }
  1279. }
  1280. .arrange-card.status-default {
  1281. border-color: #BBBBBB;
  1282. .card-left {
  1283. .left-info {
  1284. .left-date {
  1285. color: #BBBBBB;
  1286. border-color: #BBBBBB;
  1287. }
  1288. .text-name,
  1289. .text-icon {
  1290. color: #BBBBBB;
  1291. }
  1292. }
  1293. .title-text {
  1294. color: #fff;
  1295. background: #BBBBBB;
  1296. }
  1297. }
  1298. &::before {
  1299. border-right-color: #BBBBBB;
  1300. }
  1301. }
  1302. // 未来节气对应的农事卡片:跟随左侧物候期的“未开始”灰色样式
  1303. .arrange-card.future-card {
  1304. border-color: #e4e4e4;
  1305. .card-content {
  1306. color: rgba(36, 36, 36, 0.5);
  1307. }
  1308. .card-left {
  1309. .left-info {
  1310. .left-date {
  1311. color: #CACACA;
  1312. border-color: #e4e4e4;
  1313. }
  1314. }
  1315. }
  1316. &::before {
  1317. border-right-color: #e4e4e4;
  1318. }
  1319. }
  1320. }
  1321. }
  1322. }
  1323. .reproductive-item+.reproductive-item {
  1324. padding-top: 3px;
  1325. }
  1326. .phenology-bar+.phenology-bar {
  1327. padding-top: 3px;
  1328. }
  1329. .timeline-term {
  1330. position: absolute;
  1331. width: 34px;
  1332. display: flex;
  1333. align-items: flex-start;
  1334. flex-direction: column;
  1335. z-index: 2;
  1336. /* 置于中线之上 */
  1337. color: rgba(174, 174, 174, 0.6);
  1338. .term-name {
  1339. display: inline-block;
  1340. width: 100%;
  1341. min-height: 20px;
  1342. line-height: 26px;
  1343. background: #fff;
  1344. font-size: 12px;
  1345. }
  1346. }
  1347. .empty-state {
  1348. display: flex;
  1349. justify-content: center;
  1350. align-items: center;
  1351. min-height: 200px;
  1352. width: 100%;
  1353. }
  1354. }
  1355. </style>