【V3.5.0】1、【新增】轻量级定时任务 SmartJob;2、【新增】站内信;3、【新增】个人中心;4、【新增】岗位管理;5、【优化】部门员工管理

This commit is contained in:
zhuoda
2024-07-16 00:20:02 +08:00
parent 23e8ea55e1
commit 716b6303e3
504 changed files with 59745 additions and 1110 deletions

View File

@@ -22,18 +22,20 @@
<a-date-picker valueFormat="YYYY-MM-DD" v-model:value="queryForm.createTime" style="width: 150px" />
</a-form-item>
<a-form-item class="smart-query-form-item">
<a-button type="primary" @click="onSearch">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" class="smart-margin-left10">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
<a-button-group>
<a-button type="primary" @click="onSearch">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" class="smart-margin-left10">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
</a-button-group>
</a-form-item>
</a-row>
</a-form>
@@ -43,19 +45,13 @@
<!---------- 表格操作行 begin ----------->
<a-row class="smart-table-btn-block">
<div class="smart-table-operate-block">
<a-button @click="showForm" type="primary" size="small" v-privilege="'support:changeLog:add'">
<a-button @click="showForm" type="primary" v-privilege="'support:changeLog:add'">
<template #icon>
<PlusOutlined />
</template>
新建
</a-button>
<a-button
@click="confirmBatchDelete"
danger
size="small"
:disabled="selectedRowKeyList.length === 0"
v-privilege="'support:changeLog:batchDelete'"
>
<a-button @click="confirmBatchDelete" danger :disabled="selectedRowKeyList.length === 0" v-privilege="'support:changeLog:batchDelete'">
<template #icon>
<DeleteOutlined />
</template>

View File

@@ -1,11 +1,11 @@
<!--
* 代码生成 列表
*
* @Author: 1024创新实验室-主任卓大
* @Date: 2022-06-08 21:50:41
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
*
* @Author: 1024创新实验室-主任卓大
* @Date: 2022-06-08 21:50:41
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
-->
<template>
<div>
@@ -16,18 +16,20 @@
</a-form-item>
<a-form-item class="smart-query-form-item smart-margin-left10">
<a-button type="primary" @click="onSearch">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" class="smart-margin-left10">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
<a-button-group>
<a-button type="primary" @click="onSearch">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
</a-button-group>
</a-form-item>
</a-row>
</a-form>

View File

@@ -16,19 +16,20 @@
</a-form-item>
<a-form-item class="smart-query-form-item smart-margin-left10">
<a-button type="primary" @click="onSearch" v-privilege="'support:config:query'">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" v-privilege="'support:config:query'" class="smart-margin-left10">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
<a-button-group>
<a-button type="primary" @click="onSearch" v-privilege="'support:config:query'">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" v-privilege="'support:config:query'">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
</a-button-group>
<a-button @click="toEditOrAdd()" v-privilege="'support:config:add'" type="primary" class="smart-margin-left20">
<template #icon>
<PlusOutlined />

View File

@@ -15,18 +15,20 @@
</a-form-item>
<a-form-item class="smart-query-form-item smart-margin-left10">
<a-button type="primary" @click="onSearch">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" class="smart-margin-left10">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
<a-button-group>
<a-button type="primary" @click="onSearch">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
</a-button-group>
</a-form-item>
</a-row>
</a-form>
@@ -34,28 +36,21 @@
<a-card size="small" :bordered="false" :hoverable="true">
<a-row class="smart-table-btn-block">
<div class="smart-table-operate-block">
<a-button @click="addOrUpdateKey" v-privilege="'support:dict:add'" type="primary" size="small">
<a-button @click="addOrUpdateKey" v-privilege="'support:dict:add'" type="primary">
<template #icon>
<PlusOutlined />
</template>
新建
</a-button>
<a-button
@click="confirmBatchDelete"
v-privilege="'support:dict:batchDelete'"
type="text"
danger
size="small"
:disabled="selectedRowKeyList.length === 0"
>
<a-button @click="confirmBatchDelete" v-privilege="'support:dict:batchDelete'" type="text" danger :disabled="selectedRowKeyList.length === 0">
<template #icon>
<DeleteOutlined />
</template>
批量删除
</a-button>
<a-button @click="cacheRefresh" v-privilege="'support:dict:refresh'" type="primary" size="small">
<a-button @click="cacheRefresh" v-privilege="'support:dict:refresh'" type="primary">
<template #icon>
<cloud-sync-outlined />
</template>

