Skip to content

业务组件库 [@swing/widget-vue3]🚧 持续迭代中

  • 本页面汇总了 @swing/widget-vue3 业务组件库的所有组件

注意:在 vue 通过插件全局注册,在 template 模版中需要携带 Swing 前缀缩写S,类似 antdv 中的 a-button

安装

使用以下任一命令安装 @swing/widget-vue3

bash
pnpm i @swing/widget-vue3
bash
npm i @swing/widget-vue3
bash
yarn add @swing/widget-vue3

组件总览列表

点击跳转到对应模块或组件详细说明,也可通过页面右侧大纲快速定位 本组件库所有组件注册名均带有统一前缀 s-,实际注册名为 s-组件名小写中横线,如 UserAvatarWithOrg 实际注册为 s-user-avatar-with-org

所属模块组件名备注
systemUserAvatarWithOrg人员头像,人员信息和组织机构信息的展示组件
UserAssignmentModal穿梭框选择用户的组件
SelectUser下拉框选择用户组件
SelectUserByModal输入框点击弹出模态框,选择用户组件
AvatarDropdown用户下拉菜单组件
MentionUsers用户提及组件
OrganizationCascader组织机构级联选择组件
OrganizationTreeSelect组织机构树形选择组件
CommentList评论列表组件
LabelPrinting标签打印组件
gdsSelectDictionary选择字典组件
CalendarDateTag工作日历标签组件
EncodingGenerate编码生成组件
iotIotPointSelectIOT测点选择组件
IotDeviceCascaderIOT设备级联选择组件
IotMeasurementPointChartIOT测点图标展示组件
flowSubmitForApproval流程发起
ProcessApproval流程审批
ProcessStatus流程状态/流程审批人展示
noticeAppMessageTabCard应用内消息组件
NoticeList消息列表组件
NoticeOption消息选项组件

🗂️ 系统管理 [System]

简介

专为系统管理设计的 Vue 组件集合,提供用户管理、组织机构管理、评论等前端组件,支持下拉框选择用户、组织架构展示、评论交互等功能。

总览

组件名说明
userAvatarWithOrg用户头像和组织信息展示组件
userAssignmentModal穿梭框选择用户组件
selectUser下拉框选择用户组件
selectUserByModal出模态框选择用户组件
avatarDropdown用户头像下拉菜单组件
mentionUser用户提及组件
organizationCascader组织机构级联选择组件
organizationTreeSelect组织机构树形选择组件
commentList评论列表组件
labelPrinting标签打印组件

用户头像与组织

使用场景

展示用户头像、人员信息和组织机构信息的组合组件

代码示例

vue
<template>
  <s-user-avatar-with-org :user="userInfo" :show-org="true" size="large" />
</template>

<script setup>
const userInfo = ref({
  name: "张三",
  avatar: "/avatar.jpg",
  organization: {
    name: "技术部",
  },
});
</script>

API

参数说明类型默认值必填
user用户信息对象object-true
showOrg是否显示组织信息booleantruefalse
size头像大小'small' | 'default' | 'large''default'false
showName是否显示用户名booleantruefalse

穿梭框选择用户

使用场景

通过穿梭框形式选择用户的模态框组件,适用于批量用户分配场景

代码示例

vue
<template>
  <s-user-assignment-modal
    v-model:visible="visible"
    :selected-users="selectedUsers"
    @confirm="handleConfirm"
  />
</template>

<script setup>
const visible = ref(false);
const selectedUsers = ref([]);

const handleConfirm = (users) => {
  console.log('选中的用户:', users);
  selectedUsers.value = users;
  visible.value = false;
};
</script>

API

参数说明类型默认值必填
visible是否显示模态框booleanfalsetrue
selectedUsers已选中的用户列表array[]false
title模态框标题string'用户分配'false
width模态框宽度string | number800false
maxCount最大可选用户数number-false

下拉框选择用户

使用场景

下拉框形式选择用户的组件,支持搜索和单选/多选

