Commit f8878f7a by YunaiV

REVIEW 定时任务(列表)

parent cebe6f93
......@@ -23,6 +23,7 @@ declare module '@vue/runtime-core' {
DictTag: typeof import('./../components/DictTag/src/DictTag.vue')['default']
Echart: typeof import('./../components/Echart/src/Echart.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']
ElButton: typeof import('element-plus/es')['ElButton']
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
......@@ -70,6 +71,7 @@ declare module '@vue/runtime-core' {
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTableV2: typeof import('element-plus/es')['ElTableV2']
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
......
......@@ -107,7 +107,7 @@ const formRules = reactive({
const formRef = ref() // 表单 Ref
/** 打开弹窗 */
const openModal = async (type: string, id?: number) => {
const open = async (type: string, id?: number) => {
modelVisible.value = true
modelTitle.value = t('action.' + type)
formType.value = type
......@@ -122,7 +122,7 @@ const openModal = async (type: string, id?: number) => {
}
}
}
defineExpose({ openModal }) // 提供 openModal 方法,用于打开弹窗
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** cron表达式按钮操作 */
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 @@
</template>
<script setup lang="ts" name="JobView">
import * as JobApi from '@/api/infra/job'
import { parseTime } from './utils'
import { parseTime } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict'
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
......
......@@ -121,8 +121,7 @@
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
......
......@@ -137,7 +137,7 @@
<Icon icon="ep:edit" />修改
</el-button>
<el-dropdown
@command="(command) => handleCommand(command, scope.$index, scope.row)"
@command="(command) => handleCommand(command, scope.row)"
v-hasPermi="[
'system:user:delete',
'system:user:update-password',
......@@ -147,22 +147,24 @@
<el-button type="primary" link><Icon icon="ep:d-arrow-right" /> 更多</el-button>
<template #dropdown>
<el-dropdown-menu>
<!-- div包住避免控制台报错:Runtime directive used on component with non-element root node -->
<div v-hasPermi="['system:user:delete']">
<el-dropdown-item command="handleDelete">
<Icon icon="ep:delete" />删除
</el-dropdown-item>
</div>
<div v-hasPermi="['system:user:update-password']">
<el-dropdown-item command="handleResetPwd">
<Icon icon="ep:key" />重置密码
</el-dropdown-item>
</div>
<div v-hasPermi="['system:permission:assign-user-role']">
<el-dropdown-item command="handleRole">
<Icon icon="ep:circle-check" />分配角色
</el-dropdown-item>
</div>
<el-dropdown-item
command="handleDelete"
v-if="checkPermi(['system:user:delete'])"
>
<Icon icon="ep:delete" />删除
</el-dropdown-item>
<el-dropdown-item
command="handleResetPwd"
v-if="checkPermi(['system:user:update-password'])"
>
<Icon icon="ep:key" />重置密码
</el-dropdown-item>
<el-dropdown-item
command="handleRole"
v-if="checkPermi(['system:permission:assign-user-role'])"
>
<Icon icon="ep:circle-check" />分配角色
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
......@@ -189,6 +191,7 @@
</template>
<script setup lang="ts" name="User">
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { checkPermi } from '@/utils/permission'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { CommonStatusEnum } from '@/utils/constants'
......@@ -290,8 +293,7 @@ const handleExport = async () => {
}
/** 操作分发 */
const handleCommand = (command: string, index: number, row: UserApi.UserVO) => {
console.log(index)
const handleCommand = (command: string, row: UserApi.UserVO) => {
switch (command) {
case 'handleDelete':
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