View File

@@ -3,7 +3,7 @@
*
* @Author: 1024创新实验室-主任-卓大
* @Date: 2020-10-10 22:13:18
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
-->
<template>
<!---------- 查询表单form begin ----------->
@@ -28,18 +28,20 @@
<a-range-picker v-model:value="queryForm.createTime" :presets="defaultTimeRanges" style="width: 220px" @change="onChangeCreateTime" />
</a-form-item>
<a-form-item class="smart-query-form-item">
<a-button type="primary" @click="queryData">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" class="smart-margin-left10">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
<a-button-group>
<a-button type="primary" @click="queryData">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
</a-button-group>
</a-form-item>
</a-row>
</a-form>
@@ -49,7 +51,7 @@
<!---------- 表格操作行 begin ----------->
<a-row class="smart-table-btn-block">
<div class="smart-table-operate-block">
<a-button type="primary" @click="showUploadModal" size="small">
<a-button type="primary" @click="showUploadModal">
<template #icon>
<cloud-upload-outlined />
</template>
@@ -63,7 +65,16 @@
<!---------- 表格操作行 end ----------->
<!---------- 表格 begin ----------->
<a-table size="small" :dataSource="tableData" :columns="columns" rowKey="fileId" bordered :loading="tableLoading" :pagination="false">
<a-table
size="small"
:scroll="{ x: 1300 }"
:dataSource="tableData"
:columns="columns"
rowKey="fileId"
bordered
:loading="tableLoading"
:pagination="false"
>
<template #bodyCell="{ text, record, column }">
<template v-if="column.dataIndex === 'folderType'">
<span>{{ $smartEnumPlugin.getDescByValue('FILE_FOLDER_TYPE_ENUM', text) }}</span>
@@ -148,10 +159,6 @@
ellipsis: true,
width: 100,
},
{
title: '文件key',
dataIndex: 'fileKey',
},
{
title: '文件类型',
dataIndex: 'fileType',
@@ -180,6 +187,7 @@
title: '操作',
dataIndex: 'action',
width: 120,
fixed: 'right',
},
]);

View File

@@ -1,11 +1,11 @@
<!--
* 心跳记录
*
* @Author: 1024创新实验室-主任卓大
* @Date: 2022-06-02 20:23:08
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
*
* @Author: 1024创新实验室-主任卓大
* @Date: 2022-06-02 20:23:08
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
-->
<template>
<a-card size="small" :bordered="false" :hoverable="true">
@@ -38,18 +38,20 @@
</a-form-item>
<a-form-item class="smart-query-form-item smart-margin-left10">
<a-button type="primary" @click="onSearch" class="smart-margin-right10">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
<a-button-group>
<a-button type="primary" @click="onSearch">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
</a-button-group>
</a-form-item>
</a-row>
</a-form>

View File

@@ -40,7 +40,7 @@
<a-card size="small" :bordered="false">
<a-row class="smart-table-btn-block">
<div class="smart-table-operate-block">
<a-button type="primary" size="small" @click="addOrUpdate()" v-privilege="'support:helpDoc:add'">
<a-button type="primary" @click="addOrUpdate()" v-privilege="'support:helpDoc:add'">
<template #icon>
<PlusOutlined />
</template>

View File

