compareDialog.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <template>
  2. <el-dialog
  3. v-model="dialogVisible"
  4. width="80%"
  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. <div class="compare-l">
  12. <div class="left-img">
  13. <album-carousel-item
  14. lbum-carousel-item
  15. v-if="images"
  16. :key="nameRef+farmId+sampleId"
  17. :name="nameRef"
  18. :farmId="farmId"
  19. :images="images"
  20. :lock="lock"
  21. ></album-carousel-item>
  22. </div>
  23. <div class="file-wrap">
  24. <div class="file-title">
  25. <img src="@/assets/images/common/chart-yellow.png" alt="" />
  26. 果树档案
  27. <span v-show="showTag" class="tag">小农户</span>
  28. </div>
  29. <div class="box-wrap">
  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="box-r">
  49. <div class="overview-file">
  50. <div class="box-title">产量详情</div>
  51. <div class="box-wrap">
  52. <div
  53. class="box-item"
  54. v-for="(item, index) in outputBox"
  55. :key="index"
  56. @click="toggleAcitve(item.name)"
  57. :class="{ active: activeOuput === item.name }"
  58. >
  59. <div class="item-name">{{ item.name }}</div>
  60. <div class="item-val">{{ item.value }}</div>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="overview-file">
  65. <div class="box-title">质量详情</div>
  66. <div class="box-wrap">
  67. <div
  68. class="box-item"
  69. v-for="(item, index) in qualityBox"
  70. :key="index"
  71. @click="toggleQualityAcitve(item.name)"
  72. :class="{ active: activeOuput === item.name }"
  73. >
  74. <div class="item-name">{{ item.name }}</div>
  75. <div class="item-val">{{ item.value }}</div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="compare-r">
  84. <div class="left-img">
  85. <album-carousel-item
  86. lbum-carousel-item
  87. v-if="images2"
  88. :key="nameRef + '2' + farmId2 + sampleId2"
  89. :name="nameRef"
  90. :farmId="farmId2"
  91. :images="images2"
  92. :lock="lock"
  93. ></album-carousel-item>
  94. </div>
  95. <div class="file-wrap">
  96. <div class="file-title">
  97. <img src="@/assets/images/common/chart-yellow.png" alt="" />
  98. 果树档案
  99. <span v-show="showTag2" class="tag">小农户</span>
  100. </div>
  101. <div class="box-wrap">
  102. <div class="overview-file">
  103. <div class="box-title">总体档案</div>
  104. <div class="base-data">
  105. <div class="base-item" v-for="item in photoBaseData2" :key="item.label">
  106. <span class="label">{{ item.label }}</span>
  107. <div class="value">{{ item.value }}</div>
  108. </div>
  109. </div>
  110. <div class="list">
  111. <div class="list-item" v-for="item in photoList2" :key="item.key">
  112. <div class="list-name">
  113. <img src="@/assets/images/common/title-icon.png" alt="" />
  114. {{ item.key }}
  115. </div>
  116. {{ item.statement }}
  117. </div>
  118. </div>
  119. </div>
  120. <div class="box-r">
  121. <div class="overview-file">
  122. <div class="box-title">产量详情</div>
  123. <div class="box-wrap">
  124. <div
  125. class="box-item"
  126. v-for="(item, index) in outputBox2"
  127. :key="index"
  128. @click="toggleAcitve2(item.name)"
  129. :class="{ active: activeOuput2 === item.name }"
  130. >
  131. <div class="item-name">{{ item.name }}</div>
  132. <div class="item-val">{{ item.value }}</div>
  133. </div>
  134. </div>
  135. </div>
  136. <div class="overview-file">
  137. <div class="box-title">质量详情</div>
  138. <div class="box-wrap">
  139. <div
  140. class="box-item"
  141. v-for="(item, index) in qualityBox2"
  142. :key="index"
  143. @click="toggleQualityAcitve2(item.name)"
  144. :class="{ active: activeOuput2 === item.name }"
  145. >
  146. <div class="item-name">{{ item.name }}</div>
  147. <div class="item-val">{{ item.value }}</div>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </el-dialog>
  157. </template>
  158. <script setup>
  159. import { ref, computed, onMounted, onUnmounted } from "vue";
  160. import "./cacheImg.js";
  161. import AlbumCarouselItem from "./albumCarouselItem";
  162. import { dateFormat } from "@/utils/date_util.js";
  163. import eventBus from "@/api/eventBus";
  164. const lock = ref(false);
  165. const farmId = ref(766);
  166. const farmId2 = ref(766);
  167. const sampleId = ref(null);
  168. const sampleId2 = ref(null);
  169. const nameRef = ref("");
  170. const isLoadingImg = ref(true);
  171. const images = ref(null);
  172. const images2 = ref(null);
  173. const dialogVisible = ref(false);
  174. // 获取当前日期
  175. const currentDate = new Date();
  176. // 获取当前日期的前一个月
  177. const startDate = new Date(currentDate);
  178. startDate.setMonth(currentDate.getMonth() - 1);
  179. // 格式化日期
  180. const formattedStartDate = dateFormat(startDate, "YY-mm-dd");
  181. const formattedEndDate = dateFormat(currentDate, "YY-mm-dd");
  182. eventBus.on("change:watermark", function (name) {
  183. nameRef.value = name;
  184. });
  185. const outputBox = ref([
  186. { id: 1, name: "产量估计", value: "" },
  187. { id: 2, name: "高质果率", value: "" },
  188. { id: 3, name: "雌花比例", value: "" },
  189. ]);
  190. const qualityBox = ref([
  191. { id: 5, name: "通风率", value: "" },
  192. { id: 6, name: "透光率", value: "" },
  193. { id: 7, name: "病虫比例", value: "" },
  194. ]);
  195. const outputBox2 = ref([
  196. { id: 1, name: "产量估计", value: "" },
  197. { id: 2, name: "高质果率", value: "" },
  198. { id: 3, name: "雌花比例", value: "" },
  199. ]);
  200. const qualityBox2 = ref([
  201. { id: 5, name: "通风率", value: "" },
  202. { id: 6, name: "透光率", value: "" },
  203. { id: 7, name: "病虫比例", value: "" },
  204. ]);
  205. const showTag = ref(false)
  206. const showTag2 = ref(false)
  207. eventBus.on("showCompareDialog", function (compareArr) {
  208. console.log("compareArr", compareArr);
  209. images.value = []
  210. images2.value = []
  211. compareArr.map((item, index) => {
  212. dialogVisible.value = true;
  213. if (index === 0) {
  214. farmId.value = item.farmId
  215. sampleId.value = item.sampleId
  216. VE_API.miniimage.list({ farmId: item.farmId, sampleId: item.sampleId }).then((res) => {
  217. if (res.code === 0) {
  218. images.value = res.data;
  219. }
  220. });
  221. const dataItem = item.data;
  222. showTag.value = dataItem.nonghu == 1 ? true : false;
  223. VE_API.mini_farm.getSampleFiles({ geoHashSample: dataItem.geoHashSample }).then(({data}) => {
  224. photoBaseData.value[0].value = dataItem.pz;
  225. photoBaseData.value[1].value = data.meta_info.crown + "平方米";
  226. photoBaseData.value[2].value = data.meta_info.branch_num ;
  227. photoBaseData.value[3].value = data.meta_info.age + "年"
  228. photoList.value[0].key = data.meta_info.dp_alert_info.key
  229. photoList.value[0].statement = data.meta_info.dp_alert_info.statement
  230. photoList.value[1].key = data.meta_info.grow_alert_info.key
  231. photoList.value[1].statement = data.meta_info.grow_alert_info.statement
  232. photoList.value[2].key = data.meta_info.nutrition_info.key
  233. photoList.value[2].statement = data.meta_info.nutrition_info.statement
  234. photoList.value[3].key = data.meta_info.prescription_info.key
  235. photoList.value[3].statement = data.meta_info.prescription_info.statement
  236. outputBox.value[0].value = data.production_info.production + "斤"
  237. outputBox.value[1].value = data.production_info.quality.toFixed(0) + "%"
  238. outputBox.value[2].value = data.production_info.cihua_ratio.toFixed(0) + "%"
  239. qualityBox.value[0].value = data.ecology_info.ventilation + "%"
  240. qualityBox.value[1].value = data.ecology_info.transmittance + "%"
  241. qualityBox.value[2].value = data.ecology_info.dp_situation+"%"
  242. });
  243. // qualityBox.value[2].value = data.dxtj ? data.dxtj + "%" : "--";
  244. } else {
  245. farmId2.value = item.farmId
  246. sampleId2.value = item.sampleId
  247. VE_API.miniimage.list({ farmId: item.farmId, sampleId: item.sampleId }).then((res) => {
  248. if (res.code === 0) {
  249. images2.value = res.data;
  250. }
  251. });
  252. const dataItem = item.data;
  253. showTag2.value = dataItem.nonghu == 1 ? true : false;
  254. VE_API.mini_farm.getSampleFiles({ geoHashSample: dataItem.geoHashSample }).then(({data}) => {
  255. photoBaseData2.value[0].value = dataItem.pz;
  256. photoBaseData2.value[1].value = data.meta_info.crown + "平方米";
  257. photoBaseData2.value[2].value = data.meta_info.branch_num ;
  258. photoBaseData2.value[3].value = data.meta_info.age + "年"
  259. photoList2.value[0].key = data.meta_info.dp_alert_info.key
  260. photoList2.value[0].statement = data.meta_info.dp_alert_info.statement
  261. photoList2.value[1].key = data.meta_info.grow_alert_info.key
  262. photoList2.value[1].statement = data.meta_info.grow_alert_info.statement
  263. photoList2.value[2].key = data.meta_info.nutrition_info.key
  264. photoList2.value[2].statement = data.meta_info.nutrition_info.statement
  265. photoList2.value[3].key = data.meta_info.prescription_info.key
  266. photoList2.value[3].statement = data.meta_info.prescription_info.statement
  267. outputBox2.value[0].value = data.production_info.production + "斤"
  268. outputBox2.value[1].value = data.production_info.quality.toFixed(0) + "%"
  269. outputBox2.value[2].value = data.production_info.cihua_ratio.toFixed(0) + "%"
  270. qualityBox2.value[0].value = data.ecology_info.ventilation + "%"
  271. qualityBox2.value[1].value = data.ecology_info.transmittance + "%"
  272. qualityBox2.value[2].value = data.ecology_info.dp_situation+"%"
  273. });
  274. }
  275. });
  276. // isLoadingImg.value = true
  277. // let params = {sampleId,farmId}
  278. // dialogVisible.value = true
  279. // VE_API.miniimage.list(params).then(res => {
  280. // if(res.code === 0){
  281. // images.value = res.data
  282. // isLoadingImg.value = false
  283. // }
  284. // })
  285. // photoBaseData.value[0].value = data.pz;
  286. // photoBaseData.value[1].value = data.sgbmj + "米";
  287. // photoBaseData.value[2].value = data.cl + "斤";
  288. // photoBaseData.value[3].value = data.spgl + "%";
  289. // outputBox.value[0].value = data.hsl ? (data.hsl + "%") : "--";
  290. // outputBox.value[1].value = data.zzts? data.zzts : "--";
  291. // outputBox.value[2].value = data.khl? (data.khl + "%") : "--";
  292. // outputBox.value[3].value = data.xhl? (data.xhl + "%") : "--";
  293. // qualityBox.value[0].value = data.tfl? (data.tfl + "%") : "--";
  294. // qualityBox.value[1].value = data.tgl? (data.tgl + "%") : "--";
  295. // qualityBox.value[2].value = data.dxtj? (data.dxtj + "%") : "--";
  296. });
  297. eventBus.off("albumCarousel", toggleActiveImg);
  298. eventBus.on("albumCarousel", toggleActiveImg);
  299. const currentIndex = ref(0);
  300. function toggleActiveImg(index) {
  301. currentIndex.value = index;
  302. }
  303. const photoBaseData = ref([
  304. {
  305. label: "品种",
  306. value: "--",
  307. },
  308. {
  309. label: "冠幅表面积",
  310. value: "--",
  311. },
  312. {
  313. label: "总枝条",
  314. value: "--",
  315. },
  316. {
  317. label: "树龄",
  318. value: "--",
  319. },
  320. ]);
  321. const photoBaseData2 = ref([
  322. {
  323. label: "品种",
  324. value: "--",
  325. },
  326. {
  327. label: "冠幅表面积",
  328. value: "--",
  329. },
  330. {
  331. label: "总枝条",
  332. value: "--",
  333. },
  334. {
  335. label: "树龄",
  336. value: "--",
  337. },
  338. ]);
  339. const photoList = ref([
  340. {key: "病虫", statement: "--"},
  341. {key: "异常", statement: "--"},
  342. {key: "营养", statement: "--"},
  343. {key: "农事", statement: "--"},
  344. ]);
  345. const photoList2 = ref([
  346. {key: "病虫", statement: "--"},
  347. {key: "异常", statement: "--"},
  348. {key: "营养", statement: "--"},
  349. {key: "农事", statement: "--"},
  350. ]);
  351. const activeOuput = ref(1);
  352. const activeOuput2 = ref(1);
  353. // 产量详情
  354. function toggleAcitve(name) {
  355. activeOuput.value = name;
  356. toggleNamePic(name)
  357. }
  358. function toggleNamePic(name) {
  359. if (name.indexOf("开花") > -1) {
  360. eventBus.emit("change:watermark", "开花目标框");
  361. } else if (name.indexOf("花穗") > -1) {
  362. eventBus.emit("change:watermark", "花穗目标框");
  363. } else if (name.indexOf("雄花") > -1) {
  364. eventBus.emit("change:watermark", "雄花目标框");
  365. } else if (name.indexOf("枝条数") > -1) {
  366. eventBus.emit("change:watermark", "");
  367. } else {
  368. eventBus.emit("change:watermark", "");
  369. }
  370. }
  371. // 质量详情
  372. function toggleQualityAcitve() {}
  373. function toggleQualityAcitve2() {}
  374. function toggleAcitve2 (name){
  375. activeOuput.value = name;
  376. toggleNamePic(name)
  377. }
  378. </script>
  379. <style lang="scss" scoped>
  380. @import "src/styles/index";
  381. .picture-file {
  382. display: flex;
  383. .left-img {
  384. // min-width: 500px;
  385. width: 782px;
  386. height: 580px;
  387. }
  388. .compare-l {
  389. padding-right: 60px;
  390. }
  391. .file-wrap {
  392. margin-top: 16px;
  393. background: url("@/assets/images/home/file-bg-w.png") no-repeat top center / 100% 100%;
  394. padding: 12px;
  395. .file-title {
  396. font-size: 20px;
  397. color: #ffd489;
  398. .tag {
  399. border: 1px solid #FFD489;
  400. border-radius: 4px;
  401. font-size: 12px;
  402. display: inline-block;
  403. width: 44px;
  404. height: 20px;
  405. text-align: center;
  406. line-height: 18px;
  407. margin-left: 3px;
  408. padding: 1px 4px;
  409. }
  410. }
  411. .box-wrap {
  412. display: flex;
  413. .box-r {
  414. padding-left: 40px;
  415. }
  416. }
  417. .overview-file {
  418. padding-top: 20px;
  419. .box-title {
  420. font-size: 16px;
  421. padding-left: 13px;
  422. margin-bottom: 16px;
  423. position: relative;
  424. display: flex;
  425. justify-content: space-between;
  426. color: #fff;
  427. &::before {
  428. content: "";
  429. position: absolute;
  430. left: 0;
  431. top: 3px;
  432. width: 3px;
  433. height: 16px;
  434. background: #fff;
  435. border-radius: 11px;
  436. }
  437. }
  438. .title {
  439. color: #f3c11d;
  440. font-size: 16px;
  441. font-family: "PangMenZhengDao";
  442. margin-bottom: 20px;
  443. .big {
  444. width: 13px;
  445. height: 13px;
  446. margin: -10px 0 0 4px;
  447. }
  448. .small {
  449. width: 7px;
  450. height: 7px;
  451. margin-left: -3px;
  452. }
  453. }
  454. .base-data {
  455. background: rgba(207, 207, 207, 0.1);
  456. border-radius: 4px;
  457. padding: 6px 0;
  458. display: flex;
  459. .base-item {
  460. flex: 1;
  461. text-align: center;
  462. padding: 0 4px;
  463. min-width: 50px;
  464. .label {
  465. font-size: 12px;
  466. color: #666666;
  467. width: max-content;
  468. display: block;
  469. margin: 0 auto;
  470. padding-bottom: 2px;
  471. }
  472. .value {
  473. padding-top: 2px;
  474. font-size: 16px;
  475. color: #ffffff;
  476. width: max-content;
  477. margin: 0 auto;
  478. display: block;
  479. }
  480. }
  481. .base-item + .base-item {
  482. border-left: 1px solid rgba(102, 102, 102, 0.42);
  483. }
  484. }
  485. .list {
  486. margin-top: 15px;
  487. width: max-content;
  488. font-size: 14px;
  489. .list-item {
  490. color: #bbbbbb;
  491. display: flex;
  492. margin-bottom: 8px;
  493. .list-name {
  494. color: #f3c11d;
  495. margin-right: 6px;
  496. img {
  497. width: 17px;
  498. height: 13px;
  499. }
  500. }
  501. }
  502. }
  503. }
  504. .overview-file + .overview-file {
  505. margin-top: 8px;
  506. }
  507. .box-wrap {
  508. display: flex;
  509. .box-item {
  510. flex: 1;
  511. display: flex;
  512. flex-direction: column;
  513. justify-content: center;
  514. align-items: center;
  515. padding: 6px 16px;
  516. background: rgba(207, 207, 207, 0.1);
  517. border-radius: 4px;
  518. border: 1px solid rgba(207, 207, 207, 0.1);
  519. cursor: pointer;
  520. .item-name {
  521. font-size: 12px;
  522. color: #666666;
  523. width: max-content;
  524. }
  525. .item-val {
  526. font-size: 18px;
  527. color: #fff;
  528. width: max-content;
  529. padding-top: 3px;
  530. }
  531. &.active {
  532. background: rgba(255, 212, 137, 0.16);
  533. border: 1px solid #ffd489;
  534. .item-name {
  535. color: #bbbbbb;
  536. }
  537. }
  538. }
  539. .box-item + .box-item {
  540. margin-left: 8px;
  541. }
  542. }
  543. }
  544. }
  545. </style>
  546. <style lang="scss">
  547. .picture-preview-wrap {
  548. background: none;
  549. }
  550. </style>