-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
290 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,4 +103,6 @@ dist | |
.tern-port | ||
|
||
# vscode private configuration file | ||
.vscode/redis.json | ||
.vscode/redis.json | ||
|
||
.env.development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { BaseListResp } from '/@/api/model/baseModel'; | ||
|
||
/** | ||
* @description: TaskLog info response | ||
*/ | ||
export interface TaskLogInfo { | ||
id?: number; | ||
startedAt?: number; | ||
finishedAt?: number; | ||
result?: number; | ||
} | ||
|
||
/** | ||
* @description: TaskLog list response | ||
*/ | ||
|
||
export type TaskLogListResp = BaseListResp<TaskLogInfo>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { defHttp } from '/@/utils/http/axios'; | ||
import { ErrorMessageMode } from '/#/axios'; | ||
import { BaseDataResp, BaseListReq, BaseResp, BaseIDsReq, BaseIDReq } from '/@/api/model/baseModel'; | ||
import { TaskLogInfo, TaskLogListResp } from './model/taskLogModel'; | ||
|
||
enum Api { | ||
CreateTaskLog = '/sys-api/task_log/create', | ||
UpdateTaskLog = '/sys-api/task_log/update', | ||
GetTaskLogList = '/sys-api/task_log/list', | ||
DeleteTaskLog = '/sys-api/task_log/delete', | ||
GetTaskLogById = '/sys-api/task_log', | ||
} | ||
|
||
/** | ||
* @description: Get task log list | ||
*/ | ||
|
||
export const getTaskLogList = (params: BaseListReq, mode: ErrorMessageMode = 'message') => { | ||
return defHttp.post<BaseDataResp<TaskLogListResp>>( | ||
{ url: Api.GetTaskLogList, params }, | ||
{ errorMessageMode: mode }, | ||
); | ||
}; | ||
|
||
/** | ||
* @description: Create a new task log | ||
*/ | ||
export const createTaskLog = (params: TaskLogInfo, mode: ErrorMessageMode = 'message') => { | ||
return defHttp.post<BaseResp>( | ||
{ url: Api.CreateTaskLog, params: params }, | ||
{ | ||
errorMessageMode: mode, | ||
}, | ||
); | ||
}; | ||
|
||
/** | ||
* @description: Update the task log | ||
*/ | ||
export const updateTaskLog = (params: TaskLogInfo, mode: ErrorMessageMode = 'message') => { | ||
return defHttp.post<BaseResp>( | ||
{ url: Api.UpdateTaskLog, params: params }, | ||
{ | ||
errorMessageMode: mode, | ||
}, | ||
); | ||
}; | ||
|
||
/** | ||
* @description: Delete task logs | ||
*/ | ||
export const deleteTaskLog = (params: BaseIDsReq, mode: ErrorMessageMode = 'message') => { | ||
return defHttp.post<BaseResp>( | ||
{ url: Api.DeleteTaskLog, params: params }, | ||
{ | ||
errorMessageMode: mode, | ||
}, | ||
); | ||
}; | ||
|
||
/** | ||
* @description: Get task log By ID | ||
*/ | ||
export const getTaskLogById = (params: BaseIDReq, mode: ErrorMessageMode = 'message') => { | ||
return defHttp.post<BaseDataResp<TaskLogInfo>>( | ||
{ url: Api.GetTaskLogById, params: params }, | ||
{ | ||
errorMessageMode: mode, | ||
}, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<template> | ||
<BasicModal | ||
v-bind="$attrs" | ||
:title="t('sys.taskLog.taskLogList')" | ||
@register="registerModal" | ||
:wrapperFooterOffset="50" | ||
:cancelText="t('common.closeText')" | ||
:showOkBtn="false" | ||
> | ||
<BasicTable @register="registerTable" :searchInfo="searchInfo" class="tableHeight"> | ||
<template #tableTitle> | ||
<Button type="primary" danger v-if="showDeleteButton" @click="handleBatchDelete()"> | ||
<template #icon><DeleteOutlined /></template> | ||
{{ t('common.delete') }} | ||
</Button> | ||
</template> | ||
</BasicTable> | ||
</BasicModal> | ||
</template> | ||
<script lang="ts"> | ||
import DeleteOutlined from '@ant-design/icons-vue/lib/icons/DeleteOutlined'; | ||
import ExclamationCircleOutlined from '@ant-design/icons-vue/lib/icons/ExclamationCircleOutlined'; | ||
import { Modal } from 'ant-design-vue'; | ||
import { createVNode, defineComponent, reactive, ref } from 'vue'; | ||
import { useI18n } from 'vue-i18n'; | ||
import { columns, searchFormSchema } from './tasklog.data'; | ||
import { deleteTaskLog, getTaskLogList } from '/@/api/sys/taskLog'; | ||
import { Button } from '/@/components/Button'; | ||
import { BasicModal, useModalInner } from '/@/components/Modal'; | ||
import { BasicTable, useTable } from '/@/components/Table'; | ||
import { useMessage } from '/@/hooks/web/useMessage'; | ||
export default defineComponent({ | ||
components: { BasicModal, BasicTable, DeleteOutlined, Button }, | ||
setup() { | ||
const { t } = useI18n(); | ||
const selectedIds = ref<number[] | string[]>(); | ||
const showDeleteButton = ref<boolean>(false); | ||
const { notification } = useMessage(); | ||
const searchInfo = reactive<Recordable>({}); | ||
const [registerTable, { reload }] = useTable({ | ||
title: t('sys.task.taskList'), | ||
api: getTaskLogList, | ||
columns, | ||
formConfig: { | ||
labelWidth: 120, | ||
schemas: searchFormSchema, | ||
}, | ||
useSearchForm: true, | ||
showTableSetting: true, | ||
bordered: true, | ||
showIndexColumn: false, | ||
clickToRowSelect: false, | ||
rowKey: 'id', | ||
rowSelection: { | ||
type: 'checkbox', | ||
onChange: (selectedRowKeys, _selectedRows) => { | ||
selectedIds.value = selectedRowKeys as number[]; | ||
showDeleteButton.value = selectedRowKeys.length > 0; | ||
}, | ||
}, | ||
}); | ||
const [registerModal] = useModalInner(async (data) => { | ||
searchInfo.taskId = data.record.id; | ||
}); | ||
async function handleBatchDelete() { | ||
Modal.confirm({ | ||
title: t('common.deleteConfirm'), | ||
icon: createVNode(ExclamationCircleOutlined), | ||
async onOk() { | ||
const result = await deleteTaskLog({ ids: selectedIds.value as number[] }, 'modal'); | ||
if (result.code === 0) { | ||
showDeleteButton.value = false; | ||
notification.success({ | ||
message: t('common.successful'), | ||
description: t(result.msg), | ||
duration: 3, | ||
}); | ||
await reload(); | ||
} | ||
}, | ||
onCancel() { | ||
console.log('Cancel'); | ||
}, | ||
}); | ||
} | ||
return { | ||
t, | ||
registerTable, | ||
showDeleteButton, | ||
handleBatchDelete, | ||
registerModal, | ||
searchInfo, | ||
}; | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Tag } from 'ant-design-vue'; | ||
import { h } from 'vue'; | ||
import { BasicColumn, FormSchema } from '/@/components/Table'; | ||
import { useI18n } from '/@/hooks/web/useI18n'; | ||
import { formatToDateTime } from '/@/utils/dateUtil'; | ||
|
||
const { t } = useI18n(); | ||
|
||
export const columns: BasicColumn[] = [ | ||
{ | ||
title: t('sys.taskLog.startedAt'), | ||
dataIndex: 'startedAt', | ||
width: 50, | ||
customRender: ({ record }) => { | ||
return formatToDateTime(record.startedAt); | ||
}, | ||
}, | ||
{ | ||
title: t('sys.taskLog.finishedAt'), | ||
dataIndex: 'finishedAt', | ||
width: 50, | ||
customRender: ({ record }) => { | ||
return formatToDateTime(record.finishedAt); | ||
}, | ||
}, | ||
{ | ||
title: t('sys.taskLog.result'), | ||
dataIndex: 'result', | ||
width: 30, | ||
customRender: ({ record }) => { | ||
let resultText = ''; | ||
if (record.result === 1) { | ||
resultText = t('common.successful'); | ||
} else { | ||
resultText = t('common.failed'); | ||
} | ||
return h( | ||
Tag, | ||
{ | ||
color: record.result === 1 ? 'green' : 'red', | ||
}, | ||
resultText, | ||
); | ||
}, | ||
}, | ||
]; | ||
|
||
export const searchFormSchema: FormSchema[] = [ | ||
{ | ||
field: 'result', | ||
label: t('sys.taskLog.result'), | ||
component: 'Select', | ||
colProps: { span: 8 }, | ||
defaultValue: 0, | ||
componentProps: { | ||
options: [ | ||
{ label: t('common.all'), value: 0 }, | ||
{ label: t('common.successful'), value: 1 }, | ||
{ label: t('common.failed'), value: 2 }, | ||
], | ||
}, | ||
}, | ||
]; |