yh-ui/src/components/Business/User/UserInput.vue

92 lines
2.2 KiB
Vue
Raw Normal View History

2024-10-22 18:07:53 +08:00
<!--version: 4, 经营场所选择器-->
<!--版本更新内容添加prop属性修复多选-->
<template>
<div>
<template v-if="multiple">
<el-tag
v-for="(item,index) of selected"
2024-11-19 18:01:30 +08:00
:key="item.userId"
2024-10-22 18:07:53 +08:00
size="small"
style="margin-right: 4px"
disable-transitions
:closable="!disabled"
@close="onCloseSelected(index)"
2024-12-07 16:21:44 +08:00
>{{item[showProp]}}</el-tag>
2024-10-22 18:07:53 +08:00
<el-tag style="cursor: not-allowed" size="small" type="info" v-if="disabled">+</el-tag>
<el-tag style="cursor: pointer" size="small" @click="openDialog" type="success" v-else>+</el-tag>
</template>
<el-input
v-else
:value="inputBindValue"
@focus="openDialog"
:size="size"
:disabled="disabled"
readonly
2024-12-31 16:59:57 +08:00
ref="inputRef"
2024-10-22 18:07:53 +08:00
:placeholder="placeholder">
<template #suffix><i class="el-icon-arrow-right"/></template>
</el-input>
<user-dialog
2024-11-18 18:03:26 +08:00
v-if="openType === 'dialog'"
:show.sync="dialogShow"
:query="query"
:multiple="multiple"
:init-select="selected"
@select="onSubmit"
:prop="prop"
:title="title"
:list-api="listApi"
/>
<user-drawer
v-else-if="openType === 'drawer'"
2024-10-22 18:07:53 +08:00
:show.sync="dialogShow"
:query="query"
:multiple="multiple"
:init-select="selected"
@select="onSubmit"
:prop="prop"
:title="title"
:list-api="listApi"
/>
</div>
</template>
<script>
import UserDialog from "@/components/Business/User/UserDialog.vue";
import {listUser, listUserByIds} from "@/api/system/user";
2024-11-18 18:03:26 +08:00
import UserDrawer from "@/components/Business/User/UserDrawer.vue";
2024-11-19 18:01:30 +08:00
import {$businessInput} from "@/components/Business/mixins";
2024-10-22 18:07:53 +08:00
export default {
name: 'UserInput',
2024-11-19 18:01:30 +08:00
mixins: [$businessInput],
2024-11-18 18:03:26 +08:00
components: {UserDrawer, UserDialog},
2024-11-19 18:01:30 +08:00
props: {
listApi: {
type: Function,
default: listUser,
},
loadApi: {
type: Function,
default: listUserByIds
2024-10-22 18:07:53 +08:00
},
2024-11-19 18:01:30 +08:00
prop: {
2024-10-22 18:07:53 +08:00
type: String,
2024-11-19 18:01:30 +08:00
default: "userId"
2024-10-22 18:07:53 +08:00
},
// 展示值的属性
showProp: {
type: String,
default: 'nickName'
},
2024-11-18 18:03:26 +08:00
// 打开的类型
openType: {
type: String,
default: 'dialog',
2024-10-22 18:07:53 +08:00
},
}
}
</script>