@@ -0,0 +1,248 @@
<!--
* JOB 表单
* @Author: huke
* @Date: 2024/06/29
-->
<template>
<div>
<!-- 编辑 -->
<a-modal :open="updateModalShow" :width="650" title="编辑" ok-text="确认" cancel-text="取消" @cancel="closeUpdateModal" @ok="confirmUpdateJob">
<a-form ref="updateFormRef" :model="updateForm" :rules="updateRules" :label-col="{ span: 4 }">
<a-form-item label="任务名称" name="jobName">
<a-input placeholder="请输入任务名称" v-model:value="updateForm.jobName" :maxlength="100" :showCount="true" />
</a-form-item>
<a-form-item label="任务描述" name="remark">
<a-textarea
:auto-size="{ minRows: 2, maxRows: 4 }"
v-model:value="updateForm.remark"
placeholder="(可选)请输入任务备注描述"
:maxlength="250"
:showCount="true"
/>
</a-form-item>
<a-form-item label="排序" name="sort">
<a-input-number
v-model:value="updateForm.sort"
:min="-99999999"
:max="99999999"
:precision="0"
style="width: 100%"
placeholder="值越小越靠前"
>
</a-input-number>
</a-form-item>
<a-form-item label="执行类" name="jobClass">
<a-textarea
:auto-size="{ minRows: 2, maxRows: 4 }"
v-model:value="updateForm.jobClass"
placeholder="示例net.lab1024.sa.base.module.support.job.sample.SmartJobSample1"
:maxlength="200"
:showCount="true"
/>
</a-form-item>
<a-form-item label="任务参数" name="param">
<a-textarea
:auto-size="{ minRows: 3, maxRows: 6 }"
v-model:value="updateForm.param"
placeholder="(可选)请输入任务执行参数"
:maxlength="1000"
:showCount="true"
/>
</a-form-item>
<a-form-item label="触发类型" name="triggerType">
<a-radio-group v-model:value="updateForm.triggerType">
<a-radio-button :value="TRIGGER_TYPE_ENUM.CRON.value">CRON表达式</a-radio-button>
<a-radio-button :value="TRIGGER_TYPE_ENUM.FIXED_DELAY.value">固定间隔</a-radio-button>
</a-radio-group>
</a-form-item>
<a-form-item label="触发时间" name="triggerTime">
<a-input
v-if="updateForm.triggerType === TRIGGER_TYPE_ENUM.CRON.value"
placeholder="示例10 15 0/1 * * *"
v-model:value="updateForm.cron"
:maxlength="100"
:showCount="true"
/>
<a-input-number
v-else-if="updateForm.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value"
v-model:value="updateForm.fixedDelay"
:min="1"
:max="100000000"
:precision="0"
:defaultValue="100"
>
<template #addonBefore>每隔</template>
<template #addonAfter></template>
</a-input-number>
</a-form-item>
<a-form-item label="是否开启" name="enabledFlag">
<a-switch v-model:checked="updateForm.enabledFlag" />
</a-form-item>
</a-form>
</a-modal>
<!-- 立即执行 -->
<a-modal
:open="executeModalShow"
:width="650"
title="执行任务"
ok-text="执行"
cancel-text="取消"
@cancel="closeExecuteModal"
@ok="confirmExecuteJob"
>
<br />
<a-alert type="info" show-icon style="margin-left: 25px">
<template #message> 点击执行后会按照任务参数无论任务是否开启都会立即执行 </template>
</a-alert>
<br />
<a-form :label-col="{ span: 4 }">
<a-form-item label="任务名称" name="jobName">
<a-input v-model:value="executeForm.jobName" :disabled="true" />
</a-form-item>
<a-form-item label="任务类名" name="jobClass">
<a-textarea :auto-size="{ minRows: 2, maxRows: 4 }" v-model:value="executeForm.jobClass" :disabled="true" />
</a-form-item>
<a-form-item label="任务参数" name="param">
<a-textarea
:auto-size="{ minRows: 3, maxRows: 6 }"
v-model:value="executeForm.param"
placeholder="(可选)请输入任务执行参数"
:maxlength="1000"
:showCount="true"
/>
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
<script setup>
import { message } from 'ant-design-vue';
import { reactive, ref } from 'vue';
import { jobApi } from '/src/api/support/job-api';
import { smartSentry } from '/src/lib/smart-sentry';
import { SmartLoading } from '/src/components/framework/smart-loading/index.js';
import { TRIGGER_TYPE_ENUM } from '/src/constants/support/job-const.js';
// emit
const emit = defineEmits(['reloadList']);
const updateModalShow = ref(false);
const updateFormRef = ref();
const updateFormDefault = {
jobId: null,
jobName: '',
jobClass: '',
triggerType: null,
triggerValue: null,
cron: '',
fixedDelay: null,
param: '',
enabledFlag: false,
remark: '',
sort: null,
};
let updateForm = reactive({ ...updateFormDefault });
const updateRules = {
jobName: [{ required: true, message: '请输入任务名称' }],
jobClass: [{ required: true, message: '请输入执行类' }],
triggerType: [{ required: true, message: '请选择触发类型' }],
sort: [{ required: true, message: '请输入排序' }],
};
// 打开编辑弹框
function openUpdateModal(record) {
Object.assign(updateForm, record);
if (TRIGGER_TYPE_ENUM.CRON.value === record.triggerType) {
updateForm.cron = record.triggerValue;
}
if (TRIGGER_TYPE_ENUM.FIXED_DELAY.value === record.triggerType) {
updateForm.fixedDelay = record.triggerValue;
}
updateModalShow.value = true;
}
// 关闭编辑弹框
function closeUpdateModal() {
Object.assign(updateForm, updateFormDefault);
updateModalShow.value = false;
}
// 确认更新
async function confirmUpdateJob() {
updateFormRef.value
.validate()
.then(async () => {
SmartLoading.show();
if (TRIGGER_TYPE_ENUM.CRON.value === updateForm.triggerType) {
updateForm.triggerValue = updateForm.cron;
}
if (TRIGGER_TYPE_ENUM.FIXED_DELAY.value === updateForm.triggerType) {
updateForm.triggerValue = updateForm.fixedDelay;
}
try {
await jobApi.updateJob(updateForm);
message.success('更新成功');
closeUpdateModal();
emit('reloadList');
} catch (error) {
smartSentry.captureError(error);
} finally {
SmartLoading.hide();
}
})
.catch((error) => {
console.log('error', error);
message.error('参数验证错误,请检查表单数据');
});
}
// ------------------------------------ 执行任务 -------------------------------------
const executeModalShow = ref(false);
const executeFormDefault = {
jobId: null,
jobName: '',
jobClass: '',
param: null,
};
let executeForm = reactive({ ...executeFormDefault });
// 打开执行弹框
function openExecuteModal(record) {
Object.assign(executeForm, record);
executeModalShow.value = true;
}
// 关闭执行弹框
function closeExecuteModal() {
Object.assign(executeForm, executeFormDefault);
executeModalShow.value = false;
}
// 确认执行
async function confirmExecuteJob() {
try {
let executeParam = {
jobId: executeForm.jobId,
param: executeForm.param,
};
await jobApi.executeJob(executeParam);
// loading 延迟后再提示刷新
SmartLoading.show();
await new Promise((resolve) => setTimeout(resolve, 2000));
message.success('执行成功');
closeExecuteModal();
emit('reloadList');
} catch (e) {
smartSentry.captureError(e);
} finally {
SmartLoading.hide();
}
}
defineExpose({
openUpdateModal,
openExecuteModal,
});
</script>

