fix: user

pull/2/head
xingyu 2022-11-17 00:22:38 +08:00
parent 7455348a6e
commit d677207af1
11 changed files with 47 additions and 49 deletions

View File

@ -14,7 +14,8 @@ interface UseVxeGridConfig<T = any> {
getListApi: (option: any) => Promise<T>
deleteApi?: (option: any) => Promise<T>
exportListApi?: (option: any) => Promise<T>
exportName?: string
exportName?: string // 导出文件夹名称
queryParams?: any // 其他查询参数
}
const appStore = useAppStore()
@ -64,7 +65,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
pagerConfig: {
border: false, // 带边框
background: true, // 带背景颜色
perfect: true, // 配套的样式
perfect: false, // 配套的样式
pageSize: 10, // 每页大小
pagerCount: 7, // 显示页码按钮的数量
autoHidden: true, // 当只有一页时自动隐藏
@ -72,11 +73,11 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
layouts: [
'PrevJump',
'PrevPage',
'Jump',
'PageCount',
'JumpNumber',
'NextPage',
'NextJump',
'Sizes',
'FullJump',
'Total'
]
},
@ -86,7 +87,10 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
props: { result: 'list', total: 'total' },
ajax: {
query: ({ page, form }) => {
const queryParams = Object.assign({}, JSON.parse(JSON.stringify(form)))
let queryParams: any = Object.assign({}, JSON.parse(JSON.stringify(form)))
if (config?.queryParams) {
queryParams = Object.assign(queryParams, config.queryParams)
}
queryParams.pageSize = page.pageSize
queryParams.pageNo = page.currentPage
gridOptions.loading = false
@ -121,7 +125,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
* @param ref
* @returns
*/
const reloadList = async (ref) => {
const getList = async (ref) => {
if (!ref) {
console.error('未传入gridRef')
return
@ -214,7 +218,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
return {
gridOptions,
reloadList,
getList,
getSearchData,
deleteData,
exportList,

View File

@ -83,7 +83,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // grid Ref
const { gridOptions, reloadList, deleteData } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({
const { gridOptions, getList, deleteData } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({
allSchemas: allSchemas,
getListApi: ErrorCodeApi.getErrorCodePageApi,
deleteApi: ErrorCodeApi.deleteErrorCodeApi
@ -150,7 +150,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
await reloadList(xGrid)
await getList(xGrid)
}
}
})

View File

@ -82,7 +82,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, reloadList, deleteData } = useVxeGrid<NoticeApi.NoticeVO>({
const { gridOptions, getList, deleteData } = useVxeGrid<NoticeApi.NoticeVO>({
allSchemas: allSchemas,
getListApi: NoticeApi.getNoticePageApi,
deleteApi: NoticeApi.deleteNoticeApi
@ -148,7 +148,7 @@ const submitForm = async () => {
dialogVisible.value = false
} finally {
actionLoading.value = false
await reloadList(xGrid)
await getList(xGrid)
}
}
})

View File

@ -147,7 +147,7 @@ const message = useMessage() // 消息弹窗
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, reloadList, deleteData } = useVxeGrid<ClientApi.OAuth2ClientVO>({
const { gridOptions, getList, deleteData } = useVxeGrid<ClientApi.OAuth2ClientVO>({
allSchemas: allSchemas,
getListApi: ClientApi.getOAuth2ClientPageApi,
deleteApi: ClientApi.deleteOAuth2ClientApi
@ -213,7 +213,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
await reloadList(xGrid)
await getList(xGrid)
}
}
})

View File

@ -39,7 +39,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, reloadList } = useVxeGrid<TokenApi.OAuth2TokenVO>({
const { gridOptions, getList } = useVxeGrid<TokenApi.OAuth2TokenVO>({
allSchemas: allSchemas,
getListApi: TokenApi.getAccessTokenPageApi
})
@ -65,7 +65,7 @@ const handleForceLogout = (rowId: number) => {
})
.finally(async () => {
//
await reloadList(xGrid)
await getList(xGrid)
})
}
</script>

View File

@ -90,7 +90,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, reloadList, deleteData, exportList } = useVxeGrid<PostApi.PostVO>({
const { gridOptions, getList, deleteData, exportList } = useVxeGrid<PostApi.PostVO>({
allSchemas: allSchemas,
getListApi: PostApi.getPostPageApi,
deleteApi: PostApi.deletePostApi,
@ -167,7 +167,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
await reloadList(xGrid)
await getList(xGrid)
}
}
})

View File

@ -174,7 +174,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, reloadList, deleteData } = useVxeGrid<RoleApi.RoleVO>({
const { gridOptions, getList, deleteData } = useVxeGrid<RoleApi.RoleVO>({
allSchemas: allSchemas,
getListApi: RoleApi.getRolePageApi,
deleteApi: RoleApi.deleteRoleApi
@ -242,7 +242,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
await reloadList(xGrid)
await getList(xGrid)
}
}
})

View File

@ -85,7 +85,7 @@ const message = useMessage() // 消息弹窗
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, reloadList, deleteData } = useVxeGrid<SmsChannelApi.SmsChannelVO>({
const { gridOptions, getList, deleteData } = useVxeGrid<SmsChannelApi.SmsChannelVO>({
allSchemas: allSchemas,
getListApi: SmsChannelApi.getSmsChannelPageApi,
deleteApi: SmsChannelApi.deleteSmsChannelApi
@ -152,7 +152,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
await reloadList(xGrid)
await getList(xGrid)
}
}
})

View File

@ -128,7 +128,7 @@ const message = useMessage() // 消息弹窗
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, reloadList, deleteData } = useVxeGrid<SmsTemplateApi.SmsTemplateVO>({
const { gridOptions, getList, deleteData } = useVxeGrid<SmsTemplateApi.SmsTemplateVO>({
allSchemas: allSchemas,
getListApi: SmsTemplateApi.getSmsTemplatePageApi,
deleteApi: SmsTemplateApi.deleteSmsTemplateApi
@ -196,7 +196,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
await reloadList(xGrid)
await getList(xGrid)
}
}
})

