4040 {{ paginationConfig.total }}
4141 </span >
4242 </div >
43- <el-button type =" primary" @click =" handleSave" >
43+ <el-button type =" primary" :disabled = " current?.is_auth " @click =" handleSave" >
4444 {{ t('common.save') }}
4545 </el-button >
4646 </div >
5050 <el-select class =" complex-search__left" v-model =" searchType" style =" width : 120px " >
5151 <el-option :label =" $t('views.login.loginForm.username.label')" value =" name" />
5252 </el-select >
53- <el-input v-if =" searchType === 'name'" v-model =" searchForm.name"
54- @change = " getList " :placeholder =" $t('common.inputPlaceholder')" style =" width : 220px " clearable />
53+ <el-input v-if =" searchType === 'name'" v-model =" searchForm.name" @change = " getList "
54+ :placeholder =" $t('common.inputPlaceholder')" style =" width : 220px " clearable />
5555 </div >
5656 <div class =" flex align-center" >
5757 <div class =" color-secondary mr-8" >{{ $t('views.chatUser.autoAuthorization') }}</div >
58- <el-switch size =" small" v-model =" automaticAuthorization" ></el-switch >
58+ <el-switch size =" small" :model-value =" current?.is_auth" @click =" changeAuth"
59+ :loading =" loading" ></el-switch >
5960 </div >
6061 </div >
6162
8283 </el-table-column >
8384 <el-table-column :width =" 140" align =" center" >
8485 <template #header >
85- <el-checkbox :model-value =" allChecked" :indeterminate =" allIndeterminate" :disabled =" disabled"
86- @change =" handleCheckAll" >{{ $t('views.chatUser.authorization') }}</el-checkbox >
86+ <el-checkbox :model-value =" allChecked" :indeterminate =" allIndeterminate" :disabled =" current?.is_auth"
87+ @change =" handleCheckAll" >{{ $t('views.chatUser.authorization')
88+ }}</el-checkbox >
8789 </template >
8890 <template #default =" { row } " >
89- <el-checkbox v-model =" row.enable " :indeterminate =" row.indeterminate" :disabled =" disabled "
91+ <el-checkbox v-model =" row.is_auth " :indeterminate =" row.indeterminate" :disabled =" current?.is_auth "
9092 @change =" (value: boolean) => handleRowChange(value, row)" />
9193 </template >
9294 </el-table-column >
@@ -104,12 +106,11 @@ import { t } from '@/locales'
104106import type { ChatUserGroupItem , ChatUserResourceParams , ChatUserGroupUserItem } from ' @/api/type/workspaceChatUser'
105107import { useRoute } from ' vue-router'
106108import { ChatUserResourceEnum } from ' @/enums/workspaceChatUser'
109+ import { MsgSuccess } from ' @/utils/message'
107110
108111const route = useRoute ()
109112const resource: ChatUserResourceParams = { resource_id: route .params .id as string , resource_type: route .meta .resourceType as ChatUserResourceEnum }
110113
111- const disabled = computed (() => false ) // TODO
112-
113114const filterText = ref (' ' )
114115const loading = ref (false )
115116const list = ref <ChatUserGroupItem []>([])
@@ -148,13 +149,24 @@ function clickUserGroup(item: ChatUserGroupItem) {
148149 current .value = item
149150}
150151
152+ async function changeAuth() {
153+ const params = [{ user_group_id: current .value ?.id as string , is_auth: ! current .value ?.is_auth }]
154+ try {
155+ await ChatUserApi .editUserGroupList (resource , params , loading )
156+ await getUserGroupList ()
157+ current .value = { name: current .value ?.name as string , id: current .value ?.id as string , is_auth: ! current .value ?.is_auth }
158+ getList ()
159+ } catch (error ) {
160+ console .error (error )
161+ }
162+ }
163+
151164const rightLoading = ref (false )
152165
153166const searchType = ref (' name' )
154167const searchForm = ref <Record <string , any >>({
155168 name: ' ' ,
156169})
157- const automaticAuthorization = ref (false )
158170const paginationConfig = reactive ({
159171 current_page: 1 ,
160172 page_size: 20 ,
@@ -205,6 +217,7 @@ async function handleSave() {
205217 try {
206218 const params = tableData .value .map (item => ({ chat_user_id: item .id , is_auth: item .is_auth }))
207219 await ChatUserApi .putUserGroupUser (resource , current .value ?.id as string , params , rightLoading )
220+ MsgSuccess (t (' common.saveSuccess' ))
208221 } catch (error ) {
209222 console .error (error )
210223 }
0 commit comments