View File

@@ -0,0 +1,200 @@
<!--
* job log列表
* @Author: huke
* @Date: 2024/06/25
-->
<template>
<a-drawer v-model:open="showFlag" :width="1000" :title="title" placement="right" :destroyOnClose="true">
<a-form class="smart-query-form">
<a-row class="smart-query-form-row">
<a-form-item label="关键字" class="smart-query-form-item">
<a-input style="width: 200px" v-model:value="queryForm.searchWord" placeholder="请输入关键字" :maxlength="30" />
</a-form-item>
<a-form-item label="执行结果" class="smart-query-form-item">
<a-select style="width: 100px" v-model:value="queryForm.successFlag" placeholder="请选择" allowClear>
<a-select-option :key="1"> 成功 </a-select-option>
<a-select-option :key="0"> 失败 </a-select-option>
</a-select>
</a-form-item>
<a-form-item label="执行时间" class="smart-query-form-item">
<a-space direction="vertical" :size="12">
<a-range-picker v-model:value="searchDate" style="width: 220px" @change="dateChange" />
</a-space>
</a-form-item>
<a-form-item class="smart-query-form-item smart-margin-left10">
<a-button-group>
<a-button type="primary" @click="onSearch">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
</a-button-group>
</a-form-item>
</a-row>
</a-form>
<a-card size="small" :bordered="false" :hoverable="true">
<a-row justify="end">
<TableOperator class="smart-margin-bottom5" v-model="columns" :tableId="TABLE_ID_CONST.SUPPORT.JOB_LOG" :refresh="queryLogList" />
</a-row>
<a-table size="small" :loading="tableLoading" bordered :dataSource="tableData" :columns="columns" rowKey="jobLogId" :pagination="false">
<template #bodyCell="{ record, column }">
<template v-if="column.dataIndex === 'executeStartTime'">
<div><a-tag color="green"></a-tag>{{ record.executeStartTime }}</div>
<div style="margin-top: 5px"><a-tag color="blue"></a-tag>{{ record.executeEndTime }}</div>
</template>
<template v-if="column.dataIndex === 'executeTimeMillis'"> {{ record.executeTimeMillis }} ms </template>
<template v-if="column.dataIndex === 'successFlag'">
<div v-if="record.successFlag" style="color: #39c710"><CheckOutlined />成功</div>
<div v-else style="color: #f50"><WarningOutlined />失败</div>
</template>
</template>
</a-table>
<div class="smart-query-table-page">
<a-pagination
showSizeChanger
showQuickJumper
show-less-items
:pageSizeOptions="PAGE_SIZE_OPTIONS"
:defaultPageSize="queryForm.pageSize"
v-model:current="queryForm.pageNum"
v-model:pageSize="queryForm.pageSize"
:total="total"
@change="queryLogList"
@showSizeChange="queryLogList"
:show-total="(total) => `${total}`"
/>
</div>
</a-card>
</a-drawer>
</template>
<script setup>
import { reactive, ref } from 'vue';
import { jobApi } from '/src/api/support/job-api';
import { PAGE_SIZE_OPTIONS } from '/src/constants/common-const';
import { smartSentry } from '/src/lib/smart-sentry';
import TableOperator from '/src/components/support/table-operator/index.vue';
import { TABLE_ID_CONST } from '/src/constants/support/table-id-const';
const showFlag = ref(false);
const title = ref('');
function show(jobId, name) {
queryForm.jobId = jobId;
queryLogList();
showFlag.value = true;
title.value = name;
}
defineExpose({ show });
const columns = ref([
{
title: '执行人',
dataIndex: 'createName',
width: 100,
ellipsis: true,
},
{
title: '执行参数',
dataIndex: 'param',
width: 80,
ellipsis: true,
},
{
title: '执行时间',
dataIndex: 'executeStartTime',
width: 200,
},
{
title: '执行用时',
dataIndex: 'executeTimeMillis',
width: 100,
ellipsis: true,
},
{
title: '结果',
dataIndex: 'successFlag',
width: 80,
},
{
title: '执行结果',
dataIndex: 'executeResult',
ellipsis: true,
width: 100,
},
{
title: 'ip',
dataIndex: 'ip',
width: 110,
},
{
title: '进程id',
dataIndex: 'processId',
width: 60,
},
{
title: '程序目录',
dataIndex: 'programPath',
ellipsis: true,
},
]);
// ---------------- 查询数据 -----------------------
const queryFormState = {
searchWord: '',
jobId: null,
successFlag: null,
endTime: null,
startTime: null,
pageNum: 1,
pageSize: 10,
};
const queryForm = reactive({ ...queryFormState });
const tableLoading = ref(false);
const tableData = ref([]);
const total = ref(0);
// 日期选择
let searchDate = ref();
function dateChange(dates, dateStrings) {
queryForm.startTime = dateStrings[0];
queryForm.endTime = dateStrings[1];
}
function resetQuery() {
Object.assign(queryForm, queryFormState);
queryLogList();
}
function onSearch() {
queryForm.pageNum = 1;
queryLogList();
}
async function queryLogList() {
try {
tableLoading.value = true;
let responseModel = await jobApi.queryJobLog(queryForm);
const list = responseModel.data.list;
total.value = responseModel.data.total;
tableData.value = list;
} catch (e) {
smartSentry.captureError(e);
} finally {
tableLoading.value = false;
}
}
</script>

