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

@ -1,14 +1,13 @@
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";
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'
const prefix = '/system/chat_user'
/**
*
* @query
email_or_username: string
email_or_username: string
*/
const getUserManage: (
page: pageRequest,
@ -16,8 +15,8 @@ const getUserManage: (
loading?: Ref<boolean>,
) => Promise<Result<any>> = (page, email_or_username, loading) => {
return get(
`${prefix}/${page.current_page}/${page.page_size}`,
email_or_username ? { email_or_username } : undefined,
`${prefix}/user_manage/${page.current_page}/${page.page_size}`,
email_or_username ? {email_or_username} : undefined,
loading,
)
}

View File

@ -1,6 +1,6 @@
import { Result } from '@/request/Result'
import { get, post, del, put } from '@/request/index'
import type { Ref } from 'vue'
import {Result} from '@/request/Result'
import {get, post, del, put} from '@/request/index'
import type {Ref} from 'vue'
const prefix = '/system/group'
@ -15,9 +15,9 @@ const getUserGroup: (loading?: Ref<boolean>) => Promise<Result<any[]>> = () => {
*
* @param
* {
"id": "string",
"name": "string"
}
"id": "string",
"name": "string"
}
*/
const postUserGroup: (data: any, loading?: Ref<boolean>) => Promise<Result<boolean>> = (
data,
@ -41,13 +41,13 @@ const delUserGroup: (user_group_id: String, loading?: Ref<boolean>) => Promise<R
*
* @param
* {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
*/
const postAddMember: (
user_group_id: String,
user_group_id: string,
body: any,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (user_group_id, body, loading) => {
@ -57,13 +57,13 @@ const postAddMember: (
/**
*
* @param {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
*/
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

@ -1,14 +1,14 @@
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 {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 = '/user_manage'
/**
*
* @query
email_or_username: string
email_or_username: string
*/
const getUserManage: (
page: pageRequest,
@ -17,7 +17,7 @@ const getUserManage: (
) => Promise<Result<any>> = (page, email_or_username, loading) => {
return get(
`${prefix}/${page.current_page}/${page.page_size}`,
email_or_username ? { email_or_username } : undefined,
email_or_username ? {email_or_username} : undefined,
loading,
)
}
@ -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,22 +64,9 @@
>
</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>
<el-button @click.prevent="visible = false"> {{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="submit(userFormRef)" :loading="loading">
{{ $t('common.save') }}
</el-button>
@ -87,11 +74,12 @@
</el-drawer>
</template>
<script setup lang="ts">
import { ref, reactive, watch } from 'vue'
import type { FormInstance } from 'element-plus'
import userManageApi from '@/api/user/user-manage'
import { MsgSuccess } from '@/utils/message'
import { t } from '@/locales'
import {ref, reactive, watch} from 'vue'
import type {FormInstance} from 'element-plus'
import userManageApi from '@/api/system/chat-user'
import {MsgSuccess} from '@/utils/message'
import {t} from '@/locales'
const props = defineProps({
title: String,
})
@ -194,6 +182,6 @@ const submit = async (formEl: FormInstance | undefined) => {
})
}
defineExpose({ open })
defineExpose({open})
</script>
<style lang="scss" scoped></style>

View File

@ -4,8 +4,9 @@
<el-card>
<div class="flex-between mb-16">
<el-button type="primary" @click="createUser()">{{
$t('views.userManage.createUser')
}}</el-button>
$t('views.userManage.createUser')
}}
</el-button>
<div class="flex-between complex-search">
<el-select
class="complex-search__left"
@ -13,7 +14,7 @@
style="width: 120px"
@change="search_type_change"
>
<el-option :label="$t('views.login.loginForm.username.label')" value="name" />
<el-option :label="$t('views.login.loginForm.username.label')" value="name"/>
</el-select>
<el-input
v-if="search_type === 'name'"
@ -33,14 +34,16 @@
@changePage="getList"
v-loading="loading"
>
<el-table-column prop="nick_name" :label="$t('views.userManage.userForm.nick_name.label')" />
<el-table-column prop="username" :label="$t('views.userManage.userForm.username.label')" />
<el-table-column prop="nick_name" :label="$t('views.userManage.userForm.nick_name.label')"/>
<el-table-column prop="username" :label="$t('views.userManage.userForm.username.label')"/>
<el-table-column prop="is_active" :label="$t('common.status.label')">
<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,16 +99,15 @@
<template #default="{ row }">
<span @click.stop>
<el-switch
:disabled="row.role === 'ADMIN'"
size="small"
v-model="row.is_active"
:before-change="() => changeState(row)"
/>
</span>
<el-divider direction="vertical" />
<el-divider direction="vertical"/>
<span class="mr-8">
<el-button type="primary" text @click.stop="editUser(row)" :title="$t('common.edit')">
<el-icon><EditPen /></el-icon>
<el-icon><EditPen/></el-icon>
</el-button>
</span>
@ -116,7 +118,7 @@
@click.stop="editPwdUser(row)"
:title="$t('views.userManage.setting.updatePwd')"
>
<el-icon><Lock /></el-icon>
<el-icon><Lock/></el-icon>
</el-button>
</span>
<span>
@ -127,26 +129,27 @@
@click.stop="deleteUserManage(row)"
:title="$t('common.delete')"
>
<el-icon><Delete /></el-icon>
<el-icon><Delete/></el-icon>
</el-button>
</span>
</template>
</el-table-column>
</app-table>
</el-card>
<UserDrawer :title="title" ref="UserDrawerRef" @refresh="refresh" />
<UserPwdDialog ref="UserPwdDialogRef" @refresh="refresh" />
<UserDrawer :title="title" ref="UserDrawerRef" @refresh="refresh"/>
<UserPwdDialog ref="UserPwdDialogRef" @refresh="refresh"/>
</div>
</template>
<script lang="ts" setup>
import { onMounted, ref, reactive, watch } from 'vue'
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 { datetimeFormat } from '@/utils/time'
import { MsgSuccess, MsgConfirm } from '@/utils/message'
import { t } from '@/locales'
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
@ -167,8 +170,9 @@ const paginationConfig = reactive({
const userTableData = ref<any[]>([])
const search_type_change = () => {
search_form.value = { name: '' }
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,11 +52,11 @@
</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>
<el-button @click.prevent="visible = false"> {{ $t('common.cancel') }} </el-button>
<el-button @click.prevent="visible = false"> {{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="submit(userFormRef)" :loading="loading">
{{ $t('common.save') }}
</el-button>
@ -64,11 +64,12 @@
</el-drawer>
</template>
<script setup lang="ts">
import { ref, reactive, watch } from 'vue'
import type { FormInstance } from 'element-plus'
import {ref, reactive, watch} from 'vue'
import type {FormInstance} from 'element-plus'
import userManageApi from '@/api/user/user-manage'
import { MsgSuccess } from '@/utils/message'
import { t } from '@/locales'
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
}
@ -171,6 +178,6 @@ const submit = async (formEl: FormInstance | undefined) => {
})
}
defineExpose({ open })
defineExpose({open})
</script>
<style lang="scss" scoped></style>