wlzboy
2025-12-03 656d6f8029f8bf9b2daa9dcc89101a879a70b860
app/pagesTask/components/StaffSelector.vue
@@ -6,11 +6,6 @@
        <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)"
@@ -56,11 +51,6 @@
        <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>
@@ -90,16 +80,6 @@
              </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 
@@ -169,7 +149,7 @@
      allStaffList: [],
      filteredStaffList: [],
      staffSearchKeyword: '',
      staffFilterType: 'all'
      staffFilterType: 'driver' // 默认选中司机
    }
  },
  computed: {
@@ -304,7 +284,7 @@
    closeStaffSelector() {
      this.$refs.staffPopup.close()
      this.staffSearchKeyword = ''
      this.staffFilterType = 'all'
      this.staffFilterType = 'driver' // 重置为默认司机
    },
    
    // 人员搜索
@@ -323,11 +303,6 @@
    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()
@@ -336,6 +311,16 @@
                 (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
    },
@@ -354,7 +339,7 @@
        this.selectedStaff.splice(index, 1)
      } else {
        // 未选中,添加
        this.selectedStaff.push(staff)
        this.selectedStaff.push({ ...staff })
      }
    },