代码示例

vue
<template>
  <s-select-user
    v-model:value="selectedUsers"
    :multiple="true"
    placeholder="请选择用户"
    :max-tag-count="3"
    @change="handleUserChange"
  />
</template>

<script setup>
const selectedUsers = ref([]);

const handleUserChange = (users) => {
  console.log("选中的用户:", users);
};
</script>

API

参数说明类型默认值必填
value选中的用户值string | array-false
multiple是否支持多选booleanfalsefalse
placeholder占位符文本string'请选择用户'false
disabled是否禁用booleanfalsefalse
allowClear是否允许清空booleantruefalse
maxTagCount多选时最多显示标签数number3false

模态框选择用户

使用场景

输入框点击弹出模态框选择用户的组件,适用于需要搜索和选择用户的场景

代码示例

vue
<template>
  <s-select-user-by-modal
    v-model:value="selectedUser"
    placeholder="请选择用户"
    :multiple="false"
    @change="handleUserChange"
  />
</template>

<script setup>
const selectedUser = ref(null);

const handleUserChange = (user) => {
  console.log('选中的用户:', user);
};
</script>

API

参数说明类型默认值必填
value选中的用户值object | array-false
placeholder输入框占位符string'请选择用户'false
multiple是否支持多选booleanfalsefalse
disabled是否禁用booleanfalsefalse
allowClear是否允许清空booleantruefalse

头像下拉菜单

使用场景

用户头像下拉菜单组件,通常用于显示用户信息和相关操作选项

代码示例

vue
<template>
  <s-avatar-dropdown
    :user="currentUser"
    :menu-items="menuItems"
    @menu-click="handleMenuClick"
  />
</template>

<script setup>
const currentUser = ref({
  name: "张三",
  avatar: "/avatar.jpg",
  email: "zhangsan@example.com",
});

const menuItems = ref([
  { key: "profile", label: "个人资料", icon: "UserOutlined" },
  { key: "settings", label: "设置", icon: "SettingOutlined" },
  { key: "logout", label: "退出登录", icon: "LogoutOutlined" },
]);

const handleMenuClick = (key) => {
  console.log("点击菜单项:", key);
};
</script>

API

参数说明类型默认值必填
user用户信息对象object-true
menuItems菜单项配置array[]false
size头像大小'small' | 'default' | 'large''default'false
placement下拉菜单位置string'bottomRight'false

用户提及

使用场景

支持在文本输入中提及用户的组件,类似社交媒体的@功能

代码示例

vue
<template>
  <mention-user
    v-model:value="content"
    :users="userList"
    placeholder="请输入内容,使用@提及用户"
    @mention="handleMention"
  />
</template>

<script setup>
const content = ref("");
const userList = ref([
  { id: "1", name: "张三", avatar: "/avatar1.jpg" },
  { id: "2", name: "李四", avatar: "/avatar2.jpg" },
]);

const handleMention = (user) => {
  console.log("提及用户:", user);
};
</script>

API

参数说明类型默认值必填
value输入框的值string''false
users可提及的用户列表array[]false
placeholder占位符文本string'请输入内容'false
disabled是否禁用booleanfalsefalse
maxLength最大输入长度number-false

组织机构级联选择

使用场景

级联选择器形式的组织机构选择组件,支持多级组织架构选择

代码示例

vue
<template>
  <s-organization-cascader
    v-model:value="selectedOrgs"
    placeholder="请选择组织机构"
    :multiple="false"
    :show-search="true"
    @change="handleOrgChange"
  />
</template>

<script setup>
const selectedOrgs = ref([]);

const handleOrgChange = (orgs) => {
  console.log('选中的组织机构:', orgs);
};
</script>

API

参数说明类型默认值必填
value选中的组织机构值string | array-false
placeholder占位符文本string'请选择组织机构'false
multiple是否支持多选booleanfalsefalse
showSearch是否支持搜索booleantruefalse
disabled是否禁用booleanfalsefalse
allowClear是否允许清空booleantruefalse

