selfCheck.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="self-check-container">
  3. <view class="self-check-header">
  4. <text class="header-title">定/自检</text>
  5. <text class="view-all" @click="goToSelfCheckPage('all')">查看全部</text>
  6. </view>
  7. <view class="self-check-content">
  8. <!-- 已过期定检提醒 -->
  9. <view class="check-section" v-if="expiredItems.length > 0">
  10. <view class="section-header">
  11. <text class="section-title">已过期定检提醒</text>
  12. <text class="view-more" @click="goToSelfCheckPage('expired')">查看更多</text>
  13. </view>
  14. <view class="check-item" v-for="(item, index) in expiredItems" :key="index">
  15. <view class="item-indicator expired"></view>
  16. <view class="item-content">
  17. <view class="item-row">
  18. <text class="item-label">{{ item.name }}</text>
  19. <text class="item-label">{{ item.serialNumber }}</text>
  20. <text class="item-date">{{ item.date }}</text>
  21. </view>
  22. <view class="item-row">
  23. <text class="item-label">{{ item.location }}</text>
  24. <text class="item-role">{{ item.role }}</text>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 两周内到期提醒 -->
  30. <view class="check-section" v-if="twoWeeksItems.length > 0">
  31. <view class="section-header">
  32. <text class="section-title">两周内到期提醒</text>
  33. <text class="view-more" @click="goToSelfCheckPage('twoWeeks')">查看更多</text>
  34. </view>
  35. <view class="check-item" v-for="(item, index) in twoWeeksItems" :key="index">
  36. <view class="item-indicator urgent"></view>
  37. <view class="item-content">
  38. <view class="item-row">
  39. <text class="item-label">{{ item.name }}</text>
  40. <text class="item-label">{{ item.serialNumber }}</text>
  41. <text class="item-date">{{ item.date }}</text>
  42. </view>
  43. <view class="item-row">
  44. <text class="item-label">{{ item.location }}</text>
  45. <text class="item-role">{{ item.role }}</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 一月内检到期提醒 -->
  51. <view class="check-section" v-if="oneMonthItems.length > 0">
  52. <view class="section-header">
  53. <text class="section-title">一月内检到期提醒</text>
  54. <text class="view-more" @click="goToSelfCheckPage('oneMonth')">查看更多</text>
  55. </view>
  56. <view class="check-item" v-for="(item, index) in oneMonthItems" :key="index">
  57. <view class="item-indicator normal"></view>
  58. <view class="item-content">
  59. <view class="item-row">
  60. <text class="item-label">{{ item.name }}</text>
  61. <text class="item-label">{{ item.serialNumber }}</text>
  62. <text class="item-date">{{ item.date }}</text>
  63. </view>
  64. <view class="item-row">
  65. <text class="item-label">{{ item.location }}</text>
  66. <text class="item-role">{{ item.role }}</text>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import { getDeviceList } from "@/api/home-new/home-new";
  76. export default {
  77. name: 'SelfCheck',
  78. data() {
  79. return {
  80. // 已过期定检数据
  81. expiredItems: [],
  82. // 两周内到期数据
  83. twoWeeksItems: [],
  84. // 一月内到期数据
  85. oneMonthItems: []
  86. }
  87. },
  88. mounted() {
  89. this.fetchDeviceList();
  90. },
  91. methods: {
  92. goToSelfCheckPage(tab) {
  93. uni.navigateTo({
  94. url: `/pages/selfCheck/index?tab=${tab}`
  95. });
  96. },
  97. fetchDeviceList() {
  98. // 分别请求三种颜色的数据
  99. Promise.all([
  100. getDeviceList({ colorType: 'RED' }), // 已过期 - 红色
  101. getDeviceList({ colorType: 'ORANGE' }), // 两周内到期 - 橙色
  102. getDeviceList({ colorType: 'YELLOW' }) // 一月内到期 - 黄色
  103. ]).then(results => {
  104. // 处理红色数据(已过期)
  105. if (results[0].code === 200) {
  106. this.expiredItems = (results[0].data || []).slice(0, 2).map(item => this.formatDeviceItem(item));
  107. }
  108. // 处理橙色数据(两周内到期)
  109. if (results[1].code === 200) {
  110. this.twoWeeksItems = (results[1].data || []).slice(0, 2).map(item => this.formatDeviceItem(item));
  111. }
  112. // 处理黄色数据(一月内到期)
  113. if (results[2].code === 200) {
  114. this.oneMonthItems = (results[2].data || []).slice(0, 2).map(item => this.formatDeviceItem(item));
  115. }
  116. }).catch(err => {
  117. console.error('获取设备列表失败', err);
  118. });
  119. },
  120. formatDeviceItem(item) {
  121. return {
  122. name: item.equipmentName || '空',
  123. serialNumber: item.equipmentCode || '空',
  124. location: item.installationLocation || '空',
  125. role:`${item.inspectionTeamLeaderName || ''}、${item.inspectionTeamMember1Name || ''}、${item.inspectionTeamMember2Name || ''}`|| '空',
  126. date: this.formatDate(item.nextInspectionDueDate)|| '空'
  127. };
  128. },
  129. formatDate(dateStr) {
  130. if (!dateStr) return '';
  131. const date = new Date(dateStr);
  132. const year = date.getFullYear();
  133. const month = String(date.getMonth() + 1).padStart(2, '0');
  134. const day = String(date.getDate()).padStart(2, '0');
  135. return `${year}-${month}-${day}`;
  136. }
  137. }
  138. }
  139. </script>
  140. <style scoped>
  141. .self-check-container {
  142. width: 100%;
  143. padding: 12px;
  144. background-color: #f5f7fa;
  145. }
  146. .self-check-header {
  147. display: flex;
  148. justify-content: space-between;
  149. align-items: center;
  150. margin-bottom: 12px;
  151. }
  152. .header-title {
  153. font-size: 20px;
  154. font-weight: bold;
  155. color: #333;
  156. }
  157. .view-all {
  158. font-size: 14px;
  159. color: #409eff;
  160. }
  161. .self-check-content {
  162. background-color: #fff;
  163. border-radius: 12px;
  164. padding: 12px;
  165. }
  166. .check-section {
  167. margin-bottom: 16px;
  168. }
  169. .check-section:last-child {
  170. margin-bottom: 0;
  171. }
  172. .section-header {
  173. display: flex;
  174. justify-content: space-between;
  175. align-items: center;
  176. margin-bottom: 10px;
  177. }
  178. .section-title {
  179. font-size: 16px;
  180. font-weight: bold;
  181. color: #333;
  182. }
  183. .view-more {
  184. font-size: 14px;
  185. color: #409eff;
  186. }
  187. .check-item {
  188. display: flex;
  189. align-items: flex-start;
  190. padding: 10px 0;
  191. border-bottom: 1px solid #f0f0f0;
  192. }
  193. .check-item:last-child {
  194. border-bottom: none;
  195. }
  196. .item-indicator {
  197. width: 6px;
  198. border-radius: 3px;
  199. margin-right: 10px;
  200. flex-shrink: 0;
  201. }
  202. .item-indicator.expired {
  203. background-color: #FF0000;
  204. height: 48px;
  205. }
  206. .item-indicator.urgent {
  207. background-color: #FFA500;
  208. height: 48px;
  209. }
  210. .item-indicator.normal {
  211. background-color: #FFD700;
  212. height: 48px;
  213. }
  214. .item-content {
  215. flex: 1;
  216. display: flex;
  217. flex-direction: column;
  218. gap: 6px;
  219. }
  220. .item-row {
  221. display: flex;
  222. justify-content: space-between;
  223. align-items: center;
  224. }
  225. .item-label {
  226. font-size: 14px;
  227. color: #333;
  228. }
  229. .item-date {
  230. font-size: 14px;
  231. color: #333;
  232. }
  233. .item-role {
  234. font-size: 14px;
  235. color: #333;
  236. }
  237. </style>