recordsManage.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <div class="record-page" ref="containerRef">
  3. <div class="tips">
  4. <el-icon class="icon" size="24" color="#2199F8"><WarningFilled /></el-icon>
  5. <div>飞鸟提醒 您有 <span>1张</span> 农事照片未上传!农事将激活不了!用户将收不到农事消息哦~</div>
  6. </div>
  7. <div class="page-content">
  8. <div class="page-l">
  9. <el-affix :offset="120">
  10. <div class="menu-list">
  11. <el-anchor :container="containerRef" direction="vertical" type="default" @click="handleClick">
  12. <el-anchor-link
  13. v-for="(item, index) in farmWorkList"
  14. :key="index"
  15. :href="'#part' + index"
  16. :title="item.farmWorkLibName"
  17. >
  18. <div class="menu-item">
  19. <img
  20. class="menu-icon"
  21. :src="require('@/assets/images/records/icon-' + (index + 1) + '.png')"
  22. alt=""
  23. />
  24. <span>{{ item.farmWorkLibName }}</span>
  25. </div>
  26. </el-anchor-link>
  27. </el-anchor>
  28. </div>
  29. </el-affix>
  30. </div>
  31. <div class="page-r">
  32. <div v-for="(card, cardI) in farmWorkList" :key="cardI" class="done-card">
  33. <div class="id-positon" :id="'part' + cardI"></div>
  34. <div class="card-wrap">
  35. <div class="card-content">
  36. <div class="card-top">
  37. <div class="card-title serve-title">
  38. <div class="title-name">
  39. <span>{{ card.farmWorkLibName }}</span>
  40. <div class="edit-btn" @click="handleEdit('编辑农事', card)">
  41. <el-icon><Edit /></el-icon>
  42. <span>编辑</span>
  43. </div>
  44. </div>
  45. </div>
  46. <div>
  47. <div class="card-desc">
  48. <span class="desc-title">物候进程:</span>
  49. {{ card.whjc }}
  50. </div>
  51. <div class="card-desc">
  52. <span class="desc-title">执行时间:</span>
  53. {{ card.executeDate }}
  54. </div>
  55. <div class="card-desc">
  56. <span class="desc-title">生态理念:</span>
  57. {{ card.stln }}
  58. </div>
  59. <div class="card-desc condition-wrap">
  60. <div class="desc-title">农事目的:</div>
  61. <div>
  62. {{ card.targetText }}
  63. </div>
  64. </div>
  65. <div class="card-imgs" v-if="card?.images">
  66. <img-swipe :key="cardI" :imgsData="card.images"></img-swipe>
  67. </div>
  68. </div>
  69. <div class="card-link">
  70. <img class="expert-img" :src="card.expertPic" />
  71. <img class="expert-icon" src="@/assets/images/home/expert-icon.png" alt="" />
  72. <div class="expert-name">
  73. {{ card.expertName }}
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <editRecord
  84. v-if="showDialog"
  85. :rowData="rowData"
  86. :title="dialogTitle"
  87. :showDialog="showDialog"
  88. @closeDialog="handelDialog($event)"
  89. ></editRecord>
  90. <!-- 编辑弹窗 -->
  91. <!-- <el-dialog v-model="dialogVisible" title="编辑农事" align-center width="50%" :before-close="handleClose">
  92. <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="90px">
  93. <el-form-item label="农场名称" prop="name">
  94. <el-input v-model="ruleForm.name" disabled />
  95. </el-form-item>
  96. <el-form-item label="生态理念" prop="name">
  97. <el-input v-model="ruleForm.name" disabled />
  98. </el-form-item>
  99. <el-form-item label="农事目的" prop="name">
  100. <el-input v-model="ruleForm.name" disabled />
  101. </el-form-item>
  102. <el-form-item label="指导专家" prop="name">
  103. <el-input v-model="ruleForm.name" disabled />
  104. </el-form-item>
  105. <el-form-item label="执行时间" prop="time">
  106. <el-date-picker
  107. v-model="ruleForm.time"
  108. type="date"
  109. placeholder="请选择日期"
  110. :disabled-date="disabledDate"
  111. />
  112. </el-form-item>
  113. <el-form-item label="农事照片" prop="photo">
  114. <upload></upload>
  115. </el-form-item>
  116. </el-form>
  117. <template #footer>
  118. <div class="dialog-footer">
  119. <el-button @click="resetForm(ruleFormRef)">取消</el-button>
  120. <el-button type="primary" @click="submitForm(ruleFormRef)"> 确认修改 </el-button>
  121. </div>
  122. </template>
  123. </el-dialog> -->
  124. </template>
  125. <script setup>
  126. import { onMounted, reactive, ref } from "vue";
  127. import imgSwipe from "./imgSwipe.vue";
  128. import { useRoute } from "vue-router";
  129. import upload from "@/components/common/upload.vue";
  130. import eventBus from "@/api/eventBus";
  131. import editRecord from "./editRecord.vue";
  132. import { useStore } from "vuex";
  133. const store = useStore();
  134. const currentFarmId = store.getters.userinfo.curFarmId
  135. const disabledDate = (time) => {
  136. return time.getTime() > Date.now();
  137. };
  138. const ruleFormRef = ref(null);
  139. const ruleForm = reactive({
  140. name: "柏桥村",
  141. time: new Date(),
  142. photo:[]
  143. });
  144. function uploadCallback(e){
  145. ruleForm.photo = e
  146. }
  147. const submitForm = async (formEl) => {
  148. if (!formEl) return;
  149. await formEl.validate((valid, fields) => {
  150. if (valid) {
  151. console.log("submit!");
  152. resetForm(formEl);
  153. } else {
  154. console.log("error submit!", fields);
  155. }
  156. });
  157. };
  158. const resetForm = (formEl) => {
  159. if (!formEl) return;
  160. formEl.resetFields();
  161. eventBus.emit("upload:reset");
  162. dialogVisible.value = false;
  163. };
  164. const rules = reactive({
  165. time: { required: true, message: "请选择日期", trigger: "blur" },
  166. photo: { required: true, message: "请上传照片", trigger: "blur" },
  167. });
  168. const dialogVisible = ref(false);
  169. const showDialog = ref(false);
  170. const rowData = ref(null);
  171. const dialogTitle = ref("");
  172. /**
  173. * @description:添加or编辑事件
  174. * @param {*}
  175. * @return {*}
  176. */
  177. const handleEdit = (title, row = null) => {
  178. console.log('row', row);
  179. showDialog.value = true;
  180. dialogTitle.value = title;
  181. rowData.value = row;
  182. if (!row) {
  183. rowData.value = {farmId:row.farmId};
  184. }
  185. };
  186. const handelDialog = (e) => {
  187. showDialog.value = false
  188. getData();
  189. };
  190. const handleClose = () => {
  191. resetForm(ruleFormRef.value);
  192. };
  193. const route = useRoute();
  194. const containerRef = ref(null);
  195. const handleClick = (e) => {
  196. e.preventDefault();
  197. const href = e.target.getAttribute("href"); // 获取目标 hash(如 #part1)
  198. if (href) {
  199. const target = document.querySelector(href); // 找到目标元素
  200. if (target) {
  201. target.scrollIntoView({ behavior: "smooth" }); // 平滑滚动
  202. }
  203. }
  204. };
  205. const farmId = ref(null);
  206. onMounted(() => {
  207. getData();
  208. eventBus.off('upload:change',uploadCallback)
  209. eventBus.on('upload:change',uploadCallback)
  210. });
  211. function getData() {
  212. VE_API.home.getFarmBuyAutoList({ farmId: currentFarmId }).then(({ data }) => {
  213. farmWorkList.value = data;
  214. });
  215. }
  216. const farmWorkList = ref([]);
  217. </script>
  218. <style lang="scss" scoped>
  219. .record-page {
  220. width: 100%;
  221. height: 100%;
  222. position: relative;
  223. overflow: auto;
  224. .tips {
  225. color: #000;
  226. border: 1px solid rgba(33, 153, 248, 0.74);
  227. padding: 12px 10px;
  228. border-radius: 5px;
  229. display: flex;
  230. align-items: center;
  231. font-size: 15px;
  232. margin-top: 10px;
  233. .icon {
  234. margin-right: 12px;
  235. }
  236. span {
  237. color: #2199f8;
  238. font-size: 16px;
  239. }
  240. }
  241. ::v-deep {
  242. .el-affix {
  243. background: #f2f2f4;
  244. border-radius: 0 4px 4px 0;
  245. width: 90px !important;
  246. & > div {
  247. height: 100%;
  248. }
  249. }
  250. .el-anchor.el-anchor--vertical .el-anchor__list {
  251. padding-left: 0;
  252. }
  253. .el-anchor {
  254. background: #f2f3f5;
  255. }
  256. .el-anchor__item {
  257. justify-content: center;
  258. align-items: center;
  259. margin-top: 20px;
  260. }
  261. .el-anchor__marker {
  262. display: none;
  263. }
  264. .el-anchor__link {
  265. width: 90px;
  266. background: #f2f3f5;
  267. padding: 6px 0;
  268. font-size: 13px;
  269. line-height: 20px;
  270. color: #666666;
  271. text-align: center;
  272. &.is-active {
  273. background: #2199f8;
  274. color: #fff;
  275. }
  276. }
  277. }
  278. .page-content {
  279. padding-top: 10px;
  280. height: 100%;
  281. display: flex;
  282. .page-l {
  283. height: 100%;
  284. width: 90px;
  285. background: #f2f3f5;
  286. border-radius: 0 10px 10px 0;
  287. .menu-item {
  288. display: flex;
  289. align-items: center;
  290. justify-content: start;
  291. padding-left: 10px;
  292. .menu-icon {
  293. width: 14px;
  294. padding-right: 4px;
  295. }
  296. }
  297. .menu-list {
  298. height: calc(100vh - 166px);
  299. overflow: auto;
  300. }
  301. }
  302. .page-r {
  303. width: calc(100% - 90px - 20px);
  304. height: 100%;
  305. margin: 0 10px 10px 10px;
  306. .done-card {
  307. margin-bottom: 10px;
  308. .id-positon {
  309. position: relative;
  310. top: -44px;
  311. }
  312. &:last-child {
  313. .card-wrap {
  314. padding-bottom: 30px;
  315. }
  316. }
  317. }
  318. }
  319. .card-content {
  320. background: #fff;
  321. border-radius: 8px;
  322. padding: 0 8px 8px 8px;
  323. // border: 1px solid #2199f8;
  324. &.push {
  325. padding: 0 8px 12px 8px;
  326. }
  327. &.hasBg {
  328. padding: 0 8px 12px 8px;
  329. background: #fff;
  330. border: 1px solid rgba(102, 102, 102, 0.38);
  331. .card-top {
  332. border-bottom: none;
  333. padding-bottom: 0;
  334. }
  335. }
  336. .card-top {
  337. position: relative;
  338. &.noChart {
  339. border-bottom: 0;
  340. padding-bottom: 0;
  341. }
  342. .card-title {
  343. display: flex;
  344. align-items: center;
  345. padding-bottom: 8px;
  346. .serve-btn {
  347. padding: 3px 10px;
  348. background: #2199f8;
  349. border-radius: 22px;
  350. color: #fff;
  351. text-align: center;
  352. }
  353. .title-name {
  354. color: #000000;
  355. font-size: 16px;
  356. padding-right: 8px;
  357. font-weight: 600;
  358. display: flex;
  359. align-items: center;
  360. .edit-btn {
  361. margin-left: 10px;
  362. color: #fff;
  363. font-size: 12px;
  364. padding: 2px 6px;
  365. border-radius: 3px;
  366. font-weight: 400;
  367. background: #2199f8;
  368. display: flex;
  369. align-items: center;
  370. cursor: pointer;
  371. span {
  372. margin-left: 4px;
  373. }
  374. }
  375. }
  376. img {
  377. width: 24px;
  378. }
  379. .status-tag {
  380. color: #f3a302;
  381. font-size: 12px;
  382. padding: 2px 6px;
  383. border-radius: 2px;
  384. background: rgba(243, 163, 2, 0.2);
  385. margin-right: 10px;
  386. &.blue {
  387. color: #2199f8;
  388. background: rgba(33, 153, 248, 0.2);
  389. }
  390. &.good-wrap {
  391. margin-left: 4px;
  392. display: flex;
  393. align-items: center;
  394. .good {
  395. margin-left: 3px;
  396. width: 13px;
  397. }
  398. }
  399. &.standard {
  400. color: #2199f8;
  401. background: rgba(33, 153, 248, 0.2);
  402. }
  403. &.advice {
  404. color: rgba(252, 167, 3, 0.9);
  405. background: rgba(255, 220, 104, 0.38);
  406. }
  407. &.warning {
  408. color: #ff4221;
  409. background: rgba(255, 175, 160, 0.24);
  410. }
  411. }
  412. &.serve-title {
  413. padding: 12px 0 8px 0;
  414. display: flex;
  415. align-items: center;
  416. position: relative;
  417. .add-btn {
  418. position: absolute;
  419. right: -9px;
  420. top: -1px;
  421. background: #2199f8;
  422. color: #fff;
  423. font-size: 12px;
  424. border-radius: 0 8px 0 8px;
  425. padding: 2px 6px;
  426. &.unactive {
  427. background: #c3c3c3;
  428. }
  429. &.recheck {
  430. background: #f3c11d;
  431. }
  432. }
  433. .tag {
  434. display: flex;
  435. align-items: center;
  436. color: #ff7000;
  437. font-size: 10px;
  438. .desc {
  439. position: relative;
  440. left: -4px;
  441. }
  442. .photo-grid {
  443. display: flex;
  444. .photo {
  445. position: relative;
  446. img {
  447. width: 18px; /* 示例宽度,你可以根据需要调整 */
  448. height: 18px;
  449. object-fit: cover;
  450. border-radius: 50%;
  451. display: block; /* 去除图片底部的空白间隙 */
  452. }
  453. }
  454. }
  455. }
  456. }
  457. }
  458. .card-desc {
  459. color: #666666;
  460. font-size: 12px;
  461. line-height: 18.2px;
  462. &.van-ellipsis {
  463. max-width: 142px;
  464. }
  465. &.last-desc {
  466. display: flex;
  467. }
  468. .desc-title {
  469. color: #b6b6b6;
  470. }
  471. &.condition-wrap {
  472. display: flex;
  473. .desc-title {
  474. flex: none;
  475. }
  476. }
  477. .rescription-wrap {
  478. display: flex;
  479. align-items: center;
  480. .detail-text {
  481. color: #2199f8;
  482. padding-left: 6px;
  483. }
  484. }
  485. .rescription {
  486. max-width: 170px;
  487. white-space: nowrap;
  488. overflow: hidden;
  489. text-overflow: ellipsis;
  490. }
  491. .expert-link {
  492. display: inline-flex;
  493. align-items: center;
  494. color: #2199f8;
  495. .icon {
  496. padding-left: 4px;
  497. }
  498. }
  499. }
  500. .step-box {
  501. position: absolute;
  502. right: 0px;
  503. top: 15px;
  504. }
  505. .card-tips {
  506. font-size: 12px;
  507. color: #f5bc00;
  508. padding: 3px;
  509. background: rgba(243, 193, 29, 0.13);
  510. border-radius: 5px;
  511. text-align: center;
  512. margin: 8px 0;
  513. &.check {
  514. display: flex;
  515. align-items: center;
  516. justify-content: center;
  517. color: #2199f8;
  518. background: rgba(33, 153, 248, 0.1);
  519. padding: 5px;
  520. margin-bottom: 0;
  521. .icon {
  522. margin-right: 6px;
  523. font-size: 15px;
  524. }
  525. }
  526. }
  527. .card-tips-btn {
  528. .text {
  529. display: flex;
  530. align-items: center;
  531. span {
  532. margin-left: 4px;
  533. }
  534. }
  535. display: flex;
  536. justify-content: space-between;
  537. align-items: center;
  538. font-size: 12px;
  539. color: #fff;
  540. padding: 5px;
  541. border-radius: 5px;
  542. background: #2199f8;
  543. }
  544. .card-imgs {
  545. padding: 10px 0 4px 0;
  546. }
  547. .tree-img {
  548. width: 100%;
  549. height: 150px;
  550. object-fit: cover;
  551. border-radius: 8px;
  552. }
  553. .card-link {
  554. display: flex;
  555. flex-direction: column;
  556. align-items: center;
  557. justify-content: center;
  558. color: #2199f8;
  559. font-size: 12px;
  560. position: absolute;
  561. right: 6px;
  562. top: 10px;
  563. .expert-name {
  564. background: #d3e8ff;
  565. border-radius: 4px;
  566. padding: 2px 6px 3px 10px;
  567. margin-top: 4px;
  568. display: flex;
  569. align-items: center;
  570. }
  571. .expert-img {
  572. width: 43px;
  573. height: 43px;
  574. border-radius: 50%;
  575. object-fit: cover;
  576. }
  577. .expert-icon {
  578. width: 21px;
  579. height: 21px;
  580. position: absolute;
  581. right: 0;
  582. }
  583. .icon {
  584. padding-right: 2px;
  585. }
  586. }
  587. }
  588. }
  589. }
  590. }
  591. ::v-deep {
  592. .el-date-editor.el-input,
  593. .el-date-editor.el-input__wrapper {
  594. width: 100%;
  595. }
  596. }
  597. .dialog-footer {
  598. text-align: center;
  599. padding-top: 10px;
  600. border-top: 1px solid rgba(0, 0, 0, 0.2);
  601. }
  602. </style>