Skip to content

Commit 7484201

Browse files
committed
refactor: chat user
1 parent e9aa3a3 commit 7484201

File tree

6 files changed

+91
-95
lines changed

6 files changed

+91
-95
lines changed

ui/src/api/system/chat-user.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
import { Result } from '@/request/Result'
2-
import { get, put, post, del } from '@/request/index'
3-
import type { pageRequest } from '@/api/type/common'
4-
import type { Ref } from 'vue'
5-
import type {ResetPasswordRequest} from "@/api/type/user.ts";
1+
import {Result} from '@/request/Result'
2+
import {get, put, post, del} from '@/request/index'
3+
import type {pageRequest} from '@/api/type/common'
4+
import type {Ref} from 'vue'
65

76
const prefix = '/system/chat_user'
87
/**
98
* 用户分页列表
109
* @query 参数
11-
email_or_username: string
10+
email_or_username: string
1211
*/
1312
const getUserManage: (
1413
page: pageRequest,
1514
email_or_username: string,
1615
loading?: Ref<boolean>,
1716
) => Promise<Result<any>> = (page, email_or_username, loading) => {
1817
return get(
19-
`${prefix}/${page.current_page}/${page.page_size}`,
20-
email_or_username ? { email_or_username } : undefined,
18+
`${prefix}/user_manage/${page.current_page}/${page.page_size}`,
19+
email_or_username ? {email_or_username} : undefined,
2120
loading,
2221
)
2322
}

ui/src/api/system/user-group.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Result } from '@/request/Result'
2-
import { get, post, del, put } from '@/request/index'
3-
import type { Ref } from 'vue'
1+
import {Result} from '@/request/Result'
2+
import {get, post, del, put} from '@/request/index'
3+
import type {Ref} from 'vue'
44

55
const prefix = '/system/group'
66

