爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
5.6 KiB

3 weeks ago
6 days ago
3 weeks ago
3 weeks ago
3 weeks ago
6 days ago
3 weeks ago
6 days ago
3 weeks ago
6 days ago
6 days ago
3 weeks ago
6 days ago
3 weeks ago
3 weeks ago
  1. <template>
  2. <view class="staff-manage-container">
  3. <!-- 下拉刷新提示 -->
  4. <view v-if="refreshing" class="refresh-tip-bar">
  5. <uni-icons type="loading" size="22" color="#ffb400" class="refresh-loading-icon" />
  6. <text class="refresh-tip-text">正在刷新...</text>
  7. </view>
  8. <!-- 顶部导航栏 -->
  9. <view class="navbar" :style="navbarStyle">
  10. <view class="nav-left" @tap="goBack">
  11. <uni-icons type="back" size="24" color="#222" />
  12. </view>
  13. <view class="nav-title">员工管理</view>
  14. <view class="nav-right">
  15. <!-- <uni-icons type="more-filled" size="24" color="#222" style="margin-right: 16rpx;" />
  16. <uni-icons type="scan" size="24" color="#222" /> -->
  17. </view>
  18. </view>
  19. <view class="staff-list" :style="{marginTop: navBarRealHeight + 'px'}">
  20. <view v-for="(staff, idx) in staffList" :key="idx" class="staff-card" @tap="goStaffDetail(staff)">
  21. <view class="staff-info-row">
  22. <text class="staff-label">姓名</text>
  23. <text class="staff-value">{{ staff.name }}</text>
  24. </view>
  25. <view class="staff-info-row">
  26. <text class="staff-label">角色</text>
  27. <text class="staff-value">{{ staff.role }}</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import pullRefreshMixin from '../mixins/pullRefreshMixin.js'
  35. export default {
  36. mixins: [pullRefreshMixin],
  37. data() {
  38. return {
  39. staffList: [
  40. { name: '冯启彬', role: '质检员' },
  41. { name: '周琪', role: '质检员' },
  42. { name: '王凡玄', role: '质检员' },
  43. { name: '李世海', role: '质检员' },
  44. { name: '李娅', role: '质检员' },
  45. { name: '郑婷雅', role: '质检员' },
  46. { name: '冯思钰', role: '质检员' },
  47. ],
  48. statusBarHeight: 0,
  49. navBarRealHeight: 0,
  50. refreshing: false
  51. }
  52. },
  53. computed: {
  54. navbarStyle() {
  55. return `padding-top: ${this.statusBarHeight}px;`;
  56. }
  57. },
  58. onLoad() {
  59. uni.getSystemInfo({
  60. success: (res) => {
  61. this.statusBarHeight = res.statusBarHeight || 20;
  62. }
  63. });
  64. this.$nextTick(() => {
  65. uni.createSelectorQuery().select('.navbar').boundingClientRect(rect => {
  66. if (rect) {
  67. this.navBarRealHeight = rect.height;
  68. }
  69. }).exec();
  70. });
  71. // 获取员工列表
  72. this.fetchStaffList();
  73. // 监听刷新事件
  74. uni.$on('refreshStaffList', this.fetchStaffList);
  75. },
  76. onUnload() {
  77. uni.$off('refreshStaffList', this.fetchStaffList);
  78. },
  79. methods: {
  80. goBack() {
  81. uni.navigateBack();
  82. },
  83. goStaffDetail(staff) {
  84. uni.navigateTo({
  85. url: '/pages/manager/staff-detail',
  86. success: (res) => {
  87. res.eventChannel.emit('staffDetail', staff);
  88. }
  89. });
  90. },
  91. refreshData() {
  92. // TODO: 实现员工列表刷新逻辑,如重新请求接口
  93. },
  94. async onRefresh() {
  95. await this.refreshData && this.refreshData()
  96. },
  97. async fetchStaffList() {
  98. try {
  99. const res = await this.$api('getMyTeamList', { pageSize: 1000, current: 1 });
  100. if (res && res.code === 200 && res.result && Array.isArray(res.result.records)) {
  101. this.staffList = res.result.records
  102. .filter(user => user.role == 1 || user.role == 0 || user.role == 2)
  103. .map(user => ({
  104. id: user.id,
  105. name: user.nickName || '-',
  106. role: user.role == 1 ? '质检员' : user.role == 2 ? '管理员' : '用户'
  107. }));
  108. }
  109. } catch (e) {
  110. uni.showToast({ title: '获取员工列表失败', icon: 'none' });
  111. }
  112. },
  113. },
  114. onPullDownRefresh() {
  115. this.refreshing = true;
  116. Promise.resolve(this.fetchStaffList()).finally(() => {
  117. this.refreshing = false;
  118. uni.stopPullDownRefresh();
  119. });
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .staff-manage-container {
  125. min-height: 100vh;
  126. background: #f7f7f7;
  127. padding-bottom: 40rpx;
  128. }
  129. .refresh-tip-bar {
  130. position: fixed;
  131. top: 0;
  132. left: 0;
  133. width: 100vw;
  134. height: 80rpx;
  135. background: #fffbe6;
  136. color: #ffb400;
  137. font-size: 30rpx;
  138. font-weight: 500;
  139. text-align: center;
  140. line-height: 80rpx;
  141. z-index: 9999;
  142. box-shadow: 0 2rpx 8rpx rgba(255, 156, 0, 0.03);
  143. display: flex;
  144. align-items: center;
  145. justify-content: center;
  146. }
  147. .refresh-loading-icon {
  148. margin-right: 16rpx;
  149. }
  150. .refresh-tip-text {
  151. font-size: 30rpx;
  152. color: #ffb400;
  153. }
  154. .navbar {
  155. position: fixed;
  156. top: 0;
  157. left: 0;
  158. width: 100vw;
  159. height: 100rpx;
  160. background: #fff;
  161. z-index: 10;
  162. display: flex;
  163. align-items: flex-end;
  164. justify-content: space-between;
  165. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
  166. padding: 0 32rpx;
  167. .nav-left {
  168. flex: 0 0 48rpx;
  169. display: flex;
  170. align-items: center;
  171. height: 100%;
  172. }
  173. .nav-title {
  174. flex: 1;
  175. text-align: center;
  176. font-size: 36rpx;
  177. font-weight: bold;
  178. color: #222;
  179. line-height: 100rpx;
  180. }
  181. .nav-right {
  182. flex: 0 0 80rpx;
  183. display: flex;
  184. align-items: center;
  185. justify-content: flex-end;
  186. height: 100%;
  187. }
  188. }
  189. .staff-list {
  190. margin-top: calc(100rpx + var(--status-bar-height));
  191. padding: 32rpx 0;
  192. min-height: calc(100vh - 100rpx - var(--status-bar-height));
  193. box-sizing: border-box;
  194. }
  195. .staff-card {
  196. background: #fff;
  197. border-radius: 40rpx;
  198. margin: 0 32rpx 32rpx 32rpx;
  199. padding: 40rpx 36rpx 36rpx 36rpx;
  200. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
  201. }
  202. .staff-info-row {
  203. display: flex;
  204. align-items: center;
  205. margin-bottom: 18rpx;
  206. .staff-label {
  207. font-size: 30rpx;
  208. color: #b3b3b3;
  209. width: 110rpx;
  210. font-weight: 400;
  211. }
  212. .staff-value {
  213. font-size: 32rpx;
  214. color: #222;
  215. font-weight: 500;
  216. }
  217. }
  218. </style>