diff --git a/README.md b/README.md index 610695642..c98e2ed87 100644 --- a/README.md +++ b/README.md @@ -192,14 +192,14 @@ ps:核心功能已经实现,正在对接微信小程序中... | [JUnit](https://junit.org/junit5/) | Java 单元测试框架 | 5.8.2 | - | | [Mockito](https://github.com/mockito/mockito) | Java Mock 框架 | 4.0.0 | - | -### Vue2 前端 +### [Vue2 前端](./yudao-ui-admin) | 框架 | 说明 | 版本 | |------------------------------------------------------------------------------|---------------|--------| | [Vue](https://cn.vuejs.org/index.html) | JavaScript 框架 | 2.6.12 | | [Vue Element Admin](https://panjiachen.github.io/vue-element-admin-site/zh/) | 后台前端解决方案 | - | -### Vue3 前端 +### [Vue3 前端](./yudao-ui-admin-vue3) | 框架 | 说明 | 版本 | |----------------------------------------------------------------------|------------------|--------| diff --git a/yudao-ui-admin-vue3/README.md b/yudao-ui-admin-vue3/README.md index f898a6d9e..c477d2e75 100644 --- a/yudao-ui-admin-vue3/README.md +++ b/yudao-ui-admin-vue3/README.md @@ -22,6 +22,8 @@ - node >=14.18.0(建议使用 16 版本) ,pnpm >=7 - 开发建议使用 [谷歌浏览器-开发者版](https://www.google.cn/intl/zh-CN/chrome/dev/) 不支持 IE\QQ 等浏览器 +### 点击查看[使用说明](./use.md) + ### 前端依赖 | 框架 | 说明 | 版本 | diff --git a/yudao-ui-admin-vue3/package.json b/yudao-ui-admin-vue3/package.json index 4e7ebb03e..c221f0d68 100644 --- a/yudao-ui-admin-vue3/package.json +++ b/yudao-ui-admin-vue3/package.json @@ -65,8 +65,8 @@ "@types/nprogress": "^0.2.0", "@types/qrcode": "^1.4.2", "@types/qs": "^6.9.7", - "@typescript-eslint/eslint-plugin": "^5.31.0", - "@typescript-eslint/parser": "^5.31.0", + "@typescript-eslint/eslint-plugin": "^5.32.0", + "@typescript-eslint/parser": "^5.32.0", "@vitejs/plugin-vue": "^3.0.1", "@vitejs/plugin-vue-jsx": "^2.0.0", "autoprefixer": "^10.4.8", @@ -91,7 +91,7 @@ "stylelint-config-standard": "^26.0.0", "stylelint-order": "^5.0.0", "typescript": "4.7.4", - "unplugin-vue-define-options": "^0.6.2", + "unplugin-vue-define-options": "^0.7.1", "vite": "3.0.4", "vite-plugin-compression": "^0.5.1", "vite-plugin-eslint": "^1.7.0", diff --git a/yudao-ui-admin-vue3/src/api/system/dept/types.ts b/yudao-ui-admin-vue3/src/api/system/dept/types.ts index 3151c610f..470fcd3d8 100644 --- a/yudao-ui-admin-vue3/src/api/system/dept/types.ts +++ b/yudao-ui-admin-vue3/src/api/system/dept/types.ts @@ -1,9 +1,12 @@ export type DeptVO = { id: number name: string - status: number parentId: number - createTime: string + status: number + sort: number + leaderUserId: number + phone: string + email: string } export type DeptListReqVO = { diff --git a/yudao-ui-admin-vue3/src/config/axios/index.ts b/yudao-ui-admin-vue3/src/config/axios/index.ts index 95023c4e4..14bd90bad 100644 --- a/yudao-ui-admin-vue3/src/config/axios/index.ts +++ b/yudao-ui-admin-vue3/src/config/axios/index.ts @@ -1,8 +1,8 @@ import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios' -import { ElMessage, ElMessageBox, ElNotification } from 'element-plus' +import { ElMessage, ElNotification } from 'element-plus' import qs from 'qs' import { config } from '@/config/axios/config' -import { getAccessToken, getRefreshToken, getTenantId } from '@/utils/auth' +import { getAccessToken, getTenantId, removeToken } from '@/utils/auth' import errorCode from './errorCode' import { useI18n } from '@/hooks/web/useI18n' @@ -22,7 +22,7 @@ export const isRelogin = { show: false } // 请求队列 // const requestList = [] // 是否正在刷新中 -let isRefreshToken = false +// const isRefreshToken = false export const PATH_URL = base_url[import.meta.env.VITE_API_BASEPATH] @@ -55,18 +55,26 @@ service.interceptors.request.use( config.data = qs.stringify(data) } // get参数编码 - if (config.method?.toUpperCase() === 'GET' && config.params) { - let url = config.url as string + if (config.method?.toUpperCase() === 'GET' && params) { + let url = config.url + '?' + for (const propName of Object.keys(params)) { + const value = params[propName] + if (value !== void 0 && value !== null && typeof value !== 'undefined') { + if (typeof value === 'object') { + for (const val of Object.keys(value)) { + const params = propName + '[' + val + ']' + const subPart = encodeURIComponent(params) + '=' + url += subPart + encodeURIComponent(value[val]) + '&' + } + } else { + url += `${propName}=${encodeURIComponent(value)}&` + } + } + } // 给 get 请求加上时间戳参数,避免从缓存中拿数据 // const now = new Date().getTime() // params = params.substring(0, url.length - 1) + `?_t=${now}` - url += '?' - const keys = Object.keys(params) - for (const key of keys) { - if (params[key] !== void 0 && params[key] !== null) { - url += `${key}=${encodeURIComponent(params[key])}&` - } - } + url = url.slice(0, -1) config.params = {} config.url = url } @@ -90,6 +98,13 @@ service.interceptors.response.use( const { t } = useI18n() // 未设置状态码则默认成功状态 const code = data.code || result_code + // 二进制数据则直接返回 + if ( + response.request.responseType === 'blob' || + response.request.responseType === 'arraybuffer' + ) { + return response.data + } // 获取错误信息 const msg = data.msg || errorCode[code] || errorCode['default'] if (ignoreMsgs.indexOf(msg) !== -1) { @@ -97,15 +112,16 @@ service.interceptors.response.use( return Promise.reject(msg) } else if (code === 401) { // 如果未认证,并且未进行刷新令牌,说明可能是访问令牌过期了 - if (!isRefreshToken) { - isRefreshToken = true - // 1. 如果获取不到刷新令牌,则只能执行登出操作 - if (!getRefreshToken()) { - return handleAuthorized() - } - // 2. 进行刷新访问令牌 - // TODO: 引入refreshToken会循环依赖报错 - } + return handleAuthorized() + // if (!isRefreshToken) { + // isRefreshToken = true + // // 1. 如果获取不到刷新令牌,则只能执行登出操作 + // if (!getRefreshToken()) { + // return handleAuthorized() + // } + // // 2. 进行刷新访问令牌 + // // TODO: 引入refreshToken会循环依赖报错 + // } } else if (code === 500) { ElMessage.error(t('sys.api.errMsg500')) return Promise.reject(new Error(msg)) @@ -149,21 +165,12 @@ service.interceptors.response.use( return Promise.reject(error) } ) -function handleAuthorized() { +const handleAuthorized = () => { const { t } = useI18n() if (!isRelogin.show) { + removeToken() isRelogin.show = true - ElMessageBox.confirm(t('sys.api.timeoutMessage'), t('common.confirmTitle'), { - confirmButtonText: t('login.relogin'), - cancelButtonText: t('common.cancel'), - type: 'warning' - }) - .then(() => { - isRelogin.show = false - }) - .catch(() => { - isRelogin.show = false - }) + ElNotification.error(t('sys.api.timeoutMessage')) } return Promise.reject(t('sys.api.timeoutMessage')) } diff --git a/yudao-ui-admin-vue3/src/utils/tree.ts b/yudao-ui-admin-vue3/src/utils/tree.ts index a82fb1c27..76ec0a2e1 100644 --- a/yudao-ui-admin-vue3/src/utils/tree.ts +++ b/yudao-ui-admin-vue3/src/utils/tree.ts @@ -213,7 +213,7 @@ export const eachTree = (treeDatas: any[], callBack: Fn, parentNode = {}) => { * @param {*} parentId 父节点字段 默认 'parentId' * @param {*} children 孩子节点字段 默认 'children' */ -export const handleTree = (data, id?: string, parentId?: string, children?: string) => { +export const handleTree = (data: any[], id?: string, parentId?: string, children?: string) => { const config = { id: id || 'id', parentId: parentId || 'parentId', @@ -222,7 +222,7 @@ export const handleTree = (data, id?: string, parentId?: string, children?: stri const childrenListMap = {} const nodeIds = {} - const tree = [] + const tree: any[] = [] for (const d of data) { const parentId = d[config.parentId] diff --git a/yudao-ui-admin-vue3/src/views/infra/apiAccessLog/apiAccessLog.data.ts b/yudao-ui-admin-vue3/src/views/infra/apiAccessLog/apiAccessLog.data.ts index 97fae4357..69423dd9d 100644 --- a/yudao-ui-admin-vue3/src/views/infra/apiAccessLog/apiAccessLog.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/apiAccessLog/apiAccessLog.data.ts @@ -50,7 +50,16 @@ const crudSchemas = reactive([ }, { label: '请求时间', - field: 'beginTime' + field: 'beginTime', + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } + } }, { label: '执行时长', diff --git a/yudao-ui-admin-vue3/src/views/infra/apiErrorLog/apiErrorLog.data.ts b/yudao-ui-admin-vue3/src/views/infra/apiErrorLog/apiErrorLog.data.ts index 8ded13e8e..404262be5 100644 --- a/yudao-ui-admin-vue3/src/views/infra/apiErrorLog/apiErrorLog.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/apiErrorLog/apiErrorLog.data.ts @@ -50,7 +50,16 @@ const crudSchemas = reactive([ }, { label: '异常发生时间', - field: 'exceptionTime' + field: 'exceptionTime', + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } + } }, { label: '异常名', diff --git a/yudao-ui-admin-vue3/src/views/infra/codegen/codegen.data.ts b/yudao-ui-admin-vue3/src/views/infra/codegen/codegen.data.ts index 5253c9636..27e49ff31 100644 --- a/yudao-ui-admin-vue3/src/views/infra/codegen/codegen.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/codegen/codegen.data.ts @@ -50,6 +50,15 @@ const crudSchemas = reactive([ field: 'createTime', form: { show: false + }, + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } } }, { diff --git a/yudao-ui-admin-vue3/src/views/infra/config/config.data.ts b/yudao-ui-admin-vue3/src/views/infra/config/config.data.ts index c040d4fe3..425918d15 100644 --- a/yudao-ui-admin-vue3/src/views/infra/config/config.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/config/config.data.ts @@ -91,6 +91,15 @@ const crudSchemas = reactive([ field: 'createTime', form: { show: false + }, + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } } }, { diff --git a/yudao-ui-admin-vue3/src/views/infra/dataSourceConfig/dataSourceConfig.data.ts b/yudao-ui-admin-vue3/src/views/infra/dataSourceConfig/dataSourceConfig.data.ts index 2d5869f2a..4431c0c45 100644 --- a/yudao-ui-admin-vue3/src/views/infra/dataSourceConfig/dataSourceConfig.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/dataSourceConfig/dataSourceConfig.data.ts @@ -58,6 +58,15 @@ const crudSchemas = reactive([ field: 'createTime', form: { show: false + }, + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } } }, { diff --git a/yudao-ui-admin-vue3/src/views/infra/fileConfig/fileConfig.data.ts b/yudao-ui-admin-vue3/src/views/infra/fileConfig/fileConfig.data.ts index 6dd5e5e4a..b2383346f 100644 --- a/yudao-ui-admin-vue3/src/views/infra/fileConfig/fileConfig.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/fileConfig/fileConfig.data.ts @@ -76,6 +76,15 @@ const crudSchemas = reactive([ field: 'createTime', form: { show: false + }, + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } } }, { diff --git a/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts b/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts index 6984e693e..e203fd4cf 100644 --- a/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts @@ -36,6 +36,15 @@ const crudSchemas = reactive([ field: 'createTime', form: { show: false + }, + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } } }, { diff --git a/yudao-ui-admin-vue3/src/views/pay/app/app.data.ts b/yudao-ui-admin-vue3/src/views/pay/app/app.data.ts index 652da6359..544428cba 100644 --- a/yudao-ui-admin-vue3/src/views/pay/app/app.data.ts +++ b/yudao-ui-admin-vue3/src/views/pay/app/app.data.ts @@ -8,9 +8,10 @@ const { t } = useI18n() // 国际化 // 表单校验 export const rules = reactive({ name: [required], - code: [required], - sort: [required], - status: [required] + status: [required], + payNotifyUrl: [required], + refundNotifyUrl: [required], + merchantId: [required] }) // CrudSchema @@ -53,6 +54,15 @@ const crudSchemas = reactive([ field: 'createTime', form: { show: false + }, + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } } }, { diff --git a/yudao-ui-admin-vue3/src/views/pay/merchant/merchant.data.ts b/yudao-ui-admin-vue3/src/views/pay/merchant/merchant.data.ts index 7db448ea9..53a2dc581 100644 --- a/yudao-ui-admin-vue3/src/views/pay/merchant/merchant.data.ts +++ b/yudao-ui-admin-vue3/src/views/pay/merchant/merchant.data.ts @@ -7,9 +7,9 @@ const { t } = useI18n() // 国际化 // 表单校验 export const rules = reactive({ + no: [required], name: [required], - code: [required], - sort: [required], + shortName: [required], status: [required] }) @@ -77,6 +77,15 @@ const crudSchemas = reactive([ field: 'createTime', form: { show: false + }, + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } } }, { diff --git a/yudao-ui-admin-vue3/src/views/pay/order/order.data.ts b/yudao-ui-admin-vue3/src/views/pay/order/order.data.ts index e16b9979f..8cdf1c9b0 100644 --- a/yudao-ui-admin-vue3/src/views/pay/order/order.data.ts +++ b/yudao-ui-admin-vue3/src/views/pay/order/order.data.ts @@ -157,6 +157,22 @@ const crudSchemas = reactive([ label: '渠道订单号', field: 'channelOrderNo' }, + { + label: t('common.createTime'), + field: 'createTime', + form: { + show: false + }, + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } + } + }, { label: t('table.action'), field: 'action', diff --git a/yudao-ui-admin-vue3/src/views/pay/refund/refund.data.ts b/yudao-ui-admin-vue3/src/views/pay/refund/refund.data.ts index 19c8e8ec9..6d1fef177 100644 --- a/yudao-ui-admin-vue3/src/views/pay/refund/refund.data.ts +++ b/yudao-ui-admin-vue3/src/views/pay/refund/refund.data.ts @@ -84,6 +84,15 @@ const crudSchemas = reactive([ field: 'createTime', form: { show: false + }, + search: { + show: true, + component: 'DatePicker', + componentProps: { + type: 'datetimerange', + valueFormat: 'YYYY-MM-DD HH:mm:ss', + defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + } } }, { diff --git a/yudao-ui-admin-vue3/src/views/system/dept/dept.data.ts b/yudao-ui-admin-vue3/src/views/system/dept/dept.data.ts index 1a66624d3..ad6458699 100644 --- a/yudao-ui-admin-vue3/src/views/system/dept/dept.data.ts +++ b/yudao-ui-admin-vue3/src/views/system/dept/dept.data.ts @@ -1,5 +1,19 @@ import { required } from '@/utils/formRules' import { reactive } from 'vue' +// 表单校验 +export const rules = reactive({ + name: [required], + sort: [required], + email: [required], + phone: [ + { + pattern: + /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/, + trigger: 'blur', + message: '请输入正确的手机号码' + } + ] +}) export const modelSchema = reactive([ { @@ -17,7 +31,7 @@ export const modelSchema = reactive([ }, { label: '负责人', - field: 'email', + field: 'leaderUserId', component: 'Input' }, { @@ -33,7 +47,7 @@ export const modelSchema = reactive([ { label: '显示排序', field: 'sort', - component: 'Input' + component: 'InputNumber' }, { label: '状态', diff --git a/yudao-ui-admin-vue3/src/views/system/dept/index.vue b/yudao-ui-admin-vue3/src/views/system/dept/index.vue index b956eb6a1..ea3c5f6dc 100644 --- a/yudao-ui-admin-vue3/src/views/system/dept/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/dept/index.vue @@ -1,13 +1,14 @@