Commit 323f3097 authored by “lixuyan”'s avatar “lixuyan”

通用选人组件-账号组件

parent 24937f02
import { get } from '../utils/http'
import { get, post } from '../utils/http'
// 通过用户名或账号模糊匹配查询存在账号的用户
export function getUsersByAccount(params) {
return get('/DxUserInfo/byAccount', params)
}
export function getFuzzyMatchUser(value) {
return post('/AuditLog/fuzzyMatchUser?value=' + value)
}
export default {
props: {},
layoutConfigData: [
{
title: '高级组件配置',
data: [
{
key: 'component.multiple',
title: '多选',
disabled: false,
component: {
name: 'el-switch'
}
},
// {
// key: 'secret',
// title: '业务密级',
// disabled: true,
// component: {
// name: 'el-switch'
// }
// },
{
key: 'containInnerUse',
title: '是否包含内置用户',
disabled: true,
component: {
defaultValue: false,
name: 'el-select',
options: [
{ 'label': '是', 'value': true },
{ 'label': '否', 'value': false }
]
}
},
{
key: 'isAudPage',
title: '是否为审计面',
disabled: false,
component: {
defaultValue: false,
name: 'el-switch'
}
}
]
}
],
data() {
return {
// secretOptions: []
}
},
created() {
},
mounted() {
// this.$utils.getDicListByCode('SecretCode').then(res => {
// console.log('3333', JSON.stringify(res))
// this.secretOptions = res
// })
},
computed: {
},
methods: {
}
}
/**
* @Description:
* @author cxg
* @date 2022/07/04
*/
<template>
<div class="GeneralUserSelect-page">
<el-select
v-model="bindValue"
size="small"
filterable
:multiple="isMultiple"
remote
:disabled="disabled"
:remote-method="remoteMethod"
:loading="loading"
@change="UserChange"
>
<el-option
v-for="citem in UserData"
:key="citem.id"
:label="citem.name"
:value="citem.userAccount"
/>
</el-select>
</div>
</template>
<script>
import { getUsersByAccount, getFuzzyMatchUser } from '@/api/user'
import config from './config'
export default {
name: 'GeneralUserAccountSelect',
components: {},
componentName: '通用选人组件-账号',
mixins: [config],
props: {
item: {
type: Object,
default: () => {
return {}
}
},
basicData: {
type: Object,
default: () => {
return {}
}
},
multiple: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
value: {
type: [Object, String, Array, Number],
default: () => {
return {}
}
}
},
data() {
return {
bindValue: '',
UserData: [],
loading: false
// secretCode: ''
}
},
computed: {
isMultiple() {
return this.item.multiple || this.$utils._get(this.item, 'component.multiple') || false
}
},
watch: {
// 'item.secret': {
// deep: true,
// handler: function(val) {
// if (val) {
// // getSecretMatrix().then((res) => {
// // const secretCode = []
// // console.log(res.items)
// // if (res.items) {
// // Object.keys(res.items).forEach(i => {
// // if (res.items[i][val]) {
// // secretCode.push(i)
// // }
// // })
// // }
// // this.secretCode = secretCode.join(',')
// // })
// }
// },
// immediate: true
// },
value: {
immediate: true,
deep: true,
handler: function(val) {
if (val !== this.bindValue) {
if (!val || (this.$utils.isObect(val) && (Object.keys(val).length === 0))) {
this.bindValue = ''
} else {
this.bindValue = val
}
if (val || val === 0) {
let searchArray = []
if (this.$utils.isObect(val)) {
if (val.id) {
searchArray = [val.id]
}
} else if (this.$utils.isNumber(val)) {
searchArray = [val]
} else {
searchArray = val.split(',')
}
if (searchArray.length) {
const params = {
'pageFrom': 1,
'pageSize': 10,
'searchItems': {
'items': [
{
'fieldName': 'id',
'operator': 'IN',
'value': searchArray
}
],
'operator': 'AND'
}
}
this.$api.searchApi('DxUserInfo', params).then(res => {
this.UserData = res.items.content
})
}
}
}
}
}
},
methods: {
remoteMethod(query) {
if (query) {
// 针对审计页面查人
if (this.item.isAudPage) {
this.loading = true
getFuzzyMatchUser(query)
.then(res => {
this.UserData = res.items ? res.items : []
})
.finally(() => {
this.loading = false
})
} else {
// 针对非审计页面查人
const params = { userAccount: query, containInnerUser: this.item.containInnerUse || false }
if (this.item.secret) {
params.secretCode = this.$store.state.user.userInfo.secretCode
}
this.loading = true
getUsersByAccount(params)
.then(res => {
this.UserData = res.items ? res.items : []
})
.finally(() => {
this.loading = false
})
}
}
},
UserChange(val) {
this.$emit('input', val)
}
}
}
</script>
<style lang='scss'>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment