compareDialog.vue 19 KB

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