Commit f8878f7a by YunaiV

REVIEW 定时任务(列表)

parent cebe6f93
...@@ -23,6 +23,7 @@ declare module '@vue/runtime-core' { ...@@ -23,6 +23,7 @@ declare module '@vue/runtime-core' {
DictTag: typeof import('./../components/DictTag/src/DictTag.vue')['default'] DictTag: typeof import('./../components/DictTag/src/DictTag.vue')['default']
Echart: typeof import('./../components/Echart/src/Echart.vue')['default'] Echart: typeof import('./../components/Echart/src/Echart.vue')['default']
Editor: typeof import('./../components/Editor/src/Editor.vue')['default'] Editor: typeof import('./../components/Editor/src/Editor.vue')['default']
ElAutoResizer: typeof import('element-plus/es')['ElAutoResizer']
ElBadge: typeof import('element-plus/es')['ElBadge'] ElBadge: typeof import('element-plus/es')['ElBadge']
ElButton: typeof import('element-plus/es')['ElButton'] ElButton: typeof import('element-plus/es')['ElButton']
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup'] ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
...@@ -70,6 +71,7 @@ declare module '@vue/runtime-core' { ...@@ -70,6 +71,7 @@ declare module '@vue/runtime-core' {
ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable'] ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTableV2: typeof import('element-plus/es')['ElTableV2']
ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs'] ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag'] ElTag: typeof import('element-plus/es')['ElTag']
......
...@@ -107,7 +107,7 @@ const formRules = reactive({ ...@@ -107,7 +107,7 @@ const formRules = reactive({
const formRef = ref() // 表单 Ref const formRef = ref() // 表单 Ref
/** 打开弹窗 */ /** 打开弹窗 */
const openModal = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
modelVisible.value = true modelVisible.value = true
modelTitle.value = t('action.' + type) modelTitle.value = t('action.' + type)
formType.value = type formType.value = type
...@@ -122,7 +122,7 @@ const openModal = async (type: string, id?: number) => { ...@@ -122,7 +122,7 @@ const openModal = async (type: string, id?: number) => {
} }
} }
} }
defineExpose({ openModal }) // 提供 openModal 方法,用于打开弹窗 defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** cron表达式按钮操作 */ /** cron表达式按钮操作 */
const handleShowCron = () => { const handleShowCron = () => {
......
export const parseTime = (time) => {
if (!time) {
return null
}
const format = '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'object') {
date = time
} else {
if (typeof time === 'string' && /^[0-9]+$/.test(time)) {
time = parseInt(time)
} else if (typeof time === 'string') {
time = time
.replace(new RegExp(/-/gm), '/')
.replace('T', ' ')
.replace(new RegExp(/\.[\d]{3}/gm), '')
}
if (typeof time === 'number' && time.toString().length === 10) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') {
return ['日', '一', '二', '三', '四', '五', '六'][value]
}
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
}
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</template> </template>
<script setup lang="ts" name="JobView"> <script setup lang="ts" name="JobView">
import * as JobApi from '@/api/infra/job' import * as JobApi from '@/api/infra/job'
import { parseTime } from './utils' import { parseTime } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
......
...@@ -121,8 +121,7 @@ ...@@ -121,8 +121,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination <Pagination
v-show="total > 0"
:total="total" :total="total"
v-model:page="queryParams.pageNo" v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
......
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
<Icon icon="ep:edit" />修改 <Icon icon="ep:edit" />修改
</el-button> </el-button>
<el-dropdown <el-dropdown
@command="(command) => handleCommand(command, scope.$index, scope.row)" @command="(command) => handleCommand(command, scope.row)"
v-hasPermi="[ v-hasPermi="[
'system:user:delete', 'system:user:delete',
'system:user:update-password', 'system:user:update-password',
...@@ -147,22 +147,24 @@ ...@@ -147,22 +147,24 @@
<el-button type="primary" link><Icon icon="ep:d-arrow-right" /> 更多</el-button> <el-button type="primary" link><Icon icon="ep:d-arrow-right" /> 更多</el-button>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<!-- div包住避免控制台报错:Runtime directive used on component with non-element root node --> <el-dropdown-item
<div v-hasPermi="['system:user:delete']"> command="handleDelete"
<el-dropdown-item command="handleDelete"> v-if="checkPermi(['system:user:delete'])"
>
<Icon icon="ep:delete" />删除 <Icon icon="ep:delete" />删除
</el-dropdown-item> </el-dropdown-item>
</div> <el-dropdown-item
<div v-hasPermi="['system:user:update-password']"> command="handleResetPwd"
<el-dropdown-item command="handleResetPwd"> v-if="checkPermi(['system:user:update-password'])"
>
<Icon icon="ep:key" />重置密码 <Icon icon="ep:key" />重置密码
</el-dropdown-item> </el-dropdown-item>
</div> <el-dropdown-item
<div v-hasPermi="['system:permission:assign-user-role']"> command="handleRole"
<el-dropdown-item command="handleRole"> v-if="checkPermi(['system:permission:assign-user-role'])"
>
<Icon icon="ep:circle-check" />分配角色 <Icon icon="ep:circle-check" />分配角色
</el-dropdown-item> </el-dropdown-item>
</div>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
...@@ -189,6 +191,7 @@ ...@@ -189,6 +191,7 @@
</template> </template>
<script setup lang="ts" name="User"> <script setup lang="ts" name="User">
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { checkPermi } from '@/utils/permission'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import { CommonStatusEnum } from '@/utils/constants' import { CommonStatusEnum } from '@/utils/constants'
...@@ -290,8 +293,7 @@ const handleExport = async () => { ...@@ -290,8 +293,7 @@ const handleExport = async () => {
} }
/** 操作分发 */ /** 操作分发 */
const handleCommand = (command: string, index: number, row: UserApi.UserVO) => { const handleCommand = (command: string, row: UserApi.UserVO) => {
console.log(index)
switch (command) { switch (command) {
case 'handleDelete': case 'handleDelete':
handleDelete(row.id) handleDelete(row.id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment