Skip to content

岗位选择器组件

概述

PostSelector 是一个岗位选择组件,支持单选/多选岗位,通过弹窗展示岗位列表,支持搜索和分页加载。

组件路径web/apps/web-ele/src/components/zq-form/post-selector/

组件名称PostSelector

功能特性

  • 岗位列表展示
  • 支持单选/多选模式
  • 支持搜索过滤
  • 分页加载(触底加载更多)
  • 显示岗位名称和编码
  • 弹窗选择,左侧列表 + 右侧已选

Props

属性类型默认值说明
modelValuestring | string[]-选中的岗位 ID
multiplebooleanfalse是否多选
placeholderstring'请选择'占位符
disabledbooleanfalse是否禁用
clearablebooleantrue是否可清除
filterablebooleantrue是否可搜索

Events

事件参数说明
update:modelValuestring | string[] | undefined值更新
changestring | string[] | undefined值变化

Expose 方法

方法说明
openModal()打开岗位选择弹窗

使用示例

单选岗位

vue
<template>
  <PostSelector v-model="postId" placeholder="请选择岗位" />
</template>

<script setup>
import { ref } from 'vue';

const postId = ref('');
</script>

多选岗位

vue
<template>
  <PostSelector
    v-model="postIds"
    :multiple="true"
    placeholder="请选择岗位"
  />
</template>

<script setup>
import { ref } from 'vue';

const postIds = ref([]);
</script>

禁用状态

vue
<template>
  <PostSelector
    v-model="postId"
    :disabled="true"
  />
</template>

与表单设计器集成

在表单设计器中,该组件作为 post-selector 类型的表单项使用:

json
{
  "type": "post-selector",
  "field": "post_id",
  "label": "岗位",
  "props": {
    "multiple": false,
    "clearable": true,
    "filterable": true,
    "placeholder": "请选择岗位"
  }
}

弹窗布局

+------------------------------------------+
|  选择岗位                            [X] |
+------------------------------------------+
|  [搜索框]           |  已选 (2)    清空  |
|  ┌─────────────┐   |  ┌─────────────┐   |
|  │ 经理 manager│   |  │ 经理        │   |
|  │ 主管 leader │   |  │ 主管        │   |
|  │ 员工 staff  │   |  └─────────────┘   |
|  └─────────────┘   |                    |
+------------------------------------------+
|                    [取消]  [确认]        |
+------------------------------------------+

API 依赖

  • getPostListApi() - 获取岗位列表(分页)
  • getPostsByIds() - 根据 ID 批量获取岗位信息

典型应用场景

  • 用户岗位分配:为用户分配岗位
  • 组织架构管理:岗位关联配置
  • 审批流程:按岗位配置审批人

Released under the MIT License.