fix: user
parent
7455348a6e
commit
d677207af1
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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>({
|
||||
allSchemas: allSchemas,
|
||||
getListApi: UserApi.getUserPageApi,
|
||||
deleteApi: UserApi.deleteUserApi,
|
||||
exportListApi: UserApi.exportUserApi
|
||||
})
|
||||
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 => {
|
||||
|
|
|
@ -57,10 +57,7 @@ const crudSchemas = reactive<VxeCrudSchema>({
|
|||
{
|
||||
title: '部门',
|
||||
field: 'deptId',
|
||||
isTable: false,
|
||||
search: {
|
||||
visible: false
|
||||
}
|
||||
isTable: false
|
||||
},
|
||||
{
|
||||
title: '岗位',
|
||||
|
|
Loading…
Reference in New Issue