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