albumCarousel.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <el-dialog
  3. v-model="dialogVisible"
  4. width="65%"
  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="file-content">
  31. <div class="content-box">
  32. <div class="overview-file">
  33. <div class="box-title">总体档案</div>
  34. <!-- <div class="base-data">
  35. <div class="base-item" v-for="item in photoBaseData" :key="item.label">
  36. <span class="label">{{ item.label }}</span>
  37. <div class="value">{{ item.value }}</div>
  38. </div>
  39. </div> -->
  40. <div class="box-form">
  41. <el-form
  42. ref="ruleFormRef"
  43. :model="ruleForm"
  44. :rules="rules"
  45. label-position="left"
  46. label-width="92px"
  47. >
  48. <el-form-item label="品种" prop="pz">
  49. <el-input v-model="ruleForm.pz" placeholder="请输入品种" style="width: 240px;" />
  50. </el-form-item>
  51. <el-form-item label="树龄" prop="age">
  52. <el-input-number
  53. class="number-input"
  54. :controls="false"
  55. placeholder="请输入树龄"
  56. v-model="ruleForm.age"
  57. :min="0"
  58. style="width: 240px;"
  59. />
  60. </el-form-item>
  61. <el-form-item label="栽种时间" prop="time">
  62. <el-date-picker
  63. v-model="ruleForm.time"
  64. type="date"
  65. format="YYYY.MM.DD"
  66. style="width: 240px;"
  67. value-format="YYYY.MM.DD"
  68. placeholder="请选择栽种时间"
  69. />
  70. </el-form-item>
  71. <el-form-item label="守护人" prop="user">
  72. <el-select v-model="ruleForm.user" style="width: 240px;" placeholder="请选择守护人">
  73. <el-option label="张三" value="张三" />
  74. <el-option label="张四" value="张四" />
  75. </el-select>
  76. </el-form-item>
  77. </el-form>
  78. </div>
  79. </div>
  80. <div class="overview-file">
  81. <div class="box-title">产量详情</div>
  82. <div class="box-wrap">
  83. <div class="box-item" v-for="(item, index) in outputBox" :key="index">
  84. <div class="item-name">{{ item.name }}</div>
  85. <div class="item-val">{{ item.value }}</div>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="overview-file">
  90. <div class="box-title">质量详情</div>
  91. <div class="box-wrap">
  92. <div class="box-item" v-for="(item, index) in qualityBox" :key="index">
  93. <div class="item-name">{{ item.name }}</div>
  94. <div class="item-val">{{ item.value }}</div>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. <div class="btn-group">
  100. <div class="btn cancel-btn" @click="saveEdit(0)">取消</div>
  101. <div class="btn edit-btn" @click="saveEdit(1)">确认修改</div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </el-dialog>
  107. </template>
  108. <script setup>
  109. import { ref, computed, onMounted, reactive, onActivated } from "vue";
  110. import "./cacheImg.js";
  111. import AlbumCarouselItem from "./albumCarouselItem";
  112. import { dateFormat } from "@/utils/date_util.js";
  113. import eventBus from "@/api/eventBus";
  114. const lock = ref(false);
  115. const farmId = ref(766);
  116. const nameRef = ref("");
  117. const isLoadingImg = ref(true);
  118. const images = ref(null);
  119. const dialogVisible = ref(false);
  120. // 获取当前日期
  121. const currentDate = new Date();
  122. // 获取当前日期的前一个月
  123. const startDate = new Date(currentDate);
  124. startDate.setMonth(currentDate.getMonth() - 1);
  125. // 格式化日期
  126. const formattedStartDate = dateFormat(startDate, "YY-mm-dd");
  127. const formattedEndDate = dateFormat(currentDate, "YY-mm-dd");
  128. eventBus.on("change:watermark", function (name) {
  129. nameRef.value = name;
  130. });
  131. const outputBox = ref([
  132. { id: 1, name: "产量估计", value: "" },
  133. { id: 2, name: "高质果率", value: "" },
  134. ]);
  135. const qualityBox = ref([
  136. { id: 5, name: "通风率", value: "" },
  137. { id: 6, name: "透光率", value: "" },
  138. { id: 7, name: "病虫比例", value: "" },
  139. ]);
  140. const showTag = ref(false);
  141. eventBus.off("click:point", handleClickPoint);
  142. eventBus.on("click:point", handleClickPoint);
  143. function handleClickPoint({ farmId, sampleId, data }) {
  144. console.log("click:point");
  145. sampleId = data.id;
  146. getSampleFiles(data.geoHashSample);
  147. photoBaseData.value[0].value = data.pz;
  148. isLoadingImg.value = true;
  149. let startDate = new Date(currentDate);
  150. startDate.setMonth(currentDate.getMonth() - 2);
  151. // 格式化日期
  152. let params = { sampleId, farmId, startDate: dateFormat(startDate, "YY-mm-dd") };
  153. VE_API.miniimage.list(params).then((res) => {
  154. if (res.code === 0) {
  155. dialogVisible.value = true;
  156. images.value = res.data;
  157. isLoadingImg.value = false;
  158. }
  159. });
  160. showTag.value = data.nonghu == 1 ? true : false;
  161. }
  162. // eventBus.off("albumCarousel", toggleActiveImg);
  163. // eventBus.on("albumCarousel", toggleActiveImg);
  164. // const currentIndex = ref(0);
  165. // function toggleActiveImg(index) {
  166. // currentIndex.value = index;
  167. // }
  168. const getSampleFiles = (geoHash) => {
  169. VE_API.mini_farm.getSampleFiles({ geoHashSample: geoHash }).then(({ data }) => {
  170. photoBaseData.value[0].value = data.meta_info.type_id;
  171. let pj = "--";
  172. if (data.meta_info.crown) {
  173. pj = Math.sqrt(data.meta_info.crown * 1.2).toFixed(1);
  174. }
  175. photoBaseData.value[1].value = data.meta_info.crown + "平方米(蓬径" + pj + "米)";
  176. photoBaseData.value[2].value = data.meta_info.branch_num;
  177. photoBaseData.value[3].value = data.meta_info.age + "年";
  178. // if(data.production_info.production){
  179. // data.production_info.production = (data.production_info.production * 1.3).toFixed(1)
  180. // }
  181. outputBox.value[0].value = data.production_info.production + "斤";
  182. outputBox.value[1].value = data.production_info.quality.toFixed(0) + "%";
  183. qualityBox.value[0].value = data.ecology_info.ventilation + "%";
  184. qualityBox.value[1].value = data.ecology_info.transmittance + "%";
  185. qualityBox.value[2].value = data.ecology_info.dp_situation + "%";
  186. });
  187. };
  188. const photoBaseData = ref([
  189. {
  190. label: "品种",
  191. value: "--",
  192. },
  193. {
  194. label: "冠幅表面积",
  195. value: "--",
  196. },
  197. {
  198. label: "总枝条",
  199. value: "--",
  200. },
  201. {
  202. label: "树龄",
  203. value: "--",
  204. },
  205. ]);
  206. const activeOuput = ref(null);
  207. function closeDialog() {
  208. activeOuput.value = null;
  209. eventBus.emit("change:watermark", "");
  210. eventBus.emit("resetImgIndex");
  211. ruleFormRef.value.resetFields()
  212. }
  213. // 修改档案信息
  214. const ruleFormRef = ref();
  215. const ruleForm = reactive({
  216. pz: "",
  217. age: null,
  218. time: "",
  219. user: "",
  220. });
  221. const rules = reactive({
  222. pz: [{ required: true, message: "请输入品种", trigger: "blur" }],
  223. age: [{ required: true, message: "请输入树龄", trigger: "blur" }],
  224. time: [
  225. {
  226. type: "date",
  227. required: true,
  228. message: "请选择栽种时间",
  229. trigger: "change",
  230. },
  231. ],
  232. });
  233. async function saveEdit(isToSave) {
  234. if (isToSave) {
  235. // 保存
  236. await ruleFormRef.value.validate((valid, fields) => {
  237. if (valid) {
  238. console.log('submit!')
  239. } else {
  240. console.log('error submit!', fields)
  241. }
  242. })
  243. }
  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: #2199f8;
  261. display: flex;
  262. align-items: center;
  263. .tag {
  264. border: 1px solid #2199f8;
  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: #000000;
  286. &::before {
  287. content: "";
  288. position: absolute;
  289. left: 0;
  290. top: 5px;
  291. width: 3px;
  292. height: 16px;
  293. background: #000000;
  294. border-radius: 2px;
  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. .box-form {
  354. ::v-deep {
  355. .el-input-number .el-input__inner {
  356. text-align: left;
  357. }
  358. .el-form-item__label {
  359. font-size: 16px;
  360. }
  361. .el-form-item--default {
  362. margin-bottom: 12px;
  363. }
  364. }
  365. }
  366. }
  367. .btn-group {
  368. margin-top: 20px;
  369. display: flex;
  370. align-items: center;
  371. justify-content: end;
  372. width: 100%;
  373. padding: 10px 12px 0 12px;
  374. border-top: 1px solid rgba(0, 0, 0, 0.2);
  375. box-sizing: border-box;
  376. border-radius: 0 0 8px 8px;
  377. .btn {
  378. cursor: pointer;
  379. padding: 10px 20px;
  380. font-size: 14px;
  381. border-radius: 4px;
  382. color: #2199F8;
  383. }
  384. .cancel-btn {
  385. color: #000000;
  386. background: rgba(206, 206, 206, 0.4);
  387. }
  388. .edit-btn {
  389. background: #2199F8;
  390. color: #FFFFFF;
  391. }
  392. .btn + .btn {
  393. margin-left: 12px;
  394. }
  395. }
  396. .overview-file + .overview-file {
  397. margin-top: 8px;
  398. }
  399. .file-content {
  400. height: calc(100% - 30px);
  401. display: flex;
  402. flex-direction: column;
  403. .content-box {
  404. flex: 1;
  405. }
  406. }
  407. .box-wrap {
  408. display: flex;
  409. .box-item {
  410. min-width: 109px;
  411. box-sizing: border-box;
  412. display: flex;
  413. flex-direction: column;
  414. justify-content: center;
  415. align-items: center;
  416. padding: 6px;
  417. background: rgba(169, 169, 169, 0.1);
  418. border-radius: 4px;
  419. cursor: pointer;
  420. .item-name {
  421. font-size: 12px;
  422. color: rgba(102, 102, 102, 0.86);
  423. width: max-content;
  424. }
  425. .item-val {
  426. font-size: 18px;
  427. color: #000000;
  428. width: max-content;
  429. padding-top: 3px;
  430. }
  431. &.active {
  432. background: rgba(255, 212, 137, 0.16);
  433. border: 1px solid #ffd489;
  434. .item-name {
  435. color: #bbbbbb;
  436. }
  437. }
  438. }
  439. .box-item + .box-item {
  440. margin-left: 8px;
  441. }
  442. }
  443. }
  444. }
  445. </style>
  446. <style lang="scss">
  447. .picture-preview-wrap {
  448. background: none;
  449. }
  450. </style>