refactor: chat user

This commit is contained in:
wxg0103 2025-06-13 15:05:51 +08:00
parent e9aa3a311c
commit 748420167a
6 changed files with 91 additions and 95 deletions

View File

@ -2,7 +2,6 @@ import { Result } from '@/request/Result'
import {get, put, post, del} from '@/request/index'
import type {pageRequest} from '@/api/type/common'
import type {Ref} from 'vue'
import type {ResetPasswordRequest} from "@/api/type/user.ts";
const prefix = '/system/chat_user'
/**
@ -16,7 +15,7 @@ const getUserManage: (
loading?: Ref<boolean>,
) => Promise<Result<any>> = (page, email_or_username, loading) => {
return get(
`${prefix}/${page.current_page}/${page.page_size}`,
`${prefix}/user_manage/${page.current_page}/${page.page_size}`,
email_or_username ? {email_or_username} : undefined,
loading,
)

View File

@ -47,7 +47,7 @@ const delUserGroup: (user_group_id: String, loading?: Ref<boolean>) => Promise<R
}
*/
const postAddMember: (
user_group_id: String,
user_group_id: string,
body: any,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (user_group_id, body, loading) => {
@ -63,7 +63,7 @@ const postAddMember: (
}
*/
const postRemoveMember: (
user_group_id: String,
user_group_id: string,
body: any,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (user_group_id, body, loading) => {

View File

@ -91,6 +91,16 @@ const resetCurrentPassword: (
return post('/user/current/reset_password', request, undefined, loading)
}
/**
*
*/
const getSystemDefaultPassword: (
loading?: Ref<boolean>
) => Promise<Result<string>> = (loading) => {
return get('/user_manage/password', undefined, loading)
}
export default {
getUserManage,
putUserManage,
@ -98,5 +108,6 @@ export default {
postUserManage,
putUserManagePassword,
resetPassword,
resetCurrentPassword
resetCurrentPassword,
getSystemDefaultPassword
}

View File

@ -64,19 +64,6 @@
>
</el-input>
</el-form-item>
<el-form-item
:label="$t('views.userManage.form.password.label')"
prop="password"
v-if="!isEdit"
>
<el-input
type="password"
v-model="userForm.password"
:placeholder="$t('views.userManage.form.password.placeholder')"
show-password
>
</el-input>
</el-form-item>
</el-form>
<template #footer>
<el-button @click.prevent="visible = false"> {{ $t('common.cancel') }}</el-button>
@ -89,9 +76,10 @@
<script setup lang="ts">
import {ref, reactive, watch} from 'vue'
import type {FormInstance} from 'element-plus'
import userManageApi from '@/api/user/user-manage'
import userManageApi from '@/api/system/chat-user'
import {MsgSuccess} from '@/utils/message'
import {t} from '@/locales'
const props = defineProps({
title: String,
})

View File

@ -5,7 +5,8 @@
<div class="flex-between mb-16">
<el-button type="primary" @click="createUser()">{{
$t('views.userManage.createUser')
}}</el-button>
}}
</el-button>
<div class="flex-between complex-search">
<el-select
class="complex-search__left"
@ -39,8 +40,10 @@
<template #default="{ row }">
<div v-if="row.is_active" class="flex align-center">
<el-icon class="color-success mr-8" style="font-size: 16px"
><SuccessFilled
/></el-icon>
>
<SuccessFilled
/>
</el-icon>
<span class="color-secondary">
{{ $t('common.status.enabled') }}
</span>
@ -96,7 +99,6 @@
<template #default="{ row }">
<span @click.stop>
<el-switch
:disabled="row.role === 'ADMIN'"
size="small"
v-model="row.is_active"
:before-change="() => changeState(row)"
@ -143,10 +145,11 @@
import {onMounted, ref, reactive, watch} from 'vue'
import UserDrawer from './component/UserDrawer.vue'
import UserPwdDialog from './component/UserPwdDialog.vue'
import userManageApi from '@/api/user/user-manage'
import userManageApi from '@/api/system/chat-user'
import {datetimeFormat} from '@/utils/time'
import {MsgSuccess, MsgConfirm} from '@/utils/message'
import {t} from '@/locales'
const search_type = ref('name')
const search_form = ref<{
name: string
@ -169,6 +172,7 @@ const userTableData = ref<any[]>([])
const search_type_change = () => {
search_form.value = {name: ''}
}
function handleSizeChange() {
paginationConfig.current_page = 1
getList()
@ -201,6 +205,7 @@ function changeState(row: any) {
}
const title = ref('')
function editUser(row: any) {
title.value = t('views.userManage.editUser')
UserDrawerRef.value.open(row)
@ -208,22 +213,7 @@ function editUser(row: any) {
function createUser() {
title.value = t('views.userManage.createUser')
UserDrawerRef.value.open(1)
// common.asyncGetValid(ValidType.User, ValidCount.User, loading).then(async (res: any) => {
// if (res?.data) {
// title.value = t('views.userManage.createUser')
// UserDrawerRef.value.open()
// } else if (res?.code === 400) {
// MsgConfirm(t('common.tip'), t('views.userManage.tip.professionalMessage'), {
// cancelButtonText: t('common.confirm'),
// confirmButtonText: t('common.professional'),
// })
// .then(() => {
// window.open('https://maxkb.cn/pricing.html', '_blank')
// })
// .catch(() => {})
// }
// })
UserDrawerRef.value.open()
}
function deleteUserManage(row: any) {
@ -242,7 +232,8 @@ function deleteUserManage(row: any) {
getList()
})
})
.catch(() => {})
.catch(() => {
})
}
function editPwdUser(row: any) {

View File

@ -52,7 +52,7 @@
</el-input>
</el-form-item>
<el-form-item label="默认密码" v-if="!isEdit">
<span>MaxKB@123</span>
<span>{{userForm.password}}</span>
</el-form-item>
</el-form>
<template #footer>
@ -69,6 +69,7 @@ import type { FormInstance } from 'element-plus'
import userManageApi from '@/api/user/user-manage'
import {MsgSuccess} from '@/utils/message'
import {t} from '@/locales'
const props = defineProps({
title: String,
})
@ -146,7 +147,13 @@ const open = (data: any) => {
userForm.value.phone = data.phone
userForm.value.nick_name = data.nick_name
isEdit.value = true
} else {
//zxl
userManageApi.getSystemDefaultPassword().then((res: any) => {
userForm.value.password = res.data.password
})
}
visible.value = true
}