瀏覽代碼

change time disable

tags/v1.0.0^2
zhangtao 2 年之前
父節點
當前提交
142e74190e
共有 3 個檔案被更改,包括 26 行新增10 行删除
  1. +1
    -1
      src/layout/components/Header/index.vue
  2. +4
    -3
      src/router/guard/permission-guard.js
  3. +21
    -6
      src/views/task-manage/all-task/tools/form.js

+ 1
- 1
src/layout/components/Header/index.vue 查看文件

@@ -49,7 +49,7 @@ export default defineComponent({
})

const getUserInfo = computed(() => {
return userStore.userInfo
return userStore.userInfoMsg
})

const getLogoWidth = computed(() => {

+ 4
- 3
src/router/guard/permission-guard.js 查看文件

@@ -1,5 +1,5 @@
import { useUserStore } from '@/store/modules/user'
import { usePermissionStore } from '@/store/modules/permission'
import { useUserStore } from '@/store/modules/user.js'
import { usePermissionStore } from '@/store/modules/permission.js'
import { NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '@/router/routes'
import { getToken } from '@/utils/token'

@@ -13,12 +13,13 @@ export function createPermissionGuard(router) {
if (to.path === '/login') {
next({ path: '/' })
} else {
const hasUsers = !!Object.keys(userStore.userInfoMsg).length
const hasRoutes = !!permissionStore.permissionRoutes.length
if (!hasUsers) { await userStore.getUserInfo() }
if (hasRoutes) {
next()
} else {
try {
// await userStore.getUserInfo()
const routes = await permissionStore.generateRoutes()
routes.forEach((item) => {
router.addRoute(item)

+ 21
- 6
src/views/task-manage/all-task/tools/form.js 查看文件

@@ -7,21 +7,33 @@ const airOptions = ref([])
const lineOptions = ref([])

function disableTime(ts) {
/* 当前日期 */
const DATE = new Date().getDate()
/* 当前小时 */
const HOURS = new Date().getHours()
/* 当前分钟 */
const MINUTES = new Date().getMinutes()
/* 当前秒 */
const SECONDS = new Date().getSeconds()
/* 选择日期 */
const tDate = new Date(ts).getDate()
/* 选择小时 */
const tHours = new Date(ts).getHours()
/* 选择分钟 */
const tMinutes = new Date(ts).getMinutes()
return {
/* 小时禁用 */
isHourDisabled: (hour) => {
/* 选择的日期与当前日期相同,且小于当前时间 */
return tDate === DATE && hour < HOURS
},
/* 分钟禁用 */
isMinuteDisabled: (minute) => {
/* 日期相同 */
if (tDate === DATE) {
if (tHours < HOURS) {
return true
/* 选择小时大于当前小时,则可以全选 */
if (tHours > HOURS) {
return false
} else {
return minute < MINUTES
}
@@ -30,11 +42,14 @@ function disableTime(ts) {
}
},
isSecondDisabled: (second) => {
/* 日期相同 */
if (tDate === DATE) {
if (tHours < HOURS) {
return true
} else if (tMinutes < MINUTES) {
return true
/* 选择小时大于当前小时,则可以全选 */
if (tHours > HOURS) {
return false
/* 选择分钟大于当前分钟,则可以全选 */
} else if (tMinutes > MINUTES) {
return false
} else {
return second < SECONDS
}

Loading…
取消
儲存