View File

@ -242,7 +242,7 @@
</XModal>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref, unref, watch } from 'vue'
import { nextTick, onMounted, reactive, ref, unref, watch } from 'vue'
import {
ElTag,
ElInput,
@ -287,18 +287,20 @@ const defaultProps = {
label: 'name',
value: 'id'
}
const queryParams = reactive({
deptId: null
})
// ========== ==========
const tableTitle = ref('用户列表')
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, reloadList, deleteData, exportList, getSearchData } =
useVxeGrid<UserApi.UserVO>({
const { gridOptions, getList, deleteData, exportList } = useVxeGrid<UserApi.UserVO>({
allSchemas: allSchemas,
queryParams: queryParams,
getListApi: UserApi.getUserPageApi,
deleteApi: UserApi.deleteUserApi,
exportListApi: UserApi.exportUserApi
})
})
// ========== ==========
const filterText = ref('')
const deptOptions = ref<any[]>([]) //
@ -312,13 +314,8 @@ const filterNode = (value: string, data: Tree) => {
return data.name.includes(value)
}
const handleDeptNodeClick = async (row: { [key: string]: any }) => {
tableTitle.value = row.name
console.log(getSearchData(xGrid))
// gridOptions.formConfig?.data.push({
// deptId: row.id
// })
// TODO
await reloadList(xGrid)
queryParams.deptId = row.id
await getList(xGrid)
}
const { push } = useRouter()
const handleDeptEdit = () => {
@ -351,17 +348,16 @@ const setDialogTile = async (type: string) => {
//
const handleCreate = async () => {
actionType.value = 'create'
setDialogTile('create')
//
deptId.value = null
postIds.value = []
dialogVisible.value = true
dialogTitle.value = t('action.create')
}
//
const handleUpdate = async (rowId: number) => {
setDialogTile('update')
await nextTick()
unref(formRef)?.delSchema('username')
unref(formRef)?.delSchema('password')
//
@ -400,8 +396,9 @@ const submitForm = async () => {
}
dialogVisible.value = false
} finally {
// unref(formRef)?.setSchema(allSchemas.formSchema)
//
await reloadList(xGrid)
await getList(xGrid)
loading.value = false
}
}
@ -416,7 +413,7 @@ const handleStatusChange = async (row: UserApi.UserVO) => {
await UserApi.updateUserStatusApi(row.id, row.status)
message.success(text + '成功')
//
await reloadList(xGrid)
await getList(xGrid)
})
.catch(() => {
row.status =
@ -516,7 +513,7 @@ const handleFileSuccess = async (response: any): Promise<void> => {
text += '< ' + username + ': ' + data.failureUsernames[username] + ' >'
}
message.alert(text)
await reloadList(xGrid)
await getList(xGrid)
}
//
const handleExceed = (): void => {

View File

@ -57,10 +57,7 @@ const crudSchemas = reactive<VxeCrudSchema>({
{
title: '部门',
field: 'deptId',
isTable: false,
search: {
visible: false
}
isTable: false
},
{
title: '岗位',