88 style =" width : 240px ; margin-right : 12px "
99 :placeholder =" $t('user.name_account_email')"
1010 @keyup.enter =" handleSearch"
11+ @blur =" handleSearch"
1112 >
1213 <template #prefix >
1314 <el-icon >
2829 </template >
2930 {{ $t('user.batch_import') }}
3031 </el-button >
31- <el-button type =" primary" >
32+ <el-button type =" primary" @click = " editHandler(null) " >
3233 <template #icon >
3334 <icon _add_outlined ></icon _add_outlined >
3435 </template >
6364 </template >
6465 </el-table-column >
6566 <el-table-column prop =" email" :label =" $t('user.email')" width =" 280" />
66- <el-table-column prop =" phone" :label =" $t('user.phone_number')" width =" 280" />
67- <el-table-column prop =" user_source" :label =" $t('user.user_source')" width =" 280" />
68- <el-table-column prop =" workspace " :label =" $t('user.workspace')" width =" 280" />
67+ <!-- < el-table-column prop="phone" :label="$t('user.phone_number')" width="280" /> -- >
68+ <!-- < el-table-column prop="user_source" :label="$t('user.user_source')" width="280" /> -- >
69+ <el-table-column prop =" space_name " :label =" $t('user.workspace')" width =" 280" />
6970
7071 <el-table-column prop =" create_time" width =" 180" sortable :label =" $t('user.creation_time')" >
7172 <template #default =" scope " >
7576 <el-table-column fixed =" right" width =" 150" :label =" $t('ds.actions')" >
7677 <template #default =" scope " >
7778 <div class =" table-operate" >
78- <el-switch v-model =" scope.row.checked" size =" small" />
79+ <el-switch
80+ v-model =" scope.row.status"
81+ :active-value =" 1"
82+ :inactive-value =" 0"
83+ size =" small"
84+ @change =" statusHandler(scope.row)"
85+ />
7986 <div class =" line" ></div >
8087 <el-tooltip
8188 :offset =" 14"
8289 effect =" dark"
8390 :content =" $t('datasource.edit')"
8491 placement =" top"
8592 >
86- <el-icon class =" action-btn" size =" 16" @click =" editHandler(scope.row.id )" >
93+ <el-icon class =" action-btn" size =" 16" @click =" editHandler(scope.row)" >
8794 <IconOpeEdit ></IconOpeEdit >
8895 </el-icon >
8996 </el-tooltip >
9097
9198 <el-tooltip
9299 :offset =" 14"
93100 effect =" dark"
94- :content =" $t('datasource.edit ')"
101+ :content =" $t('user.change_password ')"
95102 placement =" top"
96103 >
97104 <el-icon class =" action-btn" size =" 16" @click =" handleEditPassword(scope.row.id)" >
186193 autocomplete =" off"
187194 />
188195 </el-form-item >
189- <el-form-item :label =" $t('user.phone_number')" >
196+ <!-- < el-form-item :label="$t('user.phone_number')">
190197 <el-input
191198 v-model="state.form.phoneNumber"
192199 :placeholder="
193200 $t('datasource.please_enter') + $t('common.empty') + $t('user.phone_number')
194201 "
195202 autocomplete="off"
196203 />
197- </el-form-item >
204+ </el-form-item> -->
198205
199206 <el-form-item :label =" $t('user.workspace')" >
200207 <el-select
201- v-model =" state.form.workspace "
208+ v-model =" state.form.oid "
202209 :placeholder =" $t('datasource.Please_select') + $t('common.empty') + $t('user.workspace')"
203210 >
204- <el-option label =" domain1" value =" domain1" />
205- <el-option label =" domain2" value =" domain2" />
206- <el-option label =" domain3" value =" domain3" />
211+ <el-option v-for =" item in options" :key =" item.id" :label =" item.name" :value =" item.id" />
207212 </el-select >
208213 </el-form-item >
209214 <el-form-item :label =" $t('user.user_status')" >
210- <el-switch v-model =" state.form.status" />
215+ <el-switch v-model =" state.form.status" :active-value = " 1 " :inactive-value = " 0 " />
211216 </el-form-item >
212217 </el-form >
213218 <template #footer >
@@ -282,7 +287,8 @@ import IconOpeDelete from '@/assets/svg/icon_delete.svg'
282287import iconFilter from ' @/assets/svg/icon-filter_outlined.svg'
283288import ccmUpload from ' @/assets/svg/icon_ccm-upload_outlined.svg'
284289import icon_add_outlined from ' @/assets/svg/icon_add_outlined.svg'
285- import { userApi } from ' @/api/auth'
290+ import { userApi } from ' @/api/user'
291+ import { workspaceList } from ' @/api/workspace'
286292import { formatTimestamp } from ' @/utils/date'
287293
288294const { t } = useI18n ()
@@ -294,7 +300,43 @@ const dialogVisiblePassword = ref(false)
294300const isIndeterminate = ref (true )
295301const drawerMainRef = ref ()
296302const userImportRef = ref ()
297- const filterOption = ref <any []>([])
303+ const filterOption = ref <any []>([
304+ {
305+ type: ' enum' ,
306+ option: [
307+ { id: 1 , name: t (' user.enable' ) },
308+ { id: 0 , name: t (' user.disable' ) },
309+ ],
310+ field: ' status' ,
311+ title: t (' user.user_status' ),
312+ operate: ' in' ,
313+ },
314+ {
315+ type: ' enum' ,
316+ option: [
317+ { id: ' 0' , name: t (' user.local_creation' ) },
318+ { id: 1 , name: ' LDAP' },
319+ { id: 2 , name: ' OIDC' },
320+ { id: 3 , name: ' CAS' },
321+ { id: 9 , name: ' OAuth2' },
322+ { id: 4 , name: t (' user.feishu' ) },
323+ { id: 5 , name: t (' user.dingtalk' ) },
324+ { id: 6 , name: t (' user.wechat_for_business' ) },
325+ ],
326+ field: ' origins' ,
327+ title: t (' user.user_source' ),
328+ operate: ' in' ,
329+ },
330+ {
331+ type: ' select' ,
332+ option: [],
333+ field: ' oidist' ,
334+ title: t (' user.workspace' ),
335+ operate: ' in' ,
336+ property: { placeholder: t (' common.empty' ) + t (' user.workspace' ) },
337+ },
338+ ])
339+ const options = ref <any []>([])
298340const state = reactive <any >({
299341 tableData: [],
300342 filterTexts: [],
@@ -303,7 +345,7 @@ const state = reactive<any>({
303345 id: ' ' ,
304346 name: ' ' ,
305347 account: ' ' ,
306- workspace : ' ' ,
348+ oid : ' ' ,
307349 email: ' ' ,
308350 status: ' ' ,
309351 phoneNumber: ' ' ,
@@ -417,8 +459,8 @@ const handleToggleRowSelection = (check: boolean = true) => {
417459 checkAll .value = i === state .tableData .length
418460 isIndeterminate .value = ! (i === 0 || i === state .tableData .length )
419461}
420- const handleSearch = (e : any ) => {
421- console . log ( ' search' , e )
462+ const handleSearch = () => {
463+ search ( )
422464}
423465const fillFilterText = () => {
424466 const textArray = state .conditions ?.length
@@ -439,62 +481,26 @@ const clearFilter = (params?: number) => {
439481const searchCondition = (conditions : any ) => {
440482 state .conditions = conditions
441483 fillFilterText ()
442- console . log ( conditions )
484+ search ( )
443485 drawerMainClose ()
444486}
445487const drawerMainOpen = async () => {
446- filterOption .value = [
447- {
448- type: ' enum' ,
449- option: [
450- { id: true , name: t (' user.enable' ) },
451- { id: false , name: t (' user.disable' ) },
452- ],
453- field: ' statusList' ,
454- title: t (' user.user_status' ),
455- operate: ' in' ,
456- },
457- {
458- type: ' enum' ,
459- option: [
460- { id: ' 0' , name: t (' user.local_creation' ) },
461- { id: 1 , name: ' LDAP' },
462- { id: 2 , name: ' OIDC' },
463- { id: 3 , name: ' CAS' },
464- { id: 9 , name: ' OAuth2' },
465- { id: 4 , name: t (' user.feishu' ) },
466- { id: 5 , name: t (' user.dingtalk' ) },
467- { id: 6 , name: t (' user.wechat_for_business' ) },
468- ],
469- field: ' originList' ,
470- title: t (' user.user_source' ),
471- operate: ' in' ,
472- },
473- {
474- type: ' select' ,
475- option: [{ id: ' 0' , name: ' LOCAL' }],
476- field: ' workspaceList' ,
477- title: t (' user.workspace' ),
478- operate: ' in' ,
479- property: { placeholder: t (' common.empty' ) + t (' user.workspace' ) },
480- },
481- ]
482-
483488 drawerMainRef .value .init ()
484489}
485490const drawerMainClose = () => {
486491 drawerMainRef .value .close ()
487492}
488- const editHandler = (id : any ) => {
489- console .log (' editHandler' , id )
493+ const editHandler = (row : any ) => {
494+ if (row ) {
495+ state .form = { ... row }
496+ }
490497 dialogFormVisible .value = true
491- dialogTitle .value = id ? t (' user.edit_user' ) : t (' user.add_users' )
498+ dialogTitle .value = row ?.id ? t (' user.edit_user' ) : t (' user.add_users' )
499+ }
492500
493- // userApi.query(id).then((res: any) => {
494- // console.log('term detail', res)
495- // state.form = res
496- // dialogFormVisible.value = true
497- // })
501+ const statusHandler = (row : any ) => {
502+ state .form = { ... row }
503+ editTerm ()
498504}
499505
500506const cancelDelete = () => {
@@ -521,18 +527,15 @@ const deleteHandler = (row: any) => {
521527 cancelButtonText: t (' common.cancel' ),
522528 customClass: ' confirm-no_icon' ,
523529 autofocus: false ,
524- callback : (val : string ) => {
525- console .log (val )
526- },
527530 })
528531 .then (() => {
529- /* userApi.delete(id).then(() => {
532+ userApi .delete (row . id ).then (() => {
530533 ElMessage ({
531534 type: ' success' ,
532535 message: ' Delete completed' ,
533536 })
534537 search ()
535- }) */
538+ })
536539 })
537540 .catch (() => {
538541 ElMessage ({
@@ -560,34 +563,54 @@ const onFormClose = () => {
560563 dialogFormVisible .value = false
561564}
562565
563- const search = () => {
564- userApi .pager (state .pageInfo .currentPage , state .pageInfo .pageSize ).then ((res : any ) => {
565- state .tableData = res .items
566- state .pageInfo .total = res .total
566+ const configParams = () => {
567+ let str = ' '
568+ if (keyword .value ) {
569+ str += ` keyword=${keyword .value } `
570+ }
567571
568- nextTick (() => {
569- handleToggleRowSelection ()
572+ state .conditions .forEach ((ele : any ) => {
573+ ele .value .forEach ((itx : any ) => {
574+ str += str ? ` &${ele .field }=${itx } ` : ` ${ele .field }=${itx } `
570575 })
571576 })
577+
578+ if (str .length ) {
579+ str = ` ?${str } `
580+ }
581+
582+ return str
583+ }
584+
585+ const search = () => {
586+ userApi
587+ .pager (configParams (), state .pageInfo .currentPage , state .pageInfo .pageSize )
588+ .then ((res : any ) => {
589+ state .tableData = res .items
590+ state .pageInfo .total = res .total
591+
592+ nextTick (() => {
593+ handleToggleRowSelection ()
594+ })
595+ })
572596}
573597const addTerm = () => {
574598 userApi .add (state .form ).then (() => {
575599 dialogFormVisible .value = false
576600 search ()
577601 ElMessage ({
578602 type: ' success' ,
579- message: ' Add completed ' ,
603+ message: t ( ' common.save_success ' ) ,
580604 })
581605 })
582606}
583607const editTerm = () => {
584- userApi .edit (state .form ).then ((res : any ) => {
585- console .log (' edit term' , res )
608+ userApi .edit (state .form ).then (() => {
586609 dialogFormVisible .value = false
587610 search ()
588611 ElMessage ({
589612 type: ' success' ,
590- message: ' Edit completed ' ,
613+ message: t ( ' common.save_success ' ) ,
591614 })
592615 })
593616}
@@ -607,6 +630,10 @@ const handleCurrentChange = (val: number) => {
607630 search ()
608631}
609632onMounted (() => {
633+ workspaceList ().then ((res ) => {
634+ options .value = res || []
635+ filterOption .value [2 ].option = [... options .value ]
636+ })
610637 search ()
611638})
612639 </script >
0 commit comments