View File

@@ -0,0 +1,322 @@
<!--
* JOB 列表
* @Author: huke
* @Date: 2024/06/25
-->
<template>
<div>
<a-form class="smart-query-form">
<a-row class="smart-query-form-row">
<a-form-item label="关键字" class="smart-query-form-item">
<a-input style="width: 200px" v-model:value="queryForm.searchWord" placeholder="请输入关键字" :maxlength="30" />
</a-form-item>
<a-form-item label="触发类型" class="smart-query-form-item">
<a-select style="width: 155px" v-model:value="queryForm.triggerType" placeholder="请选择触发类型" allowClear>
<a-select-option v-for="item in $smartEnumPlugin.getValueDescList('TRIGGER_TYPE_ENUM')" :key="item.value" :value="item.value">
{{ item.desc }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="状态" class="smart-query-form-item">
<a-select style="width: 150px" v-model:value="queryForm.enabledFlag" placeholder="请选择状态" allowClear>
<a-select-option :key="1"> 开启 </a-select-option>
<a-select-option :key="0"> 停止 </a-select-option>
</a-select>
</a-form-item>
<a-form-item class="smart-query-form-item smart-margin-left10">
<a-button-group>
<a-button type="primary" @click="onSearch" v-privilege="'support:job:query'">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" v-privilege="'support:job:query'">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
</a-button-group>
</a-form-item>
</a-row>
</a-form>
<a-card size="small" :bordered="false" :hoverable="true">
<a-row justify="end">
<TableOperator class="smart-margin-bottom5" v-model="columns" :tableId="TABLE_ID_CONST.SUPPORT.JOB" :refresh="queryJobList" />
</a-row>
<a-table
:scroll="{ x: 1800 }"
size="small"
:loading="tableLoading"
bordered
:dataSource="tableData"
:columns="columns"
rowKey="jobId"
:pagination="false"
>
<template #bodyCell="{ record, column }">
<template v-if="column.dataIndex === 'jobClass'">
<a-tooltip>
<template #title>{{ record.jobClass }}</template>
{{ handleJobClass(record.jobClass) }}
</a-tooltip>
</template>
<template v-if="column.dataIndex === 'triggerType'">
<a-tag v-if="record.triggerType === TRIGGER_TYPE_ENUM.CRON.value" color="success">{{ record.triggerTypeDesc }}</a-tag>
<a-tag v-else-if="record.triggerType === TRIGGER_TYPE_ENUM.FIXED_DELAY.value" color="processing">{{ record.triggerTypeDesc }}</a-tag>
<a-tag v-else color="pink">{{ record.triggerTypeDesc }}</a-tag>
</template>
<template v-if="column.dataIndex === 'lastJob'">
<div v-if="record.lastJobLog">
<a-tooltip>
<template #title>{{ handleExecuteResult(record.lastJobLog.executeResult) }}</template>
<CheckOutlined v-if="record.lastJobLog.successFlag" style="color: #39c710" />
<WarningOutlined v-else style="color: #f50" />
{{ record.lastJobLog.executeStartTime }}
</a-tooltip>
</div>
</template>
<template v-if="column.dataIndex === 'nextJob'">
<a-tooltip v-if="record.enabledFlag && record.nextJobExecuteTimeList">
<template #title>
<div>下次执行(预估时间)</div>
<div v-for="item in record.nextJobExecuteTimeList" :key="item">{{ item }}</div>
</template>
{{ record.nextJobExecuteTimeList[0] }}
</a-tooltip>
</template>
<template v-if="column.dataIndex === 'enabledFlag'">
<a-switch
v-model:checked="record.enabledFlag"
@change="(checked) => handleEnabledUpdate(checked, record)"
:loading="record.enabledLoading"
/>
</template>
<template v-if="column.dataIndex === 'action'">
<div class="smart-table-operate">
<a-button v-privilege="'support:job:update'" @click="openUpdateModal(record)" type="link">编辑</a-button>
<a-button v-privilege="'support:job:execute'" type="link" @click="openExecuteModal(record)">执行</a-button>
<a-button v-privilege="'support:job:log:query'" @click="openJobLogModal(record.jobId, record.jobName)" type="link">记录</a-button>
</div>
</template>
</template>
</a-table>
<div class="smart-query-table-page">
<a-pagination
showSizeChanger
showQuickJumper
show-less-items
:pageSizeOptions="PAGE_SIZE_OPTIONS"
:defaultPageSize="queryForm.pageSize"
v-model:current="queryForm.pageNum"
v-model:pageSize="queryForm.pageSize"
:total="total"
@change="queryJobList"
@showSizeChange="queryJobList"
:show-total="(total) => `${total}`"
/>
</div>
</a-card>
<!-- 表单操作 -->
<JobFormModal ref="jobFormModal" @reloadList="queryJobList" />
<!-- 记录 -->
<JobLogListModal ref="jobLogModal" />
</div>
</template>
<script setup>
import { message } from 'ant-design-vue';
import { onMounted, reactive, ref } from 'vue';
import { jobApi } from '/@/api/support/job-api';
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
import { smartSentry } from '/@/lib/smart-sentry';
import TableOperator from '/@/components/support/table-operator/index.vue';
import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
import { useRouter } from 'vue-router';
import { TRIGGER_TYPE_ENUM } from '/@/constants/support/job-const.js';
import JobFormModal from './components/job-form-modal.vue';
import JobLogListModal from './components/job-log-list-modal.vue';
const columns = ref([
{
title: 'id',
width: 50,
dataIndex: 'jobId',
},
{
title: '任务名称',
dataIndex: 'jobName',
minWidth: 150,
ellipsis: true,
},
{
title: '执行类',
dataIndex: 'jobClass',
minWidth: 180,
ellipsis: true,
},
{
title: '触发类型',
dataIndex: 'triggerType',
width: 110,
},
{
title: '触发配置',
dataIndex: 'triggerValue',
width: 150,
},
{
title: '上次执行',
width: 180,
dataIndex: 'lastJob',
},
{
title: '下次执行',
width: 150,
dataIndex: 'nextJob',
},
{
title: '状态',
dataIndex: 'enabledFlag',
width: 80,
},
{
title: '执行参数',
dataIndex: 'param',
ellipsis: true,
},
{
title: '任务描述',
dataIndex: 'remark',
ellipsis: true,
},
{
title: '排序',
dataIndex: 'sort',
width: 65,
},
{
title: '更新人',
dataIndex: 'updateName',
width: 90,
},
{
title: '更新时间',
dataIndex: 'updateTime',
width: 150,
},
{
title: '操作',
dataIndex: 'action',
fixed: 'right',
width: 130,
},
]);
// ---------------- 查询数据 -----------------------
const queryFormState = {
searchWord: '',
enabledFlag: null,
triggerType: null,
pageNum: 1,
pageSize: 10,
};
const queryForm = reactive({ ...queryFormState });
const tableLoading = ref(false);
const tableData = ref([]);
const total = ref(0);
function resetQuery() {
Object.assign(queryForm, queryFormState);
queryJobList();
}
function onSearch() {
queryForm.pageNum = 1;
queryJobList();
}
// 处理执行类展示 默认返回类
function handleJobClass(jobClass) {
return jobClass.split('.').pop();
}
// 上次处理结果展示 最多展示300
function handleExecuteResult(result) {
let num = 400;
return result ? result.substring(0, num) + (result.length > num ? ' ...' : '') : '';
}
async function queryJobList() {
try {
tableLoading.value = true;
let responseModel = await jobApi.queryJob(queryForm);
const list = responseModel.data.list;
total.value = responseModel.data.total;
tableData.value = list;
} catch (e) {
smartSentry.captureError(e);
} finally {
tableLoading.value = false;
}
}
onMounted(queryJobList);
// 更新状态
async function handleEnabledUpdate(checked, record) {
record.enabledLoading = true;
try {
let updateForm = {
jobId: record.jobId,
enabledFlag: checked,
};
await jobApi.updateJobEnabled(updateForm);
// 重新查询任务详情
let jobInfo = await queryJobInfo(record.jobId);
Object.assign(record, jobInfo);
message.success('更新成功');
} catch (e) {
record.enabledFlag = !checked;
smartSentry.captureError(e);
} finally {
record.enabledLoading = false;
}
}
// 查询任务详情
async function queryJobInfo(jobId) {
try {
let res = await jobApi.queryJobInfo(jobId);
return res.data;
} catch (e) {
smartSentry.captureError(e);
}
}
// ------------------------------------ 执行记录 -------------------------------------
const jobLogModal = ref();
function openJobLogModal(jobId, name) {
jobLogModal.value.show(jobId, name);
}
// ------------------------------------ 表单操作 -------------------------------------
const jobFormModal = ref();
// 打开更新表单
function openUpdateModal(record) {
jobFormModal.value.openUpdateModal(record);
}
// 打开执行表单
function openExecuteModal(record) {
jobFormModal.value.openExecuteModal(record);
}
</script>

View File

@@ -28,18 +28,20 @@
/>
</a-form-item>
<a-form-item class="smart-query-form-item">
<a-button type="primary" @click="onSearch">
<template #icon>
<SearchOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" class="smart-margin-left10">
<template #icon>
<ReloadOutlined />
</template>
重置
</a-button>
<a-button-group>
<a-button type="primary" @click="onSearch">
<template #icon>
<SearchOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" class="smart-margin-left10">
<template #icon>
<ReloadOutlined />
</template>
重置
</a-button>
</a-button-group>
</a-form-item>
</a-row>
</a-form>
@@ -49,7 +51,7 @@
<!---------- 表格操作行 begin ----------->
<a-row class="smart-table-btn-block">
<div class="smart-table-operate-block">
<a-button @click="confirmBatchDelete" danger size="small" :disabled="selectedRowKeyList.length === 0">
<a-button @click="confirmBatchDelete" danger :disabled="selectedRowKeyList.length === 0">
<template #icon>
<DeleteOutlined />
</template>

View File

@@ -1,11 +1,11 @@
<!--
* 登录登出 日志
*
* @Author: 1024创新实验室-主任卓大
* @Date: 2022-06-02 20:23:08
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
*
* @Author: 1024创新实验室-主任卓大
* @Date: 2022-06-02 20:23:08
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
-->
<template>
<a-form class="smart-query-form" v-privilege="'support:loginLog:query'" ref="queryFormRef">
@@ -23,18 +23,20 @@
</a-form-item>
<a-form-item class="smart-query-form-item smart-margin-left10">
<a-button type="primary" @click="onSearch">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" class="smart-margin-left10">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
<a-button-group>
<a-button type="primary" @click="onSearch">
<template #icon>
<SearchOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery">
<template #icon>
<ReloadOutlined />
</template>
重置
</a-button>
</a-button-group>
</a-form-item>
</a-row>
</a-form>

View File

@@ -1,11 +1,11 @@
<!--
* 操作记录 列表
*
* @Author: 1024创新实验室-主任卓大
* @Date: 2022-06-02 20:23:08
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
*
* @Author: 1024创新实验室-主任卓大
* @Date: 2022-06-02 20:23:08
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
-->
<template>
<a-form class="smart-query-form" v-privilege="'support:operateLog:query'">
@@ -27,18 +27,20 @@
</a-form-item>
<a-form-item class="smart-query-form-item smart-margin-left10">
<a-button type="primary" @click="ajaxQuery" class="smart-margin-right10">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
<a-button-group>
<a-button type="primary" @click="ajaxQuery">
<template #icon>
<ReloadOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery">
<template #icon>
<SearchOutlined />
</template>
重置
</a-button>
</a-button-group>
</a-form-item>
</a-row>
</a-form>