This commit is contained in:
shizhong
2023-06-13 10:56:20 +08:00
parent 38fa336816
commit 7cfb09fe3c
26 changed files with 173 additions and 126 deletions

View File

@ -1,5 +1,5 @@
<template>
<Dialog title="任务详细" v-model="modelVisible" width="700px">
<Dialog title="任务详细" v-model="dialogVisible" width="700px">
<el-descriptions border :column="1">
<el-descriptions-item label="任务编号" min-width="60">
{{ detailData.id }}
@ -47,14 +47,14 @@ import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime'
import * as JobApi from '@/api/infra/job'
const modelVisible = ref(false) // 弹窗的是否展示
const dialogVisible = ref(false) // 弹窗的是否展示
const detailLoading = ref(false) // 表单的加载中
const detailData = ref({}) // 详情数据
const nextTimes = ref([]) // 下一轮执行时间的数组
/** 打开弹窗 */
const open = async (id: number) => {
modelVisible.value = true
dialogVisible.value = true
// 查看,设置数据
if (id) {
detailLoading.value = true

View File

@ -1,5 +1,5 @@
<template>
<Dialog :title="modelTitle" v-model="modelVisible">
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
@ -41,7 +41,7 @@
</el-form>
<template #footer>
<el-button type="primary" @click="submitForm" :loading="formLoading"> </el-button>
<el-button @click="modelVisible = false"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
@ -50,8 +50,8 @@ import * as JobApi from '@/api/infra/job'
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const modelVisible = ref(false) // 弹窗的是否展示
const modelTitle = ref('') // 弹窗的标题
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 表单的加载中1修改时的数据加载2提交的按钮禁用
const formType = ref('') // 表单的类型create - 新增update - 修改
const formData = ref({
@ -72,8 +72,8 @@ const formRef = ref() // 表单 Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
modelVisible.value = true
modelTitle.value = t('action.' + type)
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
// 修改时,设置数据
@ -106,7 +106,7 @@ const submitForm = async () => {
await JobApi.updateJob(data)
message.success(t('common.updateSuccess'))
}
modelVisible.value = false
dialogVisible.value = false
// 发送操作成功的事件
emit('success')
} finally {

View File

@ -1,5 +1,5 @@
<template>
<Dialog title="任务详细" v-model="modelVisible" width="700px">
<Dialog title="任务详细" v-model="dialogVisible" width="700px">
<el-descriptions border :column="1">
<el-descriptions-item label="日志编号" min-width="60">
{{ detailData.id }}
@ -36,13 +36,13 @@ import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime'
import * as JobLogApi from '@/api/infra/jobLog'
const modelVisible = ref(false) // 弹窗的是否展示
const dialogVisible = ref(false) // 弹窗的是否展示
const detailLoading = ref(false) // 表单的加载中
const detailData = ref({}) // 详情数据
/** 打开弹窗 */
const open = async (id: number) => {
modelVisible.value = true
dialogVisible.value = true
// 查看,设置数据
if (id) {
detailLoading.value = true

View File

@ -0,0 +1,44 @@
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
}