Commit 1e3bd472137e3d2cd273929a2c68e81dba097e64
Committed by
Gitee
!228 新增 日期选择组件 近一周 近一个月示例
Merge pull request !228 from xingyu/master
Showing
13 changed files
with
121 additions
and
29 deletions
yudao-dependencies/pom.xml
| @@ -16,20 +16,19 @@ | @@ -16,20 +16,19 @@ | ||
| 16 | <properties> | 16 | <properties> |
| 17 | <revision>1.6.2-snapshot</revision> | 17 | <revision>1.6.2-snapshot</revision> |
| 18 | <!-- 统一依赖管理 --> | 18 | <!-- 统一依赖管理 --> |
| 19 | - <spring.boot.version>2.6.9</spring.boot.version> | 19 | + <spring.boot.version>2.6.10</spring.boot.version> |
| 20 | <!-- Web 相关 --> | 20 | <!-- Web 相关 --> |
| 21 | <knife4j.version>3.0.3</knife4j.version> | 21 | <knife4j.version>3.0.3</knife4j.version> |
| 22 | <swagger-annotations.version>1.6.6</swagger-annotations.version> | 22 | <swagger-annotations.version>1.6.6</swagger-annotations.version> |
| 23 | <servlet.versoin>2.5</servlet.versoin> | 23 | <servlet.versoin>2.5</servlet.versoin> |
| 24 | <!-- DB 相关 --> | 24 | <!-- DB 相关 --> |
| 25 | - <druid.version>1.2.8</druid.version> | 25 | + <druid.version>1.2.11</druid.version> |
| 26 | <mybatis-plus.version>3.5.2</mybatis-plus.version> | 26 | <mybatis-plus.version>3.5.2</mybatis-plus.version> |
| 27 | <mybatis-plus-generator.version>3.5.2</mybatis-plus-generator.version> | 27 | <mybatis-plus-generator.version>3.5.2</mybatis-plus-generator.version> |
| 28 | <dynamic-datasource.version>3.5.0</dynamic-datasource.version> | 28 | <dynamic-datasource.version>3.5.0</dynamic-datasource.version> |
| 29 | <redisson.version>3.17.4</redisson.version> | 29 | <redisson.version>3.17.4</redisson.version> |
| 30 | <!-- Config 配置中心相关 --> | 30 | <!-- Config 配置中心相关 --> |
| 31 | <apollo.version>1.9.2</apollo.version> | 31 | <apollo.version>1.9.2</apollo.version> |
| 32 | - <!-- Job 定时任务相关 --> | ||
| 33 | <!-- 服务保障相关 --> | 32 | <!-- 服务保障相关 --> |
| 34 | <lock4j.version>2.2.0</lock4j.version> | 33 | <lock4j.version>2.2.0</lock4j.version> |
| 35 | <resilience4j.version>1.7.1</resilience4j.version> | 34 | <resilience4j.version>1.7.1</resilience4j.version> |
yudao-ui-admin-vue3/package.json
| @@ -65,8 +65,8 @@ | @@ -65,8 +65,8 @@ | ||
| 65 | "@types/nprogress": "^0.2.0", | 65 | "@types/nprogress": "^0.2.0", |
| 66 | "@types/qrcode": "^1.4.2", | 66 | "@types/qrcode": "^1.4.2", |
| 67 | "@types/qs": "^6.9.7", | 67 | "@types/qs": "^6.9.7", |
| 68 | - "@typescript-eslint/eslint-plugin": "^5.30.7", | ||
| 69 | - "@typescript-eslint/parser": "^5.30.7", | 68 | + "@typescript-eslint/eslint-plugin": "^5.31.0", |
| 69 | + "@typescript-eslint/parser": "^5.31.0", | ||
| 70 | "@vitejs/plugin-vue": "^3.0.1", | 70 | "@vitejs/plugin-vue": "^3.0.1", |
| 71 | "@vitejs/plugin-vue-jsx": "^2.0.0", | 71 | "@vitejs/plugin-vue-jsx": "^2.0.0", |
| 72 | "autoprefixer": "^10.4.7", | 72 | "autoprefixer": "^10.4.7", |
yudao-ui-admin-vue3/src/api/system/dept/index.ts
| 1 | import { useAxios } from '@/hooks/web/useAxios' | 1 | import { useAxios } from '@/hooks/web/useAxios' |
| 2 | -import type { DeptVO } from './types' | 2 | +import type { DeptVO, DeptListReqVO } from './types' |
| 3 | 3 | ||
| 4 | const request = useAxios() | 4 | const request = useAxios() |
| 5 | 5 | ||
| @@ -9,7 +9,7 @@ export const listSimpleDeptApi = () => { | @@ -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 | return request.get({ url: '/system/dept/list', params }) | 13 | return request.get({ url: '/system/dept/list', params }) |
| 14 | } | 14 | } |
| 15 | 15 |
yudao-ui-admin-vue3/src/api/system/dept/types.ts
yudao-ui-admin-vue3/src/api/system/dict/dict.data.ts
| 1 | import { useAxios } from '@/hooks/web/useAxios' | 1 | import { useAxios } from '@/hooks/web/useAxios' |
| 2 | -import type { DictDataVO } from './types' | 2 | +import type { DictDataVO, DictDataPageReqVO, DictDataExportReqVO } from './types' |
| 3 | 3 | ||
| 4 | const request = useAxios() | 4 | const request = useAxios() |
| 5 | 5 | ||
| @@ -9,7 +9,7 @@ export const listSimpleDictDataApi = () => { | @@ -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 | return request.get({ url: '/system/dict-data/page', params }) | 13 | return request.get({ url: '/system/dict-data/page', params }) |
| 14 | } | 14 | } |
| 15 | 15 | ||
| @@ -33,6 +33,6 @@ export const deleteDictDataApi = (id: number) => { | @@ -33,6 +33,6 @@ export const deleteDictDataApi = (id: number) => { | ||
| 33 | return request.delete({ url: '/system/dict-data/delete?id=' + id }) | 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 | return request.get({ url: '/system/dict-data/export', params }) | 37 | return request.get({ url: '/system/dict-data/export', params }) |
| 38 | } | 38 | } |
yudao-ui-admin-vue3/src/api/system/dict/dict.type.ts
| 1 | import { useAxios } from '@/hooks/web/useAxios' | 1 | import { useAxios } from '@/hooks/web/useAxios' |
| 2 | -import type { DictTypeVO } from './types' | 2 | +import type { DictTypeVO, DictTypePageReqVO, DictTypeExportReqVO } from './types' |
| 3 | 3 | ||
| 4 | const request = useAxios() | 4 | const request = useAxios() |
| 5 | 5 | ||
| @@ -9,7 +9,7 @@ export const listSimpleDictTypeApi = () => { | @@ -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 | return request.get({ url: '/system/dict-type/page', params }) | 13 | return request.get({ url: '/system/dict-type/page', params }) |
| 14 | } | 14 | } |
| 15 | 15 | ||
| @@ -33,6 +33,6 @@ export const deleteDictTypeApi = (id: number) => { | @@ -33,6 +33,6 @@ export const deleteDictTypeApi = (id: number) => { | ||
| 33 | return request.delete({ url: '/system/dict-type/delete?id=' + id }) | 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 | return request.get({ url: '/system/dict-type/export', params }) | 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,6 +7,20 @@ export type DictTypeVO = { | ||
| 7 | createTime: string | 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 | export type DictDataVO = { | 24 | export type DictDataVO = { |
| 11 | id: number | 25 | id: number |
| 12 | sort: number | 26 | sort: number |
| @@ -19,3 +33,14 @@ export type DictDataVO = { | @@ -19,3 +33,14 @@ export type DictDataVO = { | ||
| 19 | remark: string | 33 | remark: string |
| 20 | createTime: string | 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 | import { useAxios } from '@/hooks/web/useAxios' | 1 | import { useAxios } from '@/hooks/web/useAxios' |
| 2 | -import type { PostVO } from './types' | 2 | +import type { PostVO, PostPageReqVO, PostExportReqVO } from './types' |
| 3 | 3 | ||
| 4 | const request = useAxios() | 4 | const request = useAxios() |
| 5 | 5 | ||
| 6 | // 查询岗位列表 | 6 | // 查询岗位列表 |
| 7 | -export const getPostPageApi = async (params) => { | 7 | +export const getPostPageApi = async (params: PostPageReqVO) => { |
| 8 | return await request.get({ url: '/system/post/page', params }) | 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,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 | return await request.download({ url: '/system/post/export', params }) | 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,3 +7,15 @@ export type PostVO = { | ||
| 7 | remark: string | 7 | remark: string |
| 8 | createTime: string | 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 | import download from '@/utils/download' | 1 | import download from '@/utils/download' |
| 2 | import { Table, TableExpose } from '@/components/Table' | 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 | import type { TableProps } from '@/components/Table/src/types' | 5 | import type { TableProps } from '@/components/Table/src/types' |
| 6 | import { useI18n } from '@/hooks/web/useI18n' | 6 | import { useI18n } from '@/hooks/web/useI18n' |
| 7 | 7 | ||
| 8 | const { t } = useI18n() | 8 | const { t } = useI18n() |
| 9 | interface ResponseType<T = any> { | 9 | interface ResponseType<T = any> { |
| 10 | list: T[] | 10 | list: T[] |
| 11 | - total?: string | 11 | + total?: number |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | interface UseTableConfig<T = any> { | 14 | interface UseTableConfig<T = any> { |
| @@ -114,15 +114,13 @@ export const useTable = <T = any>(config?: UseTableConfig<T>) => { | @@ -114,15 +114,13 @@ export const useTable = <T = any>(config?: UseTableConfig<T>) => { | ||
| 114 | ElMessage.success(t('common.delSuccess')) | 114 | ElMessage.success(t('common.delSuccess')) |
| 115 | 115 | ||
| 116 | // 计算出临界点 | 116 | // 计算出临界点 |
| 117 | - const currentPage = | 117 | + tableObject.currentPage = |
| 118 | tableObject.total % tableObject.pageSize === idsLength || tableObject.pageSize === 1 | 118 | tableObject.total % tableObject.pageSize === idsLength || tableObject.pageSize === 1 |
| 119 | ? tableObject.currentPage > 1 | 119 | ? tableObject.currentPage > 1 |
| 120 | ? tableObject.currentPage - 1 | 120 | ? tableObject.currentPage - 1 |
| 121 | : tableObject.currentPage | 121 | : tableObject.currentPage |
| 122 | : tableObject.currentPage | 122 | : tableObject.currentPage |
| 123 | - | ||
| 124 | - tableObject.currentPage = currentPage | ||
| 125 | - methods.getList() | 123 | + await methods.getList() |
| 126 | } | 124 | } |
| 127 | 125 | ||
| 128 | const methods = { | 126 | const methods = { |
| @@ -132,8 +130,10 @@ export const useTable = <T = any>(config?: UseTableConfig<T>) => { | @@ -132,8 +130,10 @@ export const useTable = <T = any>(config?: UseTableConfig<T>) => { | ||
| 132 | tableObject.loading = false | 130 | tableObject.loading = false |
| 133 | }) | 131 | }) |
| 134 | if (res) { | 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 | setProps: async (props: TableProps = {}) => { | 139 | setProps: async (props: TableProps = {}) => { |
| @@ -194,7 +194,7 @@ export const useTable = <T = any>(config?: UseTableConfig<T>) => { | @@ -194,7 +194,7 @@ export const useTable = <T = any>(config?: UseTableConfig<T>) => { | ||
| 194 | .then(async () => { | 194 | .then(async () => { |
| 195 | const res = await config?.exportListApi?.(unref(paramsObj) as unknown as T) | 195 | const res = await config?.exportListApi?.(unref(paramsObj) as unknown as T) |
| 196 | if (res) { | 196 | if (res) { |
| 197 | - download.excel(res, fileName) | 197 | + download.excel(res as unknown as Blob, fileName) |
| 198 | } | 198 | } |
| 199 | }) | 199 | }) |
| 200 | .finally(() => { | 200 | .finally(() => { |
yudao-ui-admin-vue3/src/views/system/dict/dict.type.ts
| @@ -43,6 +43,28 @@ const crudSchemas = reactive<CrudSchema[]>([ | @@ -43,6 +43,28 @@ const crudSchemas = reactive<CrudSchema[]>([ | ||
| 43 | dictType: DICT_TYPE.COMMON_STATUS | 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 | label: t('form.remark'), | 68 | label: t('form.remark'), |
| 47 | field: 'remark', | 69 | field: 'remark', |
| 48 | table: { | 70 | table: { |
yudao-ui-admin-vue3/src/views/system/post/index.vue
| @@ -21,7 +21,7 @@ const { getList, setSearchParams, delList, exportList } = methods | @@ -21,7 +21,7 @@ const { getList, setSearchParams, delList, exportList } = methods | ||
| 21 | 21 | ||
| 22 | // 导出操作 | 22 | // 导出操作 |
| 23 | const handleExport = async () => { | 23 | const handleExport = async () => { |
| 24 | - await exportList('用户数据.xls') | 24 | + await exportList('岗位数据.xls') |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | // ========== CRUD 相关 ========== | 27 | // ========== CRUD 相关 ========== |
yudao-ui-admin-vue3/src/views/system/user/user.data.ts
| @@ -115,9 +115,38 @@ const crudSchemas = reactive<CrudSchema[]>([ | @@ -115,9 +115,38 @@ const crudSchemas = reactive<CrudSchema[]>([ | ||
| 115 | show: true, | 115 | show: true, |
| 116 | component: 'DatePicker', | 116 | component: 'DatePicker', |
| 117 | componentProps: { | 117 | componentProps: { |
| 118 | - type: 'daterange', | 118 | + type: 'datetimerange', |
| 119 | valueFormat: 'YYYY-MM-DD HH:mm:ss', | 119 | valueFormat: 'YYYY-MM-DD HH:mm:ss', |
| 120 | - defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] | 120 | + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)], |
| 121 | + shortcuts: [ | ||
| 122 | + { | ||
| 123 | + text: '近一周', | ||
| 124 | + value: () => { | ||
| 125 | + const end = new Date() | ||
| 126 | + const start = new Date() | ||
| 127 | + start.setTime(start.getTime() - 3600 * 1000 * 24 * 7) | ||
| 128 | + return [start, end] | ||
| 129 | + } | ||
| 130 | + }, | ||
| 131 | + { | ||
| 132 | + text: '近一个月', | ||
| 133 | + value: () => { | ||
| 134 | + const end = new Date() | ||
| 135 | + const start = new Date() | ||
| 136 | + start.setTime(start.getTime() - 3600 * 1000 * 24 * 30) | ||
| 137 | + return [start, end] | ||
| 138 | + } | ||
| 139 | + }, | ||
| 140 | + { | ||
| 141 | + text: '近三个月', | ||
| 142 | + value: () => { | ||
| 143 | + const end = new Date() | ||
| 144 | + const start = new Date() | ||
| 145 | + start.setTime(start.getTime() - 3600 * 1000 * 24 * 90) | ||
| 146 | + return [start, end] | ||
| 147 | + } | ||
| 148 | + } | ||
| 149 | + ] | ||
| 121 | } | 150 | } |
| 122 | } | 151 | } |
| 123 | }, | 152 | }, |