AgriculturalDynamics.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <div class="agricultural-dynamics">
  3. <!-- 任务列表 -->
  4. <div class="task-list">
  5. <div v-for="(task, index) in taskList" :key="index" class="task-item">
  6. <div class="task-content">
  7. <div class="task-header">
  8. <div class="task-status-tag">待完成</div>
  9. <div class="task-title">{{ task.title }}</div>
  10. </div>
  11. <div class="task-time">执行时间 {{ task.executionTime }}</div>
  12. </div>
  13. <div class="task-action" @click="handleTaskAction(task)" :class="{ orange: index === 1 }">
  14. {{ index === 0 ? "上传照片" : "确认执行时间" }}
  15. </div>
  16. </div>
  17. </div>
  18. <div class="title">农情互动</div>
  19. <!-- 内容区域 -->
  20. <div class="agricultural-list">
  21. <div v-if="!unansweredList.length" class="empty-block">暂无数据</div>
  22. <template v-else>
  23. <div class="agricultural-item" v-for="(item, index) in unansweredList" :key="index">
  24. <!-- 头部区域 -->
  25. <div class="header-section">
  26. <div class="header-left">
  27. <div class="farm-name">{{ item.farmName }}</div>
  28. <div class="tag-group">
  29. <div class="tag tag-blue">{{ item.typeName }}</div>
  30. <div class="tag tag-orange">托管客户</div>
  31. </div>
  32. </div>
  33. <div class="remind-btn" @click="handleRemind(item)">提醒客户</div>
  34. </div>
  35. <!-- 警告通知块 -->
  36. <div class="warning-block" v-if="item.latestPhenologyProgressBroadcast" v-html="item.latestPhenologyProgressBroadcast?.content"></div>
  37. <div class="timeline">
  38. <div class="timeline-item" v-for="timelineItem in item.timelineList" :key="timelineItem.id">
  39. <div class="timeline-left">
  40. <div class="dot"></div>
  41. <div class="line"></div>
  42. </div>
  43. <div class="timeline-right">
  44. <div class="date">
  45. 预计{{ timelineItem.daysUntilTrigger }}天后触发<span class="work-name">{{ timelineItem.farmWorkName }}</span>
  46. </div>
  47. <div class="text">
  48. 预计报价<span class="price">{{ timelineItem.estimatedCost }}元</span>
  49. <span class="action-detail" @click="showPriceSheetPopup(timelineItem)">查看报价单</span>
  50. </div>
  51. </div>
  52. <div class="timeline-action" @click="handleTimelineAction(timelineItem, item.farmId)">转入农事任务</div>
  53. </div>
  54. </div>
  55. </div>
  56. </template>
  57. </div>
  58. </div>
  59. <offer-popup ref="offerPopupRef"></offer-popup>
  60. <!-- 新增:激活上传弹窗 -->
  61. <active-upload-popup ref="activeUploadPopupRef" @handleUploadSuccess="handleUploadSuccess"></active-upload-popup>
  62. <!-- 服务报价单 -->
  63. <price-sheet-popup ref="priceSheetPopupRef"></price-sheet-popup>
  64. </template>
  65. <script setup>
  66. import router from "@/router";
  67. import { ref, onMounted } from "vue";
  68. import offerPopup from "@/components/popup/offerPopup.vue";
  69. import eventBus from "@/api/eventBus";
  70. import activeUploadPopup from "@/components/popup/activeUploadPopup.vue";
  71. import priceSheetPopup from "@/components/popup/priceSheetPopup.vue";
  72. // 任务列表数据
  73. const taskList = ref([
  74. { id: 1, title: "梢期杀虫", executionTime: "2025.05.06", status: "pending" },
  75. { id: 2, title: "梢期杀虫", executionTime: "2025.05.06", status: "pending" },
  76. ]);
  77. const offerPopupRef = ref(null);
  78. const handleTaskAction = (item) => {
  79. const data = {
  80. address: "岭南印象园东南",
  81. executeDate: "2025-11-19",
  82. executeEvidence: '["birdseye-look-mini/91754/1763544788985.jpg"]',
  83. farmArea: "50.089606952166854",
  84. farmId: 93684,
  85. farmMiniUserId: 91429,
  86. farmMiniUserName: "丝丝1",
  87. farmName: "17ss籼稻农场",
  88. farmWorkArrangeId: "124",
  89. farmWorkLibId: "2220005",
  90. farmWorkName: "蘖末防治",
  91. id: "276567",
  92. isFollow: null,
  93. isIgnored: 0,
  94. isPublic: 0,
  95. mapInfo: "11.19 蘖末防治",
  96. orderId: "778948195706212352",
  97. point: "POINT(113.407189 23.032344)",
  98. quoteCount: "1",
  99. solarTerm: null,
  100. typeId: "223",
  101. typeName: "丝苗米",
  102. };
  103. offerPopupRef.value.openPopup(data);
  104. };
  105. // 查询当前农资店的成员列表(只保留有“任务接单”权限的成员)
  106. const getManagerList = async () => {
  107. const { data } = await VE_API.mine.listManagerList({onlyExecutor: true});
  108. if (data && data.length > 0) {
  109. // 过滤 permissionList 中包含“任务接单”的成员
  110. executorList.value = data;
  111. }
  112. };
  113. const executorList = ref([])
  114. const handleTimelineAction = (item, farmId) => {
  115. // 处理转入农事任务逻辑
  116. eventBus.emit("activeUpload:show", {
  117. gardenIdVal: farmId,
  118. needExecutorVal: true,
  119. problemTitleVal: '请选择 ' + item.farmWorkName + ' 执行截止时间',
  120. imgDescVal: '请上传凭证(转入农事任务凭证)',
  121. arrangeIdVal: item.arrangeId,
  122. executorListVal: executorList.value,
  123. });
  124. };
  125. const priceSheetPopupRef = ref(null);
  126. const showPriceSheetPopup = (item) => {
  127. console.log('item', item)
  128. VE_API.z_farm_work_record.getDetail({ id: item.farmWorkId }).then(({ data }) => {
  129. const res = data[0];
  130. priceSheetPopupRef.value.handleShowPopup(res);
  131. });
  132. };
  133. const handleUploadSuccess = async () => {
  134. await getUnansweredFarms();
  135. };
  136. const handleRemind = (item) => {
  137. router.push(`/remind_customer?farmId=${item.farmId}`);
  138. };
  139. onMounted(() => {
  140. getUnansweredFarms();
  141. getManagerList()
  142. });
  143. //农情互动的农场列表接口(分页)
  144. const unansweredList = ref([]);
  145. const getUnansweredFarms = async () => {
  146. const params = {
  147. page: 0,
  148. limit: 3,
  149. };
  150. const res = await VE_API.home.listUnansweredFarms(params);
  151. unansweredList.value = (res.data || []).map(item => ({
  152. ...item,
  153. timelineList: []
  154. }));
  155. // 串行请求,一个完成后再请求下一个
  156. if(unansweredList.value.length){
  157. for(let i = 0; i < unansweredList.value.length; i++){
  158. await getFutureFarmWorkWarning(unansweredList.value[i]);
  159. }
  160. }
  161. };
  162. //查询未来农事预警
  163. const getFutureFarmWorkWarning = async (item) => {
  164. const res = await VE_API.home.listFutureFarmWorkWarning({farmId: item.farmId});
  165. item.timelineList = res.data || [];
  166. };
  167. </script>
  168. <style scoped lang="scss">
  169. .agricultural-dynamics {
  170. padding: 0 10px;
  171. // 任务列表样式
  172. .task-list {
  173. .task-item {
  174. display: flex;
  175. align-items: center;
  176. justify-content: space-between;
  177. background-color: #ffffff;
  178. border-radius: 8px;
  179. padding: 12px;
  180. margin-top: 10px;
  181. position: relative;
  182. overflow: hidden;
  183. &::after {
  184. content: "";
  185. position: absolute;
  186. top: -10px;
  187. right: 0;
  188. width: 72px;
  189. height: 72px;
  190. pointer-events: none;
  191. background: url("@/assets/img/home/task-icon.png") no-repeat center center / 100% 100%;
  192. }
  193. .task-content {
  194. .task-header {
  195. display: flex;
  196. align-items: center;
  197. margin-bottom: 4px;
  198. gap: 8px;
  199. }
  200. .task-status-tag {
  201. background-color: rgba(33, 153, 248, 0.1);
  202. color: #2199f8;
  203. font-size: 12px;
  204. padding: 1px 6px;
  205. border-radius: 2px;
  206. }
  207. .task-title {
  208. font-size: 16px;
  209. font-weight: 500;
  210. color: #1d2129;
  211. }
  212. .task-time {
  213. font-size: 12px;
  214. color: rgba(78, 89, 105, 0.5);
  215. }
  216. }
  217. .task-action {
  218. background-color: rgba(33, 153, 248, 0.1);
  219. color: #2199f8;
  220. border-radius: 25px;
  221. padding: 7px 14px;
  222. font-size: 12px;
  223. &.orange {
  224. color: #ff953d;
  225. background: rgba(255, 149, 61, 0.1);
  226. }
  227. }
  228. }
  229. }
  230. .title {
  231. font-size: 16px;
  232. font-weight: 500;
  233. color: #1d2129;
  234. margin-top: 10px;
  235. }
  236. .agricultural-list {
  237. .empty-block {
  238. display: flex;
  239. align-items: center;
  240. justify-content: center;
  241. height: 120px;
  242. color: #a0a0a0;
  243. font-size: 14px;
  244. background-color: #ffffff;
  245. border-radius: 8px;
  246. margin-top: 8px;
  247. }
  248. .agricultural-item {
  249. background-color: #ffffff;
  250. border-radius: 8px;
  251. padding: 8px 12px;
  252. margin-top: 8px;
  253. // 头部区域样式
  254. .header-section {
  255. display: flex;
  256. align-items: center;
  257. justify-content: space-between;
  258. padding-bottom: 5px;
  259. border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
  260. .header-left {
  261. display: flex;
  262. align-items: center;
  263. gap: 8px;
  264. .farm-name {
  265. font-size: 16px;
  266. font-weight: 500;
  267. color: #1d2129;
  268. }
  269. .tag-group {
  270. display: flex;
  271. gap: 4px;
  272. .tag {
  273. padding: 2px 8px;
  274. border-radius: 2px;
  275. font-size: 12px;
  276. &.tag-blue {
  277. background-color: #e8f3ff;
  278. color: #2199f8;
  279. }
  280. &.tag-orange {
  281. background-color: rgba(255, 149, 61, 0.1);
  282. color: #ff953d;
  283. }
  284. }
  285. }
  286. }
  287. .remind-btn {
  288. background-color: #2199f8;
  289. color: #ffffff;
  290. border-radius: 25px;
  291. padding: 7px 12px;
  292. font-size: 12px;
  293. }
  294. }
  295. // 警告通知块样式
  296. .warning-block {
  297. background-color: rgba(33, 153, 248, 0.1);
  298. border-radius: 5px;
  299. padding: 5px;
  300. margin-top: 8px;
  301. font-size: 12px;
  302. color: #252525;
  303. ::v-deep{
  304. p{
  305. padding: 0;
  306. margin: 0;
  307. }
  308. }
  309. }
  310. .timeline {
  311. margin-left: -5px;
  312. margin-top: 8px;
  313. .timeline-item {
  314. display: flex;
  315. align-items: flex-start;
  316. font-size: 14px;
  317. color: #ffffff;
  318. line-height: 22px;
  319. & + .timeline-item {
  320. margin-top: 10px;
  321. }
  322. .timeline-left {
  323. width: 22px;
  324. display: flex;
  325. flex-direction: column;
  326. align-items: center;
  327. .dot {
  328. width: 6px;
  329. height: 6px;
  330. border-radius: 50%;
  331. background: #a2d5fd;
  332. margin-top: 6px;
  333. }
  334. .line {
  335. border-left: 1px dashed #a2d5fd;
  336. margin-top: 4px;
  337. height: 28px;
  338. }
  339. }
  340. .timeline-right {
  341. padding-left: 5px;
  342. flex: 1;
  343. .date {
  344. color: #1d2129;
  345. font-weight: 500;
  346. font-size: 14px;
  347. line-height: 22px;
  348. }
  349. .text {
  350. font-size: 12px;
  351. color: #d7d7d7;
  352. .price {
  353. padding-left: 4px;
  354. }
  355. .action-detail {
  356. margin-left: 6px;
  357. color: #2199f8;
  358. border-bottom: 1px solid;
  359. }
  360. }
  361. .work-name {
  362. padding-left: 4px;
  363. }
  364. }
  365. .timeline-action {
  366. align-self: center;
  367. height: 28px;
  368. line-height: 28px;
  369. flex: none;
  370. background: rgba(33, 153, 248, 0.1);
  371. color: #2199f8;
  372. font-size: 12px;
  373. padding: 0px 11px;
  374. border-radius: 20px;
  375. }
  376. }
  377. }
  378. }
  379. }
  380. }
  381. </style>