This commit is contained in:
parent
95ced0d8fa
commit
37d0bc12d9
|
|
@ -36,8 +36,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="Index">
|
<script setup name="Index">
|
||||||
import { ref, markRaw } from 'vue'
|
import { ref, computed, markRaw } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import auth from '@/plugins/auth'
|
||||||
import {
|
import {
|
||||||
User,
|
User,
|
||||||
Lock,
|
Lock,
|
||||||
|
|
@ -50,39 +51,65 @@ import {
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
// 功能图标列表 - 使用 markRaw 避免组件被响应式化
|
// 功能图标列表配置 - 包含权限标识
|
||||||
const iconItems = ref([
|
const allIconItems = [
|
||||||
{
|
{
|
||||||
icon: markRaw(User),
|
icon: markRaw(User),
|
||||||
title: '用户管理',
|
title: '用户管理',
|
||||||
path: '/system/user',
|
path: '/system/user',
|
||||||
|
permissions: ['system:user:list', 'system:user:query'], // 只要有其中一个权限即可
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: markRaw(Lock),
|
icon: markRaw(Lock),
|
||||||
title: '角色管理',
|
title: '角色管理',
|
||||||
path: '/system/role',
|
path: '/system/role',
|
||||||
|
permissions: ['system:role:list', 'system:role:query'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: markRaw(OfficeBuilding),
|
icon: markRaw(OfficeBuilding),
|
||||||
title: '部门管理',
|
title: '部门管理',
|
||||||
path: '/system/dept',
|
path: '/system/dept',
|
||||||
|
permissions: ['system:dept:list', 'system:dept:query'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: markRaw(UserFilled),
|
icon: markRaw(UserFilled),
|
||||||
title: '人员管理',
|
title: '人员管理',
|
||||||
path: '/basicManage/personManage',
|
path: '/basicManage/personManage',
|
||||||
|
permissions: ['person:person:list', 'person:person:query', 'basicManage:personManage:list'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: markRaw(Collection),
|
icon: markRaw(Collection),
|
||||||
title: '分组管理',
|
title: '分组管理',
|
||||||
path: '/basicManage/groupManage',
|
path: '/basicManage/groupManage',
|
||||||
|
permissions: [
|
||||||
|
'basicManage:groupManage:list',
|
||||||
|
'basicManage:groupManage:query',
|
||||||
|
'group:group:list',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: markRaw(Message),
|
icon: markRaw(Message),
|
||||||
title: '短信任务',
|
title: '短信任务',
|
||||||
path: '/sMsSendManage/loopSend',
|
path: '/sMsSendManage/loopSend',
|
||||||
|
permissions: [
|
||||||
|
'sMsSendManage:loopSend:list',
|
||||||
|
'sMsSendManage:loopSend:query',
|
||||||
|
'sms:loopSend:list',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
])
|
]
|
||||||
|
|
||||||
|
// 根据权限过滤可见的图标列表
|
||||||
|
const iconItems = computed(() => {
|
||||||
|
return allIconItems.filter((item) => {
|
||||||
|
// 如果有权限配置,检查用户是否有权限(只要拥有权限列表中的任意一个即可)
|
||||||
|
if (item.permissions && item.permissions.length > 0) {
|
||||||
|
return auth.hasPermiOr(item.permissions)
|
||||||
|
}
|
||||||
|
// 如果没有权限配置,默认不显示(安全起见)
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// 处理图标点击
|
// 处理图标点击
|
||||||
function handleIconClick(path) {
|
function handleIconClick(path) {
|
||||||
|
|
|
||||||
|
|
@ -426,9 +426,318 @@ const handleShowCron = () => {
|
||||||
cronDialogConfig.outerVisible = true
|
cronDialogConfig.outerVisible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取星期名称
|
||||||
|
const getWeekName = (week) => {
|
||||||
|
const weekMap = {
|
||||||
|
0: '日',
|
||||||
|
1: '一',
|
||||||
|
2: '二',
|
||||||
|
3: '三',
|
||||||
|
4: '四',
|
||||||
|
5: '五',
|
||||||
|
6: '六',
|
||||||
|
7: '日',
|
||||||
|
}
|
||||||
|
return weekMap[week] || week
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将Cron表达式解析为中文说明
|
||||||
|
const parseCronToChinese = (cronExpression) => {
|
||||||
|
if (!cronExpression) return ''
|
||||||
|
|
||||||
|
const parts = cronExpression.trim().split(/\s+/)
|
||||||
|
if (parts.length < 6) return ''
|
||||||
|
|
||||||
|
const [second, minute, hour, day, month, week, year] = parts
|
||||||
|
|
||||||
|
// 格式化时间(时分秒)
|
||||||
|
const formatTime = (h, m, s) => {
|
||||||
|
// 如果值是*,替换为0
|
||||||
|
const hVal = h === '*' || h === '**' ? '0' : h
|
||||||
|
const mVal = m === '*' || m === '**' ? '0' : m
|
||||||
|
const sVal = s === '*' || s === '**' ? '0' : s
|
||||||
|
const hStr = String(hVal).replace(/\*/g, '0').padStart(2, '0')
|
||||||
|
const mStr = String(mVal).replace(/\*/g, '0').padStart(2, '0')
|
||||||
|
const sStr = String(sVal).replace(/\*/g, '0').padStart(2, '0')
|
||||||
|
return `${hStr}:${mStr}:${sStr}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取单个值(如果是列表,取第一个)
|
||||||
|
const getSingleValue = (value) => {
|
||||||
|
if (value.includes(',')) {
|
||||||
|
return value.split(',')[0]
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析星期
|
||||||
|
const parseWeek = (weekValue) => {
|
||||||
|
if (!weekValue || weekValue === '?' || weekValue === '*') return ''
|
||||||
|
if (weekValue.includes(',')) {
|
||||||
|
const weeks = weekValue.split(',').map(getWeekName)
|
||||||
|
return `每周${weeks.join('、')}`
|
||||||
|
}
|
||||||
|
if (weekValue.includes('-')) {
|
||||||
|
const [start, end] = weekValue.split('-')
|
||||||
|
return `每周${getWeekName(start)}到周${getWeekName(end)}`
|
||||||
|
}
|
||||||
|
return `每周${getWeekName(weekValue)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析日期
|
||||||
|
const parseDay = (dayValue, isYearly = false) => {
|
||||||
|
if (!dayValue || dayValue === '?' || dayValue === '*') return ''
|
||||||
|
if (dayValue.includes(',')) {
|
||||||
|
const days = dayValue.split(',')
|
||||||
|
return isYearly ? `${days.join('、')}日` : `每月${days.join('、')}日`
|
||||||
|
}
|
||||||
|
if (dayValue.includes('-')) {
|
||||||
|
const [start, end] = dayValue.split('-')
|
||||||
|
return isYearly ? `${start}到${end}日` : `每月${start}到${end}日`
|
||||||
|
}
|
||||||
|
return isYearly ? `${dayValue}日` : `每月${dayValue}日`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析月份
|
||||||
|
const parseMonth = (monthValue) => {
|
||||||
|
if (!monthValue || monthValue === '*') return ''
|
||||||
|
if (monthValue.includes(',')) {
|
||||||
|
const months = monthValue.split(',')
|
||||||
|
return `${months.join('、')}月`
|
||||||
|
}
|
||||||
|
if (monthValue.includes('-')) {
|
||||||
|
const [start, end] = monthValue.split('-')
|
||||||
|
return `${start}月到${end}月`
|
||||||
|
}
|
||||||
|
return `${monthValue}月`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析年份
|
||||||
|
const parseYear = (yearValue) => {
|
||||||
|
if (!yearValue || yearValue === '*') return ''
|
||||||
|
if (yearValue.includes(',')) {
|
||||||
|
const years = yearValue.split(',')
|
||||||
|
return `${years.join('、')}年`
|
||||||
|
}
|
||||||
|
if (yearValue.includes('-')) {
|
||||||
|
const [start, end] = yearValue.split('-')
|
||||||
|
return `${start}年到${end}年`
|
||||||
|
}
|
||||||
|
return `${yearValue}年`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理步长表达式
|
||||||
|
const hasStep = (value) => {
|
||||||
|
return value.includes('/') && value.split('/')[0] === '*'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 特殊情况1:每天固定时间执行(最常用)
|
||||||
|
if (
|
||||||
|
second !== '?' &&
|
||||||
|
minute !== '?' &&
|
||||||
|
hour !== '?' &&
|
||||||
|
day === '*' &&
|
||||||
|
month === '*' &&
|
||||||
|
week === '?' &&
|
||||||
|
(!year || year === '*')
|
||||||
|
) {
|
||||||
|
const s = getSingleValue(second)
|
||||||
|
const m = getSingleValue(minute)
|
||||||
|
const h = getSingleValue(hour)
|
||||||
|
|
||||||
|
if (!hasStep(second) && !hasStep(minute) && !hasStep(hour)) {
|
||||||
|
let result = `每天${formatTime(h, m, s)}执行`
|
||||||
|
// 清理所有可能的*符号
|
||||||
|
result = result.replace(/(\d)\*/g, '$10').replace(/\*/g, '0')
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 特殊情况2:每周固定时间执行
|
||||||
|
if (
|
||||||
|
second !== '?' &&
|
||||||
|
minute !== '?' &&
|
||||||
|
hour !== '?' &&
|
||||||
|
day === '?' &&
|
||||||
|
month === '*' &&
|
||||||
|
week !== '?' &&
|
||||||
|
week !== '*' &&
|
||||||
|
(!year || year === '*')
|
||||||
|
) {
|
||||||
|
const s = getSingleValue(second)
|
||||||
|
const m = getSingleValue(minute)
|
||||||
|
const h = getSingleValue(hour)
|
||||||
|
const weekDesc = parseWeek(week)
|
||||||
|
|
||||||
|
if (!hasStep(second) && !hasStep(minute) && !hasStep(hour)) {
|
||||||
|
let result = `${weekDesc},${formatTime(h, m, s)}执行`
|
||||||
|
// 清理所有可能的*符号
|
||||||
|
result = result.replace(/(\d)\*/g, '$10').replace(/\*/g, '0')
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 特殊情况3:每月固定日期执行
|
||||||
|
if (
|
||||||
|
second !== '?' &&
|
||||||
|
minute !== '?' &&
|
||||||
|
hour !== '?' &&
|
||||||
|
day !== '*' &&
|
||||||
|
day !== '?' &&
|
||||||
|
month === '*' &&
|
||||||
|
week === '?' &&
|
||||||
|
(!year || year === '*')
|
||||||
|
) {
|
||||||
|
const s = getSingleValue(second)
|
||||||
|
const m = getSingleValue(minute)
|
||||||
|
const h = getSingleValue(hour)
|
||||||
|
const dayDesc = parseDay(day)
|
||||||
|
|
||||||
|
if (!hasStep(second) && !hasStep(minute) && !hasStep(hour)) {
|
||||||
|
let result = `${dayDesc},${formatTime(h, m, s)}执行`
|
||||||
|
// 清理所有可能的*符号
|
||||||
|
result = result.replace(/(\d)\*/g, '$10').replace(/\*/g, '0')
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 特殊情况4:每年固定日期时间执行
|
||||||
|
if (
|
||||||
|
second !== '?' &&
|
||||||
|
minute !== '?' &&
|
||||||
|
hour !== '?' &&
|
||||||
|
day !== '*' &&
|
||||||
|
day !== '?' &&
|
||||||
|
month !== '*' &&
|
||||||
|
week === '?' &&
|
||||||
|
(!year || year === '*' || year === '')
|
||||||
|
) {
|
||||||
|
const s = getSingleValue(second)
|
||||||
|
const m = getSingleValue(minute)
|
||||||
|
const h = getSingleValue(hour)
|
||||||
|
const dayDesc = parseDay(day, true) // 每年模式,不显示"每月"
|
||||||
|
const monthDesc = parseMonth(month)
|
||||||
|
|
||||||
|
if (!hasStep(second) && !hasStep(minute) && !hasStep(hour)) {
|
||||||
|
let result = `每年${monthDesc}${dayDesc},${formatTime(h, m, s)}执行`
|
||||||
|
// 清理所有可能的*符号
|
||||||
|
result = result.replace(/(\d)\*/g, '$10').replace(/\*/g, '0')
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通用情况:按年月日时分秒顺序构建
|
||||||
|
const partsDesc = []
|
||||||
|
|
||||||
|
// 判断是否是每年模式(月份和日期都有值,但年份为空或*)
|
||||||
|
const isYearlyMode = month !== '*' && day !== '*' && day !== '?' && (!year || year === '*')
|
||||||
|
|
||||||
|
// 年份
|
||||||
|
if (year && year !== '*' && year !== '') {
|
||||||
|
const yearDesc = parseYear(year)
|
||||||
|
if (yearDesc) partsDesc.push(yearDesc)
|
||||||
|
} else if (isYearlyMode) {
|
||||||
|
// 如果是每年模式,添加"每年"前缀
|
||||||
|
partsDesc.push('每年')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 月份
|
||||||
|
if (month !== '*') {
|
||||||
|
const monthDesc = parseMonth(month)
|
||||||
|
if (monthDesc) partsDesc.push(monthDesc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 日期或星期
|
||||||
|
if (day !== '?' && day !== '*') {
|
||||||
|
// 如果是每年模式,不显示"每月"
|
||||||
|
const dayDesc = parseDay(day, isYearlyMode)
|
||||||
|
if (dayDesc) partsDesc.push(dayDesc)
|
||||||
|
} else if (week !== '?' && week !== '*') {
|
||||||
|
const weekDesc = parseWeek(week)
|
||||||
|
if (weekDesc) partsDesc.push(weekDesc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 时间(时分秒)
|
||||||
|
const timeParts = []
|
||||||
|
if (hour !== '*' && !hasStep(hour)) {
|
||||||
|
const h = getSingleValue(hour)
|
||||||
|
timeParts.push(h.padStart(2, '0'))
|
||||||
|
} else {
|
||||||
|
timeParts.push('**')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minute !== '*' && !hasStep(minute)) {
|
||||||
|
const m = getSingleValue(minute)
|
||||||
|
timeParts.push(m.padStart(2, '0'))
|
||||||
|
} else {
|
||||||
|
timeParts.push('**')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (second !== '*' && !hasStep(second)) {
|
||||||
|
const s = getSingleValue(second)
|
||||||
|
timeParts.push(s.padStart(2, '0'))
|
||||||
|
} else {
|
||||||
|
timeParts.push('**')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果时间部分有具体值,添加到描述中
|
||||||
|
if (timeParts.some((t) => t !== '**')) {
|
||||||
|
// 将**替换为00,确保没有*符号
|
||||||
|
const timeStr = timeParts.map((t) => (t === '**' ? '00' : t)).join(':')
|
||||||
|
if (timeStr !== '00:00:00' || (hour === '*' && minute === '*' && second === '*')) {
|
||||||
|
partsDesc.push(timeStr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理步长表达式
|
||||||
|
if (hour.includes('/') && hour.split('/')[0] === '*') {
|
||||||
|
const step = hour.split('/')[1]
|
||||||
|
partsDesc.push(`每${step}小时`)
|
||||||
|
}
|
||||||
|
if (minute.includes('/') && minute.split('/')[0] === '*') {
|
||||||
|
const step = minute.split('/')[1]
|
||||||
|
partsDesc.push(`每${step}分钟`)
|
||||||
|
}
|
||||||
|
if (second.includes('/') && second.split('/')[0] === '*') {
|
||||||
|
const step = second.split('/')[1]
|
||||||
|
partsDesc.push(`每${step}秒`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建最终描述
|
||||||
|
if (partsDesc.length === 0) {
|
||||||
|
if (
|
||||||
|
second === '*' &&
|
||||||
|
minute === '*' &&
|
||||||
|
hour === '*' &&
|
||||||
|
day === '*' &&
|
||||||
|
month === '*' &&
|
||||||
|
week === '?'
|
||||||
|
) {
|
||||||
|
return '每秒执行'
|
||||||
|
}
|
||||||
|
return `Cron表达式:${cronExpression}`
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = `${partsDesc.join(',')}执行`
|
||||||
|
|
||||||
|
// 清理所有可能的*符号,将0*替换为00
|
||||||
|
result = result.replace(/(\d)\*/g, '$10')
|
||||||
|
result = result.replace(/\*/g, '0')
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
// Cron表达式回填
|
// Cron表达式回填
|
||||||
const crontabFill = (value) => {
|
const crontabFill = (value) => {
|
||||||
formData.value.cronExpression = value
|
formData.value.cronExpression = value
|
||||||
|
|
||||||
|
// 生成中文说明并赋值给备注
|
||||||
|
const chineseDesc = parseCronToChinese(value)
|
||||||
|
if (chineseDesc) {
|
||||||
|
// 清空之前的备注,直接赋值新的中文说明
|
||||||
|
formData.value.remark = chineseDesc
|
||||||
|
}
|
||||||
|
|
||||||
cronDialogConfig.outerVisible = false
|
cronDialogConfig.outerVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue