diff --git a/OrangeFormsOpen-VUE3/index.html b/OrangeFormsOpen-VUE3/index.html index 023f6a14..ad5c1710 100644 --- a/OrangeFormsOpen-VUE3/index.html +++ b/OrangeFormsOpen-VUE3/index.html @@ -4,7 +4,7 @@ - 加载中 + 橙单代码生成平台
diff --git a/OrangeFormsOpen-VUE3/package-lock.json b/OrangeFormsOpen-VUE3/package-lock.json index de4c4fd8..b8c21295 100644 --- a/OrangeFormsOpen-VUE3/package-lock.json +++ b/OrangeFormsOpen-VUE3/package-lock.json @@ -25,6 +25,7 @@ "highlight.js": "^11.9.0", "jsencrypt": "^3.3.2", "json-bigint": "^1.0.0", + "lodash": "^4.17.21", "pinia": "^2.1.6", "pinia-plugin-persist": "^1.0.0", "vant": "^4.7.3", @@ -58,7 +59,6 @@ "eslint-plugin-import": "^2.29.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vue": "^9.8.0", - "lodash": "^4.17.21", "node-polyfill-webpack-plugin": "^4.0.0", "postcss": "^8.4.20", "postcss-html": "^1.5.0", diff --git a/OrangeFormsOpen-VUE3/package.json b/OrangeFormsOpen-VUE3/package.json index 00840b51..a8f3a02d 100644 --- a/OrangeFormsOpen-VUE3/package.json +++ b/OrangeFormsOpen-VUE3/package.json @@ -1,5 +1,5 @@ { - "name": "vite", + "name": "orange", "private": true, "version": "0.0.0", "scripts": { diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useCommon.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useCommon.ts index ba27c94e..ccbf4d08 100644 --- a/OrangeFormsOpen-VUE3/src/common/hooks/useCommon.ts +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useCommon.ts @@ -1,5 +1,5 @@ +import { getCurrentInstance } from 'vue'; import { Delete, Search, Edit, Plus, Refresh, Picture } from '@element-plus/icons-vue'; -import { EpPropMergeType } from 'element-plus/es/utils'; import { useDate } from '@/common/hooks/useDate'; import { usePermissions } from '@/common/hooks/usePermission'; import { Dialog } from '@/components/Dialog'; diff --git a/OrangeFormsOpen-VUE3/src/common/hooks/useDate.ts b/OrangeFormsOpen-VUE3/src/common/hooks/useDate.ts index e710d295..8c5018c9 100644 --- a/OrangeFormsOpen-VUE3/src/common/hooks/useDate.ts +++ b/OrangeFormsOpen-VUE3/src/common/hooks/useDate.ts @@ -43,43 +43,24 @@ export const useDate = () => { * @param {String} statsType 转换类型(day, month, year) * @param {String} format 输出格式 */ - const getDateRangeFilter = (date: string, statsType = 'day', format = 'YYYY-MM-dd HH:mm:ss') => { + const getDateRangeFilter = (date: string, statsType = 'day', format = 'YYYY-MM-DD HH:mm:ss') => { if (date == null) return []; - - statsType = allowStatsType.indexOf(statsType) === -1 ? 'day' : statsType; - date = date.substring(0, date.indexOf(' ')); - const tempList = date.split('-'); - const year = Number.parseInt(tempList[0]); - const month = Number.parseInt(tempList[1]); - const day = Number.parseInt(tempList[2]); - if (isNaN(year) || isNaN(month) || isNaN(day)) { + const tempDate = parseDate(date, format); + console.log('tempDate', tempDate); + if (tempDate && tempDate.isValid()) { + switch (statsType) { + case 'day': + return [tempDate.startOf('d').format(format), tempDate.endOf('d').format(format)]; + case 'month': + return [tempDate.startOf('M').format(format), tempDate.endOf('M').format(format)]; + case 'year': + return [tempDate.startOf('y').format(format), tempDate.endOf('y').format(format)]; + default: + return []; + } + } else { return []; } - const tempDate = new Date(year, month - 1, day); - // 判断是否正确的日期 - if (isNaN(tempDate.getTime())) return []; - - tempDate.setHours(0, 0, 0, 0); - let retDate: Date[] = []; - // TODO 如果类型为'time', 'datetime'会出错 - switch (statsType) { - case 'day': - retDate = [new Date(tempDate), new Date(tempDate.setDate(tempDate.getDate() + 1))]; - break; - case 'month': - tempDate.setDate(1); - retDate = [new Date(tempDate), new Date(tempDate.setMonth(tempDate.getMonth() + 1))]; - break; - case 'year': - tempDate.setDate(1); - tempDate.setMonth(0); - retDate = [new Date(tempDate), new Date(tempDate.setFullYear(tempDate.getFullYear() + 1))]; - break; - } - - retDate[1] = new Date(retDate[1].getTime() - 1); - - return [formatDate(retDate[0], format), formatDate(retDate[1], format)]; }; return { diff --git a/OrangeFormsOpen-VUE3/src/components/DeptSelect/index.vue b/OrangeFormsOpen-VUE3/src/components/DeptSelect/index.vue index 0504fc74..da29ddd4 100644 --- a/OrangeFormsOpen-VUE3/src/components/DeptSelect/index.vue +++ b/OrangeFormsOpen-VUE3/src/components/DeptSelect/index.vue @@ -1,7 +1,7 @@