serviceRecords.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div class="service-records-page">
  3. <custom-header name="服务记录"></custom-header>
  4. <div class="record-list">
  5. <div v-for="(item, index) in recordList" :key="index" class="record-card" @click="handleItemClick(item)">
  6. <img class="thumb" :src=" base_img_url2 + item.executeEvidenceList[0] + resize" alt="照片" />
  7. <div class="card-body">
  8. <div class="card-header">
  9. <div class="title van-ellipsis">{{ item.farmWorkName }}</div>
  10. <div class="date">{{ item.executeDate }}</div>
  11. </div>
  12. <div class="line">
  13. <span class="label">农场名称:</span>
  14. <span class="text van-ellipsis">{{ item.farmName }}</span>
  15. </div>
  16. <div class="line">
  17. <span class="label">药肥处方:</span>
  18. <span class="text van-ellipsis">{{ getPrescriptionText(item) }}</span>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script setup>
  26. import { ref, onMounted } from "vue";
  27. import customHeader from "@/components/customHeader.vue";
  28. import { useRouter } from "vue-router";
  29. import { base_img_url2 } from "@/api/config";
  30. const router = useRouter();
  31. const resize = "?x-oss-process=image/resize,w_300";
  32. // 服务记录列表数据
  33. const recordList = ref([]);
  34. onMounted(() => {
  35. getSimpleList();
  36. });
  37. const getSimpleList = async () => {
  38. const { data } = await VE_API.mine.getSimpleList({
  39. role: localStorage.getItem("SET_USER_CUR_ROLE"),
  40. includePrescription: true,
  41. isServiceRecord: true,
  42. });
  43. if (data.length > 0) {
  44. recordList.value = data;
  45. }
  46. };
  47. // 处理列表项点击
  48. const handleItemClick = (data) => {
  49. router.push(`/review_work?miniJson={"id":${data.id},"goBack":true,"isBtn":true}`);
  50. };
  51. // 获取药肥处方文本(从prescriptionList中提取pesticideFertilizerList的defaultName,用+连接)
  52. const getPrescriptionText = (item) => {
  53. if (!item.prescriptionList || !Array.isArray(item.prescriptionList) || item.prescriptionList.length === 0) {
  54. return item.prescription || "暂无";
  55. }
  56. const nameList = [];
  57. item.prescriptionList.forEach((prescription) => {
  58. if (prescription.pesticideFertilizerList && Array.isArray(prescription.pesticideFertilizerList)) {
  59. prescription.pesticideFertilizerList.forEach((pesticide) => {
  60. if (pesticide.defaultName) {
  61. nameList.push(pesticide.defaultName);
  62. }
  63. });
  64. }
  65. });
  66. return nameList.length > 0 ? nameList.join(" + ") : item.prescription || "暂无";
  67. };
  68. </script>
  69. <style lang="scss" scoped>
  70. .service-records-page {
  71. width: 100%;
  72. min-height: 100vh;
  73. background: #f5f5f5;
  74. .record-list {
  75. padding: 10px 12px 20px;
  76. display: flex;
  77. flex-direction: column;
  78. gap: 14px;
  79. }
  80. .record-card {
  81. display: flex;
  82. gap: 16px;
  83. padding: 10px;
  84. background: #ffffff;
  85. border-radius: 16px;
  86. align-items: center;
  87. .thumb {
  88. width: 64px;
  89. height: 64px;
  90. border-radius: 8px;
  91. object-fit: cover;
  92. }
  93. .card-body {
  94. width: calc(100% - 64px - 16px);
  95. .card-header {
  96. display: flex;
  97. justify-content: space-between;
  98. align-items: center;
  99. .title {
  100. font-size: 16px;
  101. font-weight: 600;
  102. margin-bottom: 4px;
  103. }
  104. .date {
  105. font-size: 12px;
  106. color: #999999;
  107. }
  108. }
  109. .line {
  110. font-size: 12px;
  111. color: #666;
  112. display: flex;
  113. align-items: center;
  114. .label {
  115. color: #bbb;
  116. }
  117. .text {
  118. flex: 1;
  119. }
  120. }
  121. }
  122. }
  123. }
  124. </style>