index.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const common_assets = require("../../common/assets.js");
  4. const _sfc_main = {
  5. data() {
  6. return {
  7. // 用户数据
  8. userData: {
  9. nickname: "张三",
  10. selectedPlot: "南地块"
  11. },
  12. // 农场数据
  13. farmData: {
  14. plotCount: 5,
  15. deviceCount: 12,
  16. deviceOnlineRate: 85,
  17. taskCompletionRate: 76,
  18. recentActivities: [
  19. { title: "稻田水稻施肥", date: "2023-05-15", status: "pending", id: 1, executor: "李四" },
  20. { title: "南地块除草", date: "2023-05-12", status: "completed", id: 2, executor: "王五" },
  21. { title: "西北区域杀虫", date: "2023-05-08", status: "completed", id: 3, executor: "张三" }
  22. ]
  23. },
  24. // 天气数据
  25. weatherData: {
  26. temperature: 28,
  27. description: "晴朗",
  28. humidity: 65,
  29. windLevel: 3,
  30. rainfall: 0,
  31. advice: "今日适宜进行春玉米防虫作业,注意水分管理。"
  32. },
  33. // 作物数据
  34. crops: [
  35. { name: "水稻", area: 48, progress: 75, icon: "🌾", bgColor: "#4CAF50" },
  36. { name: "小麦", area: 36, progress: 60, icon: "🌿", bgColor: "#66BB6A" },
  37. { name: "玉米", area: 32, progress: 85, icon: "🌽", bgColor: "#43A047" },
  38. { name: "大豆", area: 12, progress: 40, icon: "🫘", bgColor: "#388E3C" }
  39. ],
  40. // 监控设备指标
  41. deviceMetrics: [
  42. {
  43. name: "在线设备",
  44. value: "28",
  45. icon: "wifi",
  46. gradient: "linear-gradient(135deg, #26A69A, #00796B)",
  47. trend: {
  48. type: "up",
  49. value: "5.2%"
  50. }
  51. },
  52. {
  53. name: "告警设备",
  54. value: "3",
  55. icon: "error-circle",
  56. gradient: "linear-gradient(135deg, #FF7043, #E64A19)",
  57. trend: {
  58. type: "down",
  59. value: "2.1%"
  60. }
  61. },
  62. {
  63. name: "离线设备",
  64. value: "5",
  65. icon: "close-circle",
  66. gradient: "linear-gradient(135deg, #78909C, #455A64)",
  67. trend: {
  68. type: "down",
  69. value: "1.8%"
  70. }
  71. },
  72. {
  73. name: "数据稳定性",
  74. value: "96.3%",
  75. icon: "checkmark-circle",
  76. gradient: "linear-gradient(135deg, #66BB6A, #388E3C)",
  77. trend: {
  78. type: "up",
  79. value: "0.5%"
  80. }
  81. }
  82. ],
  83. // 农业机械指标
  84. machineryMetrics: [
  85. {
  86. name: "今日运行时长",
  87. value: "36.5",
  88. unit: "小时",
  89. icon: "clock",
  90. gradient: "linear-gradient(135deg, #42A5F5, #1976D2)"
  91. },
  92. {
  93. name: "今日作业地块",
  94. value: "8",
  95. unit: "块",
  96. icon: "map",
  97. gradient: "linear-gradient(135deg, #66BB6A, #388E3C)"
  98. },
  99. {
  100. name: "今日执行任务",
  101. value: "12",
  102. unit: "个",
  103. icon: "calendar",
  104. gradient: "linear-gradient(135deg, #FFA726, #F57C00)"
  105. },
  106. {
  107. name: "使用率",
  108. value: "78.2%",
  109. icon: "star",
  110. gradient: "linear-gradient(135deg, #5C6BC0, #3949AB)",
  111. trend: {
  112. type: "up",
  113. value: "3.7%"
  114. }
  115. }
  116. ],
  117. // 当前选择的周期
  118. currentPeriod: "month",
  119. // 警报摘要数据
  120. alertSummaries: [
  121. {
  122. title: "设备离线",
  123. value: "3 台",
  124. iconSrc: "/static/icons/offline.png",
  125. description: "最长离线时长:26 小时",
  126. type: "device-offline"
  127. },
  128. {
  129. title: "虫害预警",
  130. value: "稻飞虱|小地老虎",
  131. iconSrc: "/static/icons/Pest_Alert.png",
  132. description: "预警等级:中",
  133. type: "pest-warning"
  134. },
  135. {
  136. title: "气象预警",
  137. value: "强风(8级)",
  138. iconSrc: "/static/icons/weather_risk.png",
  139. description: "预计:未来 12 小时内",
  140. type: "weather-risk"
  141. },
  142. {
  143. title: "作业延迟",
  144. value: "5 项",
  145. iconSrc: "/static/icons/task_delay.png",
  146. description: "最长延迟:3 天",
  147. type: "task-delay"
  148. }
  149. ],
  150. // 农场绩效图表数据 - 月度数据
  151. monthlyData: {
  152. months: ["1月", "2月", "3月", "4月", "5月", "6月"],
  153. thisYearValues: [2.8, 3.4, 2.9, 3.6, 3.8, 3.2],
  154. lastYearValues: [2.5, 2.8, 2.4, 3, 3.2, 2.7]
  155. },
  156. // 季度数据
  157. quarterlyData: {
  158. months: ["Q1", "Q2", "Q3", "Q4"],
  159. thisYearValues: [3.2, 3.7, 4, 3.5],
  160. lastYearValues: [2.7, 3.3, 3.6, 3]
  161. },
  162. // 年度数据
  163. yearlyData: {
  164. months: ["2019", "2020", "2021", "2022", "2023"],
  165. thisYearValues: [2.2, 2.5, 3, 3.5, 3.8],
  166. lastYearValues: [2, 2.3, 2.7, 3.2, 3.4]
  167. }
  168. };
  169. },
  170. computed: {
  171. // 核心统计数据
  172. coreStats() {
  173. return [
  174. {
  175. label: "地块",
  176. value: this.farmData.plotCount,
  177. icon: "map"
  178. },
  179. {
  180. label: "设备",
  181. value: this.farmData.deviceCount,
  182. icon: "setting"
  183. },
  184. {
  185. label: "设备在线",
  186. value: this.farmData.deviceOnlineRate + "%",
  187. icon: "wifi"
  188. },
  189. {
  190. label: "任务完成",
  191. value: this.farmData.taskCompletionRate + "%",
  192. icon: "checkmark-circle"
  193. }
  194. ];
  195. },
  196. // 根据当前周期计算要显示的数据
  197. farmPerformanceData() {
  198. if (this.currentPeriod === "month") {
  199. return this.monthlyData;
  200. } else if (this.currentPeriod === "quarter") {
  201. return this.quarterlyData;
  202. } else {
  203. return this.yearlyData;
  204. }
  205. }
  206. },
  207. methods: {
  208. // 处理切换地块
  209. handleSwitchPlot() {
  210. common_vendor.index.showActionSheet({
  211. itemList: ["南地块", "西北区域", "稻田", "东区试验田"],
  212. success: (res) => {
  213. this.userData.selectedPlot = ["南地块", "西北区域", "稻田", "东区试验田"][res.tapIndex];
  214. }
  215. });
  216. },
  217. // 导航到个人资料
  218. navigateToProfile() {
  219. common_vendor.index.navigateTo({
  220. url: "/pages/profile/index"
  221. });
  222. },
  223. // 导航到活动详情
  224. navigateToActivity(activity) {
  225. common_vendor.index.navigateTo({
  226. url: `/pages/activity/detail?id=${activity.id}`
  227. });
  228. },
  229. // 导航到警报详情
  230. navigateToAlertDetail(type) {
  231. common_vendor.index.__f__("log", "at pages/dashboard/index.vue:482", `Navigating to alert detail for type: ${type}`);
  232. },
  233. // 切换周期
  234. changePeriod(period) {
  235. this.currentPeriod = period;
  236. }
  237. },
  238. mounted() {
  239. }
  240. };
  241. if (!Array) {
  242. const _component_u_icon = common_vendor.resolveComponent("u-icon");
  243. _component_u_icon();
  244. }
  245. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  246. return common_vendor.e({
  247. a: common_vendor.t($data.userData.nickname),
  248. b: common_vendor.t($data.userData.selectedPlot),
  249. c: common_vendor.o((...args) => $options.handleSwitchPlot && $options.handleSwitchPlot(...args)),
  250. d: common_assets._imports_0,
  251. e: common_vendor.o((...args) => $options.navigateToProfile && $options.navigateToProfile(...args)),
  252. f: common_vendor.f($data.alertSummaries, (alert, index, i0) => {
  253. return {
  254. a: alert.iconSrc,
  255. b: common_vendor.t(alert.title),
  256. c: common_vendor.t(alert.value),
  257. d: common_vendor.t(alert.description),
  258. e: index,
  259. f: common_vendor.o(($event) => $options.navigateToAlertDetail(alert.type), index)
  260. };
  261. }),
  262. g: $data.weatherData.description === "晴朗"
  263. }, $data.weatherData.description === "晴朗" ? {} : $data.weatherData.description.includes("雨") ? {} : $data.weatherData.description.includes("云") ? {} : {}, {
  264. h: $data.weatherData.description.includes("雨"),
  265. i: $data.weatherData.description.includes("云"),
  266. j: common_vendor.t($data.weatherData.temperature),
  267. k: common_vendor.t($data.weatherData.description),
  268. l: common_vendor.t($data.weatherData.humidity),
  269. m: common_vendor.t($data.weatherData.windLevel),
  270. n: common_vendor.t($data.weatherData.rainfall),
  271. o: common_vendor.p({
  272. name: "info",
  273. color: "#ffffff",
  274. size: "14"
  275. }),
  276. p: common_vendor.t($data.weatherData.advice),
  277. q: $data.currentPeriod === "month" ? 1 : "",
  278. r: common_vendor.o(($event) => $options.changePeriod("month")),
  279. s: $data.currentPeriod === "quarter" ? 1 : "",
  280. t: common_vendor.o(($event) => $options.changePeriod("quarter")),
  281. v: $data.currentPeriod === "year" ? 1 : "",
  282. w: common_vendor.o(($event) => $options.changePeriod("year")),
  283. x: common_vendor.p({
  284. name: "arrow-upward",
  285. color: "#3BB44A",
  286. size: "12"
  287. }),
  288. y: common_vendor.p({
  289. name: "arrow-upward",
  290. color: "#3BB44A",
  291. size: "12"
  292. }),
  293. z: common_vendor.f([4, 3, 2, 1, 0], (value, index, i0) => {
  294. return {
  295. a: common_vendor.t(value),
  296. b: index
  297. };
  298. }),
  299. A: common_vendor.f($options.farmPerformanceData.months, (month, index, i0) => {
  300. return {
  301. a: $options.farmPerformanceData.lastYearValues[index] / 4 * 100 + "%",
  302. b: $options.farmPerformanceData.thisYearValues[index] / 4 * 100 + "%",
  303. c: common_vendor.t(month),
  304. d: index
  305. };
  306. }),
  307. B: common_vendor.f($data.deviceMetrics, (metric, index, i0) => {
  308. return {
  309. a: "a869e244-3-" + i0,
  310. b: common_vendor.p({
  311. name: metric.icon,
  312. color: "#ffffff",
  313. size: "18"
  314. }),
  315. c: metric.gradient,
  316. d: common_vendor.t(metric.name),
  317. e: common_vendor.t(metric.value),
  318. f: "a869e244-4-" + i0,
  319. g: common_vendor.p({
  320. name: metric.trend.type === "up" ? "arrow-upward" : "arrow-downward",
  321. color: metric.trend.type === "up" ? "#3BB44A" : "#FF5252",
  322. size: "14"
  323. }),
  324. h: common_vendor.t(metric.trend.value),
  325. i: common_vendor.n(metric.trend.type),
  326. j: index
  327. };
  328. }),
  329. C: common_vendor.f($data.machineryMetrics, (metric, index, i0) => {
  330. return common_vendor.e({
  331. a: "a869e244-5-" + i0,
  332. b: common_vendor.p({
  333. name: metric.icon,
  334. color: "#ffffff",
  335. size: "18"
  336. }),
  337. c: metric.gradient,
  338. d: common_vendor.t(metric.name),
  339. e: common_vendor.t(metric.value),
  340. f: metric.trend
  341. }, metric.trend ? {
  342. g: "a869e244-6-" + i0,
  343. h: common_vendor.p({
  344. name: metric.trend.type === "up" ? "arrow-upward" : "arrow-downward",
  345. color: metric.trend.type === "up" ? "#3BB44A" : "#FF5252",
  346. size: "14"
  347. }),
  348. i: common_vendor.t(metric.trend.value),
  349. j: common_vendor.n(metric.trend.type)
  350. } : {
  351. k: common_vendor.t(metric.unit)
  352. }, {
  353. l: index
  354. });
  355. }),
  356. D: common_vendor.p({
  357. name: "arrow-right",
  358. color: "#ffffff",
  359. size: "14"
  360. }),
  361. E: common_vendor.f($data.farmData.recentActivities, (activity, index, i0) => {
  362. return {
  363. a: common_vendor.n(activity.status),
  364. b: common_vendor.t(activity.title),
  365. c: common_vendor.t(activity.date),
  366. d: common_vendor.t(activity.executor),
  367. e: "a869e244-8-" + i0,
  368. f: common_vendor.o(($event) => $options.navigateToActivity(activity), index),
  369. g: index
  370. };
  371. }),
  372. F: common_vendor.p({
  373. name: "arrow-right",
  374. color: "#3BB44A",
  375. size: "14"
  376. })
  377. });
  378. }
  379. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-a869e244"]]);
  380. wx.createPage(MiniProgramPage);
  381. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/dashboard/index.js.map