serviceRecords.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. flowStatus: "5",
  43. });
  44. if (data.length > 0) {
  45. recordList.value = data;
  46. }
  47. };
  48. // 处理列表项点击
  49. const handleItemClick = (data) => {
  50. router.push(`/review_work?miniJson={"id":${data.id},"goBack":true,"isBtn":true}`);
  51. };
  52. // 获取药肥处方文本(从prescriptionList中提取pesticideFertilizerList的defaultName,用+连接)
  53. const getPrescriptionText = (item) => {
  54. if (!item.prescriptionList || !Array.isArray(item.prescriptionList) || item.prescriptionList.length === 0) {
  55. return item.prescription || "暂无";
  56. }
  57. const nameList = [];
  58. item.prescriptionList.forEach((prescription) => {
  59. if (prescription.pesticideFertilizerList && Array.isArray(prescription.pesticideFertilizerList)) {
  60. prescription.pesticideFertilizerList.forEach((pesticide) => {
  61. if (pesticide.defaultName || pesticide.pesticideFertilizerName) {
  62. nameList.push(pesticide.defaultName || pesticide.pesticideFertilizerName);
  63. }
  64. });
  65. }
  66. });
  67. return nameList.length > 0 ? nameList.join(" + ") : item.prescription || "暂无";
  68. };
  69. </script>
  70. <style lang="scss" scoped>
  71. .service-records-page {
  72. width: 100%;
  73. min-height: 100vh;
  74. background: #f5f5f5;
  75. .record-list {
  76. padding: 10px 12px 20px;
  77. display: flex;
  78. flex-direction: column;
  79. gap: 14px;
  80. }
  81. .record-card {
  82. display: flex;
  83. gap: 16px;
  84. padding: 10px;
  85. background: #ffffff;
  86. border-radius: 16px;
  87. align-items: center;
  88. .thumb {
  89. width: 64px;
  90. height: 64px;
  91. border-radius: 8px;
  92. object-fit: cover;
  93. }
  94. .card-body {
  95. width: calc(100% - 64px - 16px);
  96. .card-header {
  97. display: flex;
  98. justify-content: space-between;
  99. align-items: center;
  100. .title {
  101. font-size: 16px;
  102. font-weight: 600;
  103. margin-bottom: 4px;
  104. }
  105. .date {
  106. font-size: 12px;
  107. color: #999999;
  108. }
  109. }
  110. .line {
  111. font-size: 12px;
  112. color: #666;
  113. display: flex;
  114. align-items: center;
  115. .label {
  116. color: #bbb;
  117. }
  118. .text {
  119. flex: 1;
  120. }
  121. }
  122. }
  123. }
  124. }
  125. </style>