Commit c98a39cb authored by jingnan's avatar jingnan 👀

合并产品【10235】【测评】安全管理员--用户管理--增加设置用户的密级功能

parent 5be2c0ac
/**
* @Description: 编辑用户
* @author wx
* @date 2022/04/18
*/
<template>
<div class="edit-user-com">
<dee-as-com
ref="form"
:form="defaultData"
:lay-config="{
typeName: 'DxUserInfo',
layKey: 'defaultEditBySecadmin'
}"
:basic-data="basicData"
@getOriPboData="getPboData"
>
<span style="display:flex">
<el-button type="primary" class="searchBtn" @click="handleSubmit">确定</el-button>
<el-button class="searchBtn" @click="handleClose">取消</el-button>
</span>
</dee-as-com>
</div>
</template>
<script>
import { findCurrentPostByUserOrg } from '@/api/userSystem/user'
export default {
componentName: '编辑用户',
name: 'EditUser',
// import引入的组件需要注入到对象中才能使用
components: {},
props: {
basicData: {
type: Object,
default: null
},
searchOriParams: {
type: Object,
default: null
},
parentTableData: {
type: Object,
default: null
}
},
data() {
// 这里存放数据
return {
addOrgFormData: {},
defaultData: {},
orgOptions: [],
postOptions: [],
orgFormObj: {
orgId: '',
postIds: ''
}
}
},
computed: {
editId() {
return this.basicData && this.basicData.id ? this.basicData.id + '' : ''
}
},
watch: {
parentTableData: {
immediate: true,
deep: true,
handler: function(val) {
if (val) {
this.$set(this.orgFormObj, 'orgId', val.id)
}
}
},
'orgFormObj.orgId': {
immediate: true,
handler: function(val) {
if (val) {
this.getPostOptions(val)
} else {
this.$set(this.orgFormObj, 'postIds', [])
}
}
},
'defaultData.targetDxPostMemberLink': {
immediate: true,
handler: function(val) {
if (val) {
this.$set(this.orgFormObj, 'postIds', val.map((el) => el.sourceId))
}
}
}
},
// 方法集合
methods: {
getPboData(form) {
if (form && form.targetDxPostMemberLink && !this.orgFormObj.postIds) {
const arr = []
form.targetDxPostMemberLink.forEach(org => {
arr.push(org.sourceId)
})
this.$set(this.orgFormObj, 'postIds', arr)
}
},
getPostOptions(val) {
findCurrentPostByUserOrg({ orgId: val }).then((res) => {
this.postOptions = []
if (!this.defaultData.dxOrganizationId || (this.defaultData.dxOrganizationId && this.defaultData.dxOrganizationId !== this.orgFormObj.orgId)) {
this.$set(this.orgFormObj, 'postIds', [])
}
if (res.items) {
res.items.globalPost && res.items.globalPost.forEach(item => {
this.postOptions.push(
{
label: `${item.postName}-${item.dxOrganization ? item.dxOrganization.name : '全局'}`,
value: item.id,
disabled: item.postState === 'DISABLE',
postState: item.postState
}
)
})
res.items.orgPost && res.items.orgPost.forEach(item => {
if (!this.postOptions.find(r => r.value === item.id)) {
this.postOptions.push(
{
label: `${item.postName}-${item.dxOrganization ? item.dxOrganization.name : '全局'}`,
value: item.id,
disabled: item.postState === 'DISABLE',
postState: item.postState
}
)
}
})
}
})
},
handleSubmit() {
this.$refs.form.$refs.asCom.$refs.deeForm.$refs.form.validate((valid) => {
if (!valid) {
return
}
const form = { ...this.$refs.form.$refs.asCom.form }
if (this.basicData && this.basicData.id) {
// 编辑
const params = {
...form,
dxOrganizationId: this.orgFormObj.orgId,
dxOrganizationIdType: 'DxOrganization',
operator: 'MODIFY'
}
this.saveUser(params, 'DxUserInfo')
}
})
},
saveUser(dxUserInfo, modelName) {
this.$api.recursion(modelName, dxUserInfo).then(res => {
this.$emit('completeEven', {})
this.$utils.showMessageSuccess(res.message)
})
},
handleClose() {
this.$emit('cancel', {})
}
}
}
</script>
<style lang='scss'>
.edit-user-com{
.avatar{
width: 100px;
height: 100px;
}
.add-btn{
margin-bottom:22px!important;
}
.topLevel div:nth-child(2){
margin:0 auto;
}
}
.el-message-box__wrapper{
z-index: 99999!important;
}
</style>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<span class="change-text">{{ data.name }}</span> <span class="change-text">{{ data.name }}</span>
</div> </div>
<span class="tree-btn-box"> <span v-if="!ternaryUserInfo.isSecAdmin" class="tree-btn-box">
<span class="btn-item" title="新增" @click="() => append(data, node)"> <span class="btn-item" title="新增" @click="() => append(data, node)">
<img src="/icons/add-L.png" alt=""> <img src="/icons/add-L.png" alt="">
</span> </span>
...@@ -142,6 +142,12 @@ export default { ...@@ -142,6 +142,12 @@ export default {
}] }]
} }
}, },
computed: {
// 三元用户信息
ternaryUserInfo() {
return this.$store.getters.ternaryUserInfo
}
},
watch: { watch: {
inputVal: { inputVal: {
handler: function(keyword) { handler: function(keyword) {
...@@ -167,7 +173,7 @@ export default { ...@@ -167,7 +173,7 @@ export default {
return type !== 'inner' return type !== 'inner'
} }
}, },
loadNode() { loadNode(data) {
const serverParams = { const serverParams = {
'searchItems': { 'searchItems': {
'children': [], 'children': [],
...@@ -206,6 +212,10 @@ export default { ...@@ -206,6 +212,10 @@ export default {
this.treeData = res.items.content || [] this.treeData = res.items.content || []
if (this.treeData.length) { if (this.treeData.length) {
this.defaultExpandedKeys = [this.treeData[0].id] this.defaultExpandedKeys = [this.treeData[0].id]
if (data) {
this.$refs.tree.setCurrentKey(data.id)
this.$emit('nodeClick', data)
}
} }
// resolve(res.items.content || []) // resolve(res.items.content || [])
// if (node.level === 0) { // if (node.level === 0) {
...@@ -267,7 +277,7 @@ export default { ...@@ -267,7 +277,7 @@ export default {
completeEven(data) { completeEven(data) {
if (data.buttonInformation.type === 'submit') { if (data.buttonInformation.type === 'submit') {
if (this.basicData && this.basicData.id) { if (this.basicData && this.basicData.id) {
this.loadNode() this.loadNode(this.basicData)
} else { } else {
if (!this.curNode.data.children) { if (!this.curNode.data.children) {
this.$set(this.curNode.data, 'children', []) this.$set(this.curNode.data, 'children', [])
......
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