@@ -15,9 +15,9 @@ const getUserGroup: (loading?: Ref<boolean>) => Promise<Result<any[]>> = () => {
1515
* 创建用户组
1616
* @param 参数
1717
* {
18-
"id": "string",
19-
"name": "string"
20-
}
18+
"id": "string",
19+
"name": "string"
20+
}
2121
*/
2222
const postUserGroup: (data: any, loading?: Ref<boolean>) => Promise<Result<boolean>> = (
2323
data,
@@ -41,13 +41,13 @@ const delUserGroup: (user_group_id: String, loading?: Ref<boolean>) => Promise<R
4141
* 给用户组添加用户
4242
* @param 参数
4343
* {
44-
"additionalProp1": "string",
45-
"additionalProp2": "string",
46-
"additionalProp3": "string"
47-
}
44+
"additionalProp1": "string",
45+
"additionalProp2": "string",
46+
"additionalProp3": "string"
47+
}
4848
*/
4949
const postAddMember: (
50-
user_group_id: String,
50+
user_group_id: string,
5151
body: any,
5252
loading?: Ref<boolean>,
5353
) => Promise<Result<any>> = (user_group_id, body, loading) => {
@@ -57,13 +57,13 @@ const postAddMember: (
5757
/**
5858
* 从用户组删除用户
5959
* @param 参数 {
60-
"additionalProp1": "string",
61-
"additionalProp2": "string",
62-
"additionalProp3": "string"
63-
}
60+
"additionalProp1": "string",
61+
"additionalProp2": "string",
62+
"additionalProp3": "string"
63+
}
6464
*/
6565
const postRemoveMember: (
66-
user_group_id: String,
66+
user_group_id: string,
6767
body: any,
6868
loading?: Ref<boolean>,
6969
) => Promise<Result<any>> = (user_group_id, body, loading) => {

ui/src/api/user/user-manage.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { Result } from '@/request/Result'
2-
import { get, put, post, del } from '@/request/index'
3-
import type { pageRequest } from '@/api/type/common'
4-
import type { Ref } from 'vue'
1+
import {Result} from '@/request/Result'
2+
import {get, put, post, del} from '@/request/index'
3+
import type {pageRequest} from '@/api/type/common'
4+
import type {Ref} from 'vue'
55
import type {ResetPasswordRequest} from "@/api/type/user.ts";
66

77
const prefix = '/user_manage'
88
/**
99
* 用户分页列表
1010
* @query 参数
11-
email_or_username: string
11+
email_or_username: string
1212
*/
1313
const getUserManage: (
1414
page: pageRequest,
@@ -17,7 +17,7 @@ const getUserManage: (
1717
) => Promise<Result<any>> = (page, email_or_username, loading) => {
1818
return get(
1919
`${prefix}/${page.current_page}/${page.page_size}`,
20-
email_or_username ? { email_or_username } : undefined,
20+
email_or_username ? {email_or_username} : undefined,
2121
loading,
2222
)
2323
}
@@ -91,12 +91,23 @@ const resetCurrentPassword: (
9191
return post('/user/current/reset_password', request, undefined, loading)
9292
}
9393

94+
/**
95+
* 获取系统默认密码
96+
*/
97+
const getSystemDefaultPassword: (
98+
loading?: Ref<boolean>
99+
) => Promise<Result<string>> = (loading) => {
100+
return get('/user_manage/password', undefined, loading)
101+
}
102+
103+
94104
export default {
95105
getUserManage,
96106
putUserManage,
97107
delUserManage,
98108
postUserManage,
99109
putUserManagePassword,
100110
resetPassword,
101-
resetCurrentPassword
111+
resetCurrentPassword,
112+
getSystemDefaultPassword
102113
}

ui/src/views/system-chat-user/user-manage/component/UserDrawer.vue

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,34 +64,22 @@
6464
>
6565
</el-input>
6666
</el-form-item>
67-
<el-form-item
68-
:label="$t('views.userManage.form.password.label')"
69-
prop="password"
70-
v-if="!isEdit"
71-
>
72-
<el-input
73-
type="password"
74-
v-model="userForm.password"
75-
:placeholder="$t('views.userManage.form.password.placeholder')"
76-
show-password
77-
>
78-
</el-input>
79-
</el-form-item>
8067
</el-form>
8168
<template #footer>
82-
<el-button @click.prevent="visible = false"> {{ $t('common.cancel') }} </el-button>
69+
<el-button @click.prevent="visible = false"> {{ $t('common.cancel') }}</el-button>
8370
<el-button type="primary" @click="submit(userFormRef)" :loading="loading">
8471
{{ $t('common.save') }}
8572
</el-button>
8673
</template>
8774
</el-drawer>
8875
</template>
8976
<script setup lang="ts">
90-
import { ref, reactive, watch } from 'vue'
91-
import type { FormInstance } from 'element-plus'
92-
import userManageApi from '@/api/user/user-manage'
93-
import { MsgSuccess } from '@/utils/message'
94-
import { t } from '@/locales'
77+
import {ref, reactive, watch} from 'vue'
78+
import type {FormInstance} from 'element-plus'
79+
import userManageApi from '@/api/system/chat-user'
80+
import {MsgSuccess} from '@/utils/message'
81+
import {t} from '@/locales'
82+
9583
const props = defineProps({
9684
title: String,
9785
})
@@ -194,6 +182,6 @@ const submit = async (formEl: FormInstance | undefined) => {
194182
})
195183
}
196184
197-
defineExpose({ open })
185+
defineExpose({open})
198186
</script>
199187
<style lang="scss" scoped></style>

ui/src/views/system-chat-user/user-manage/index.vue

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
<el-card>
55
<div class="flex-between mb-16">
66
<el-button type="primary" @click="createUser()">{{
7-
$t('views.userManage.createUser')
8-
}}</el-button>
7+
$t('views.userManage.createUser')
8+
}}
9+
</el-button>
910
<div class="flex-between complex-search">
1011
<el-select
1112
class="complex-search__left"
1213
v-model="search_type"
1314
style="width: 120px"
1415
@change="search_type_change"
1516
>
16-
<el-option :label="$t('views.login.loginForm.username.label')" value="name" />
17+
<el-option :label="$t('views.login.loginForm.username.label')" value="name"/>
1718
</el-select>
1819
<el-input
1920
v-if="search_type === 'name'"
@@ -33,14 +34,16 @@
3334
@changePage="getList"
3435
v-loading="loading"
3536
>
36-
<el-table-column prop="nick_name" :label="$t('views.userManage.userForm.nick_name.label')" />
37-
<el-table-column prop="username" :label="$t('views.userManage.userForm.username.label')" />
37+
<el-table-column prop="nick_name" :label="$t('views.userManage.userForm.nick_name.label')"/>
38+
<el-table-column prop="username" :label="$t('views.userManage.userForm.username.label')"/>
3839
<el-table-column prop="is_active" :label="$t('common.status.label')">
3940
<template #default="{ row }">
4041
<div v-if="row.is_active" class="flex align-center">
4142
<el-icon class="color-success mr-8" style="font-size: 16px"
42-
><SuccessFilled
43-
/></el-icon>
43+
>
44+
<SuccessFilled
45+
/>
46+
</el-icon>
4447
<span class="color-secondary">
4548
{{ $t('common.status.enabled') }}
4649
</span>
@@ -96,16 +99,15 @@
9699
<template #default="{ row }">
97100
<span @click.stop>
98101
<el-switch
99-
:disabled="row.role === 'ADMIN'"
100102
size="small"
101103
v-model="row.is_active"
102104
:before-change="() => changeState(row)"
103105
/>
104106
</span>
105-
<el-divider direction="vertical" />
107+
<el-divider direction="vertical"/>
106108
<span class="mr-8">
107109
<el-button type="primary" text @click.stop="editUser(row)" :title="$t('common.edit')">
108-
<el-icon><EditPen /></el-icon>
110+
<el-icon><EditPen/></el-icon>
109111
</el-button>
110112
</span>
111113

