albumCarousel.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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.on("click:point",function({farmId,sampleId, data}){
  117. sampleId = data.id;
  118. getSampleFiles(data.geoHashSample);
  119. photoBaseData.value[0].value = data.pz;
  120. isLoadingImg.value = true
  121. let startDate = new Date(currentDate);
  122. startDate.setFullYear(currentDate.getFullYear() - 2);
  123. // 格式化日期
  124. let params = {sampleId,farmId,startDate:dateFormat(startDate, "YY-mm-dd")}
  125. VE_API.miniimage.list(params).then(res => {
  126. if(res.code === 0){
  127. dialogVisible.value = true
  128. images.value = res.data
  129. isLoadingImg.value = false
  130. }
  131. })
  132. showTag.value = data.nonghu == 1 ? true : false
  133. // photoBaseData.value[0].value = data.pz;
  134. // photoBaseData.value[1].value = data?.sgbmj ? data?.sgbmj + "平方米" : "--";
  135. // photoBaseData.value[2].value = data?.zzts ? data.zzts + "" : "--";
  136. // photoBaseData.value[3].value = data?.sl ? data?.sl + "年" : "--";
  137. // outputBox.value[0].value = data?.cl ? (data.cl + "斤") : "--";
  138. // outputBox.value[1].value = data?.spgl? (data.spgl + "%") : "--";
  139. // qualityBox.value[0].value = data?.tfl? (data.tfl + "%") : "--";
  140. // qualityBox.value[1].value = data?.tgl? (data.tgl + "%") : "--";
  141. // qualityBox.value[2].value = data?.dxtj? (data.dxtj + "%") : "--";
  142. })
  143. eventBus.off("albumCarousel", toggleActiveImg);
  144. eventBus.on("albumCarousel", toggleActiveImg);
  145. const currentIndex = ref(0);
  146. function toggleActiveImg(index) {
  147. currentIndex.value = index;
  148. }
  149. const getSampleFiles = (geoHash) => {
  150. // photoList.value = [];
  151. const farmId = sessionStorage.getItem("farmId");
  152. VE_API.mini_farm.getSampleFiles({ geoHashSample: geoHash,farmId }).then(({data,extData}) => {
  153. photoBaseData.value[0].value = data.meta_info.type_id;
  154. let i = 1;
  155. for(let key of Object.keys(data.meta_info)){
  156. let dict = extData.find((item) => item.field == key)
  157. if(dict){
  158. photoBaseData.value[i].label = dict.label
  159. if(dict.field === "crown"){
  160. photoBaseData.value[i].value = data.meta_info[dict.field]
  161. let pj = Math.sqrt(photoBaseData.value[i].value * 1.2).toFixed(1);
  162. photoBaseData.value[i].value = photoBaseData.value[i].value + dict.unit + "(蓬径"+pj+"米)";
  163. }else{
  164. photoBaseData.value[i].value = data.meta_info[dict.field] + dict.unit
  165. }
  166. i++;
  167. }
  168. }
  169. i = 0;
  170. for(let key of Object.keys(data.production_info)){
  171. let dict = extData.find((item) => item.field == key)
  172. if(dict){
  173. outputBox.value[i].name = dict.label
  174. outputBox.value[i].value = data.production_info[dict.field] + dict.unit
  175. i++;
  176. }
  177. }
  178. i = 0;
  179. for(let key of Object.keys(data.ecology_info)){
  180. let dict = extData.find((item) => item.field == key)
  181. if(dict){
  182. qualityBox.value[i].name = dict.label
  183. qualityBox.value[i].value = data.ecology_info[dict.field] + dict.unit
  184. i++;
  185. }
  186. }
  187. photoList.value[0].key = data.meta_info.dp_alert_info.key
  188. photoList.value[0].statement = data.meta_info.dp_alert_info.statement
  189. photoList.value[1].key = data.meta_info.grow_alert_info.key
  190. photoList.value[1].statement = data.meta_info.grow_alert_info.statement
  191. photoList.value[2].key = data.meta_info.nutrition_info.key
  192. photoList.value[2].statement = data.meta_info.nutrition_info.statement
  193. photoList.value[3].key = data.meta_info.prescription_info.key
  194. photoList.value[3].statement = data.meta_info.prescription_info.statement
  195. });
  196. };
  197. const photoBaseData = ref([
  198. {
  199. label: "品种",
  200. value: "--",
  201. },
  202. {
  203. label: "冠幅表面积",
  204. value: "--",
  205. },
  206. {
  207. label: "总枝条",
  208. value: "--",
  209. },
  210. {
  211. label: "树龄",
  212. value: "--",
  213. },
  214. ]);
  215. const photoList = ref([
  216. {key: "病虫", statement: "--"},
  217. {key: "异常", statement: "--"},
  218. {key: "营养", statement: "--"},
  219. {key: "农事", statement: "--"},
  220. ]);
  221. const activeOuput = ref(null);
  222. // 产量详情
  223. function toggleAcitve(name) {
  224. activeOuput.value = name;
  225. if (name.indexOf("开花") > -1) {
  226. eventBus.emit("change:watermark", "开花目标框")
  227. } else if (name.indexOf("花穗") > -1) {
  228. eventBus.emit("change:watermark", "花穗目标框")
  229. } else if (name.indexOf("雄花") > -1) {
  230. eventBus.emit("change:watermark", "雄花目标框")
  231. } else if (name.indexOf("枝条数") > -1) {
  232. eventBus.emit("change:watermark", "")
  233. } else {
  234. eventBus.emit("change:watermark", "")
  235. }
  236. }
  237. function closeDialog() {
  238. activeOuput.value = null
  239. eventBus.emit("change:watermark", "")
  240. eventBus.emit("resetImgIndex")
  241. }
  242. // 质量详情
  243. function toggleQualityAcitve() {
  244. }
  245. </script>
  246. <style lang="scss" scoped>
  247. @import "src/styles/index";
  248. .picture-file {
  249. display: flex;
  250. .left-img {
  251. min-width: 780px;
  252. min-height: 300px;
  253. }
  254. .file-wrap {
  255. background: url("@/assets/images/home/file-bg.png") no-repeat top center / 100% 100%;
  256. margin-left: 12px;
  257. padding: 12px;
  258. .file-title {
  259. font-size: 20px;
  260. color: #ffd489;
  261. display: flex;
  262. align-items: center;
  263. .tag {
  264. border: 1px solid #FFD489;
  265. border-radius: 4px;
  266. font-size: 12px;
  267. display: inline-block;
  268. width: 44px;
  269. height: 20px;
  270. text-align: center;
  271. line-height: 18px;
  272. margin-left: 3px;
  273. padding: 1px 4px;
  274. }
  275. }
  276. .overview-file {
  277. padding-top: 20px;
  278. .box-title {
  279. font-size: 16px;
  280. padding-left: 13px;
  281. margin-bottom: 16px;
  282. position: relative;
  283. display: flex;
  284. justify-content: space-between;
  285. color: #fff;
  286. &::before {
  287. content: "";
  288. position: absolute;
  289. left: 0;
  290. top: 3px;
  291. width: 3px;
  292. height: 16px;
  293. background: #fff;
  294. border-radius: 11px;
  295. }
  296. }
  297. .title {
  298. color: #f3c11d;
  299. font-size: 16px;
  300. font-family: "PangMenZhengDao";
  301. margin-bottom: 20px;
  302. .big {
  303. width: 13px;
  304. height: 13px;
  305. margin: -10px 0 0 4px;
  306. }
  307. .small {
  308. width: 7px;
  309. height: 7px;
  310. margin-left: -3px;
  311. }
  312. }
  313. .base-data {
  314. background: rgba(207, 207, 207, 0.1);
  315. border-radius: 4px;
  316. padding: 6px 0;
  317. display: flex;
  318. .base-item {
  319. flex: 1;
  320. text-align: center;
  321. .label {
  322. font-size: 12px;
  323. color: #666666;
  324. }
  325. .value {
  326. padding-top: 2px;
  327. font-size: 16px;
  328. color: #ffffff;
  329. }
  330. }
  331. .base-item + .base-item {
  332. border-left: 1px solid rgba(102, 102, 102, 0.42);
  333. }
  334. }
  335. .list {
  336. margin-top: 15px;
  337. width: max-content;
  338. font-size: 14px;
  339. .list-item {
  340. color: #bbbbbb;
  341. display: flex;
  342. margin-bottom: 8px;
  343. .list-name {
  344. color: #f3c11d;
  345. margin-right: 6px;
  346. img {
  347. width: 17px;
  348. height: 13px;
  349. }
  350. }
  351. }
  352. }
  353. }
  354. .overview-file + .overview-file {
  355. margin-top: 8px;
  356. }
  357. .box-wrap {
  358. display: flex;
  359. .box-item {
  360. min-width: 140px;
  361. box-sizing: border-box;
  362. display: flex;
  363. flex-direction: column;
  364. justify-content: center;
  365. align-items: center;
  366. padding: 6px;
  367. background: rgba(207, 207, 207, 0.1);
  368. border-radius: 4px;
  369. border: 1px solid rgba(207, 207, 207, 0.1);
  370. cursor: pointer;
  371. .item-name {
  372. font-size: 12px;
  373. color: #666666;
  374. width: max-content;
  375. }
  376. .item-val {
  377. font-size: 18px;
  378. color: #fff;
  379. width: max-content;
  380. padding-top: 3px;
  381. }
  382. &.active {
  383. background: rgba(255, 212, 137, 0.16);
  384. border: 1px solid #ffd489;
  385. .item-name {
  386. color: #bbbbbb;
  387. }
  388. }
  389. }
  390. .box-item + .box-item {
  391. margin-left: 8px;
  392. }
  393. }
  394. }
  395. }
  396. </style>
  397. <style lang="scss">
  398. .picture-preview-wrap {
  399. background: none;
  400. }
  401. </style>