| | |
| | | <view class="staff-item" v-for="(staff, index) in selectedStaff" :key="staff.userId"> |
| | | <view class="staff-info"> |
| | | <text class="staff-name">{{ staff.nickName }}</text> |
| | | <view class="staff-roles"> |
| | | <text class="staff-role" v-for="(roleType, idx) in staff.types" :key="idx"> |
| | | {{ getUserTypeName(roleType) }} |
| | | </text> |
| | | </view> |
| | | </view> |
| | | <uni-icons |
| | | v-if="canRemove(index)" |
| | |
| | | <view class="staff-filter"> |
| | | <view |
| | | class="filter-item" |
| | | :class="{ active: staffFilterType === 'all' }" |
| | | @click="filterStaff('all')" |
| | | >全部</view> |
| | | <view |
| | | class="filter-item" |
| | | :class="{ active: staffFilterType === 'driver' }" |
| | | @click="filterStaff('driver')" |
| | | >司机</view> |
| | |
| | | </view> |
| | | <view class="staff-detail-row"> |
| | | <text class="staff-dept">{{ staff.deptName }}</text> |
| | | <view class="staff-types"> |
| | | <text |
| | | class="type-tag" |
| | | :class="'type-' + type" |
| | | v-for="(type, idx) in staff.types" |
| | | :key="idx" |
| | | > |
| | | {{ getUserTypeName(type) }} |
| | | </text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <uni-icons |
| | |
| | | allStaffList: [], |
| | | filteredStaffList: [], |
| | | staffSearchKeyword: '', |
| | | staffFilterType: 'all' |
| | | staffFilterType: 'driver' // 默认选中司机 |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | closeStaffSelector() { |
| | | this.$refs.staffPopup.close() |
| | | this.staffSearchKeyword = '' |
| | | this.staffFilterType = 'all' |
| | | this.staffFilterType = 'driver' // 重置为默认司机 |
| | | }, |
| | | |
| | | // 人员搜索 |
| | |
| | | filterStaffList() { |
| | | let list = [...this.allStaffList] |
| | | |
| | | // 按类型过滤(支持多类型) |
| | | if (this.staffFilterType !== 'all') { |
| | | list = list.filter(staff => staff.types.includes(this.staffFilterType)) |
| | | } |
| | | |
| | | // 按关键词搜索 |
| | | if (this.staffSearchKeyword && this.staffSearchKeyword.trim() !== '') { |
| | | const keyword = this.staffSearchKeyword.trim().toLowerCase() |
| | |
| | | (staff.phonenumber && staff.phonenumber.includes(keyword)) |
| | | }) |
| | | } |
| | | |
| | | // 根据选中的类型,将有该身份的人排在前面 |
| | | list.sort((a, b) => { |
| | | const aHasType = a.types.includes(this.staffFilterType) |
| | | const bHasType = b.types.includes(this.staffFilterType) |
| | | |
| | | if (aHasType && !bHasType) return -1 // a有该身份,排前面 |
| | | if (!aHasType && bHasType) return 1 // b有该身份,排前面 |
| | | return 0 // 都有或都没有,保持原顺序 |
| | | }) |
| | | |
| | | this.filteredStaffList = list |
| | | }, |
| | |
| | | this.selectedStaff.splice(index, 1) |
| | | } else { |
| | | // 未选中,添加 |
| | | this.selectedStaff.push(staff) |
| | | this.selectedStaff.push({ ...staff }) |
| | | } |
| | | }, |
| | | |