Commit e4c3a233 authored by ztf's avatar ztf

添加选择用户和选择项目组件

parent f59ddfc7
import { post, get, put } from '../utils/http'
// export function login(data) {
// return post('/api/users/auth/login', data)
// }
// ?account=root&password=i
// export function login(data) {
// return post(`/workflow/user/auth/login?account=${data.account}&password=${data.password}`)
// }
export function login(data) {
return post('/DxUserAccount/auth/login', data, true)
// return post('/login', data)
// return post('/workflow/login', data)
}
// export function logout() {
// return post('/api/users/auth/logout')
// }
export function logout(params, userAction = true) {
return post('/DxUserAccount/auth/logout', params, userAction)
// return post('/logout?account=' + params[0], params)
}
// export function logout(params) {
// return post('/client/user/logout/' + params[0], params)
// }
// 获取部件单位字典清单
export function getUnitParts() {
return get('/api/systems/units/parts')
}
// 获取用户身份列表
export function getIdentList(params) {
return get('/UserAccount/getCurrentAccountRole', params)
}
// 切换用户身份信息
export function putAccountRole(params) {
return put('/UserAccount/selectAccountRole', params)
}
// 查询所有用户列表
export function getAllUsers(params) {
return post('/DxUserInfo/find/recursion', params)
}
// 修改密码
export function modifyPassword(params) {
return post('/UserAccount/modifyPassword', params, true)
}
export function getUserGroup() {
return post('/User/getUserOrg/')
}
// 通过用户名或账号模糊匹配查询存在账号的用户
export function getUsersByAccount(params) {
return get('/DxUserInfo/byAccount', params)
}
export function getFuzzyMatchUser(value) {
return post('/AuditLog/fuzzyMatchUser?value=' + value)
}
export function setUserTheme(theme) {
return post('/userTheme/collect?theme=' + theme, null, true)
}
export function getUserTheme() {
return get('/userTheme/findCollections')
}
export function getSecretMatrix() {
return get('/SecretCodeMatrix/getSecretMatrix')
}
export function getUserRole(userId) {
return get('/perm/Role/getUserRoleVO?userId=' + userId)
}
export function fetchFuzzyMatchUser(params) {
return post('/AuditLog/fuzzyMatchUser?' + params)
}
<template>
<div class="user-select-com">
<el-select v-model="cloneValue" :value-key="valueKey" :disabled="disabled" :size="size" clearable filterable :remote="isRemote ? true : false" :remote-method="remoteMethod" @change="change">
<el-option
v-for="n in userListOptions"
:key="n.value"
:label="n.label"
:value="valueKey ? n.data : n.value"
/>
</el-select>
</div>
</template>
<script>
import { getAllUsers, getUsersByAccount } from '@/api/user'
import _get from 'lodash.get'
export default {
name: 'SelectUser',
componentName: '选择用户',
components: { },
props: {
searchItems: {
type: Array,
default: () => []
},
user: {
type: [Number, String, Object],
default: ''
},
value: {
type: [Number, String, Object],
default: ''
},
disabled: {
type: Boolean,
default: false
},
isRemote: {
type: Boolean,
default: true
},
size: {
type: String,
default: () => ''
},
inputAttr: {
type: String,
default: () => 'value'
},
valueKey: {
type: String,
default: () => ''
}
},
data() {
return {
cloneValue: '',
userListOptions: []
}
},
computed: {
},
watch: {
user(val) {
if (val) {
this.cloneValue = this.getValue(val)
}
},
value: {
immediate: true,
handler(val) {
this.getUsers()
// console.log('valueKey', this.valueKey)
// if (val) {
// let cloneValue = this.getValue(this.value)
// let userIds = cloneValue
// if (this.valueKey) {
// cloneValue = val
// userIds = [val.id]
// }
// this.cloneValue = cloneValue
// this.getUsers(this.valueKey ? userIds : [userIds])
// } else {
// this.cloneValue = ''
// this.change('')
// }
}
}
},
mounted() {
// this.getUsers()
},
methods: {
getValue(val) {
return Object.prototype.toString.call(val) === '[object Object]' ? (val.id ? Number(val.id) : '') : Number(val)
},
getUsers(userArr) {
// console.log('this.searchItems', this.searchItems)
// console.log('userArr', userArr)
const params = {
'indices': [
'USERS'
],
'pageFrom': 1,
'pageSize': 9999,
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
],
'searchItems': {
'operator': 'AND',
'items': this.searchItems.length ? this.searchItems : []
}
}
if (userArr && userArr.length) {
params.searchItems.children = [
{
'items': [
{
'fieldName': 'id',
'operator': 'IN',
'value': userArr
}
]
}
]
}
getAllUsers(params).then(res => {
if (res.items && res.items.content) {
this.userListOptions = res.items.content.map(n => {
return {
label: `${n.userName}`,
value: n.id,
data: n
}
})
} else {
this.userListOptions = []
}
if (userArr && userArr.length) {
this.change(this.cloneValue)
}
})
},
remoteMethod(query) {
console.log('query', query)
if (query.length > 1) {
const params = {
userAccount: query.trim()
}
getUsersByAccount(params).then(res => {
if (res.items) {
this.userListOptions = res.items.map(item => {
return {
label: item.userName + '(' + item.userAccount + ')',
value: item.id,
data: item
}
}).filter(r => r)
}
})
}
},
change(val) {
if (this.valueKey) {
this.$emit('getUser', val)
this.$emit('input', val)
} else {
const item = this.userListOptions.find(r => {
return r.value === val
})
this.$emit('getUser', item && item.data)
if (this.inputAttr) {
this.$emit('input', item ? _get(item, this.inputAttr) : '')
}
}
}
}
}
</script>
<style lang="scss" >
.user-select-com{
.el-form-item{
margin-bottom:22px!important;
}
}
</style>
<template>
<div>
<div class="select-project">
<!--input输入-->
<el-input v-model="project" placeholder="请输入" />
<img
v-if="show"
class="icon"
src="/icons/c-add.png"
title="选择合同"
@click="handleClickOpen"
>
<dee-dialog
width="45%"
:title="`选择合同`"
:dialog-visible="dialogShow"
@handleClose="dialogShow = false"
>
这个是合同的列表
</dee-dialog>
</div>
</div>
</template>
<script>
export default {
name: 'CreateNewProject',
componentName: '选择项目名称',
props: {
form: {
type: Object,
default: () => {}
}
},
data() {
return {
project: '',
dialogShow: false,
show: false
}
},
watch: {
'form.projectCategory': {
immediate: true,
deep: true,
handler: function(val) {
// console.log('val', val)
if (val) {
if (val === 'program') {
this.show = false
} else {
this.show = true
}
}
}
}
},
methods: {
handleClickOpen() {
this.dialogShow = true
console.log('打开合同弹框')
}
}
}
</script>
<style lang="scss" scoped>
.select-project{
display: flex;
align-items: center;
justify-content: space-between;
.icon{
width: 15px;
height:15px;
margin-left: 6px;
cursor: pointer;
}
}
</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