ArchivesFarmTimeLine.vue 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506
  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">
  63. <div class="title-text" v-if="fw.flowStatus != null && fw.flowStatus != 0">{{ flowStatusStr[fw.flowStatus] }}</div>
  64. <div class="title-text blue-tag" v-if="fw.flowStatus != null && fw.flowStatus != 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. return "status-act";
  527. } else {
  528. if (t == 10) return "status-complete";
  529. if (t == 11) return "status-warning";
  530. return "status-normal";
  531. }
  532. };
  533. const handleRowClick = (item) => {
  534. // 跳转前记录当前滚动位置
  535. saveTimelineScrollTop();
  536. emits("row-click", item);
  537. };
  538. // 获取农事规划数据
  539. const getFarmWorkPlan = () => {
  540. if (!props.farmId) return;
  541. // 如果正在请求,或者 regionId 与上次请求的相同,直接返回,防止重复请求
  542. if (isRequesting.value || lastRequestedFarmId.value === props.regionId) return;
  543. // 设置请求标志和记录 regionId
  544. isRequesting.value = true;
  545. lastRequestedFarmId.value = props.regionId;
  546. // 更新时间戳,确保key变化,触发DOM重新渲染
  547. uniqueTimestamp.value = Date.now();
  548. // 重置测量高度,等待重新测量
  549. timelineListHeight.value = 0;
  550. // 重置空数据状态
  551. isEmpty.value = false;
  552. let savedScrollTop = 0;
  553. if (!isInitialLoad.value && timelineContainerRef.value) {
  554. savedScrollTop = timelineContainerRef.value.scrollTop || 0;
  555. }
  556. const apiFunc = props.pageType === 'agri_record' ? VE_API.monitor.getFarmWorkPlan : VE_API.monitor.getArchivesList;
  557. const params = {
  558. farmId: props.farmId,
  559. regionId: props.regionId,
  560. }
  561. if (props.pageType === 'agri_record') {
  562. params.containerId = props.containerId;
  563. }
  564. apiFunc(params)
  565. .then(async ({ data, code }) => {
  566. if (code === 0) {
  567. const list = Array.isArray(data?.solarTermsList) ? data.solarTermsList : [];
  568. const filtered = list
  569. .filter((t) => t && t.type === 1)
  570. .map((t) => ({
  571. id:
  572. t.id ??
  573. t.solarTermsId ??
  574. t.termId ??
  575. `${t.name || t.solarTermsName || t.termName || "term"}-${t.createDate || ""}`,
  576. displayName: t.name || t.solarTermsName || t.termName || "节气",
  577. createDate: t.createDate || null,
  578. progress: Number(t.progress) || 0,
  579. }));
  580. solarTerms.value = filtered;
  581. // 物候期数据
  582. const processedPhenologyList = Array.isArray(data?.phenologyList)
  583. ? await Promise.all(
  584. data.phenologyList.map(async (it) => {
  585. const reproductiveList = Array.isArray(it.reproductiveList)
  586. ? await Promise.all(
  587. it.reproductiveList.map(async (r) => {
  588. const farmWorkArrangeList = Array.isArray(r.broadcastList || r.interactionFarmWorkList)
  589. ? await Promise.all(
  590. (r.broadcastList || r.interactionFarmWorkList).map(async (fw) => {
  591. const sourceDataJson = parseSourceDataSafe(fw.sourceData);
  592. // 如果有 imageIds,获取图片 URL
  593. if (
  594. sourceDataJson &&
  595. sourceDataJson.imageIds &&
  596. Array.isArray(sourceDataJson.imageIds) &&
  597. sourceDataJson.imageIds.length > 0
  598. ) {
  599. const resFilenameList = await fetchImageUrls(
  600. {
  601. imageIds: sourceDataJson.imageIds,
  602. page: 1,
  603. limit: 100,
  604. }
  605. );
  606. sourceDataJson.resFilename = resFilenameList;
  607. // 调用 findSuitabilityByPoint 接口获取天气适宜性信息
  608. if (fw.farmId && fw.createTime) {
  609. try {
  610. const dateStr = formatDateForAPI(fw.createTime);
  611. if (dateStr) {
  612. const suitabilityRes = await VE_API.ali.findSuitabilityByPoint({
  613. farmId: fw.farmId,
  614. date: dateStr,
  615. });
  616. if (suitabilityRes && suitabilityRes.code === 0 && suitabilityRes.data) {
  617. // 将返回的数据合并到 sourceDataJson
  618. sourceDataJson.suitability = suitabilityRes.data;
  619. }
  620. }
  621. } catch (error) {
  622. console.error("获取天气适宜性信息失败:", error);
  623. }
  624. }
  625. }
  626. return {
  627. ...fw,
  628. phenologyName: r.phenologyName,
  629. sourceDataJson,
  630. containerSpaceTimeId: it.containerSpaceTimeId,
  631. };
  632. })
  633. )
  634. : [];
  635. return {
  636. ...r,
  637. farmWorkArrangeList,
  638. };
  639. })
  640. )
  641. : [];
  642. return {
  643. id: it.id ?? it.phenologyId ?? it.name ?? `${it.progress}-${it.progress2}`,
  644. progress: Number(it.progress) || 0, // 起点 %
  645. progress2: Number(it.progress2) || 0, // 终点 %
  646. phenologyName: it.phenologyName,
  647. startDate: it.startDate,
  648. startTimeMs: safeParseDate(
  649. it.startDate || it.beginDate || it.startTime || it.start || it.start_at
  650. ),
  651. reproductiveList,
  652. };
  653. })
  654. )
  655. : [];
  656. phenologyList.value = processedPhenologyList;
  657. // 使用多次 nextTick 和 requestAnimationFrame 确保DOM完全渲染
  658. nextTick(() => {
  659. requestAnimationFrame(() => {
  660. nextTick(() => {
  661. requestAnimationFrame(() => {
  662. // 测量timeline-list的实际渲染高度
  663. if (timelineListRef.value) {
  664. const height =
  665. timelineListRef.value.offsetHeight || timelineListRef.value.clientHeight;
  666. if (height > 0) {
  667. timelineListHeight.value = height;
  668. }
  669. }
  670. const hasRestoredScrollTop = restoreTimelineScrollTopWithRetry();
  671. if (isInitialLoad.value) {
  672. if (hasRestoredScrollTop) {
  673. isInitialLoad.value = false;
  674. } else {
  675. // 如果测量失败,延迟一下再尝试滚动
  676. setTimeout(() => {
  677. if (timelineListRef.value) {
  678. const height =
  679. timelineListRef.value.offsetHeight ||
  680. timelineListRef.value.clientHeight;
  681. if (height > 0) {
  682. timelineListHeight.value = height;
  683. }
  684. }
  685. if (!restoreTimelineScrollTopWithRetry()) {
  686. const currentSeason = getCurrentSeason();
  687. handleSeasonClick(currentSeason);
  688. }
  689. isInitialLoad.value = false;
  690. }, 200);
  691. }
  692. } else {
  693. if (!hasRestoredScrollTop && timelineContainerRef.value && savedScrollTop > 0) {
  694. timelineContainerRef.value.scrollTop = savedScrollTop;
  695. }
  696. }
  697. });
  698. });
  699. });
  700. });
  701. // 收集所有farmWorkId
  702. const farmWorkIds = [];
  703. const farmWorks = [];
  704. phenologyList.value.forEach((phenology) => {
  705. if (Array.isArray(phenology.reproductiveList)) {
  706. phenology.reproductiveList.forEach((reproductive) => {
  707. if (Array.isArray(reproductive.farmWorkArrangeList)) {
  708. reproductive.farmWorkArrangeList.forEach((farmWork) => {
  709. if (farmWork.farmWorkId && farmWork.isFollow !== 0) {
  710. farmWorkIds.push(farmWork.farmWorkId);
  711. farmWorks.push(farmWork);
  712. }
  713. });
  714. }
  715. });
  716. }
  717. });
  718. // 调用验证方法,传入所有ids
  719. if (farmWorkIds.length > 0) {
  720. batchValidatePesticideFertilizerQuotes(farmWorkIds, farmWorks);
  721. }
  722. // 判断是否为空数据:没有节气或没有物候期数据
  723. if (solarTerms.value.length === 0 && phenologyList.value.length === 0) {
  724. isEmpty.value = true;
  725. } else {
  726. isEmpty.value = false;
  727. }
  728. } else {
  729. // 接口返回错误码,显示暂无数据
  730. isEmpty.value = true;
  731. solarTerms.value = [];
  732. phenologyList.value = [];
  733. }
  734. })
  735. .catch((error) => {
  736. console.error("获取农事规划数据失败:", error);
  737. ElMessage.error("获取农事规划数据失败");
  738. // 接口报错,显示暂无数据
  739. isEmpty.value = true;
  740. solarTerms.value = [];
  741. phenologyList.value = [];
  742. })
  743. .finally(() => {
  744. // 请求完成,重置请求标志
  745. isRequesting.value = false;
  746. });
  747. };
  748. const updateFarmWorkPlan = () => {
  749. solarTerms.value = [];
  750. phenologyList.value = [];
  751. isEmpty.value = false;
  752. getFarmWorkPlan();
  753. };
  754. watch(
  755. () => props.regionId,
  756. (val, oldVal) => {
  757. // 如果 farmId 没有值,则不触发
  758. if (!val) return;
  759. // 如果 farmId 变化了,重置上次请求的 farmId,允许请求新数据
  760. if (val !== oldVal) {
  761. lastRequestedFarmId.value = null;
  762. }
  763. // getFarmWorkPlan 内部已经有防重复请求的检查,这里直接调用即可
  764. isInitialLoad.value = true;
  765. updateFarmWorkPlan();
  766. },
  767. { immediate: true }
  768. );
  769. const handleStatusDetail = (fw) => {
  770. // 跳转前记录当前滚动位置
  771. saveTimelineScrollTop();
  772. if (props.pageType === 'agri_plan') {
  773. if (fw?.sourceData && fw?.id) {
  774. router.push({
  775. path: "/agricultural_detail",
  776. query: {
  777. farmId: props.farmId,
  778. regionId: props.regionId,
  779. date: fw?.createTime?.slice(0, 10),
  780. content: fw?.content
  781. },
  782. });
  783. }
  784. } else {
  785. router.push({
  786. path: "/work_detail",
  787. query: {
  788. miniJson: JSON.stringify({
  789. paramsPage: JSON.stringify({
  790. farmId: props.farmId,
  791. farmWorkLibId: fw?.farmWorkLibId,
  792. recordId: fw?.farmWorkRecordId,
  793. typeId: props.typeId
  794. }),
  795. }),
  796. },
  797. });
  798. }
  799. };
  800. // 格式化日期为 MM-DD 格式
  801. const formatDate = (dateStr) => {
  802. if (!dateStr) return "--";
  803. const date = new Date(dateStr);
  804. if (Number.isNaN(date.getTime())) return dateStr;
  805. const m = `${date.getMonth() + 1}`.padStart(2, "0");
  806. const d = `${date.getDate()}`.padStart(2, "0");
  807. return `${m}-${d}`;
  808. };
  809. // 格式化日期为 YYYY-MM-DD 格式(用于接口调用)
  810. const formatDateForAPI = (dateStr) => {
  811. if (!dateStr) return null;
  812. const date = new Date(dateStr);
  813. if (Number.isNaN(date.getTime())) return null;
  814. const y = date.getFullYear();
  815. const m = `${date.getMonth() + 1}`.padStart(2, "0");
  816. const d = `${date.getDate()}`.padStart(2, "0");
  817. return `${y}-${m}-${d}`;
  818. };
  819. // 获取下一个即将到来的节气(当前节气)的 progress
  820. const getNextTermProgress = () => {
  821. if (!solarTerms.value || solarTerms.value.length === 0) return Infinity;
  822. const now = new Date();
  823. now.setHours(0, 0, 0, 0);
  824. let nextTermProgress = Infinity;
  825. // 找到当前日期之后的下一个节气(当前节气)
  826. solarTerms.value.forEach((term) => {
  827. const termDate = safeParseDate(term.createDate);
  828. if (!isNaN(termDate)) {
  829. const termDateObj = new Date(termDate);
  830. termDateObj.setHours(0, 0, 0, 0);
  831. // 找到大于等于当前日期的第一个节气
  832. if (termDateObj >= now) {
  833. const termProgress = Number(term.progress) || 0;
  834. if (termProgress < nextTermProgress) {
  835. nextTermProgress = termProgress;
  836. }
  837. }
  838. }
  839. });
  840. // 如果没有找到未来的节气,说明所有节气都已过,返回 Infinity(所有物候期都显示蓝色)
  841. return nextTermProgress === Infinity ? Infinity : nextTermProgress;
  842. };
  843. // 根据物候期的 progress 判断它所属节气的 progress
  844. const getPhenologyTermProgress = (phenologyProgress) => {
  845. if (!solarTerms.value || solarTerms.value.length === 0) return -1;
  846. const progress = Number(phenologyProgress) || 0;
  847. // 找到物候期所属的节气(progress 最接近且小于等于的节气)
  848. let matchedTermProgress = -1;
  849. solarTerms.value.forEach((term) => {
  850. const termProgress = Number(term.progress) || 0;
  851. if (progress >= termProgress && termProgress > matchedTermProgress) {
  852. matchedTermProgress = termProgress;
  853. }
  854. });
  855. // 如果物候期的 progress 小于所有节气,返回第一个节气的 progress
  856. if (matchedTermProgress === -1 && solarTerms.value.length > 0) {
  857. const firstTermProgress = Number(solarTerms.value[0].progress) || 0;
  858. return firstTermProgress;
  859. }
  860. return matchedTermProgress;
  861. };
  862. const flowStatusStr = {
  863. '3': '待认证',
  864. '-1': '已过期',
  865. '2': '已认证',
  866. }
  867. // 判断物候期是否应该显示蓝色(已过或当前节气的物候期)
  868. const shouldShowBlue = (phenology) => {
  869. // 农事记录页兼容:只要该物候期下存在待认证农事,左侧生育期/物候期均高亮为蓝色
  870. if (props.pageType === "agri_record") {
  871. const hasPendingAuth = (Array.isArray(phenology?.reproductiveList) ? phenology.reproductiveList : []).some((reproductive) =>
  872. (Array.isArray(reproductive?.farmWorkArrangeList) ? reproductive.farmWorkArrangeList : []).some((fw) => Number(fw?.flowStatus) === 3)
  873. );
  874. if (hasPendingAuth) {
  875. return true;
  876. }
  877. }
  878. // 优先使用物候期真实日期判断:未来日期不应显示蓝色
  879. const phenologyTimeMs =
  880. Number(phenology?.startTimeMs) ||
  881. safeParseDate(phenology?.startDate || phenology?.beginDate || phenology?.startTime || phenology?.start || phenology?.start_at);
  882. if (!Number.isNaN(phenologyTimeMs) && phenologyTimeMs > 0) {
  883. const today = new Date();
  884. today.setHours(0, 0, 0, 0);
  885. return phenologyTimeMs <= today.getTime();
  886. }
  887. // 日期缺失时,回退到 progress 规则(兼容老数据)
  888. // 获取下一个即将到来的节气(当前节气)的 progress
  889. const nextTermProgress = getNextTermProgress();
  890. // 如果所有节气都已过(nextTermProgress === Infinity),所有物候期都显示蓝色
  891. if (nextTermProgress === Infinity) {
  892. return true;
  893. }
  894. // 根据物候期的 progress 判断它属于哪个节气
  895. const phenologyProgress = Math.min(Number(phenology?.progress) || 0, Number(phenology?.progress2) || 0);
  896. const phenologyTermProgress = getPhenologyTermProgress(phenologyProgress);
  897. // 找到下一个节气的完整信息,用于判断物候期是否属于当前节气
  898. let nextTerm = null;
  899. solarTerms.value.forEach((term) => {
  900. const termProgress = Number(term.progress) || 0;
  901. if (termProgress === nextTermProgress) {
  902. nextTerm = term;
  903. }
  904. });
  905. // 如果物候期所属的节气的 progress < 下一个节气的 progress,显示蓝色
  906. // 如果物候期所属的节气的 progress === 下一个节气的 progress,也显示蓝色(当前节气)
  907. // 也就是说,只有属于当前节气或之前节气的物候期才显示蓝色
  908. if (phenologyTermProgress === -1) {
  909. return false;
  910. }
  911. // 如果物候期正好属于下一个节气,需要判断它的 progress 是否在下一个节气的范围内
  912. if (phenologyTermProgress === nextTermProgress && nextTerm) {
  913. // 如果物候期的 progress 小于等于下一个节气的 progress,说明它属于当前节气,显示蓝色
  914. return phenologyProgress <= nextTermProgress;
  915. }
  916. // 如果物候期所属的节气的 progress < 下一个节气的 progress,显示蓝色
  917. return phenologyTermProgress < nextTermProgress;
  918. };
  919. defineExpose({
  920. updateFarmWorkPlan,
  921. });
  922. // 使用 ResizeObserver 监听高度变化,确保在DOM完全渲染后获取准确高度
  923. const setupResizeObserver = () => {
  924. if (!timelineListRef.value || typeof ResizeObserver === "undefined") {
  925. return;
  926. }
  927. // 如果已经存在观察者,先断开
  928. if (resizeObserver) {
  929. resizeObserver.disconnect();
  930. }
  931. // 创建新的观察者
  932. resizeObserver = new ResizeObserver((entries) => {
  933. for (const entry of entries) {
  934. const height = entry.contentRect.height;
  935. if (height > 0 && height !== timelineListHeight.value) {
  936. timelineListHeight.value = height;
  937. }
  938. }
  939. });
  940. // 开始观察
  941. resizeObserver.observe(timelineListRef.value);
  942. };
  943. // 组件挂载后设置 ResizeObserver
  944. onMounted(() => {
  945. nextTick(() => {
  946. requestAnimationFrame(() => {
  947. setupResizeObserver();
  948. restoreTimelineScrollTopWithRetry();
  949. });
  950. });
  951. });
  952. // 组件卸载前清理 ResizeObserver
  953. onUnmounted(() => {
  954. saveTimelineScrollTop();
  955. if (resizeObserver) {
  956. resizeObserver.disconnect();
  957. resizeObserver = null;
  958. }
  959. });
  960. onActivated(() => {
  961. nextTick(() => {
  962. requestAnimationFrame(() => {
  963. restoreTimelineScrollTopWithRetry();
  964. });
  965. });
  966. });
  967. onDeactivated(() => {
  968. saveTimelineScrollTop();
  969. });
  970. onBeforeRouteLeave(() => {
  971. saveTimelineScrollTop();
  972. });
  973. // 在数据更新后重新设置 ResizeObserver
  974. watch(
  975. () => phenologyList.value.length,
  976. () => {
  977. nextTick(() => {
  978. requestAnimationFrame(() => {
  979. setupResizeObserver();
  980. });
  981. });
  982. }
  983. );
  984. </script>
  985. <style scoped lang="scss">
  986. .timeline-container {
  987. height: 100%;
  988. overflow: auto;
  989. position: relative;
  990. box-sizing: border-box;
  991. .timeline-list {
  992. position: relative;
  993. }
  994. .timeline-middle-line {
  995. position: absolute;
  996. left: 13px;
  997. /* 位于节气文字列中间(列宽约30px) */
  998. top: 0;
  999. bottom: 0;
  1000. width: 2px;
  1001. background: #e8e8e8;
  1002. z-index: 1;
  1003. }
  1004. .phenology-bar {
  1005. align-items: stretch;
  1006. justify-content: center;
  1007. box-sizing: border-box;
  1008. position: relative;
  1009. .phenology-title {
  1010. width: 18px;
  1011. height: 99.5%;
  1012. color: #fff;
  1013. font-size: 12px;
  1014. position: absolute;
  1015. // left: 39px;
  1016. left: -1px;
  1017. z-index: 10;
  1018. text-align: center;
  1019. display: flex;
  1020. align-items: center;
  1021. &.phenology-blue {
  1022. background: #2199f8;
  1023. }
  1024. &.phenology-red {
  1025. background: #f1f1f1;
  1026. color: #808080;
  1027. }
  1028. }
  1029. .reproductive-item {
  1030. font-size: 12px;
  1031. text-align: center;
  1032. word-break: break-all;
  1033. writing-mode: vertical-rl;
  1034. text-orientation: upright;
  1035. letter-spacing: 3px;
  1036. width: 100%;
  1037. line-height: 23px;
  1038. color: inherit;
  1039. position: relative;
  1040. .phenology-name {
  1041. width: 18px;
  1042. line-height: 16px;
  1043. height: 100%;
  1044. color: #fff;
  1045. padding: 4px 0;
  1046. font-size: 12px;
  1047. box-sizing: border-box;
  1048. &.mr {
  1049. margin-right: 3px;
  1050. }
  1051. &.single {
  1052. width: 39px;
  1053. line-height: 39px;
  1054. // z-index: 10;
  1055. // position: relative;
  1056. }
  1057. &.phenology-blue {
  1058. background: #2199f8;
  1059. }
  1060. &.phenology-red {
  1061. background: #f1f1f1;
  1062. color: #808080;
  1063. }
  1064. &.text-blue {
  1065. background: rgba(33, 153, 248, 0.15);
  1066. color: #2199f8;
  1067. border: 1px solid #2199f8;
  1068. line-height: 16px;
  1069. box-sizing: border-box;
  1070. }
  1071. &.text-red {
  1072. background: rgba(128, 128, 128, 0.15);
  1073. color: #808080;
  1074. border: 1px solid rgba(128, 128, 128, 0.35);
  1075. line-height: 16px;
  1076. box-sizing: border-box;
  1077. }
  1078. }
  1079. .arranges {
  1080. display: flex;
  1081. max-width: calc(100vw - 88px);
  1082. min-width: calc(100vw - 78px);
  1083. gap: 5px;
  1084. letter-spacing: 0px;
  1085. // min-height: 90px;
  1086. .arrange-card {
  1087. width: 95%;
  1088. border: 0.5px solid #2199f8;
  1089. border-radius: 8px;
  1090. background: #fff;
  1091. box-sizing: border-box;
  1092. position: relative;
  1093. padding: 8px 15px 8px 10px;
  1094. writing-mode: horizontal-tb;
  1095. margin-bottom: 10px;
  1096. // &.last-card {
  1097. // margin-bottom: 0;
  1098. // }
  1099. .card-content {
  1100. color: #242424;
  1101. display: flex;
  1102. justify-content: space-between;
  1103. align-items: center;
  1104. font-size: 14px;
  1105. .card-left {
  1106. width: calc(100% - 45px);
  1107. .left-info {
  1108. display: flex;
  1109. align-items: center;
  1110. gap: 6px;
  1111. .left-date {
  1112. color: #2199f8;
  1113. border: 1px solid #2199f8;
  1114. padding: 1px 0;
  1115. border-radius: 2px;
  1116. font-size: 12px;
  1117. width: 45px;
  1118. box-sizing: border-box;
  1119. }
  1120. .text {
  1121. display: flex;
  1122. align-items: center;
  1123. gap: 2px;
  1124. width: calc(100% - 50px);
  1125. }
  1126. }
  1127. .title-text {
  1128. margin-top: 5px;
  1129. width: fit-content;
  1130. max-width: 100%;
  1131. text-align: left;
  1132. color: #2199F8;
  1133. padding: 0 6px;
  1134. border-radius: 2px;
  1135. font-size: 12px;
  1136. box-sizing: border-box;
  1137. background: rgba(33, 153, 248, 0.1);
  1138. }
  1139. &.agri-record-card {
  1140. .title-wrap {
  1141. display: flex;
  1142. align-items: flex-end;
  1143. gap: 6px;
  1144. .expert-info {
  1145. display: flex;
  1146. align-items: center;
  1147. gap: 2px;
  1148. font-size: 12px;
  1149. color: #B7B7B7;
  1150. }
  1151. .blue-tag{
  1152. color: #2199F8;
  1153. background: rgba(33, 153, 248, 0.1);
  1154. }
  1155. }
  1156. }
  1157. }
  1158. .card-right {
  1159. display: flex;
  1160. align-items: center;
  1161. position: relative;
  1162. img {
  1163. width: 45px;
  1164. height: 45px;
  1165. border-radius: 4px;
  1166. object-fit: cover;
  1167. }
  1168. .num {
  1169. position: absolute;
  1170. width: 18px;
  1171. height: 18px;
  1172. box-sizing: border-box;
  1173. top: -4px;
  1174. right: -6px;
  1175. background: #BFBFBF;
  1176. color: #fff;
  1177. font-size: 12px;
  1178. border-radius: 50%;
  1179. display: flex;
  1180. align-items: center;
  1181. justify-content: center;
  1182. }
  1183. }
  1184. }
  1185. &::before {
  1186. content: "";
  1187. position: absolute;
  1188. left: -5px;
  1189. top: 50%;
  1190. transform: translateY(-50%);
  1191. width: 0;
  1192. height: 0;
  1193. border-top: 5px solid transparent;
  1194. border-bottom: 5px solid transparent;
  1195. border-right: 5px solid #2199f8;
  1196. }
  1197. }
  1198. .arrange-card.normal-style {
  1199. opacity: 0.3;
  1200. }
  1201. .arrange-card.status-normal {
  1202. border-color: #2199f8;
  1203. &::before {
  1204. border-right-color: #2199f8;
  1205. }
  1206. }
  1207. .arrange-card.status-warning {
  1208. border-color: #FF4E4E;
  1209. .card-left {
  1210. .left-info {
  1211. .left-date {
  1212. color: #FF4E4E;
  1213. border-color: #FF4E4E;
  1214. }
  1215. }
  1216. .title-text {
  1217. color: #FF4E4E;
  1218. background: rgba(255, 78, 78, 0.1);
  1219. }
  1220. }
  1221. &::before {
  1222. border-right-color: #FF4E4E;
  1223. }
  1224. }
  1225. .arrange-card.status-complete {
  1226. border-color: #FF943D;
  1227. .card-left {
  1228. .left-info {
  1229. .left-date {
  1230. color: #FF943D;
  1231. border-color: #FF943D;
  1232. }
  1233. }
  1234. .title-text {
  1235. color: #FF943D;
  1236. background: rgba(255, 149, 61, 0.1);
  1237. }
  1238. }
  1239. &::before {
  1240. border-right-color: #FF943D;
  1241. }
  1242. }
  1243. .arrange-card.status-warning-bg {
  1244. border-color: #FF943D;
  1245. .card-left {
  1246. .left-info {
  1247. .left-date {
  1248. color: #FF943D;
  1249. border-color: #FF943D;
  1250. }
  1251. }
  1252. .title-text {
  1253. color: #fff;
  1254. background: #FF943D;;
  1255. }
  1256. }
  1257. &::before {
  1258. border-right-color: #FF943D;
  1259. }
  1260. }
  1261. .arrange-card.status-act {
  1262. border-color: #FF953D;
  1263. .card-left {
  1264. .left-info {
  1265. .left-date {
  1266. color: #FF953D;
  1267. border-color: #FF953D;
  1268. }
  1269. }
  1270. .title-text {
  1271. color: #fff;
  1272. background: #FF953D;
  1273. }
  1274. }
  1275. &::before {
  1276. border-right-color: #FF953D;
  1277. }
  1278. }
  1279. .arrange-card.status-default {
  1280. border-color: #BBBBBB;
  1281. .card-left {
  1282. .left-info {
  1283. .left-date {
  1284. color: #BBBBBB;
  1285. border-color: #BBBBBB;
  1286. }
  1287. .text-name,
  1288. .text-icon {
  1289. color: #BBBBBB;
  1290. }
  1291. }
  1292. .title-text {
  1293. color: #fff;
  1294. background: #BBBBBB;
  1295. }
  1296. }
  1297. &::before {
  1298. border-right-color: #BBBBBB;
  1299. }
  1300. }
  1301. // 未来节气对应的农事卡片:跟随左侧物候期的“未开始”灰色样式
  1302. .arrange-card.future-card {
  1303. border-color: #e4e4e4;
  1304. .card-content {
  1305. color: rgba(36, 36, 36, 0.5);
  1306. }
  1307. .card-left {
  1308. .left-info {
  1309. .left-date {
  1310. color: #CACACA;
  1311. border-color: #e4e4e4;
  1312. }
  1313. }
  1314. }
  1315. &::before {
  1316. border-right-color: #e4e4e4;
  1317. }
  1318. }
  1319. }
  1320. }
  1321. }
  1322. .reproductive-item+.reproductive-item {
  1323. padding-top: 3px;
  1324. }
  1325. .phenology-bar+.phenology-bar {
  1326. padding-top: 3px;
  1327. }
  1328. .timeline-term {
  1329. position: absolute;
  1330. width: 34px;
  1331. display: flex;
  1332. align-items: flex-start;
  1333. flex-direction: column;
  1334. z-index: 2;
  1335. /* 置于中线之上 */
  1336. color: rgba(174, 174, 174, 0.6);
  1337. .term-name {
  1338. display: inline-block;
  1339. width: 100%;
  1340. min-height: 20px;
  1341. line-height: 26px;
  1342. background: #fff;
  1343. font-size: 12px;
  1344. }
  1345. }
  1346. .empty-state {
  1347. display: flex;
  1348. justify-content: center;
  1349. align-items: center;
  1350. min-height: 200px;
  1351. width: 100%;
  1352. }
  1353. }
  1354. </style>