组织机构树形选择

使用场景

树形选择器形式的组织机构选择组件,以树形结构展示组织架构

代码示例

vue
<template>
  <s-organization-tree-select
    v-model:value="selectedOrgs"
    placeholder="请选择组织机构"
    :tree-checkable="true"
    :show-checked-strategy="SHOW_PARENT"
    @change="handleOrgChange"
  />
</template>

<script setup>
import { TreeSelect } from "ant-design-vue";
const { SHOW_PARENT } = TreeSelect;

const selectedOrgs = ref([]);

const handleOrgChange = (orgs) => {
  console.log("选中的组织机构:", orgs);
};
</script>

API

参数说明类型默认值必填
value选中的组织机构值string | array-false
placeholder占位符文本string'请选择组织机构'false
treeCheckable是否支持多选booleanfalsefalse
showCheckedStrategy多选时的显示策略enumSHOW_PARENTfalse
disabled是否禁用booleanfalsefalse
allowClear是否允许清空booleantruefalse

评论列表

使用场景

展示评论列表的组件,支持评论的增删改查和分页展示

代码示例

vue
<template>
  <s-comment-list
    :comments="commentData"
    :loading="loading"
    :current-user="currentUser"
    @add-comment="handleAddComment"
    @delete-comment="handleDeleteComment"
  />
</template>

<script setup>
const commentData = ref([]);
const loading = ref(false);
const currentUser = ref({
  id: "1",
  name: "张三",
  avatar: "/avatar.jpg",
});

const handleAddComment = (comment) => {
  console.log("添加评论:", comment);
};

const handleDeleteComment = (commentId) => {
  console.log("删除评论:", commentId);
};
</script>

API

参数说明类型默认值必填
comments评论数据列表array[]false
loading加载状态booleanfalsefalse
currentUser当前用户信息object-true
showAvatar是否显示头像booleantruefalse
showActions是否显示操作按钮booleantruefalse

标签打印

使用场景

应用于需要批量生成、打印标签的业务场景

代码示例

vue
<template>
  <s-label-printing label-code="TEST-CODE" :template-ids="[]" />
</template>

<script setup></script>

API

参数说明类型默认值必填
labelCode标签模板编码string-true
templateIds匹配值列表string[]-true
icon标签打印图标IconTypePrinterOutlined(antd-vue-icon)false
divider分割线"left" | "right" | nullnullfalse
fields数据库表中的字段名(列名)stringidfalse

🗂️ 通用数据管理服务 [Gds]

简介

专为通用数据管理设计的 Vue 组件集合,提供数据字典选择、编码生成、工作日历标签等前端组件。

总览

组件名说明
encodingGenerate编码生成组件
selectDictionary数据字典选择组件
calendarDateTag工作日历标签组件

编码生成

使用场景

基于编码规则配置生成特定的编码值

代码示例

vue
<template>
  <encoding-generate ruleCode="TEST" :isCreate="id" businessCode="01" />
</template>

<script setup>
const id = ref('');
</script>

API

参数说明类型默认值必填
isCreate是否在表单创建时使用booleannulltrue
ruleCode编码规则编码stringnulltrue
businessCode业务参数stringnullfalse

数据字典选择

使用场景

从字典项下拉选择特定的字典项

代码示例

vue
<template>
  <select-dictionary ref="dictionary" />
</template>

<script setup>
const dictionary = ref();

// 获取字典项数据
dictionary.value?.getOptions();
</script>

API

参数说明类型默认值必填
code字典项代码stringnulltrue
getOptions()获取字典项数据void--

工作日历标签

使用场景

用于标记工作日期和法定节假日日期

代码示例

vue
<template>
  <calendar-date-tag :workday="true" :holiday="false" :closable="true" />
</template>

API

