serviceRecords.vue 4.4 KB

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