albumCarousel.vue 13 KB

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