index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <template>
  2. <div class="base-container no-events">
  3. <div class="content">
  4. <!-- <navigation @handleTab="handleTab"></navigation> -->
  5. <div class="left yes-events">
  6. <component :is="components[currentComponent]" @backHome="backHome" />
  7. </div>
  8. <div class="right yes-events">
  9. <div class="list adopt-list-wrap">
  10. <chart-box name="果树管理" arrow="" color="yellow">
  11. <el-tabs v-model="activeName" class="demo-tabs">
  12. <el-tab-pane label="果树列表" name="果树列表">
  13. <adopt-list></adopt-list>
  14. </el-tab-pane>
  15. <el-tab-pane label="待分配" name="待分配">
  16. <client-list
  17. :checkDistributeShow="checkDistributeShow"
  18. :startReloadList="startReloadList"
  19. @update:checkDistributeShow="hanldeDistributeCheck"
  20. @update:checkData="handlCheckChange"
  21. ></client-list>
  22. </el-tab-pane>
  23. <el-tab-pane label="已分配" name="已分配">
  24. <apply-list
  25. :startReloadList="startReloadList"
  26. @update:userList="setReload"
  27. ></apply-list>
  28. </el-tab-pane>
  29. <!-- <el-tab-pane label="确认地址" name="确认地址">
  30. <address-list></address-list>
  31. </el-tab-pane> -->
  32. </el-tabs>
  33. </chart-box>
  34. </div>
  35. </div>
  36. <!-- 图例 -->
  37. <div v-if="legendArr && legendArr.length" class="map-bg map-legend yes-events">
  38. <div class="item" v-for="(legend, legendI) in legendArr" :key="legendI">
  39. <span class="legend-block" :style="{ background: legend.color }"></span>
  40. {{ legend.name }}
  41. </div>
  42. </div>
  43. <div v-else class="map-bg map-legend yes-events">
  44. <div class="item" v-show="!checkDistributeShow">
  45. <img src="@/assets/images/map/status/wry.png" alt="" />
  46. 未开放
  47. </div>
  48. <div class="item" v-show="!checkShow">
  49. <img src="@/assets/images/map/status/dry.png" alt="" />
  50. 待守护
  51. </div>
  52. <!-- <div class="item" v-show="!checkShow">
  53. <img src="@/assets/images/map/status/yry.png" alt="" />
  54. 已守护
  55. </div> -->
  56. <div class="item selected-item" v-show="checkShow || checkDistributeShow">
  57. <img src="@/assets/images/map/status/selected.png" alt="" />
  58. 已选择
  59. </div>
  60. </div>
  61. <div class="tips" v-show="checkShow">
  62. <div class="text">
  63. <span>提示:</span>请在底图上点选 <span>未开放的果树</span>,或按住 Ctrl 框选
  64. <span>开放守护的区域</span>
  65. </div>
  66. </div>
  67. <div class="tips" v-show="checkDistributeShow">
  68. <div class="text">
  69. <span>提示:</span>请在底图上点选 <span>待守护的果树</span>,或按住 Ctrl 框选
  70. <span>分配的区域</span>
  71. </div>
  72. </div>
  73. <div v-show="!checkShow && !checkDistributeShow" class="right-button yes-events" @click="hanldeCheck">
  74. 新增守护区域
  75. </div>
  76. <div v-show="checkShow" class="center-button">
  77. <div class="cancel yes-events" @click="handleCancel">取消</div>
  78. <div class="yes-events" @click="saveEdit">确认开放守护权限</div>
  79. </div>
  80. <div v-show="checkDistributeShow" class="center-button">
  81. <div class="cancel yes-events" @click="handleCancel">取消分配</div>
  82. <div class="yes-events" @click="saveDistributeEdit" :class="{'disabled': (!selectedTree.length || !selectedTels.length) || selectedTree.length < selectedTels.length}">
  83. 确认分配<span class="select-text">(已选{{selectedTree.length}}/<span class="select-total">{{ selectedTels.length }}</span>)</span>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <custom-map class="bottom-map" ref="mapRef" @update:selectedTree="handleSelectedTree"></custom-map>
  89. <!-- 图片弹窗 -->
  90. <PicturePreview :imageUrl="urls" :curIndex="urlsIndex"></PicturePreview>
  91. <PdfDialog title="果园报告"></PdfDialog>
  92. </template>
  93. <script setup>
  94. import { nextTick, onMounted, onUnmounted, ref } from "vue";
  95. import config from "@/api/config.js";
  96. import timeLine from "@/components/timeLine.vue";
  97. import PicturePreview from "@/components/PicturePreview.vue";
  98. import navigation from "@/components/navigation.vue";
  99. import chartBox from "@/components/chartBox.vue";
  100. import leftTabs from "./components/leftTabs/index.vue";
  101. import treeDetail from "./components/treeDetail.vue";
  102. import adoptList from "./components/adoptList.vue";
  103. import clientList from "./components/clientList.vue";
  104. import customMap from "./homeMap.vue";
  105. import applyList from "./components/applyList.vue";
  106. import addressList from "./components/addressList.vue";
  107. import { convertPointToArray } from "@/utils/index";
  108. import { useRoute } from "vue-router";
  109. import { useStore } from "vuex";
  110. import eventBus from "@/api/eventBus";
  111. import PdfDialog from "../../components/PdfDialog";
  112. import { ElMessage } from "element-plus";
  113. let store = useStore();
  114. const components = {
  115. leftTabs,
  116. treeDetail,
  117. };
  118. const route = useRoute();
  119. const mapRef = ref(null);
  120. const activeName = ref("果树列表");
  121. onMounted(() => {
  122. //区域切换监听事件
  123. eventBus.on("area:id", areaId);
  124. sessionStorage.setItem("currentFarmId", 766);
  125. areaId({ areaId: 0, farmId: 766 });
  126. // 修改单棵树信息后刷新地图数据
  127. eventBus.off("refreshMapData", getPointList);
  128. eventBus.on("refreshMapData", getPointList);
  129. if (route.query.acitveName) {
  130. activeName.value = route.query.acitveName
  131. }
  132. });
  133. onUnmounted(() => {
  134. if (mapRef.value) {
  135. mapRef.value.destroy(); // 确保在自定义地图组件中实现了destroy方法
  136. }
  137. eventBus.off("area:id", areaId);
  138. eventBus.off("changePointLegend", toggleLegend);
  139. eventBus.off("clickMapPoint", toggleLeftComponet);
  140. });
  141. const getPointList = () => {
  142. VE_API.manage_interface.fetchSampleList({ farmId: organId.value }).then(({ data }) => {
  143. if (mapRef.value) {
  144. nextTick(() => {
  145. mapRef.value.addCluster(data);
  146. // mapRef.value.initData(arr)
  147. // mapRef.value.initMap(arr, () => mapRef.value.getRegionList(organId.value))
  148. });
  149. }
  150. });
  151. };
  152. const regionData = ref([]);
  153. function getBlueRegionList() {
  154. VE_API.manage_interface.fetchRegionList({ farmId: organId.value }).then(({ data }) => {
  155. regionData.value = data;
  156. mapRef.value.initAreaMap(data);
  157. });
  158. }
  159. const checkShow = ref(false);
  160. const hanldeCheck = () => {
  161. checkShow.value = true;
  162. mapRef.value.enableBoxSelect();
  163. };
  164. // 分配果树
  165. const checkDistributeShow = ref(false);
  166. const startReloadList = ref(false);
  167. const hanldeDistributeCheck = () => {
  168. checkDistributeShow.value = true;
  169. mapRef.value.enableDistributeBoxSelect();
  170. };
  171. // 分配果树勾选值变化事件
  172. const selectedTels = ref([]);
  173. const handlCheckChange = (val) => {
  174. selectedTels.value = val;
  175. };
  176. // 地图--选树时抛出的事件
  177. const selectedTree = ref([]);
  178. const handleSelectedTree = (data) => {
  179. selectedTree.value = data;
  180. }
  181. const handleCancel = () => {
  182. checkShow.value = false;
  183. checkDistributeShow.value = false;
  184. selectedTree.value = []
  185. selectedTels.value = []
  186. // mapRef.value.clearSelection()
  187. mapRef.value.stopBoxSelect();
  188. };
  189. const saveEdit = () => {
  190. mapRef.value.saveSelect(() => {
  191. getPointList();
  192. });
  193. checkShow.value = false;
  194. checkDistributeShow.value = false;
  195. };
  196. const saveDistributeEdit = () => {
  197. // mapRef.value.saveDistributeSelect(() => {
  198. // getPointList();
  199. // });
  200. const params = {
  201. farmId: 766,
  202. sampleIds: selectedTree.value,
  203. tels: selectedTels.value,
  204. };
  205. VE_API.manage_interface.saveTreeUser(params).then(({code}) => {
  206. if (code === 0) {
  207. ElMessage.success("分配成功");
  208. startReloadList.value = true; // 触发重新加载列表
  209. activeName.value = "已分配"
  210. handleCancel()
  211. return;
  212. }
  213. })
  214. };
  215. // 图例
  216. const legendArr = ref([]);
  217. const organId = ref("");
  218. const regionId = ref(null);
  219. const tabName = ref("");
  220. const tabId = ref(0);
  221. eventBus.off("changePointLegend", toggleLegend);
  222. eventBus.on("changePointLegend", toggleLegend);
  223. function toggleLegend({ colorObj }) {
  224. legendArr.value = colorObj?.list;
  225. }
  226. //选项卡事件监听
  227. const handleTab = async ({ name, id, isUpdate, params, legend, colorObj }) => {
  228. eventBus.emit("changePointType", { legend, colorObj });
  229. legendArr.value = colorObj?.list;
  230. tabName.value = name;
  231. tabId.value = id;
  232. // if (id === 0) {
  233. // }
  234. };
  235. //区域切换监听事件
  236. function areaId({ areaId, farmId }) {
  237. organId.value = farmId;
  238. regionId.value = areaId;
  239. // 树点位
  240. getPointList();
  241. // 分区
  242. if (!regionData.value.length) {
  243. // 全部区域
  244. getBlueRegionList();
  245. }
  246. }
  247. const urls = ref([]);
  248. const urlsIndex = ref(0);
  249. const currentComponent = ref("leftTabs");
  250. eventBus.on("clickMapPoint", toggleLeftComponet);
  251. function toggleLeftComponet() {
  252. currentComponent.value = "treeDetail";
  253. }
  254. function backHome() {
  255. currentComponent.value = "leftTabs";
  256. mapRef.value.resetCurrentTree();
  257. }
  258. function setReload() {
  259. startReloadList.value = true
  260. }
  261. </script>
  262. <style lang="scss" scoped>
  263. .base-container {
  264. width: 100%;
  265. height: 100%;
  266. position: absolute;
  267. box-sizing: border-box;
  268. z-index: 1;
  269. color: #ffffff;
  270. .content {
  271. width: 100%;
  272. height: calc(100% - 36px);
  273. display: flex;
  274. justify-content: space-between;
  275. box-sizing: border-box;
  276. .left,
  277. .right {
  278. width: 376px;
  279. height: calc(100% - 10px);
  280. margin-top: 10px;
  281. box-sizing: border-box;
  282. display: flex;
  283. position: relative;
  284. }
  285. .left {
  286. background: #fff;
  287. border-radius: 8px;
  288. margin-left: 25px;
  289. padding: 0 10px 10px;
  290. .arrow {
  291. position: absolute;
  292. right: -16px;
  293. top: calc(50% - 40px);
  294. background: #fff;
  295. width: 16px;
  296. height: 80px;
  297. line-height: 80px;
  298. border-radius: 0 5px 5px 0;
  299. text-align: center;
  300. cursor: pointer;
  301. }
  302. ::v-deep {
  303. .el-tabs__item {
  304. outline: none;
  305. }
  306. }
  307. }
  308. .right {
  309. width: 376px;
  310. margin-right: 25px;
  311. .adopt-list-wrap {
  312. ::v-deep {
  313. .el-tabs {
  314. height: 100%;
  315. }
  316. .el-tabs__content {
  317. height: calc(100% - 40px - 15px);
  318. position: static;
  319. }
  320. .el-tabs__item {
  321. color: #727272;
  322. width: 100px;
  323. }
  324. .el-tabs__active-bar {
  325. background-color: #2199f8;
  326. height: 1px;
  327. }
  328. .el-tabs__item.is-active {
  329. color: #2199f8;
  330. }
  331. .el-tabs__nav-wrap:after {
  332. height: 1px;
  333. background-color: rgba(127, 127, 127, 0.1);
  334. }
  335. .el-tabs__nav {
  336. left: 50%;
  337. transform: translateX(-50%) !important;
  338. }
  339. .el-tab-pane {
  340. height: 100%;
  341. }
  342. }
  343. }
  344. .list {
  345. width: 100%;
  346. height: 100%;
  347. overflow: auto;
  348. .btn-wrap {
  349. width: 100%;
  350. height: 25px;
  351. line-height: 25px;
  352. margin: 10px 0;
  353. display: flex;
  354. align-items: center;
  355. justify-content: space-between;
  356. div {
  357. width: 48%;
  358. height: 100%;
  359. color: #ffd489;
  360. border: 1px solid rgba(255, 213, 137, 0.6);
  361. border-radius: 2px;
  362. text-align: center;
  363. font-size: 12px;
  364. cursor: pointer;
  365. &.active {
  366. background: #ffd489;
  367. color: #000;
  368. }
  369. }
  370. }
  371. .img-box {
  372. width: 100%;
  373. height: calc(100% - 35px);
  374. overflow: auto;
  375. }
  376. .img-box1 {
  377. width: 100%;
  378. height: calc(100% - 10px);
  379. overflow: auto;
  380. margin-top: 10px;
  381. }
  382. .img-box2 {
  383. width: 100%;
  384. height: calc(100% - 45px);
  385. overflow: auto;
  386. margin-top: 10px;
  387. }
  388. img {
  389. width: 100%;
  390. height: auto;
  391. object-fit: cover;
  392. margin-bottom: 12px;
  393. cursor: pointer;
  394. }
  395. .mt {
  396. margin-top: -12px;
  397. }
  398. }
  399. }
  400. .overflow {
  401. overflow: auto;
  402. }
  403. .legend {
  404. position: fixed;
  405. bottom: 8px;
  406. right: 64px;
  407. height: 20px;
  408. }
  409. .map-bg {
  410. position: fixed;
  411. z-index: 2;
  412. background: rgba(35, 35, 35, 0.8);
  413. border-radius: 18px;
  414. padding: 7px 16px;
  415. left: 460px;
  416. }
  417. .tips {
  418. position: fixed;
  419. z-index: 2;
  420. top: 105px;
  421. width: 100%;
  422. display: flex;
  423. justify-content: center;
  424. .text {
  425. font-size: 20px;
  426. padding: 6px 16px;
  427. font-family: "PangMenZhengDao";
  428. background: rgba(4, 3, 0, 0.6);
  429. border-radius: 20px;
  430. span {
  431. color: #ffd489;
  432. }
  433. }
  434. }
  435. .right-button {
  436. position: fixed;
  437. z-index: 2;
  438. right: 460px;
  439. bottom: 36px;
  440. font-size: 24px;
  441. font-family: "PangMenZhengDao";
  442. padding: 16px 32px 20px 32px;
  443. cursor: pointer;
  444. background: url("@/assets/images/foster-home/btn-bg.png") no-repeat center center / 100% 100%;
  445. }
  446. .center-button {
  447. position: fixed;
  448. z-index: 2;
  449. width: 100%;
  450. display: flex;
  451. align-items: center;
  452. justify-content: center;
  453. bottom: 116px;
  454. div {
  455. cursor: pointer;
  456. width: 248px;
  457. text-align: center;
  458. padding: 15px;
  459. font-family: "PangMenZhengDao";
  460. color: #000;
  461. font-size: 20px;
  462. background: linear-gradient(0deg, #ffd887, #ed9e1e);
  463. border: 2px solid rgba(255, 255, 255, 0.61);
  464. border-radius: 12px;
  465. }
  466. .cancel {
  467. margin-right: 20px;
  468. background: #eeeeee;
  469. }
  470. .disabled {
  471. opacity: 0.6;
  472. pointer-events: none;
  473. cursor: not-allowed;
  474. }
  475. }
  476. .select-text {
  477. padding-left: 4px;
  478. font-size: 16px;
  479. .select-total {
  480. color: rgba(29, 29, 29, 0.5);
  481. }
  482. }
  483. .map-btn {
  484. top: 19px;
  485. cursor: pointer;
  486. }
  487. .map-legend {
  488. bottom: 36px;
  489. display: flex;
  490. align-items: center;
  491. .item {
  492. display: flex;
  493. align-items: center;
  494. font-size: 14px;
  495. img {
  496. width: 16px;
  497. margin-right: 6px;
  498. }
  499. .legend-block {
  500. width: 16px;
  501. height: 16px;
  502. box-sizing: border-box;
  503. border-radius: 50%;
  504. border: 2px solid #fff;
  505. margin-right: 6px;
  506. }
  507. }
  508. .selected-item {
  509. img {
  510. width: 24px;
  511. }
  512. }
  513. .legend-title {
  514. border-bottom: 1px solid rgba(102, 102, 102, 0.35);
  515. }
  516. .item + .item {
  517. padding-left: 12px;
  518. }
  519. }
  520. }
  521. }
  522. .bottom-map {
  523. width: 100%;
  524. height: 100%;
  525. position: absolute;
  526. z-index: 0;
  527. }
  528. .compare-start-btn {
  529. position: absolute;
  530. z-index: 2;
  531. left: 50%;
  532. transform: translateX(-50%);
  533. cursor: pointer;
  534. bottom: 106px;
  535. // right: 445px;
  536. img {
  537. height: 55px;
  538. }
  539. }
  540. </style>
  541. <style lang="less">
  542. .file-wrap {
  543. &.map-file {
  544. width: 367px;
  545. position: relative;
  546. background: url("@/assets/images/home/file-bg.png") no-repeat top center / 100% 100%;
  547. margin-left: 12px;
  548. padding: 12px;
  549. .file-title {
  550. font-size: 20px;
  551. color: #ffd489;
  552. .tag {
  553. border: 1px solid #ffd489;
  554. border-radius: 4px;
  555. font-size: 12px;
  556. display: inline-block;
  557. width: 44px;
  558. height: 20px;
  559. text-align: center;
  560. line-height: 18px;
  561. margin-left: 8px;
  562. padding: 1px 4px;
  563. }
  564. }
  565. .overview-file {
  566. padding-top: 20px;
  567. .box-title {
  568. font-size: 16px;
  569. padding-left: 13px;
  570. margin-bottom: 16px;
  571. position: relative;
  572. display: flex;
  573. justify-content: space-between;
  574. color: #fff;
  575. &::before {
  576. content: "";
  577. position: absolute;
  578. left: 0;
  579. top: 3px;
  580. width: 3px;
  581. height: 16px;
  582. background: #fff;
  583. border-radius: 11px;
  584. }
  585. }
  586. .title {
  587. color: #f3c11d;
  588. font-size: 16px;
  589. font-family: "PangMenZhengDao";
  590. margin-bottom: 20px;
  591. .big {
  592. width: 13px;
  593. height: 13px;
  594. margin: -10px 0 0 4px;
  595. }
  596. .small {
  597. width: 7px;
  598. height: 7px;
  599. margin-left: -3px;
  600. }
  601. }
  602. .base-data {
  603. background: rgba(207, 207, 207, 0.1);
  604. border-radius: 4px;
  605. padding: 6px 0;
  606. display: flex;
  607. .base-item {
  608. flex: 1;
  609. text-align: center;
  610. .label {
  611. font-size: 12px;
  612. color: #666666;
  613. }
  614. .value {
  615. padding-top: 2px;
  616. font-size: 16px;
  617. color: #ffffff;
  618. }
  619. }
  620. .base-item + .base-item {
  621. border-left: 1px solid rgba(102, 102, 102, 0.42);
  622. }
  623. }
  624. .list {
  625. margin-top: 15px;
  626. width: max-content;
  627. font-size: 14px;
  628. .list-item {
  629. color: #bbbbbb;
  630. display: flex;
  631. margin-bottom: 8px;
  632. .list-name {
  633. color: #f3c11d;
  634. margin-right: 6px;
  635. img {
  636. width: 17px;
  637. height: 13px;
  638. }
  639. }
  640. }
  641. }
  642. }
  643. .overview-file + .overview-file {
  644. margin-top: 8px;
  645. }
  646. .box-wrap {
  647. display: flex;
  648. .box-item {
  649. // flex: 1;
  650. min-width: 109px;
  651. display: flex;
  652. flex-direction: column;
  653. justify-content: center;
  654. align-items: center;
  655. padding: 6px;
  656. box-sizing: border-box;
  657. background: rgba(207, 207, 207, 0.1);
  658. border-radius: 4px;
  659. border: 1px solid rgba(207, 207, 207, 0.1);
  660. cursor: pointer;
  661. .item-name {
  662. font-size: 12px;
  663. color: #666666;
  664. width: max-content;
  665. }
  666. .item-val {
  667. font-size: 18px;
  668. color: #fff;
  669. width: max-content;
  670. padding-top: 3px;
  671. }
  672. &.active {
  673. background: rgba(255, 212, 137, 0.16);
  674. border: 1px solid #ffd489;
  675. .item-name {
  676. color: #bbbbbb;
  677. }
  678. }
  679. }
  680. .box-item + .box-item {
  681. margin-left: 8px;
  682. }
  683. }
  684. }
  685. }
  686. </style>