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

View File

@ -47,7 +47,7 @@ const delUserGroup: (user_group_id: String, loading?: Ref<boolean>) => Promise<R
} }
*/ */
const postAddMember: ( const postAddMember: (
user_group_id: String, user_group_id: string,
body: any, body: any,
loading?: Ref<boolean>, loading?: Ref<boolean>,
) => Promise<Result<any>> = (user_group_id, body, loading) => { ) => Promise<Result<any>> = (user_group_id, body, loading) => {
@ -63,7 +63,7 @@ const postAddMember: (
} }
*/ */
const postRemoveMember: ( const postRemoveMember: (
user_group_id: String, user_group_id: string,
body: any, body: any,
loading?: Ref<boolean>, loading?: Ref<boolean>,
) => Promise<Result<any>> = (user_group_id, body, loading) => { ) => 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) 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 { export default {
getUserManage, getUserManage,
putUserManage, putUserManage,
@ -98,5 +108,6 @@ export default {
postUserManage, postUserManage,
putUserManagePassword, putUserManagePassword,
resetPassword, resetPassword,
resetCurrentPassword resetCurrentPassword,
getSystemDefaultPassword
} }

View File

@ -64,19 +64,6 @@
> >
</el-input> </el-input>
</el-form-item> </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> </el-form>
<template #footer> <template #footer>
<el-button @click.prevent="visible = false"> {{ $t('common.cancel') }}</el-button> <el-button @click.prevent="visible = false"> {{ $t('common.cancel') }}</el-button>
@ -89,9 +76,10 @@
<script setup lang="ts"> <script setup lang="ts">
import {ref, reactive, watch} from 'vue' import {ref, reactive, watch} from 'vue'
import type {FormInstance} from 'element-plus' 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 {MsgSuccess} from '@/utils/message'
import {t} from '@/locales' import {t} from '@/locales'
const props = defineProps({ const props = defineProps({
title: String, title: String,
}) })

View File

@ -5,7 +5,8 @@
<div class="flex-between mb-16"> <div class="flex-between mb-16">
<el-button type="primary" @click="createUser()">{{ <el-button type="primary" @click="createUser()">{{
$t('views.userManage.createUser') $t('views.userManage.createUser')
}}</el-button> }}
</el-button>
<div class="flex-between complex-search"> <div class="flex-between complex-search">
<el-select <el-select
class="complex-search__left" class="complex-search__left"
@ -39,8 +40,10 @@
<template #default="{ row }"> <template #default="{ row }">
<div v-if="row.is_active" class="flex align-center"> <div v-if="row.is_active" class="flex align-center">
<el-icon class="color-success mr-8" style="font-size: 16px" <el-icon class="color-success mr-8" style="font-size: 16px"
><SuccessFilled >
/></el-icon> <SuccessFilled
/>
</el-icon>
<span class="color-secondary"> <span class="color-secondary">
{{ $t('common.status.enabled') }} {{ $t('common.status.enabled') }}
</span> </span>
@ -96,7 +99,6 @@
<template #default="{ row }"> <template #default="{ row }">
<span @click.stop> <span @click.stop>
<el-switch <el-switch
:disabled="row.role === 'ADMIN'"
size="small" size="small"
v-model="row.is_active" v-model="row.is_active"
:before-change="() => changeState(row)" :before-change="() => changeState(row)"
@ -143,10 +145,11 @@
import {onMounted, ref, reactive, watch} from 'vue' import {onMounted, ref, reactive, watch} from 'vue'
import UserDrawer from './component/UserDrawer.vue' import UserDrawer from './component/UserDrawer.vue'
import UserPwdDialog from './component/UserPwdDialog.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 {datetimeFormat} from '@/utils/time'
import {MsgSuccess, MsgConfirm} from '@/utils/message' import {MsgSuccess, MsgConfirm} from '@/utils/message'
import {t} from '@/locales' import {t} from '@/locales'
const search_type = ref('name') const search_type = ref('name')
const search_form = ref<{ const search_form = ref<{
name: string name: string
@ -169,6 +172,7 @@ const userTableData = ref<any[]>([])
const search_type_change = () => { const search_type_change = () => {
search_form.value = {name: ''} search_form.value = {name: ''}
} }
function handleSizeChange() { function handleSizeChange() {
paginationConfig.current_page = 1 paginationConfig.current_page = 1
getList() getList()
@ -201,6 +205,7 @@ function changeState(row: any) {
} }
const title = ref('') const title = ref('')
function editUser(row: any) { function editUser(row: any) {
title.value = t('views.userManage.editUser') title.value = t('views.userManage.editUser')
UserDrawerRef.value.open(row) UserDrawerRef.value.open(row)
@ -208,22 +213,7 @@ function editUser(row: any) {
function createUser() { function createUser() {
title.value = t('views.userManage.createUser') title.value = t('views.userManage.createUser')
UserDrawerRef.value.open(1) UserDrawerRef.value.open()
// 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(() => {})
// }
// })
} }
function deleteUserManage(row: any) { function deleteUserManage(row: any) {
@ -242,7 +232,8 @@ function deleteUserManage(row: any) {
getList() getList()
}) })
}) })
.catch(() => {}) .catch(() => {
})
} }
function editPwdUser(row: any) { function editPwdUser(row: any) {

View File

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