参数说明类型默认值必填
workday是否为工作日booleanfalsefalse
holiday是否为法定节假日booleanfalsefalse
closable是否可以关闭booleanfalsefalse
其他属性参考 Ant Design Vue Tag---

🗂️ 工业数据服务 [Iot]

简介

专为 IoT 平台设计的 Vue 组件集合,提供设备选择、测点选择、实时数据展示等前端组件。

总览

组件名说明
iotPointSelect数据测点选择
iotDeviceCascader设备级联选择
iotMeasurementPointChart测点数据折线图

数据测点选择

何时使用

用户从下拉菜单中,选择特定设备的数据测点

代码演示

vue
<template>
  <iot-point-select :deviceId="deviceId" v-model:value="pointId" />
</template>

<script>
const deviceId = ref<string>('device-id')
const pointId = ref<string>()
</script>

API

参数
说明
类型
默认值
必填
deviceId设备 Idstring-true
mode设置 Select 的模式为多选或标签multiple | tags |comboboxmultiplefalse
allowClear支持清除booleantruefalse
showSearch配置是否可搜索boolean单选为 false,多选为 truefalse
placeholder选择框默认文字string请选择测点false
其余 APIhttps://www.antdv.com/components/select-cn#api---

设备级联选择

何时使用

用户从级联选择中,选择特定设备

代码演示

vue
<template>
  <iot-device-cascader v-model:value="deviceId" @change="onChange" />
</template>

<script>
const deviceId = ref<string>()

const onChange = (value: string) => {
    console.log(value)
}
</script>

API

参数
说明
类型
默认值
必填
allowClear支持清除booleantruefalse
showSearch配置是否可搜索booleanfalsefalse
placeholder选择框默认文字string请选择设备false
其余 APIhttps://www.antdv.com/components/cascader-cn#api---

测点数据折线图

何时使用

用户需要查看某个测点的走势及数据时使用

代码演示

vue
<template>
  <iot-measurement-pointChart
    :deviceCode="deviceCode"
    :pointCode="pointCode"
    :params="range"
  />
</template>

<script>
const formState = reactive<{ deviceCode: string; pointCode: string; range: EndPointListQueryParameter }>({
  deviceCode: 'device-01',
  pointCode: 'point-01',
  range: undefined,
})
</script>

API

参数
说明
类型
默认值
必填
deviceCode设备编码string-true
pointCode测点编码string-true
range日期范围EndPointListQueryParameter-false

Props

typescript
export declare interface EndPointListQueryParameter extends QueryParameter {
  /** Query condition: 开始时间 (用于匹配某一个时间区间时使用)单位:s */
  from?: string;
  /** Query condition: 结束时间 (用于匹配某一个时间区间时使用)单位:s */
  to?: string;
}

🗂️ 工作流 [Flow]

简介

专为流程中心设计的 Vue 组件集合,提供流程状态/审批人预览前端组件。

总览

组件名说明
SubmitForApproval流程发起
ProcessApproval流程审批
processStatus流程状态/审批人预览

流程发起

何时使用

业务场景需要发起工作流进行审批的时候,使用此组件。

代码演示

vue
<template>
    <SubmitForApproval
        model-key="AAAA"
        business-id="123"
        :user-info="userStore.currentUser"
        v-permission="'xxxx-add'"
        button-type="button"
        @handleAdd="
        () => {
          reload();
        }
        "
    >
      <icon-add style="font-size: 1.25em; margin-right: -0.12em; vertical-align: -0.23em" />
      <span>发起审批</span>
    </SubmitForApproval>
</template>
<script setup>
  import SubmitForApproval from '@/components/workflow/SubmitForApproval/index.vue';
</script>

API

参数
说明
类型
默认值
必填
modelKey模型keystringtrue
businessId业务IDString""false
userInfo用户信息Usertrue
hideForm是否隐藏Form展示Booleanfalsefalse
buttonType发起按钮类型Stringafalse
disabled是否禁用Booleanfalsefalse
formContent表单数据Record<string, any>nullfalse