@@ -116,7 +118,7 @@
116118
@click.stop="editPwdUser(row)"
117119
:title="$t('views.userManage.setting.updatePwd')"
118120
>
119-
<el-icon><Lock /></el-icon>
121+
<el-icon><Lock/></el-icon>
120122
</el-button>
121123
</span>
122124
<span>
@@ -127,26 +129,27 @@
127129
@click.stop="deleteUserManage(row)"
128130
:title="$t('common.delete')"
129131
>
130-
<el-icon><Delete /></el-icon>
132+
<el-icon><Delete/></el-icon>
131133
</el-button>
132134
</span>
133135
</template>
134136
</el-table-column>
135137
</app-table>
136138
</el-card>
137-
<UserDrawer :title="title" ref="UserDrawerRef" @refresh="refresh" />
138-
<UserPwdDialog ref="UserPwdDialogRef" @refresh="refresh" />
139+
<UserDrawer :title="title" ref="UserDrawerRef" @refresh="refresh"/>
140+
<UserPwdDialog ref="UserPwdDialogRef" @refresh="refresh"/>
139141
</div>
140142
</template>
141143

142144
<script lang="ts" setup>
143-
import { onMounted, ref, reactive, watch } from 'vue'
145+
import {onMounted, ref, reactive, watch} from 'vue'
144146
import UserDrawer from './component/UserDrawer.vue'
145147
import UserPwdDialog from './component/UserPwdDialog.vue'
146-
import userManageApi from '@/api/user/user-manage'
147-
import { datetimeFormat } from '@/utils/time'
148-
import { MsgSuccess, MsgConfirm } from '@/utils/message'
149-
import { t } from '@/locales'
148+
import userManageApi from '@/api/system/chat-user'
149+
import {datetimeFormat} from '@/utils/time'
150+
import {MsgSuccess, MsgConfirm} from '@/utils/message'
151+
import {t} from '@/locales'
152+
150153
const search_type = ref('name')
151154
const search_form = ref<{
152155
name: string
@@ -167,8 +170,9 @@ const paginationConfig = reactive({
167170
const userTableData = ref<any[]>([])
168171
169172
const search_type_change = () => {
170-
search_form.value = { name: '' }
173+
search_form.value = {name: ''}
171174
}
175+
172176
function handleSizeChange() {
173177
paginationConfig.current_page = 1
174178
getList()
@@ -201,29 +205,15 @@ function changeState(row: any) {
201205
}
202206
203207
const title = ref('')
208+
204209
function editUser(row: any) {
205210
title.value = t('views.userManage.editUser')
206211
UserDrawerRef.value.open(row)
207212
}
208213
209214
function createUser() {
210215
title.value = t('views.userManage.createUser')
211-
UserDrawerRef.value.open(1)
212-
// common.asyncGetValid(ValidType.User, ValidCount.User, loading).then(async (res: any) => {
213-
// if (res?.data) {
214-
// title.value = t('views.userManage.createUser')
215-
// UserDrawerRef.value.open()
216-
// } else if (res?.code === 400) {
217-
// MsgConfirm(t('common.tip'), t('views.userManage.tip.professionalMessage'), {
218-
// cancelButtonText: t('common.confirm'),
219-
// confirmButtonText: t('common.professional'),
220-
// })
221-
// .then(() => {
222-
// window.open('https://maxkb.cn/pricing.html', '_blank')
223-
// })
224-
// .catch(() => {})
225-
// }
226-
// })
216+
UserDrawerRef.value.open()
227217
}
228218
229219
function deleteUserManage(row: any) {
@@ -242,7 +232,8 @@ function deleteUserManage(row: any) {
242232
getList()
243233
})
244234
})
245-
.catch(() => {})
235+
.catch(() => {
236+
})
246237
}
247238
248239
function editPwdUser(row: any) {

0 commit comments

Comments
 (0)