index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="container">
  3. <!-- 列表区域 -->
  4. <scroll-view class="scroll-container" scroll-y refresher-enabled @refresherrefresh="onRefresh"
  5. :refresher-triggered="isRefreshing">
  6. <view class="security-list">
  7. <view v-for="(item, index) in securityList" :key="index" class="security-card">
  8. <view class="card-left">
  9. <image class="avatar"
  10. :src="item.gender === '男' ? '../../static/img/anbaoimg/male.png' : '../../static/img/anbaoimg/female.png'"
  11. mode="aspectFill" />
  12. </view>
  13. <view class="card-middle">
  14. <text class="name">{{ item.name }}</text>
  15. <text class="phone">联系方式:{{ item.contactPhone }}</text>
  16. <text class="position">籍贯:{{ item.nativePlace }}</text>
  17. </view>
  18. <view class="card-right">
  19. <view class="action-buttons">
  20. <button size="mini" type="primary" class="action-btn"
  21. @tap.stop="onCardTap(item)">查看详情</button>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </scroll-view>
  27. </view>
  28. </template>
  29. <script lang="ts" setup>
  30. import { ref } from 'vue';
  31. import { clientGet } from '../../utils/request';
  32. interface SecurityPerson {
  33. name : string,
  34. birthDate : string,
  35. contactPhone : string,
  36. createBy : string,
  37. createTime : string,
  38. currentAddress : string,
  39. email : string,
  40. ethnicity : string,
  41. gender : string,
  42. id : number,
  43. idNumber : string,
  44. maritalStatus : string,
  45. nativePlace : string,
  46. updateBy : string,
  47. updateTime : string
  48. }
  49. const isRefreshing = ref(false);
  50. const currentPage = ref(1);
  51. const pageSize = ref(100);
  52. const total = ref(0);
  53. const securityList = ref<SecurityPerson[]>([]);
  54. const getEventList = async () => {
  55. const res = await clientGet("/park/securityPersonnel/findByPage", {
  56. pageNum: currentPage.value,
  57. pageSize: pageSize.value,
  58. })
  59. if (res.code !== 200) {
  60. uni.showToast({
  61. title: "请求数据失败",
  62. duration: 2000
  63. })
  64. }
  65. console.log("获取数据", res);
  66. securityList.value = res.records
  67. }
  68. getEventList()
  69. const onRefresh = () => {
  70. isRefreshing.value = true;
  71. setTimeout(() => {
  72. isRefreshing.value = false;
  73. }, 1000);
  74. };
  75. const onCardTap = (item : SecurityPerson) => {
  76. uni.navigateTo({
  77. url: `/pages/security/personnelDetails?name=${item.name}`
  78. })
  79. };
  80. </script>
  81. <style>
  82. page {
  83. height: 100%;
  84. }
  85. .container {
  86. height: 100%;
  87. display: flex;
  88. flex-direction: column;
  89. background-color: #f5f5f5;
  90. }
  91. .scroll-container {
  92. flex: 1;
  93. overflow: auto;
  94. }
  95. .security-list {
  96. padding: 20rpx;
  97. }
  98. .security-card {
  99. display: flex;
  100. align-items: center;
  101. padding: 30rpx;
  102. background-color: #ffffff;
  103. border-radius: 12rpx;
  104. margin-bottom: 20rpx;
  105. }
  106. .card-left {
  107. margin-right: 30rpx;
  108. flex-shrink: 0;
  109. }
  110. .avatar {
  111. width: 120rpx;
  112. height: 120rpx;
  113. border-radius: 60rpx;
  114. }
  115. .card-middle {
  116. flex: 1;
  117. display: flex;
  118. flex-direction: column;
  119. }
  120. .name {
  121. font-size: 16px;
  122. font-weight: 600;
  123. color: #333333;
  124. margin-bottom: 8rpx;
  125. }
  126. .phone {
  127. font-size: 14px;
  128. color: #666666;
  129. margin-bottom: 8rpx;
  130. }
  131. .position {
  132. font-size: 14px;
  133. color: #999999;
  134. }
  135. .card-right {
  136. display: flex;
  137. flex-direction: column;
  138. align-items: flex-end;
  139. flex-shrink: 0;
  140. }
  141. .status-tag {
  142. padding: 4rpx 16rpx;
  143. border-radius: 4rpx;
  144. font-size: 12px;
  145. margin-bottom: 16rpx;
  146. }
  147. .status-active {
  148. background-color: #e6f7ff;
  149. color: #1890ff;
  150. }
  151. .status-inactive {
  152. background-color: #fff1f0;
  153. color: #ff4d4f;
  154. }
  155. .action-buttons {
  156. display: flex;
  157. gap: 16rpx;
  158. }
  159. .action-btn {
  160. font-size: 12px;
  161. padding: 0 20rpx;
  162. }
  163. </style>