mirror of https://github.com/veops/cmdb.git
[更新] 完成基础role和user管理
This commit is contained in:
parent
224a48a5f3
commit
8d1517d550
|
@ -33,7 +33,6 @@ class UserView(APIView):
|
|||
page_size = get_page_size(request.values.get('page_size'))
|
||||
q = request.values.get("q")
|
||||
numfound, users = UserCRUD.search(q, page, page_size)
|
||||
|
||||
id2parents = RoleRelationCRUD.get_parents(uids=[i.uid for i in users])
|
||||
|
||||
users = [i.to_dict() for i in users]
|
||||
|
|
|
@ -13,7 +13,7 @@ export function searchUser (params) {
|
|||
return axios({
|
||||
url: urlPrefix + `/users`,
|
||||
method: 'GET',
|
||||
data: params
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
label="角色列表"
|
||||
>
|
||||
<a-select name="otherID" v-decorator="['otherID', {rules: [{ required: true, message: '请选择另一个角色'}]} ]">
|
||||
<a-select-option v-for="role in allRoles" :key="role.id">{{ role.name }}</a-select-option>
|
||||
<a-select-option v-for="role in allRoles" v-if="role.id != current_record.id" :key="role.id">{{ role.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
|
@ -65,7 +65,8 @@ export default {
|
|||
drawerTitle: '角色关联',
|
||||
drawerVisible: false,
|
||||
formLayout: 'vertical',
|
||||
allRoles: []
|
||||
allRoles: [],
|
||||
current_record: null
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -105,6 +106,7 @@ export default {
|
|||
this.drawerVisible = false
|
||||
},
|
||||
handleAddRoleRelation (record) {
|
||||
this.current_record = record
|
||||
this.drawerVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.getAllRoles()
|
||||
|
|
|
@ -21,15 +21,7 @@
|
|||
v-decorator="['name', {rules: [{ required: true, message: '请输入资源名'}]} ]"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
:label-col="formItemLayout.labelCol"
|
||||
:wrapper-col="formItemLayout.wrapperCol"
|
||||
label="应用列表"
|
||||
>
|
||||
<a-select name="app_id" default-value="1" v-decorator="['app_id', {rules: []} ]">
|
||||
<a-select-option value="1">默认应用</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
:label-col="formItemLayout.labelCol"
|
||||
:wrapper-col="formItemLayout.wrapperCol"
|
||||
|
@ -40,6 +32,14 @@
|
|||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-input
|
||||
name="app_id"
|
||||
type="hidden"
|
||||
v-decorator="['app_id', {rules: []} ]"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-input
|
||||
name="id"
|
||||
|
@ -137,7 +137,7 @@ export default {
|
|||
this.form.setFieldsValue({
|
||||
id: record.id,
|
||||
name: record.name,
|
||||
app_id: record.app_id,
|
||||
app_id: this.$store.state.app.name,
|
||||
resource_type_id: record.resource_type_id
|
||||
})
|
||||
})
|
||||
|
|
|
@ -21,16 +21,6 @@
|
|||
v-decorator="['name', {rules: [{ required: true, message: '请输入角色名'}]} ]"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
:label-col="formItemLayout.labelCol"
|
||||
:wrapper-col="formItemLayout.wrapperCol"
|
||||
label="应用列表"
|
||||
>
|
||||
<a-select name="app_id" default-value="1" v-decorator="['app_id', {rules: []} ]">
|
||||
<a-select-option value="1">默认应用</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
:label-col="horizontalFormItemLayout.labelCol"
|
||||
:wrapper-col="horizontalFormItemLayout.wrapperCol"
|
||||
|
@ -43,6 +33,14 @@
|
|||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-input
|
||||
name="app_id"
|
||||
type="hidden"
|
||||
v-decorator="['app_id', {rules: []} ]"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-input
|
||||
name="id"
|
||||
|
@ -140,7 +138,7 @@ export default {
|
|||
this.form.setFieldsValue({
|
||||
id: record.id,
|
||||
name: record.name,
|
||||
app_id: record.app_id,
|
||||
app_id: this.$store.state.app.name,
|
||||
is_app_admin: record.is_app_admin
|
||||
})
|
||||
})
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
>
|
||||
<a-input
|
||||
name="email"
|
||||
v-decorator="['email', {rules: [{ required: true, message: '请输入邮箱'},{message: '请输入正确的邮箱', pattern: RegExp('^\w+@\w+\.\w+$')}]} ]"
|
||||
v-decorator="['email', {rules: [{ required: true, message: '请输入邮箱'},{message: '请输入正确的邮箱', pattern: /^\w+\@\w+(\.\w+)+$/}]} ]"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
|
@ -72,7 +72,7 @@
|
|||
>
|
||||
<a-input
|
||||
name="mobile"
|
||||
v-decorator="['mobile', {rules: [{message: '请输入正确的手机号码', pattern: RegExp('^1\d{10}$')}]} ]"
|
||||
v-decorator="['mobile', {rules: [{message: '请输入正确的手机号码', pattern: /^1\d{10}$/ }]} ]"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
|
@ -183,7 +183,7 @@ export default {
|
|||
console.log(record)
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue({
|
||||
uid: record.uid,
|
||||
id: record.uid,
|
||||
username: record.username,
|
||||
nickname: record.nickname,
|
||||
department: record.department,
|
||||
|
|
|
@ -1,21 +1,9 @@
|
|||
<template>
|
||||
<a-card :bordered="false">
|
||||
<a-form layout="inline">
|
||||
<a-row :gutter="48">
|
||||
<a-col :md="3" :sm="24">
|
||||
<div class="action-btn">
|
||||
<a-button @click="handleCreate" type="primary" style="margin-right: 0.3rem;">{{ btnName }}</a-button>
|
||||
</div>
|
||||
</a-col>
|
||||
<a-col :md="8" :sm="24">
|
||||
<a-form-item label="应用列表">
|
||||
<a-select placeholder="请选择" v-model="queryParam.app_id">
|
||||
<a-select-option v-for="app in appList" :key="app.id" :label="app.name" :value="app.id">{{ app.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
|
||||
<div class="action-btn">
|
||||
<a-button @click="handleCreate" type="primary" style="margin-right: 0.3rem;">{{ btnName }}</a-button>
|
||||
</div>
|
||||
|
||||
<s-table
|
||||
:alert="options.alert"
|
||||
|
@ -65,10 +53,6 @@
|
|||
<template v-else>{{ text }}</template>
|
||||
</template>
|
||||
|
||||
<span slot="app_id" slot-scope="text">
|
||||
<template>{{ text }}</template>
|
||||
</span>
|
||||
|
||||
<span slot="resource_type_id" slot-scope="text">
|
||||
<a-icon type="check" v-if="text"/>
|
||||
</span>
|
||||
|
@ -145,13 +129,6 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '应用',
|
||||
dataIndex: 'app_id',
|
||||
width: 50,
|
||||
sorter: false,
|
||||
scopedSlots: { customRender: 'app_id' }
|
||||
},
|
||||
{
|
||||
title: '资源类型',
|
||||
dataIndex: 'resource_type_id',
|
||||
|
@ -169,6 +146,7 @@ export default {
|
|||
}
|
||||
],
|
||||
loadData: parameter => {
|
||||
parameter.app_id = this.$store.state.app.name
|
||||
parameter.page = parameter.pageNo
|
||||
parameter.page_size = parameter.pageSize
|
||||
delete parameter.pageNo
|
||||
|
@ -214,10 +192,6 @@ export default {
|
|||
this.form = this.$form.createForm(this)
|
||||
},
|
||||
|
||||
created () {
|
||||
this.queryParam.app_id = this.appList[0].id
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
||||
formItemLayout () {
|
||||
|
@ -243,7 +217,6 @@ export default {
|
|||
|
||||
},
|
||||
mounted () {
|
||||
this.searchResources(this.queryParam)
|
||||
this.setScrollY()
|
||||
},
|
||||
inject: ['reload'],
|
||||
|
@ -260,11 +233,6 @@ export default {
|
|||
this.columnSearchText[column.dataIndex] = ''
|
||||
this.queryParam[column.dataIndex] = ''
|
||||
},
|
||||
searchResources (params) {
|
||||
searchResource(params).then(res => {
|
||||
this.allResources = res.resources
|
||||
})
|
||||
},
|
||||
|
||||
setScrollY () {
|
||||
this.scroll.y = window.innerHeight - this.$refs.table.$el.offsetTop - 200
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
:alert="options.alert"
|
||||
:columns="columns"
|
||||
:data="loadData"
|
||||
:rowKey="record=>record.id"
|
||||
:rowKey="record=>record.uid"
|
||||
:rowSelection="options.rowSelection"
|
||||
:scroll="scroll"
|
||||
:pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} 共 ${total} 条记录`, pageSizeOptions: pageSizeOptions}"
|
||||
|
@ -123,7 +123,7 @@ export default {
|
|||
title: '用户名',
|
||||
dataIndex: 'username',
|
||||
sorter: false,
|
||||
width: 250,
|
||||
width: 150,
|
||||
scopedSlots: {
|
||||
customRender: 'usernameSearchRender',
|
||||
filterDropdown: 'filterDropdown',
|
||||
|
@ -142,7 +142,7 @@ export default {
|
|||
title: '中文名',
|
||||
dataIndex: 'nickname',
|
||||
sorter: false,
|
||||
width: 250,
|
||||
width: 150,
|
||||
scopedSlots: {
|
||||
customRender: 'nicknameSearchRender',
|
||||
filterDropdown: 'filterDropdown',
|
||||
|
@ -160,7 +160,7 @@ export default {
|
|||
{
|
||||
title: '部门',
|
||||
dataIndex: 'department',
|
||||
width: 50,
|
||||
width: 200,
|
||||
sorter: false,
|
||||
scopedSlots: { customRender: 'department' }
|
||||
|
||||
|
@ -169,7 +169,7 @@ export default {
|
|||
title: '小组',
|
||||
dataIndex: 'catalog',
|
||||
sorter: false,
|
||||
width: 50,
|
||||
width: 200,
|
||||
scopedSlots: { customRender: 'catalog' }
|
||||
|
||||
},
|
||||
|
@ -177,7 +177,7 @@ export default {
|
|||
title: '邮箱',
|
||||
dataIndex: 'email',
|
||||
sorter: false,
|
||||
width: 50,
|
||||
width: 200,
|
||||
scopedSlots: { customRender: 'email' }
|
||||
|
||||
},
|
||||
|
@ -185,7 +185,7 @@ export default {
|
|||
title: '手机',
|
||||
dataIndex: 'mobile',
|
||||
sorter: false,
|
||||
width: 50,
|
||||
width: 200,
|
||||
scopedSlots: { customRender: 'mobile' }
|
||||
|
||||
},
|
||||
|
@ -193,7 +193,7 @@ export default {
|
|||
title: '锁定',
|
||||
dataIndex: 'block',
|
||||
sorter: false,
|
||||
width: 50,
|
||||
width: 100,
|
||||
scopedSlots: { customRender: 'block' }
|
||||
|
||||
},
|
||||
|
@ -203,6 +203,13 @@ export default {
|
|||
sorter: false,
|
||||
scopedSlots: { customRender: 'date_joined' }
|
||||
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
width: 100,
|
||||
fixed: 'right',
|
||||
scopedSlots: { customRender: 'action' }
|
||||
}
|
||||
],
|
||||
loadData: parameter => {
|
||||
|
@ -276,7 +283,6 @@ export default {
|
|||
|
||||
},
|
||||
mounted () {
|
||||
this.searchUsers()
|
||||
this.setScrollY()
|
||||
},
|
||||
inject: ['reload'],
|
||||
|
@ -293,11 +299,6 @@ export default {
|
|||
this.columnSearchText[column.dataIndex] = ''
|
||||
this.queryParam[column.dataIndex] = ''
|
||||
},
|
||||
searchUsers () {
|
||||
searchUser().then(res => {
|
||||
this.allUsers = res.users
|
||||
})
|
||||
},
|
||||
|
||||
setScrollY () {
|
||||
this.scroll.y = window.innerHeight - this.$refs.table.$el.offsetTop - 200
|
||||
|
@ -307,7 +308,7 @@ export default {
|
|||
this.$refs.userForm.handleEdit(record)
|
||||
},
|
||||
handleDelete (record) {
|
||||
this.deleteUserById(record.id)
|
||||
this.deleteUser(record.uid)
|
||||
},
|
||||
handleOk () {
|
||||
this.$refs.table.refresh()
|
||||
|
|
Loading…
Reference in New Issue