albumCarousel.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <el-dialog
  3. v-model="dialogVisible"
  4. width="60%"
  5. align-center
  6. class="picture-preview-wrap v-dialog"
  7. :show-close="false"
  8. append-to-body
  9. @close="closeDialog"
  10. >
  11. <div class="picture-file">
  12. <div class="left-img">
  13. <!-- v-loading="isLoadingImg" element-loading-background="rgba(0, 0, 0, 0.3)" -->
  14. <album-carousel-item
  15. lbum-carousel-item
  16. v-if="images"
  17. :key="nameRef"
  18. :name="nameRef"
  19. :farmId="farmId"
  20. :images="images"
  21. :lock="lock"
  22. ></album-carousel-item>
  23. </div>
  24. <div class="file-wrap">
  25. <div class="file-title">
  26. <img src="@/assets/images/common/chart-yellow.png" alt="" />
  27. 果树档案
  28. <span class="tag" v-if="showTag">小农户</span>
  29. </div>
  30. <div class="overview-file">
  31. <div class="box-title">总体档案</div>
  32. <!-- <div class="base-data">
  33. <div class="base-item" v-for="item in photoBaseData" :key="item.label">
  34. <span class="label">{{ item.label }}</span>
  35. <div class="value">{{ item.value }}</div>
  36. </div>
  37. </div> -->
  38. </div>
  39. <div class="overview-file">
  40. <div class="box-title">产量详情</div>
  41. <div class="box-wrap">
  42. <div
  43. class="box-item"
  44. v-for="(item, index) in outputBox"
  45. :key="index"
  46. >
  47. <div class="item-name">{{ item.name }}</div>
  48. <div class="item-val">{{ item.value }}</div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="overview-file">
  53. <div class="box-title">质量详情</div>
  54. <div class="box-wrap">
  55. <div
  56. class="box-item"
  57. v-for="(item, index) in qualityBox"
  58. :key="index"
  59. >
  60. <div class="item-name">{{ item.name }}</div>
  61. <div class="item-val">{{ item.value }}</div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </el-dialog>
  68. </template>
  69. <script setup>
  70. import { ref, computed, onMounted, onUnmounted } from "vue";
  71. import "./cacheImg.js";
  72. import AlbumCarouselItem from "./albumCarouselItem";
  73. import { dateFormat } from "@/utils/date_util.js";
  74. import eventBus from "@/api/eventBus";
  75. const lock = ref(false);
  76. const farmId = ref(766);
  77. const nameRef = ref("");
  78. const isLoadingImg = ref(true);
  79. const images = ref(null);
  80. const dialogVisible = ref(false);
  81. // 获取当前日期
  82. const currentDate = new Date();
  83. // 获取当前日期的前一个月
  84. const startDate = new Date(currentDate);
  85. startDate.setMonth(currentDate.getMonth() - 1);
  86. // 格式化日期
  87. const formattedStartDate = dateFormat(startDate, "YY-mm-dd");
  88. const formattedEndDate = dateFormat(currentDate, "YY-mm-dd");
  89. eventBus.on("change:watermark", function (name) {
  90. nameRef.value = name;
  91. });
  92. const outputBox = ref([
  93. { id: 1, name: "产量估计", value: "" },
  94. { id: 2, name: "高质果率", value: "" },
  95. ]);
  96. const qualityBox = ref([
  97. { id: 5, name: "通风率", value: "" },
  98. { id: 6, name: "透光率", value: "" },
  99. { id: 7, name: "病虫比例", value: "" },
  100. ]);
  101. const showTag = ref(false);
  102. eventBus.off("click:point", handleClickPoint);
  103. eventBus.on("click:point", handleClickPoint);
  104. function handleClickPoint({ farmId, sampleId, data }) {
  105. console.log("click:point");
  106. sampleId = data.id;
  107. getSampleFiles(data.geoHashSample);
  108. photoBaseData.value[0].value = data.pz;
  109. isLoadingImg.value = true;
  110. let startDate = new Date(currentDate);
  111. startDate.setMonth(currentDate.getMonth() - 2);
  112. // 格式化日期
  113. let params = { sampleId, farmId, startDate: dateFormat(startDate, "YY-mm-dd") };
  114. VE_API.miniimage.list(params).then((res) => {
  115. if (res.code === 0) {
  116. dialogVisible.value = true;
  117. images.value = res.data;
  118. isLoadingImg.value = false;
  119. }
  120. });
  121. showTag.value = data.nonghu == 1 ? true : false;
  122. }
  123. // eventBus.off("albumCarousel", toggleActiveImg);
  124. // eventBus.on("albumCarousel", toggleActiveImg);
  125. // const currentIndex = ref(0);
  126. // function toggleActiveImg(index) {
  127. // currentIndex.value = index;
  128. // }
  129. const getSampleFiles = (geoHash) => {
  130. VE_API.mini_farm.getSampleFiles({ geoHashSample: geoHash }).then(({ data }) => {
  131. photoBaseData.value[0].value = data.meta_info.type_id;
  132. let pj = "--";
  133. if (data.meta_info.crown) {
  134. pj = Math.sqrt(data.meta_info.crown * 1.2).toFixed(1);
  135. }
  136. photoBaseData.value[1].value = data.meta_info.crown + "平方米(蓬径" + pj + "米)";
  137. photoBaseData.value[2].value = data.meta_info.branch_num;
  138. photoBaseData.value[3].value = data.meta_info.age + "年";
  139. // if(data.production_info.production){
  140. // data.production_info.production = (data.production_info.production * 1.3).toFixed(1)
  141. // }
  142. outputBox.value[0].value = data.production_info.production + "斤";
  143. outputBox.value[1].value = data.production_info.quality.toFixed(0) + "%";
  144. qualityBox.value[0].value = data.ecology_info.ventilation + "%";
  145. qualityBox.value[1].value = data.ecology_info.transmittance + "%";
  146. qualityBox.value[2].value = data.ecology_info.dp_situation + "%";
  147. });
  148. };
  149. const photoBaseData = ref([
  150. {
  151. label: "品种",
  152. value: "--",
  153. },
  154. {
  155. label: "冠幅表面积",
  156. value: "--",
  157. },
  158. {
  159. label: "总枝条",
  160. value: "--",
  161. },
  162. {
  163. label: "树龄",
  164. value: "--",
  165. },
  166. ]);
  167. const activeOuput = ref(null);
  168. function closeDialog() {
  169. activeOuput.value = null;
  170. eventBus.emit("change:watermark", "");
  171. eventBus.emit("resetImgIndex");
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. @import "src/styles/index";
  176. .picture-file {
  177. display: flex;
  178. .left-img {
  179. min-width: 780px;
  180. min-height: 300px;
  181. }
  182. .file-wrap {
  183. background: url("@/assets/images/home/file-bg.png") no-repeat top center / 100% 100%;
  184. margin-left: 12px;
  185. padding: 12px;
  186. .file-title {
  187. font-size: 20px;
  188. color: #2199F8;
  189. display: flex;
  190. align-items: center;
  191. .tag {
  192. border: 1px solid #2199F8;
  193. border-radius: 4px;
  194. font-size: 12px;
  195. display: inline-block;
  196. width: 44px;
  197. height: 20px;
  198. text-align: center;
  199. line-height: 18px;
  200. margin-left: 3px;
  201. padding: 1px 4px;
  202. }
  203. }
  204. .overview-file {
  205. padding-top: 20px;
  206. .box-title {
  207. font-size: 16px;
  208. padding-left: 13px;
  209. margin-bottom: 16px;
  210. position: relative;
  211. display: flex;
  212. justify-content: space-between;
  213. color: #000000;
  214. &::before {
  215. content: "";
  216. position: absolute;
  217. left: 0;
  218. top: 3px;
  219. width: 3px;
  220. height: 16px;
  221. background: #000000;
  222. border-radius: 11px;
  223. }
  224. }
  225. .title {
  226. color: #f3c11d;
  227. font-size: 16px;
  228. font-family: "PangMenZhengDao";
  229. margin-bottom: 20px;
  230. .big {
  231. width: 13px;
  232. height: 13px;
  233. margin: -10px 0 0 4px;
  234. }
  235. .small {
  236. width: 7px;
  237. height: 7px;
  238. margin-left: -3px;
  239. }
  240. }
  241. .base-data {
  242. background: rgba(207, 207, 207, 0.1);
  243. border-radius: 4px;
  244. padding: 6px 0;
  245. display: flex;
  246. .base-item {
  247. flex: 1;
  248. text-align: center;
  249. .label {
  250. font-size: 12px;
  251. color: #666666;
  252. }
  253. .value {
  254. padding-top: 2px;
  255. font-size: 16px;
  256. color: #ffffff;
  257. }
  258. }
  259. .base-item + .base-item {
  260. border-left: 1px solid rgba(102, 102, 102, 0.42);
  261. }
  262. }
  263. .list {
  264. margin-top: 15px;
  265. width: max-content;
  266. font-size: 14px;
  267. .list-item {
  268. color: #bbbbbb;
  269. display: flex;
  270. margin-bottom: 8px;
  271. .list-name {
  272. color: #f3c11d;
  273. margin-right: 6px;
  274. img {
  275. width: 17px;
  276. height: 13px;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. .overview-file + .overview-file {
  283. margin-top: 8px;
  284. }
  285. .box-wrap {
  286. display: flex;
  287. .box-item {
  288. min-width: 109px;
  289. box-sizing: border-box;
  290. display: flex;
  291. flex-direction: column;
  292. justify-content: center;
  293. align-items: center;
  294. padding: 6px;
  295. background: rgba(169, 169, 169, 0.1);
  296. border-radius: 4px;
  297. cursor: pointer;
  298. .item-name {
  299. font-size: 12px;
  300. color: rgba(102, 102, 102, 0.86);
  301. width: max-content;
  302. }
  303. .item-val {
  304. font-size: 18px;
  305. color: #000000;
  306. width: max-content;
  307. padding-top: 3px;
  308. }
  309. &.active {
  310. background: rgba(255, 212, 137, 0.16);
  311. border: 1px solid #ffd489;
  312. .item-name {
  313. color: #bbbbbb;
  314. }
  315. }
  316. }
  317. .box-item + .box-item {
  318. margin-left: 8px;
  319. }
  320. }
  321. }
  322. }
  323. </style>
  324. <style lang="scss">
  325. .picture-preview-wrap {
  326. background: none;
  327. }
  328. </style>