✨ 计划任务选择模板.
This commit is contained in:
@@ -221,6 +221,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
||||
// 添加内置参数
|
||||
params.put("userId", request.getUserId());
|
||||
params.put("username", request.getUsername());
|
||||
params.put("source", request.getSourceId());
|
||||
params.put("sourceId", request.getSourceId());
|
||||
params.put("seq", request.getExecSeq());
|
||||
params.put("execId", execId);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<h3>执行命令</h3>
|
||||
<span v-permission="['asset:exec-template:query']"
|
||||
class="span-blue usn pointer"
|
||||
@click="openTemplate">
|
||||
@click="emits('openTemplate')">
|
||||
从模板中选择
|
||||
</span>
|
||||
</div>
|
||||
@@ -17,9 +17,6 @@
|
||||
<div v-pre class="editor-help">
|
||||
使用 @{{ xxx }} 来替换参数, 输入_可以获取全部变量
|
||||
</div>
|
||||
<!-- 命令模板模态框 -->
|
||||
<exec-template-modal ref="templateModal"
|
||||
@selected="s => emits('selected', s)" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -30,17 +27,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import ExecTemplateModal from '@/components/exec/template/modal/index.vue';
|
||||
|
||||
const emits = defineEmits(['selected']);
|
||||
|
||||
const templateModal = ref<any>();
|
||||
|
||||
// 打开模板
|
||||
const openTemplate = () => {
|
||||
templateModal.value.open();
|
||||
};
|
||||
const emits = defineEmits(['openTemplate']);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<template #form>
|
||||
<a-form :model="formModel"
|
||||
ref="formRef"
|
||||
class="form-wrapper"
|
||||
label-align="right"
|
||||
:rules="formRules">
|
||||
<!-- 执行主机 -->
|
||||
@@ -70,7 +71,7 @@
|
||||
</exec-command-panel-form>
|
||||
<!-- 执行命令 -->
|
||||
<exec-command-panel-editor class="exec-command-container"
|
||||
@selected="setWithTemplate">
|
||||
@open-template="() => templateModal.open()">
|
||||
<exec-editor v-model="formModel.command"
|
||||
theme="vs-dark"
|
||||
:parameter="parameterSchema" />
|
||||
@@ -79,6 +80,9 @@
|
||||
<exec-command-panel-history class="exec-history-container"
|
||||
ref="historyRef"
|
||||
@selected="setWithExecLog" />
|
||||
<!-- 命令模板模态框 -->
|
||||
<exec-template-modal ref="templateModal"
|
||||
@selected="setWithTemplate" />
|
||||
<!-- 主机模态框 -->
|
||||
<authorized-host-modal ref="hostModal"
|
||||
@selected="setSelectedHost" />
|
||||
@@ -106,6 +110,7 @@
|
||||
import ExecCommandPanelForm from './exec-command-panel-form.vue';
|
||||
import ExecCommandPanelHistory from './exec-command-panel-history.vue';
|
||||
import ExecCommandPanelEditor from './exec-command-panel-editor.vue';
|
||||
import ExecTemplateModal from '@/components/exec/template/modal/index.vue';
|
||||
|
||||
const emits = defineEmits(['submit']);
|
||||
|
||||
@@ -121,6 +126,7 @@
|
||||
const hostModal = ref<any>();
|
||||
const historyRef = ref<any>();
|
||||
const formRef = ref<any>();
|
||||
const templateModal = ref<any>();
|
||||
const parameterFormRef = ref<any>();
|
||||
const formModel = ref<ExecCommandRequest>({ ...defaultForm() });
|
||||
const parameterFormModel = ref<Record<string, any>>({});
|
||||
@@ -257,6 +263,11 @@
|
||||
}
|
||||
|
||||
.exec-form-container {
|
||||
|
||||
.form-wrapper {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.selected-host {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
@@ -285,7 +296,7 @@
|
||||
:deep(.panel-header) {
|
||||
width: 100%;
|
||||
height: 28px;
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 4px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
|
||||
@@ -69,11 +69,20 @@
|
||||
</a-col>
|
||||
<!-- 执行命令 -->
|
||||
<a-col :span="24">
|
||||
<a-form-item field="command"
|
||||
<a-form-item class="command-item"
|
||||
field="command"
|
||||
label="执行命令"
|
||||
:hide-label="true"
|
||||
:wrapper-col-props="{ span: 24 }"
|
||||
:help="'使用 @{{ xxx }} 来替换参数, 输入_可以获取全部变量'">
|
||||
<template #extra>
|
||||
<span v-permission="['asset:exec-template:query']"
|
||||
class="span-blue usn pointer"
|
||||
@click="emits('openTemplate')">
|
||||
从模板中选择
|
||||
</span>
|
||||
</template>
|
||||
<!-- 命令框 -->
|
||||
<exec-editor v-model="formModel.command"
|
||||
container-class="command-editor"
|
||||
theme="vs-dark"
|
||||
@@ -94,6 +103,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecJobUpdateRequest } from '@/api/exec/exec-job';
|
||||
import type { ExecTemplateQueryResponse } from '@/api/exec/exec-template';
|
||||
import { onUnmounted, ref } from 'vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import useVisible from '@/hooks/visible';
|
||||
@@ -104,7 +114,7 @@
|
||||
import { useDictStore } from '@/store';
|
||||
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
||||
|
||||
const emits = defineEmits(['added', 'updated', 'openHost', 'testCron']);
|
||||
const emits = defineEmits(['added', 'updated', 'openHost', 'openTemplate', 'testCron']);
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { loading, setLoading } = useLoading();
|
||||
@@ -170,7 +180,13 @@
|
||||
formModel.value.hostIdList = hosts;
|
||||
};
|
||||
|
||||
defineExpose({ openAdd, openUpdate, setSelectedHost });
|
||||
// 通过模板设置
|
||||
const setWithTemplate = (template: ExecTemplateQueryResponse) => {
|
||||
formModel.value.command = template.command;
|
||||
formModel.value.timeout = template.timeout;
|
||||
};
|
||||
|
||||
defineExpose({ openAdd, openUpdate, setSelectedHost, setWithTemplate });
|
||||
|
||||
// 打开选择主机
|
||||
const openSelectHost = () => {
|
||||
@@ -249,6 +265,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
.command-item {
|
||||
:deep(.arco-form-item-extra) {
|
||||
margin-top: -18px;
|
||||
width: 100%;
|
||||
text-align: end;
|
||||
}
|
||||
}
|
||||
|
||||
.command-editor {
|
||||
width: 100%;
|
||||
height: calc(100vh - 264px);
|
||||
|
||||
@@ -11,11 +11,15 @@
|
||||
@added="modalAddCallback"
|
||||
@updated="modalUpdateCallback"
|
||||
@open-host="(e) => hostModal.open(e)"
|
||||
@open-template="() => templateModal.open()"
|
||||
@test-cron="openNextCron" />
|
||||
<!-- 详情模态框 -->
|
||||
<!-- 任务详情模态框 -->
|
||||
<exec-job-detail-drawer ref="detail" />
|
||||
<!-- cron 执行时间模态框 -->
|
||||
<next-cron-modal ref="nextCron" />
|
||||
<!-- 执行模板模态框 -->
|
||||
<exec-template-modal ref="templateModal"
|
||||
@selected="(e) => drawer.setWithTemplate(e)" />
|
||||
<!-- 主机模态框 -->
|
||||
<authorized-host-modal ref="hostModal"
|
||||
@selected="(e) => drawer.setSelectedHost(e)" />
|
||||
@@ -37,12 +41,14 @@
|
||||
import ExecJobDetailDrawer from './components/exec-job-detail-drawer.vue';
|
||||
import AuthorizedHostModal from '@/components/asset/host/authorized-host-modal/index.vue';
|
||||
import NextCronModal from '@/components/meta/expression/next-cron-modal/index.vue';
|
||||
import ExecTemplateModal from '@/components/exec/template/modal/index.vue';
|
||||
|
||||
const render = ref(false);
|
||||
const table = ref();
|
||||
const drawer = ref();
|
||||
const detail = ref();
|
||||
const nextCron = ref();
|
||||
const templateModal = ref();
|
||||
const hostModal = ref();
|
||||
|
||||
// 添加回调
|
||||
|
||||
Reference in New Issue
Block a user