index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <div class="home-index">
  3. <div class="top-row">
  4. <el-input class="search-bar" placeholder="搜索农场">
  5. <template #prefix>
  6. <el-icon>
  7. <Search />
  8. </el-icon>
  9. </template>
  10. </el-input>
  11. <div class="filter-row">
  12. <el-select class="filter-item" v-model="value" placeholder="选择地区">
  13. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
  14. </el-select>
  15. <el-select class="filter-item" v-model="value" placeholder="选择品类">
  16. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
  17. </el-select>
  18. </div>
  19. </div>
  20. <!-- 农场信息卡片 -->
  21. <div class="farm-card">
  22. <div class="farm-header">
  23. <div class="farm-header-left">
  24. <div class="farm-title">
  25. <span>{{ farmInfo.name }}</span>
  26. <div class="title-tags">
  27. <div class="title-tag tag-danger">
  28. <span>干旱预警</span>
  29. <el-icon>
  30. <ArrowRight />
  31. </el-icon>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="farm-subtitle">{{ farmInfo.address }}</div>
  36. </div>
  37. <div class="farm-more" @click="handleMoreClick">详情</div>
  38. </div>
  39. <div class="farm-content" v-if="isShowPl">
  40. <div class="farm-pl">
  41. <span class="pl-label">品类:</span>
  42. <div class="title-tags">
  43. <div class="title-tag">荔枝</div>
  44. <div class="title-tag">水稻</div>
  45. </div>
  46. </div>
  47. <div class="farm-invite">邀请互动</div>
  48. </div>
  49. <div v-else class="farm-content-grid">
  50. <div class="title-tags">
  51. <div class="title-tag">荔枝-桂味 糯米糍</div>
  52. </div>
  53. <div class="content-grid">
  54. <div class="label-column">
  55. <div class="label-cell" v-for="row in rows" :key="row.label">
  56. {{ row.label }}
  57. </div>
  58. </div>
  59. <div class="main-grid">
  60. <div class="row" v-for="row in rows" :key="row.label">
  61. <div v-for="card in row.cards" :key="card.id" class="status-card" :class="card.type"
  62. @click="handleBlockClick(card)">
  63. <badge class="status-badge" dot v-if="card.title === '冲楸异常'" :offset="[80, -10]"></badge>
  64. <div class="status-title">
  65. {{ card.title }}
  66. </div>
  67. <div class="status-sub" v-if="card.sub">
  68. {{ card.sub }}
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="custom-bottom-fixed-btns center-btn">
  77. <div class="bottom-btn primary-btn" @click="handleAddClient">新增客户</div>
  78. </div>
  79. </div>
  80. <!-- 新增客户弹窗 -->
  81. <action-sheet v-model:show="showAddClient">
  82. <div class="add-client-actions">
  83. <div class="add-client-btn add-client-btn--self" @click="handleAddClientSelf">
  84. 自行创建
  85. </div>
  86. <div class="add-client-btn add-client-btn--invite" @click="handleAddClientInvite">
  87. 邀请用户创建
  88. </div>
  89. </div>
  90. </action-sheet>
  91. </template>
  92. <script setup>
  93. import { ref } from "vue";
  94. import { Badge,ActionSheet } from 'vant';
  95. import { useRouter } from "vue-router";
  96. const router = useRouter();
  97. const showAddClient = ref(false);
  98. const handleAddClientSelf = () => {
  99. showAddClient.value = false;
  100. router.push("/create_farm?type=add");
  101. };
  102. const handleAddClientInvite = () => {
  103. showAddClient.value = false;
  104. router.push("/create_farm?type=add");
  105. };
  106. const handleAddClient = () => {
  107. showAddClient.value = true;
  108. };
  109. const isShowPl = ref(false);
  110. const value = ref('')
  111. const options = [
  112. {
  113. value: 'Option1',
  114. label: 'Option1',
  115. },
  116. {
  117. value: 'Option2',
  118. label: 'Option2',
  119. },
  120. {
  121. value: 'Option3',
  122. label: 'Option3',
  123. },
  124. {
  125. value: 'Option4',
  126. label: 'Option4',
  127. },
  128. {
  129. value: 'Option5',
  130. label: 'Option5',
  131. },
  132. ]
  133. const farmInfo = ref({
  134. name: "从化荔博园合作社",
  135. address: "广东省广州市从化区某某街道",
  136. });
  137. const rows = ref([
  138. {
  139. label: "农情",
  140. cards: [
  141. {
  142. id: 1,
  143. title: "新梢萌动",
  144. sub: "预计3天后进入",
  145. type: "risk-strong",
  146. },
  147. {
  148. id: 2,
  149. title: "冲楸异常",
  150. sub: "占比3%",
  151. type: "normal",
  152. badge: true,
  153. },
  154. {
  155. id: 3,
  156. title: "病虫风险",
  157. sub: "一级风险",
  158. type: "danger",
  159. },
  160. ],
  161. },
  162. {
  163. label: "农事",
  164. cards: [
  165. {
  166. id: 4,
  167. title: "第一段防治",
  168. sub: "待完成",
  169. type: "risk-strong",
  170. },
  171. {
  172. id: 5,
  173. title: "控梢",
  174. sub: "待触发",
  175. type: "normal",
  176. },
  177. {
  178. id: 6,
  179. title: "无",
  180. sub: "",
  181. type: "disabled",
  182. },
  183. ],
  184. },
  185. ]);
  186. const handleBlockClick = (block) => {
  187. // 预留点击跳转/弹窗逻辑
  188. console.log("点击卡片:", block);
  189. };
  190. const handleMoreClick = () => {
  191. router.push("/agricultural_details");
  192. };
  193. </script>
  194. <style scoped lang="scss">
  195. .home-index {
  196. width: 100%;
  197. min-height: 100vh;
  198. box-sizing: border-box;
  199. padding: 12px 12px 24px;
  200. background: #f5f7fa;
  201. .top-row {
  202. display: flex;
  203. align-items: center;
  204. justify-content: space-between;
  205. margin-bottom: 12px;
  206. .search-bar {
  207. width: 104px;
  208. ::v-deep {
  209. .el-input__wrapper {
  210. border-radius: 25px;
  211. border: 0.5px solid rgba(0, 0, 0, 0.2);
  212. box-shadow: none;
  213. }
  214. }
  215. }
  216. .filter-row {
  217. display: flex;
  218. gap: 8px;
  219. .filter-item {
  220. width: 100px;
  221. }
  222. }
  223. }
  224. .farm-card {
  225. background: #ffffff;
  226. border-radius: 8px;
  227. padding: 10px 12px;
  228. border: 0.5px solid rgba(0, 0, 0, 0.2);
  229. .title-tags {
  230. display: flex;
  231. align-items: center;
  232. gap: 4px;
  233. .title-tag {
  234. font-size: 13px;
  235. padding: 2px 8px;
  236. border-radius: 2px;
  237. background: #E8F3FF;
  238. color: #2199F8;
  239. display: flex;
  240. align-items: center;
  241. gap: 2px;
  242. &.tag-danger {
  243. background: rgba(255, 149, 61, 0.2);
  244. color: #FF953D;
  245. }
  246. }
  247. }
  248. .farm-header {
  249. display: flex;
  250. justify-content: space-between;
  251. align-items: center;
  252. padding-bottom: 10px;
  253. border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
  254. margin-bottom: 10px;
  255. .farm-header-left {
  256. .farm-title {
  257. display: flex;
  258. align-items: center;
  259. gap: 10px;
  260. font-size: 16px;
  261. color: #1D2129;
  262. margin-bottom: 4px;
  263. }
  264. .farm-subtitle {
  265. font-size: 12px;
  266. color: rgba(32, 32, 32, 0.4);
  267. }
  268. }
  269. .farm-more {
  270. font-size: 12px;
  271. color: rgba(37, 47, 56, 0.5);
  272. }
  273. }
  274. .farm-content {
  275. display: flex;
  276. align-items: center;
  277. justify-content: space-between;
  278. .farm-pl {
  279. display: flex;
  280. align-items: center;
  281. gap: 5px;
  282. .pl-label {
  283. color: rgba(32, 32, 32, 0.4);
  284. }
  285. }
  286. .farm-invite {
  287. font-size: 16px;
  288. color: #fff;
  289. padding: 5px 10px;
  290. background: #2199F8;
  291. border-radius: 2px;
  292. font-family: "PangMenZhengDao";
  293. }
  294. }
  295. .farm-content-grid {
  296. .content-grid {
  297. display: flex;
  298. gap: 8px;
  299. margin-top: 10px;
  300. .label-column {
  301. .label-cell {
  302. padding: 13px 3px;
  303. letter-spacing: 3px;
  304. border-radius: 2px;
  305. background: rgba(134, 134, 134, 0.05);
  306. color: #666666;
  307. font-size: 12px;
  308. display: flex;
  309. align-items: center;
  310. justify-content: center;
  311. writing-mode: vertical-rl;
  312. }
  313. .label-cell+.label-cell {
  314. margin-top: 10px;
  315. }
  316. }
  317. .main-grid {
  318. flex: 1;
  319. .row {
  320. display: grid;
  321. grid-template-columns: repeat(3, 1fr);
  322. gap: 6px;
  323. margin-bottom: 10px;
  324. .status-card {
  325. border-radius: 2px;
  326. padding: 10px 0;
  327. background: #ffffff;
  328. border: 0.5px solid #e5e6eb;
  329. display: flex;
  330. flex-direction: column;
  331. align-items: center;
  332. justify-content: center;
  333. .status-badge {
  334. // position: absolute;
  335. // top: 0;
  336. // right: 0;
  337. }
  338. .status-title {
  339. font-size: 16px;
  340. }
  341. .status-sub {
  342. font-size: 10px;
  343. color: rgba(32, 32, 32, 0.4);
  344. }
  345. &.risk-strong {
  346. background: #FF6A6A;
  347. border-color: #FF6A6A;
  348. .status-title,
  349. .status-sub {
  350. color: #ffffff;
  351. }
  352. }
  353. &.danger {
  354. background: #FFE9E9;
  355. border-color: #ff8e8e;
  356. .status-sub {
  357. color: #FF6A6A;
  358. }
  359. }
  360. }
  361. }
  362. }
  363. }
  364. }
  365. }
  366. .custom-bottom-fixed-btns {
  367. &.center-btn {
  368. justify-content: center;
  369. }
  370. }
  371. }
  372. .add-client-actions {
  373. padding: 16px 20px 24px;
  374. background: #ffffff;
  375. .add-client-btn {
  376. width: 100%;
  377. text-align: center;
  378. border-radius: 6px;
  379. font-size: 16px;
  380. color: #ffffff;
  381. padding: 10px 0;
  382. }
  383. .add-client-btn--self {
  384. background: #2199f8;
  385. margin-bottom: 12px;
  386. }
  387. .add-client-btn--invite {
  388. background: #ff953d;
  389. }
  390. }
  391. </style>