@@ -2,10 +2,10 @@ import { ref, onMounted } from 'vue'
22import AdminModel from '@/lin/model/admin'
33
44export const useUserList = ( ) => {
5- const groups = ref ( [ ] )
5+ const allGroups = ref ( [ ] )
66 const pageCount = ref ( 10 ) // 每页10条数据
77 const tableData = ref ( [ ] )
8- const groupID = ref ( null )
8+ const groupId = ref ( null )
99 const loading = ref ( false )
1010 const totalNum = ref ( 0 ) // 分组内的用户总数
1111 const currentPage = ref ( 1 ) // 默认获取第一页的数据
@@ -14,11 +14,11 @@ export const useUserList = () => {
1414 * 获取管理员列表数据
1515 */
1616 const getAdminUsers = async ( ) => {
17- let res
17+ let res = { }
1818 try {
1919 loading . value = true
2020 res = await AdminModel . getAdminUsers ( {
21- groupID : groupID . value ,
21+ groupId : groupId . value ,
2222 count : pageCount . value ,
2323 page : currentPage . value - 1 ,
2424 } )
@@ -37,7 +37,7 @@ export const useUserList = () => {
3737 const getAllGroups = async ( ) => {
3838 try {
3939 loading . value = true
40- groups . value = await AdminModel . getAllGroups ( )
40+ allGroups . value = await AdminModel . getAllGroups ( )
4141 loading . value = false
4242 } catch ( e ) {
4343 loading . value = false
@@ -46,16 +46,12 @@ export const useUserList = () => {
4646 }
4747
4848 /**
49- * 多分组用 ', ' 分割展示
49+ * 多分组用 ', ' 分割展示
5050 */
5151 const shuffleList = users => {
5252 const list = [ ]
5353 users . forEach ( element => {
54- const userGroups = [ ]
55- element . groups . forEach ( item => {
56- userGroups . push ( item . name )
57- } )
58- element . groupNames = userGroups . join ( ',' )
54+ element . groupNames = element . groups . map ( item => item . name ) . join ( ',' )
5955 list . push ( element )
6056 } )
6157 return list
@@ -67,18 +63,18 @@ export const useUserList = () => {
6763 } )
6864
6965 return {
70- groups,
71- groupID,
66+ groupId,
7267 loading,
7368 totalNum,
69+ allGroups,
7470 pageCount,
7571 tableData,
7672 currentPage,
7773 getAdminUsers,
7874 }
7975}
8076
81- export const useFormData = ( ctx , dialogFormVisible , getAdminUsers , currentPage , loading ) => {
77+ export const useFormData = ( ctx , dialogFormVisible , getAdminUsers , currentPage , loading , info , password ) => {
8278 const id = ref ( null )
8379 const activeTab = ref ( '修改信息' )
8480
@@ -113,13 +109,6 @@ export const useFormData = (ctx, dialogFormVisible, getAdminUsers, currentPage,
113109 }
114110 }
115111
116- /**
117- * 切换弹窗Tab栏
118- */
119- const handleClick = tab => {
120- activeTab . value = tab . name
121- }
122-
123112 /**
124113 * 翻页
125114 */
@@ -133,9 +122,9 @@ export const useFormData = (ctx, dialogFormVisible, getAdminUsers, currentPage,
133122 */
134123 const confirmEdit = async ( ) => {
135124 if ( activeTab . value === '修改信息' ) {
136- await ctx . refs . userInfo . submitForm ( 'form' )
125+ await info . value . submitForm ( )
137126 } else {
138- await ctx . refs . password . submitForm ( 'form' )
127+ await password . value . submitForm ( )
139128 }
140129 }
141130
@@ -147,14 +136,18 @@ export const useFormData = (ctx, dialogFormVisible, getAdminUsers, currentPage,
147136 done ( )
148137 }
149138
139+ const handleClick = tab => {
140+ activeTab . value = tab . props . name
141+ }
142+
150143 /**
151144 * 重置表单
152145 */
153146 const resetForm = ( ) => {
154147 if ( activeTab . value === '修改信息' ) {
155- ctx . refs . userInfo . resetForm ( 'form' )
148+ info . value . resetForm ( )
156149 } else {
157- ctx . refs . password . resetForm ( 'form' )
150+ password . value . resetForm ( )
158151 }
159152 }
160153
0 commit comments