albumCarousel.vue 11 KB

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