Commit 877254af10c1a515ab93889ae9f94c29973e85c8

Authored by xingyu
1 parent 3d0cb520

fix: useTable warning

yudao-ui-admin-vue3/src/api/system/dept/index.ts
1 1 import { useAxios } from '@/hooks/web/useAxios'
2   -import type { DeptVO } from './types'
  2 +import type { DeptVO, DeptListReqVO } from './types'
3 3  
4 4 const request = useAxios()
5 5  
... ... @@ -9,7 +9,7 @@ export const listSimpleDeptApi = () => {
9 9 }
10 10  
11 11 // 查询部门列表
12   -export const getDeptPageApi = (params) => {
  12 +export const getDeptPageApi = (params: DeptListReqVO) => {
13 13 return request.get({ url: '/system/dept/list', params })
14 14 }
15 15  
... ...
yudao-ui-admin-vue3/src/api/system/dept/types.ts
... ... @@ -5,3 +5,8 @@ export type DeptVO = {
5 5 parentId: number
6 6 createTime: string
7 7 }
  8 +
  9 +export type DeptListReqVO = {
  10 + name: string
  11 + status: number
  12 +}
... ...
yudao-ui-admin-vue3/src/api/system/dict/dict.data.ts
1 1 import { useAxios } from '@/hooks/web/useAxios'
2   -import type { DictDataVO } from './types'
  2 +import type { DictDataVO, DictDataPageReqVO, DictDataExportReqVO } from './types'
3 3  
4 4 const request = useAxios()
5 5  
... ... @@ -9,7 +9,7 @@ export const listSimpleDictDataApi = () => {
9 9 }
10 10  
11 11 // 查询字典数据列表
12   -export const getDictDataPageApi = (params) => {
  12 +export const getDictDataPageApi = (params: DictDataPageReqVO) => {
13 13 return request.get({ url: '/system/dict-data/page', params })
14 14 }
15 15  
... ... @@ -33,6 +33,6 @@ export const deleteDictDataApi = (id: number) => {
33 33 return request.delete({ url: '/system/dict-data/delete?id=' + id })
34 34 }
35 35 // 导出字典类型数据
36   -export const exportDictDataApi = (params: DictDataVO) => {
  36 +export const exportDictDataApi = (params: DictDataExportReqVO) => {
37 37 return request.get({ url: '/system/dict-data/export', params })
38 38 }
... ...
yudao-ui-admin-vue3/src/api/system/dict/dict.type.ts
1 1 import { useAxios } from '@/hooks/web/useAxios'
2   -import type { DictTypeVO } from './types'
  2 +import type { DictTypeVO, DictTypePageReqVO, DictTypeExportReqVO } from './types'
3 3  
4 4 const request = useAxios()
5 5  
... ... @@ -9,7 +9,7 @@ export const listSimpleDictTypeApi = () => {
9 9 }
10 10  
11 11 // 查询字典列表
12   -export const getDictTypePageApi = (params) => {
  12 +export const getDictTypePageApi = (params: DictTypePageReqVO) => {
13 13 return request.get({ url: '/system/dict-type/page', params })
14 14 }
15 15  
... ... @@ -33,6 +33,6 @@ export const deleteDictTypeApi = (id: number) => {
33 33 return request.delete({ url: '/system/dict-type/delete?id=' + id })
34 34 }
35 35 // 导出字典类型
36   -export const exportDictTypeApi = (params: DictTypeVO) => {
  36 +export const exportDictTypeApi = (params: DictTypeExportReqVO) => {
37 37 return request.get({ url: '/system/dict-type/export', params })
38 38 }
... ...
yudao-ui-admin-vue3/src/api/system/dict/types.ts
... ... @@ -7,6 +7,20 @@ export type DictTypeVO = {
7 7 createTime: string
8 8 }
9 9  
  10 +export type DictTypePageReqVO = {
  11 + name: string
  12 + type: string
  13 + status: number
  14 + createTime: []
  15 +}
  16 +
  17 +export type DictTypeExportReqVO = {
  18 + name: string
  19 + type: string
  20 + status: number
  21 + createTime: []
  22 +}
  23 +
10 24 export type DictDataVO = {
11 25 id: number
12 26 sort: number
... ... @@ -19,3 +33,14 @@ export type DictDataVO = {
19 33 remark: string
20 34 createTime: string
21 35 }
  36 +export type DictDataPageReqVO = {
  37 + label: string
  38 + dictType: string
  39 + status: number
  40 +}
  41 +
  42 +export type DictDataExportReqVO = {
  43 + label: string
  44 + dictType: string
  45 + status: number
  46 +}
... ...
yudao-ui-admin-vue3/src/api/system/post/index.ts
1 1 import { useAxios } from '@/hooks/web/useAxios'
2   -import type { PostVO } from './types'
  2 +import type { PostVO, PostPageReqVO, PostExportReqVO } from './types'
3 3  
4 4 const request = useAxios()
5 5  
6 6 // 查询岗位列表
7   -export const getPostPageApi = async (params) => {
  7 +export const getPostPageApi = async (params: PostPageReqVO) => {
8 8 return await request.get({ url: '/system/post/page', params })
9 9 }
10 10  
... ... @@ -33,6 +33,6 @@ export const deletePostApi = async (id: number) => {
33 33 }
34 34  
35 35 // 导出岗位
36   -export const exportPostApi = async (params) => {
  36 +export const exportPostApi = async (params: PostExportReqVO) => {
37 37 return await request.download({ url: '/system/post/export', params })
38 38 }
... ...
yudao-ui-admin-vue3/src/api/system/post/types.ts
... ... @@ -7,3 +7,15 @@ export type PostVO = {
7 7 remark: string
8 8 createTime: string
9 9 }
  10 +
  11 +export type PostPageReqVO = {
  12 + code: string
  13 + name: string
  14 + status: number
  15 +}
  16 +
  17 +export type PostExportReqVO = {
  18 + code: string
  19 + name: string
  20 + status: number
  21 +}
... ...
yudao-ui-admin-vue3/src/hooks/web/useTable.ts
1 1 import download from '@/utils/download'
2 2 import { Table, TableExpose } from '@/components/Table'
3   -import { ElTable, ElMessageBox, ElMessage } from 'element-plus'
4   -import { ref, reactive, watch, computed, unref, nextTick } from 'vue'
  3 +import { ElMessage, ElMessageBox, ElTable } from 'element-plus'
  4 +import { computed, nextTick, reactive, ref, unref, watch } from 'vue'
5 5 import type { TableProps } from '@/components/Table/src/types'
6 6 import { useI18n } from '@/hooks/web/useI18n'
7 7  
8 8 const { t } = useI18n()
9 9 interface ResponseType<T = any> {
10 10 list: T[]
11   - total?: string
  11 + total?: number
12 12 }
13 13  
14 14 interface UseTableConfig<T = any> {
... ... @@ -114,15 +114,13 @@ export const useTable = &lt;T = any&gt;(config?: UseTableConfig&lt;T&gt;) =&gt; {
114 114 ElMessage.success(t('common.delSuccess'))
115 115  
116 116 // 计算出临界点
117   - const currentPage =
  117 + tableObject.currentPage =
118 118 tableObject.total % tableObject.pageSize === idsLength || tableObject.pageSize === 1
119 119 ? tableObject.currentPage > 1
120 120 ? tableObject.currentPage - 1
121 121 : tableObject.currentPage
122 122 : tableObject.currentPage
123   -
124   - tableObject.currentPage = currentPage
125   - methods.getList()
  123 + await methods.getList()
126 124 }
127 125  
128 126 const methods = {
... ... @@ -132,8 +130,10 @@ export const useTable = &lt;T = any&gt;(config?: UseTableConfig&lt;T&gt;) =&gt; {
132 130 tableObject.loading = false
133 131 })
134 132 if (res) {
135   - tableObject.tableList = res?.list
136   - tableObject.total = res?.total
  133 + tableObject.tableList = (res as unknown as ResponseType).list
  134 + if ((res as unknown as ResponseType).total) {
  135 + tableObject.total = (res as unknown as ResponseType).total as unknown as number
  136 + }
137 137 }
138 138 },
139 139 setProps: async (props: TableProps = {}) => {
... ... @@ -194,7 +194,7 @@ export const useTable = &lt;T = any&gt;(config?: UseTableConfig&lt;T&gt;) =&gt; {
194 194 .then(async () => {
195 195 const res = await config?.exportListApi?.(unref(paramsObj) as unknown as T)
196 196 if (res) {
197   - download.excel(res, fileName)
  197 + download.excel(res as unknown as Blob, fileName)
198 198 }
199 199 })
200 200 .finally(() => {
... ...
yudao-ui-admin-vue3/src/views/system/dict/dict.type.ts
... ... @@ -43,6 +43,28 @@ const crudSchemas = reactive&lt;CrudSchema[]&gt;([
43 43 dictType: DICT_TYPE.COMMON_STATUS
44 44 },
45 45 {
  46 + label: t('common.createTime'),
  47 + field: 'createTime',
  48 + table: {
  49 + show: false
  50 + },
  51 + form: {
  52 + show: false
  53 + },
  54 + detail: {
  55 + show: false
  56 + },
  57 + search: {
  58 + show: true,
  59 + component: 'DatePicker',
  60 + componentProps: {
  61 + type: 'datetimerange',
  62 + valueFormat: 'YYYY-MM-DD HH:mm:ss',
  63 + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]
  64 + }
  65 + }
  66 + },
  67 + {
46 68 label: t('form.remark'),
47 69 field: 'remark',
48 70 table: {
... ...
yudao-ui-admin-vue3/src/views/system/post/index.vue
... ... @@ -21,7 +21,7 @@ const { getList, setSearchParams, delList, exportList } = methods
21 21  
22 22 // 导出操作
23 23 const handleExport = async () => {
24   - await exportList('用户数据.xls')
  24 + await exportList('岗位数据.xls')
25 25 }
26 26  
27 27 // ========== CRUD 相关 ==========
... ...
yudao-ui-admin-vue3/src/views/system/user/user.data.ts
... ... @@ -115,7 +115,7 @@ const crudSchemas = reactive&lt;CrudSchema[]&gt;([
115 115 show: true,
116 116 component: 'DatePicker',
117 117 componentProps: {
118   - type: 'daterange',
  118 + type: 'datetimerange',
119 119 valueFormat: 'YYYY-MM-DD HH:mm:ss',
120 120 defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]
121 121 }
... ...