fix: user
parent
7455348a6e
commit
d677207af1
|
@ -14,7 +14,8 @@ interface UseVxeGridConfig<T = any> {
|
||||||
getListApi: (option: any) => Promise<T>
|
getListApi: (option: any) => Promise<T>
|
||||||
deleteApi?: (option: any) => Promise<T>
|
deleteApi?: (option: any) => Promise<T>
|
||||||
exportListApi?: (option: any) => Promise<T>
|
exportListApi?: (option: any) => Promise<T>
|
||||||
exportName?: string
|
exportName?: string // 导出文件夹名称
|
||||||
|
queryParams?: any // 其他查询参数
|
||||||
}
|
}
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
|
@ -64,7 +65,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
|
||||||
pagerConfig: {
|
pagerConfig: {
|
||||||
border: false, // 带边框
|
border: false, // 带边框
|
||||||
background: true, // 带背景颜色
|
background: true, // 带背景颜色
|
||||||
perfect: true, // 配套的样式
|
perfect: false, // 配套的样式
|
||||||
pageSize: 10, // 每页大小
|
pageSize: 10, // 每页大小
|
||||||
pagerCount: 7, // 显示页码按钮的数量
|
pagerCount: 7, // 显示页码按钮的数量
|
||||||
autoHidden: true, // 当只有一页时自动隐藏
|
autoHidden: true, // 当只有一页时自动隐藏
|
||||||
|
@ -72,11 +73,11 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
|
||||||
layouts: [
|
layouts: [
|
||||||
'PrevJump',
|
'PrevJump',
|
||||||
'PrevPage',
|
'PrevPage',
|
||||||
'Jump',
|
'JumpNumber',
|
||||||
'PageCount',
|
|
||||||
'NextPage',
|
'NextPage',
|
||||||
'NextJump',
|
'NextJump',
|
||||||
'Sizes',
|
'Sizes',
|
||||||
|
'FullJump',
|
||||||
'Total'
|
'Total'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -86,7 +87,10 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
|
||||||
props: { result: 'list', total: 'total' },
|
props: { result: 'list', total: 'total' },
|
||||||
ajax: {
|
ajax: {
|
||||||
query: ({ page, form }) => {
|
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.pageSize = page.pageSize
|
||||||
queryParams.pageNo = page.currentPage
|
queryParams.pageNo = page.currentPage
|
||||||
gridOptions.loading = false
|
gridOptions.loading = false
|
||||||
|
@ -121,7 +125,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
|
||||||
* @param ref
|
* @param ref
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const reloadList = async (ref) => {
|
const getList = async (ref) => {
|
||||||
if (!ref) {
|
if (!ref) {
|
||||||
console.error('未传入gridRef')
|
console.error('未传入gridRef')
|
||||||
return
|
return
|
||||||
|
@ -214,7 +218,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
gridOptions,
|
gridOptions,
|
||||||
reloadList,
|
getList,
|
||||||
getSearchData,
|
getSearchData,
|
||||||
deleteData,
|
deleteData,
|
||||||
exportList,
|
exportList,
|
||||||
|
|
|
@ -83,7 +83,7 @@ const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // grid Ref
|
const xGrid = ref<VxeGridInstance>() // grid Ref
|
||||||
const { gridOptions, reloadList, deleteData } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({
|
const { gridOptions, getList, deleteData } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: ErrorCodeApi.getErrorCodePageApi,
|
getListApi: ErrorCodeApi.getErrorCodePageApi,
|
||||||
deleteApi: ErrorCodeApi.deleteErrorCodeApi
|
deleteApi: ErrorCodeApi.deleteErrorCodeApi
|
||||||
|
@ -150,7 +150,7 @@ const submitForm = async () => {
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -82,7 +82,7 @@ const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, reloadList, deleteData } = useVxeGrid<NoticeApi.NoticeVO>({
|
const { gridOptions, getList, deleteData } = useVxeGrid<NoticeApi.NoticeVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: NoticeApi.getNoticePageApi,
|
getListApi: NoticeApi.getNoticePageApi,
|
||||||
deleteApi: NoticeApi.deleteNoticeApi
|
deleteApi: NoticeApi.deleteNoticeApi
|
||||||
|
@ -148,7 +148,7 @@ const submitForm = async () => {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -147,7 +147,7 @@ const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, reloadList, deleteData } = useVxeGrid<ClientApi.OAuth2ClientVO>({
|
const { gridOptions, getList, deleteData } = useVxeGrid<ClientApi.OAuth2ClientVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: ClientApi.getOAuth2ClientPageApi,
|
getListApi: ClientApi.getOAuth2ClientPageApi,
|
||||||
deleteApi: ClientApi.deleteOAuth2ClientApi
|
deleteApi: ClientApi.deleteOAuth2ClientApi
|
||||||
|
@ -213,7 +213,7 @@ const submitForm = async () => {
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -39,7 +39,7 @@ const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, reloadList } = useVxeGrid<TokenApi.OAuth2TokenVO>({
|
const { gridOptions, getList } = useVxeGrid<TokenApi.OAuth2TokenVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: TokenApi.getAccessTokenPageApi
|
getListApi: TokenApi.getAccessTokenPageApi
|
||||||
})
|
})
|
||||||
|
@ -65,7 +65,7 @@ const handleForceLogout = (rowId: number) => {
|
||||||
})
|
})
|
||||||
.finally(async () => {
|
.finally(async () => {
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -90,7 +90,7 @@ const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, reloadList, deleteData, exportList } = useVxeGrid<PostApi.PostVO>({
|
const { gridOptions, getList, deleteData, exportList } = useVxeGrid<PostApi.PostVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: PostApi.getPostPageApi,
|
getListApi: PostApi.getPostPageApi,
|
||||||
deleteApi: PostApi.deletePostApi,
|
deleteApi: PostApi.deletePostApi,
|
||||||
|
@ -167,7 +167,7 @@ const submitForm = async () => {
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -174,7 +174,7 @@ const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, reloadList, deleteData } = useVxeGrid<RoleApi.RoleVO>({
|
const { gridOptions, getList, deleteData } = useVxeGrid<RoleApi.RoleVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: RoleApi.getRolePageApi,
|
getListApi: RoleApi.getRolePageApi,
|
||||||
deleteApi: RoleApi.deleteRoleApi
|
deleteApi: RoleApi.deleteRoleApi
|
||||||
|
@ -242,7 +242,7 @@ const submitForm = async () => {
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -85,7 +85,7 @@ const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, reloadList, deleteData } = useVxeGrid<SmsChannelApi.SmsChannelVO>({
|
const { gridOptions, getList, deleteData } = useVxeGrid<SmsChannelApi.SmsChannelVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: SmsChannelApi.getSmsChannelPageApi,
|
getListApi: SmsChannelApi.getSmsChannelPageApi,
|
||||||
deleteApi: SmsChannelApi.deleteSmsChannelApi
|
deleteApi: SmsChannelApi.deleteSmsChannelApi
|
||||||
|
@ -152,7 +152,7 @@ const submitForm = async () => {
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -128,7 +128,7 @@ const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, reloadList, deleteData } = useVxeGrid<SmsTemplateApi.SmsTemplateVO>({
|
const { gridOptions, getList, deleteData } = useVxeGrid<SmsTemplateApi.SmsTemplateVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: SmsTemplateApi.getSmsTemplatePageApi,
|
getListApi: SmsTemplateApi.getSmsTemplatePageApi,
|
||||||
deleteApi: SmsTemplateApi.deleteSmsTemplateApi
|
deleteApi: SmsTemplateApi.deleteSmsTemplateApi
|
||||||
|
@ -196,7 +196,7 @@ const submitForm = async () => {
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -242,7 +242,7 @@
|
||||||
</XModal>
|
</XModal>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, reactive, ref, unref, watch } from 'vue'
|
import { nextTick, onMounted, reactive, ref, unref, watch } from 'vue'
|
||||||
import {
|
import {
|
||||||
ElTag,
|
ElTag,
|
||||||
ElInput,
|
ElInput,
|
||||||
|
@ -287,18 +287,20 @@ const defaultProps = {
|
||||||
label: 'name',
|
label: 'name',
|
||||||
value: 'id'
|
value: 'id'
|
||||||
}
|
}
|
||||||
|
const queryParams = reactive({
|
||||||
|
deptId: null
|
||||||
|
})
|
||||||
// ========== 列表相关 ==========
|
// ========== 列表相关 ==========
|
||||||
const tableTitle = ref('用户列表')
|
const tableTitle = ref('用户列表')
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, reloadList, deleteData, exportList, getSearchData } =
|
const { gridOptions, getList, deleteData, exportList } = useVxeGrid<UserApi.UserVO>({
|
||||||
useVxeGrid<UserApi.UserVO>({
|
allSchemas: allSchemas,
|
||||||
allSchemas: allSchemas,
|
queryParams: queryParams,
|
||||||
getListApi: UserApi.getUserPageApi,
|
getListApi: UserApi.getUserPageApi,
|
||||||
deleteApi: UserApi.deleteUserApi,
|
deleteApi: UserApi.deleteUserApi,
|
||||||
exportListApi: UserApi.exportUserApi
|
exportListApi: UserApi.exportUserApi
|
||||||
})
|
})
|
||||||
// ========== 创建部门树结构 ==========
|
// ========== 创建部门树结构 ==========
|
||||||
const filterText = ref('')
|
const filterText = ref('')
|
||||||
const deptOptions = ref<any[]>([]) // 树形结构
|
const deptOptions = ref<any[]>([]) // 树形结构
|
||||||
|
@ -312,13 +314,8 @@ const filterNode = (value: string, data: Tree) => {
|
||||||
return data.name.includes(value)
|
return data.name.includes(value)
|
||||||
}
|
}
|
||||||
const handleDeptNodeClick = async (row: { [key: string]: any }) => {
|
const handleDeptNodeClick = async (row: { [key: string]: any }) => {
|
||||||
tableTitle.value = row.name
|
queryParams.deptId = row.id
|
||||||
console.log(getSearchData(xGrid))
|
await getList(xGrid)
|
||||||
// gridOptions.formConfig?.data.push({
|
|
||||||
// deptId: row.id
|
|
||||||
// })
|
|
||||||
// TODO 查询
|
|
||||||
await reloadList(xGrid)
|
|
||||||
}
|
}
|
||||||
const { push } = useRouter()
|
const { push } = useRouter()
|
||||||
const handleDeptEdit = () => {
|
const handleDeptEdit = () => {
|
||||||
|
@ -351,17 +348,16 @@ const setDialogTile = async (type: string) => {
|
||||||
|
|
||||||
// 新增操作
|
// 新增操作
|
||||||
const handleCreate = async () => {
|
const handleCreate = async () => {
|
||||||
actionType.value = 'create'
|
setDialogTile('create')
|
||||||
// 重置表单
|
// 重置表单
|
||||||
deptId.value = null
|
deptId.value = null
|
||||||
postIds.value = []
|
postIds.value = []
|
||||||
dialogVisible.value = true
|
|
||||||
dialogTitle.value = t('action.create')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改操作
|
// 修改操作
|
||||||
const handleUpdate = async (rowId: number) => {
|
const handleUpdate = async (rowId: number) => {
|
||||||
setDialogTile('update')
|
setDialogTile('update')
|
||||||
|
await nextTick()
|
||||||
unref(formRef)?.delSchema('username')
|
unref(formRef)?.delSchema('username')
|
||||||
unref(formRef)?.delSchema('password')
|
unref(formRef)?.delSchema('password')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
|
@ -400,8 +396,9 @@ const submitForm = async () => {
|
||||||
}
|
}
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
} finally {
|
} finally {
|
||||||
|
// unref(formRef)?.setSchema(allSchemas.formSchema)
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,7 +413,7 @@ const handleStatusChange = async (row: UserApi.UserVO) => {
|
||||||
await UserApi.updateUserStatusApi(row.id, row.status)
|
await UserApi.updateUserStatusApi(row.id, row.status)
|
||||||
message.success(text + '成功')
|
message.success(text + '成功')
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
row.status =
|
row.status =
|
||||||
|
@ -516,7 +513,7 @@ const handleFileSuccess = async (response: any): Promise<void> => {
|
||||||
text += '< ' + username + ': ' + data.failureUsernames[username] + ' >'
|
text += '< ' + username + ': ' + data.failureUsernames[username] + ' >'
|
||||||
}
|
}
|
||||||
message.alert(text)
|
message.alert(text)
|
||||||
await reloadList(xGrid)
|
await getList(xGrid)
|
||||||
}
|
}
|
||||||
// 文件数超出提示
|
// 文件数超出提示
|
||||||
const handleExceed = (): void => {
|
const handleExceed = (): void => {
|
||||||
|
|
|
@ -57,10 +57,7 @@ const crudSchemas = reactive<VxeCrudSchema>({
|
||||||
{
|
{
|
||||||
title: '部门',
|
title: '部门',
|
||||||
field: 'deptId',
|
field: 'deptId',
|
||||||
isTable: false,
|
isTable: false
|
||||||
search: {
|
|
||||||
visible: false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '岗位',
|
title: '岗位',
|
||||||
|
|
Loading…
Reference in New Issue