emits

参数
说明
类型
默认值
必填
handle审批成功回调Functionfalse

流程审批

img.png

何时使用

业务场景需要工作流进行审批的时候,使用此组件。

代码演示

vue
<template>
  <process-approval
      :user-info="userStore.currentUser"
      :process-instance-id="record.processInstanceId"
      style="padding: 0"
      v-permission="'xxxx-approval'"
  >
    <a-tooltip>
      <template #title>审批/进度</template>
      <SolutionOutlined />
    </a-tooltip>
  </process-approval>
</template>
<script setup>
    import ProcessApproval from '@/components/workflow/ProcessApproval/index.vue';
</script>

API

参数
说明
类型
默认值
必填
businessId业务IDstring""false
processInstanceId实例IDStringtrue
userInfo用户信息Usertrue
hideForm是否隐藏Form展示Booleanfalsefalse
buttonType发起按钮类型Stringafalse
disabled是否禁用Booleanfalsefalse

emits

参数
说明
类型
默认值
必填
handle审批成功回调Functionfalse

流程状态

该组件分两种形态,一种显示流程状态,另一种显示当前审批人。 可通过配置miniInfo属性,切换形态。

何时使用

业务场景需要展示工作流当前审批状态或者当前审批人时候,使用此组件。

代码演示

vue
<template>
    <processStatus
      :process-instance-id="record.id"
       mini-info
    />
</template>
<script setup>
    import { ProcessStatus } from '@swing/widget-vue3'
</script>

API

参数
说明
类型
默认值
必填
processInstanceId流程实例IDstring""processInstanceData二选一
processInstanceData流程实例详情InstancenullprocessInstanceId二选一
miniInfo显示状态切换booleanfalsefalse

🗂️ 消息通知 [Notice]

简介

消息中心是不同模块、服务或系统之间传递消息的中介角色,让用户和系统之间的消息更方便、快捷的触达到指定用户或系统,以此来提升效率和降低成本。

总览

组件名说明
noticeOption消息铃铛
noticeList消息列表
appMessageTabCard消息卡片

消息铃铛

何时使用

平台默认已有功能,业务场景如有需求也可使用。

代码演示

vue

<template>
  <notice-option :currentUser="user"/>
</template>

<script>
  const user = ref < User > (null)
</script>

API

参数
说明
类型
默认值
必填
minWidth最小宽度string300pxfalse
icon图标VNode-false
iconClassNameicon图标类名string-false
placement下拉列表位置bottomLeft | bottom |bottomRight |topLeft |top |topRightbottomLeftfalse
dividericon 图标隔离线left | right-false
currentUser当前登录的用户User-false
siteId站点IDstring-false
messageSubjectCode消息主题编码string-false
showClearAction消息主题编码booleantruefalse
title标题string未读消息false
clearText清除文本string清空false
emptyText空文本string你已查看所有通知false

消息列表

何时使用

用于展示应用内的消息列表组件,消息数据需要自己传递。

代码演示

vue

<template>
  <notice-list :list="messageList"/>
</template>

<script>
  const messageList = ref < MessageReceiveVO[] > ([])
</script>

API

参数
说明
类型
默认值
必填
list消息列表数据MessageReceiveVO[]-false
onClick点击消息回调(item: MessageReceiveVO) => void-false
emptyText列表为空时显示的文本string暂无数据false
loading加载中loadingbooleanfalsefalse

消息卡片

何时使用

用于展示应用内的消息列表,消息数据默认查询。

代码演示

vue
<template>
  <app-message-tab-card />
</template>

<script></script>

API

参数
说明
类型
默认值
必填
currentUser当前登录的用户User-false
isAllMessage是否显示所有的消息booleanfalsefalse
siteId站点 IDstring-false
messageSubjectCode消息主题编码string-false

总结

通过使用 @swing/widget-vue3,可以给业务开发提供通用组件,减少业务开发的重复代码。

西安抟微科技有限公司