| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- const n = `<template>
- <span class="s-user-select-button-common">
- <a-button :type="type" :size="size" :disabled="disabled" @click="open">
- <component v-if="icon" :is="icon" />
- <slot>{{ buttonText }}</slot>
- </a-button>
- <!-- 隐藏的人员选择器:点击按钮时调用其 open() 打开弹窗,确认后事件回传结果 -->
- <s-user-select
- v-show="false"
- ref="userSelectRef"
- :value="value"
- :multiple="multiple"
- :title="title"
- :placeholder="placeholder"
- @update:value="onUpdateValue"
- @change="onChange"
- />
- </span>
- </template>
- <script setup>
- import { ref } from 'vue'
- const props = defineProps({
- // 已选值:单选为字符串,多选为数组(与 s-user-select 的 value 一致),支持 v-model:value
- value: {
- type: [String, Array],
- default() {
- return ''
- }
- },
- // 是否多选,false 为单选
- multiple: {
- type: Boolean,
- default: true
- },
- // 按钮文案
- buttonText: {
- type: String,
- default() {
- return window.$l('选择人员')
- }
- },
- // 按钮类型:default / primary / dashed / link / text
- type: {
- type: String,
- default: 'default'
- },
- // 按钮尺寸:large / middle / small
- size: {
- type: String,
- default: 'middle'
- },
- // 是否禁用
- disabled: {
- type: Boolean,
- default: false
- },
- // 弹窗标题
- title: {
- type: String,
- default() {
- return window.$l('人员选择')
- }
- },
- // 未选择时的占位文案
- placeholder: {
- type: String,
- default() {
- return window.$l('请选择')
- }
- },
- // 是否显示按钮图标
- icon: {
- type: String,
- default: ''
- }
- })
- const emits = defineEmits(['change', 'update:value'])
- const userSelectRef = ref(null)
- // 点击按钮打开人员选择弹窗
- const open = () => {
- if (props.disabled) return
- userSelectRef.value && userSelectRef.value.open()
- }
- const onUpdateValue = (val) => {
- emits('update:value', val)
- }
- // 选择确认后回传:tags/nameList/idList/list
- const onChange = (...args) => {
- emits('change', ...args)
- }
- defineExpose({ open })
- <\/script>
- <style lang="less" scoped>
- .s-user-select-button-common {
- display: inline-block;
- }
- </style>
- `;
- export {
- n as default
- };
|