1.1.4 • Published 2 years ago

mobile-org v1.1.4

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

Mobile Org

Introduction

移动端组织架构数据选择方案,包括组织机构、角色以及人员等分类,支持单选、多选、关键字段自定义以及多种事件及插槽等,适用于大部分组织选人场景。

  • 支持懒加载回调,点击获取当前组织下的子组织及人员等
  • 支持单选、多选、必选等条件限制
  • 支持自定义子节点、key 值、头像等字段
  • 支持自定义可选类型
  • 多事件绑定类型,实现全生命周期全监测
  • 多部位插槽,支持默认样式以及快速实现定制化

Modules

Instructions

Functional demonstration

单选.gif多选.gif搜索.gif
单选多选搜索

Links

Attributes

proptypeoptionsdefaultdescription
dataArray[]渲染数据源
labelStringname展示字段名称
nodeKeyStringid数据 key(如: id)
childrenStringchildren子节点的字段名称
iconStringavatar头像的字段名称
isShowClearBtnBooleantrue是否显示搜索框右侧的清除按钮
isShowIconBooleanfalse是否显示图标
defaultIconString默认图标,本地图片引用::defaultIcon="require('@/assets/demo/icon.jpg')"
checkboxStyleStringround/squareround复选框显示样式,正方形 square 或圆形 round
isMultipleBooleantrue是否多选
selectTypesArray'user', 'org', 'role'可选项,user 用户,org,组织部门,role 角色
isSelectRequiredBooleantrue是否必选
selectedListArray[]已经选择的数据,可用作回显
slideDistanceNumber100滑动手时触发距离
searchPlaceholderString搜索搜索框提示占位符文字
defaultShowTypeStringorg/roleorg默认展示类型
orgTextString组织切换按钮 org 文字
roleTextString角色切换按钮 role 文字
submitTextString提交提交按钮文字
cancelTextString取消取消按钮文字

Events

namedescriptionparameterremark
on-select点击选项时触发,返回当前点击的选项信息item
on-submit提交时触发,返回所有已选项selectedItems
on-cancel点击取消按钮时候触发,可用来关闭组件等
on-search搜索框输入时候触发searchKey
on-expand点击下级时候触发currentNode
on-nav点击面包屑导航时触发currentNode返回 -1 时为点击全部
on-clear点击清除搜索框时候触发
on-slide滑动手势触发的事件
on-switch-show-type点击切换显示类型按钮触发showType

Slots

namedescriptionparameter
switch-show-type-btn切换显示类型按钮插槽showType
content-area中间内容区renderData
empty-tips无数据时提示信息
selected-list已经选择项的集合展示区selectedItems
result-area底部操作区selectedItems

Install

npm install mobile-org -S

Quick Start

import Vue from "vue";

// import mobile-org component
import MobileOrg from "mobile-org";
// import mobile-org style file
import "mobile-org/mobile-org.css";

Vue.use(MobileOrg);

Demo

<MobileOrg
  :data="data"
  label="name"
  children="children"
  icon="avatar"
  :isMultiple="true"
  :selectedList="selectedList"
  @on-submit="handleSubmit"
  @on-search="handleSearch"
  @on-expand="handleExpand"
  @on-nav="handleNav"
  @on-clear="clearSearchKey"
  @on-switch-show-type="handleSwitchShowType"
>
  <!-- 此处示例插槽只做展示,非必需,如无特殊需求,不建议使用。 -->
  <!-- 切换显示类型按钮插槽 -->
  <template slot="switch-show-type-btn" slot-scope="scope">
    通过 scope.showType 来获取切换的显示类型
  </template>

  <!-- 内容区插槽 -->
  <template slot="content-area" slot-scope="scope">
    通过 scope.renderData 来获取显示区数据
  </template>

  <!-- 无数据提示信息插槽 -->
  <template slot="empty-tips"> 暂无数据 </template>

  <!-- 底部已选项展示区插槽 -->
  <template slot="selected-list" slot-scope="scope">
    通过 scope.selectedItems 来获取已选项数据
  </template>

  <!-- 底部操作区插槽 -->
  <template slot="result-area" slot-scope="scope">
    通过 scope.selectedItems 来获取已选项数据
  </template>
</MobileOrg>

Function realization

数据渲染

data 绑定对应数据即可

// 需将数据转换为以下结构(以组织部分代码为例), name 和 id 可通过 prop 属性进行自定义
[
  {
    name: "研发部",
    id: "3zs96s5ddds2c4f1re5",
    children: [],
    type: "org",
    avatar: "",
  },
  {
    name: "人事部",
    id: "5ef2eo2qwh56yil15wa",
    avatar: "",
    type: "org",
    children: [
      {
        name: "培训组",
        id: "a3s5d21v4forut96521",
        avatar: "",
        type: "org",
        children: [
          {
            name: "张晓丽",
            id: "3a6s5d2f8d555e4r1fp",
            type: "user",
            avatar: "",
          },
        ],
      },
      {
        name: "赵海",
        id: "a8s5d4c111d4f5e2f3s",
        type: "user",
        avatar: "",
      },
    ],
  },
];

获取下级数据

  1. 通过 on-expand 事件来获取当前级信息
  2. 通过当前级 id 或其他标识来请求下级信息并将返回值赋值给 data

单选/多选

通过给 isMultiple 绑定 false 或 `true 来实现单选/多选

提交数据

通过 on-submit 绑定的事件来获取已选项信息

搜索数据

通过 on-search 事件来获取搜索关键字并作出对应操作

清空搜索关键字

  1. 通过 on-clear 事件来清空搜索关键字
  2. 重新获取数据并赋值给 data

切换显示类型

  1. 通过 on-switch-show-type 事件来切换显示类型
  2. 根据显示类型获取对应的数据
  3. 将获取的数据赋值给 data

点击导航

  1. 通过 on-nav 事件获取当前点击的导航信息
  2. 根据导航信息来获取对应的数据
  3. 将获取的数据赋值给 data
  4. 接收参数为 -1 时,表示当前点击的为 全部

:rocket: Top

1.1.1

2 years ago

1.1.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago