feat:2.5.0

1. 用户页面调整完成
This commit is contained in:
byteblogs168 2023-11-26 11:36:27 +08:00
parent 3a76423849
commit dffdaa3aa8
4 changed files with 62 additions and 35 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<a-dropdown> <a-dropdown v-if="namespaceIds && namespaceIds.length > 0">
<a-menu slot="overlay" @click="handleMenuClick"> <a-menu slot="overlay" @click="handleMenuClick">
<a-menu-item :key="item.uniqueId" v-for="item in namespaceIds"> <a-menu-item :key="item.uniqueId" v-for="item in namespaceIds">
<a href="javascript:;">{{ item.name }}</a> <a href="javascript:;">{{ item.name }}</a>
@ -7,6 +7,9 @@
</a-menu> </a-menu>
<a-button shape="round"> {{ name }} <a-icon type="down" /> </a-button> <a-button shape="round"> {{ name }} <a-icon type="down" /> </a-button>
</a-dropdown> </a-dropdown>
<span v-else>
<a-spin size="small" :style="{ marginLeft: 8, marginRight: 8 }" />
</span>
</template> </template>
<script> <script>
import namespaceMixin from '@/store/namespace-mixin' import namespaceMixin from '@/store/namespace-mixin'
@ -20,6 +23,16 @@ export default {
name: 'Default' name: 'Default'
} }
}, },
computed: {
refreshNamespace () {
return this.$store.getters.namespaces
}
},
watch: {
refreshNamespace (val) {
this.namespaceIds = val
}
},
mounted () { mounted () {
setTimeout(() => { setTimeout(() => {
this.namespaceIds = this.$store.getters.namespaces this.namespaceIds = this.$store.getters.namespaces

View File

@ -389,7 +389,6 @@ export default {
}) })
}, },
handleTaskTypeChange (value) { handleTaskTypeChange (value) {
console.log(value)
this.taskTypeValue = value this.taskTypeValue = value
}, },
handlerCron () { handlerCron () {

View File

@ -45,14 +45,14 @@
<span slot="action" slot-scope="text, record"> <span slot="action" slot-scope="text, record">
<template> <template>
<a @click="handleEdit(record)">编辑</a> <a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical" /> <!-- <a-divider type="vertical" />-->
<a-popconfirm <!-- <a-popconfirm-->
title="命名空间删除后不可恢复,请确认是否删除这个空间?" <!-- title="命名空间删除后不可恢复,请确认是否删除这个空间?"-->
ok-text="删除" <!-- ok-text="删除"-->
cancel-text="取消" <!-- cancel-text="取消"-->
@confirm="handleDel(record)"> <!-- @confirm="handleDel(record)">-->
<a href="javascript:;">删除</a> <!-- <a href="javascript:;">删除</a>-->
</a-popconfirm> <!-- </a-popconfirm>-->
</template> </template>
</span> </span>
@ -158,6 +158,7 @@ export default {
delNamespace(record.id).then(res => { delNamespace(record.id).then(res => {
this.$message.success('删除成功') this.$message.success('删除成功')
this.$refs.table.refresh() this.$refs.table.refresh()
this.$store.dispatch('GetInfo')
}) })
}, },
handleGoBack () { handleGoBack () {

View File

@ -4,7 +4,7 @@
<div></div> <div></div>
</page-header-wrapper> </page-header-wrapper>
<a-card class="card" title="" :bordered="false"> <a-card class="card" title="" :bordered="false">
<a-form @submit="handleSubmit" :form="form" :body-style="{padding: '24px 32px'}" v-bind="formItemLayout" :rules="rules"> <a-form @submit="handleSubmit" :form="form" :body-style="{padding: '24px 32px'}" v-bind="formItemLayout">
<a-form-item> <a-form-item>
<a-input <a-input
hidden hidden
@ -20,25 +20,32 @@
]" /> ]" />
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="密码"> label="修改密码"
v-if="formType === 'edit'">
<a-switch checked-children="修改" un-checked-children="不修改" @change="onChange" />
</a-form-item>
<a-form-item
label="密码"
v-if="updatePass">
<a-input <a-input
placeholder="请输入密码" placeholder="请输入密码"
type="password" type="password"
autocomplete="off" autocomplete="off"
v-decorator="[ v-decorator="[
'password', 'password',
{rules: [{ required: formType === 'create', message: '请输入密码', whitespace: true}, {validator: validatePass, validateTrigger: ['change', 'blur']}]} {rules: [{ required: true, message: '请输入密码', whitespace: true}, {validator: validatePass, trigger: ['change', 'blur']}]}
]"/> ]"/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="确认密码"> label="确认密码"
v-if="updatePass">
<a-input <a-input
placeholder="请输入确认密码" placeholder="请输入确认密码"
type="password" type="password"
autocomplete="off" autocomplete="off"
v-decorator="[ v-decorator="[
'checkPassword', 'checkPassword',
{rules: [{ required: formType === 'create', message: '请输入密码', whitespace: true}, {validator: validateCheckPass, validateTrigger: ['change', 'blur']}]} {rules: [{ required: true, message: '请输入确认密码', whitespace: true}, {validator: validateCheckPass, trigger: ['change', 'blur']}]}
]"/> ]"/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
@ -82,7 +89,7 @@
'permissions', 'permissions',
{rules: [{ required: true, message: '请分配组'}]} {rules: [{ required: true, message: '请分配组'}]}
]"> ]">
<a-select-option v-for="(item, index) in groupNameList" :key="index" :value="item.groupName + '@@'+ item.namespaceId"> <a-select-option v-for="(item, index) in groupNameList" :key="index" :value="item.groupName + '@'+ item.namespaceId">
{{ item.groupName }} ({{ item.namespaceId }}) {{ item.groupName }} ({{ item.namespaceId }})
</a-select-option> </a-select-option>
</a-select> </a-select>
@ -125,7 +132,8 @@ export default {
wrapperCol: { lg: { span: 10 }, sm: { span: 17 } } wrapperCol: { lg: { span: 10 }, sm: { span: 17 } }
}, },
groupNameList: [], groupNameList: [],
namespaceList: [] namespaceList: [],
updatePass: true
} }
}, },
mounted () { mounted () {
@ -135,6 +143,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
if (this.$route.query.username) { if (this.$route.query.username) {
this.updatePass = false
getSystemUserByUserName({ username: this.$route.query.username }).then(res => { getSystemUserByUserName({ username: this.$route.query.username }).then(res => {
this.loadEditInfo(res.data) this.loadEditInfo(res.data)
}) })
@ -159,16 +168,13 @@ export default {
} }
if (values.permissions) { if (values.permissions) {
const filteredData = values.permissions.map(input => { values['permissions'] = values.permissions.map(input => {
const [groupName, namespaceId] = input.split('@@') const [groupName, namespaceId] = input.split('@')
console.log(this.groupNameList)
return this.groupNameList.filter(item => return this.groupNameList.filter(item =>
item.groupName === groupName && item.namespaceId === namespaceId item.groupName === groupName && item.namespaceId === namespaceId
) )
}).flat() }).flat()
values['permissions'] = filteredData
console.log(filteredData)
} }
values.role = parseInt(values.role) values.role = parseInt(values.role)
@ -180,23 +186,25 @@ export default {
}) })
}, },
validatePass (rule, value, callback) { validatePass (rule, value, callback) {
if (value === '') { if (value) {
callback(new Error('请输入密码'))
} else {
if (this.form.getFieldValue('checkPassword') !== '') { if (this.form.getFieldValue('checkPassword') !== '') {
this.$refs.form.validateField('checkPassword') this.form.validateFields(['checkPassword'], (errors, values) => {
console.log(errors)
})
}
} }
callback() callback()
}
}, },
validateCheckPass (rule, value, callback) { validateCheckPass (rule, value, callback) {
if (value === '') { console.log(value)
callback(new Error('请再次输入密码')) if (value) {
} else if (value !== this.form.getFieldValue('password')) { console.log(value)
if (value !== this.form.getFieldValue('password')) {
callback(new Error('两次密码不匹配!')) callback(new Error('两次密码不匹配!'))
} else { } else {
callback() callback()
} }
}
}, },
loadEditInfo (data) { loadEditInfo (data) {
this.formType = 'edit' this.formType = 'edit'
@ -207,11 +215,17 @@ export default {
}).then(() => { }).then(() => {
const formData = pick(data, ['id', 'username', 'role', 'permissions', 'namespaceIds']) const formData = pick(data, ['id', 'username', 'role', 'permissions', 'namespaceIds'])
formData.role = formData.role.toString() formData.role = formData.role.toString()
this.role = formData.role
formData.namespaceIds = formData.namespaceIds.map(i => i.uniqueId) formData.namespaceIds = formData.namespaceIds.map(i => i.uniqueId)
formData.permissions = formData.permissions.map(i => i.groupName + '@@' + i.namespaceId) formData.permissions = formData.permissions.map(i => i.groupName + '@' + i.namespaceId)
form.setFieldsValue(formData) form.setFieldsValue(formData)
this.handleNamespacesIdChange(formData.namespaceIds)
}) })
},
onChange (checked) {
this.updatePass = checked
} }
} }
} }
</script> </script>