🔨 命令执行用户.
This commit is contained in:
@@ -73,7 +73,7 @@
|
||||
type="text"
|
||||
size="mini"
|
||||
status="danger"
|
||||
:disabled="record.status !== execHostStatus.WAITING && record.status !== execHostStatus.RUNNING">
|
||||
:disabled="record.status !== ExecHostStatus.WAITING && record.status !== ExecHostStatus.RUNNING">
|
||||
中断
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
@@ -106,7 +106,7 @@
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/host-table.columns';
|
||||
import { execHostStatusKey, execHostStatus } from '@/components/exec/log/const';
|
||||
import { execHostStatusKey, ExecHostStatus } from '@/components/exec/log/const';
|
||||
import { useDictStore } from '@/store';
|
||||
import { useExpandable } from '@/hooks/table';
|
||||
import { dateFormat, formatDuration } from '@/utils';
|
||||
@@ -139,7 +139,7 @@
|
||||
hostLogId: record.id
|
||||
});
|
||||
Message.success('已中断');
|
||||
record.status = execHostStatus.INTERRUPTED;
|
||||
record.status = ExecHostStatus.INTERRUPTED;
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
@@ -177,7 +177,7 @@
|
||||
type="text"
|
||||
size="mini"
|
||||
status="danger"
|
||||
:disabled="record.status !== execStatus.WAITING && record.status !== execStatus.RUNNING">
|
||||
:disabled="record.status !== ExecStatus.WAITING && record.status !== ExecStatus.RUNNING">
|
||||
中断
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
@@ -219,7 +219,7 @@
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { execStatus, execStatusKey } from '@/components/exec/log/const';
|
||||
import { ExecStatus, execStatusKey } from '@/components/exec/log/const';
|
||||
import { useExpandable, useTablePagination, useRowSelection } from '@/hooks/table';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dateFormat, formatDuration } from '@/utils';
|
||||
@@ -312,7 +312,7 @@
|
||||
logId: record.id
|
||||
});
|
||||
Message.success('已中断');
|
||||
record.status = execStatus.COMPLETED;
|
||||
record.status = ExecStatus.COMPLETED;
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -345,7 +345,7 @@
|
||||
// 加载状态
|
||||
const pullExecStatus = async () => {
|
||||
const unCompleteIdList = tableRenderData.value
|
||||
.filter(s => s.status === execStatus.WAITING || s.status === execStatus.RUNNING)
|
||||
.filter(s => s.status === ExecStatus.WAITING || s.status === ExecStatus.RUNNING)
|
||||
.map(s => s.id);
|
||||
if (!unCompleteIdList.length) {
|
||||
return;
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
type="text"
|
||||
size="mini"
|
||||
status="danger"
|
||||
:disabled="record.status !== execHostStatus.WAITING && record.status !== execHostStatus.RUNNING">
|
||||
:disabled="record.status !== ExecHostStatus.WAITING && record.status !== ExecHostStatus.RUNNING">
|
||||
中断
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
@@ -103,7 +103,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ExecLogQueryResponse, ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
||||
import { deleteExecJobHostLog, interruptHostExecJob } from '@/api/exec/exec-job-log';
|
||||
import { execHostStatusKey, execHostStatus } from '@/components/exec/log/const';
|
||||
import { execHostStatusKey, ExecHostStatus } from '@/components/exec/log/const';
|
||||
import { useDictStore } from '@/store';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '@/views/exec/exec-command-log/types/host-table.columns';
|
||||
@@ -139,7 +139,7 @@
|
||||
hostLogId: record.id
|
||||
});
|
||||
Message.success('已中断');
|
||||
record.status = execHostStatus.INTERRUPTED;
|
||||
record.status = ExecHostStatus.INTERRUPTED;
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
@@ -118,6 +118,28 @@
|
||||
{{ record.command }}
|
||||
</span>
|
||||
</template>
|
||||
<!-- 执行用户 -->
|
||||
<template #username="{ record }">
|
||||
<div class="flex-center">
|
||||
<!-- 执行用户 -->
|
||||
<span :title="record.username">
|
||||
{{ record.username }}
|
||||
</span>
|
||||
<!-- 手动触发 -->
|
||||
<a-tooltip v-if="ExecMode.MANUAL === record.execMode"
|
||||
position="top"
|
||||
content="手动触发"
|
||||
mini>
|
||||
<a-tag class="ml8"
|
||||
style="width: 28px"
|
||||
color="pinkpurple">
|
||||
<template #icon>
|
||||
<icon-user />
|
||||
</template>
|
||||
</a-tag>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 执行状态 -->
|
||||
<template #status="{ record }">
|
||||
<a-tag :color="getDictValue(execStatusKey, record.status, 'color')">
|
||||
@@ -160,7 +182,7 @@
|
||||
type="text"
|
||||
size="mini"
|
||||
status="danger"
|
||||
:disabled="record.status !== execStatus.WAITING && record.status !== execStatus.RUNNING">
|
||||
:disabled="record.status !== ExecStatus.WAITING && record.status !== ExecStatus.RUNNING">
|
||||
中断
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
@@ -202,7 +224,7 @@
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { execStatus, execStatusKey } from '@/components/exec/log/const';
|
||||
import { ExecStatus, execStatusKey, ExecMode } from '@/components/exec/log/const';
|
||||
import { useExpandable, useTablePagination, useRowSelection } from '@/hooks/table';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dateFormat, formatDuration } from '@/utils';
|
||||
@@ -267,7 +289,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 中断执行
|
||||
const doInterruptExecJob = async (record: ExecLogQueryResponse) => {
|
||||
try {
|
||||
@@ -277,7 +298,7 @@
|
||||
logId: record.id
|
||||
});
|
||||
Message.success('已中断');
|
||||
record.status = execStatus.COMPLETED;
|
||||
record.status = ExecStatus.COMPLETED;
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -310,7 +331,7 @@
|
||||
// 加载状态
|
||||
const pullJobStatus = async () => {
|
||||
const unCompleteIdList = tableRenderData.value
|
||||
.filter(s => s.status === execStatus.WAITING || s.status === execStatus.RUNNING)
|
||||
.filter(s => s.status === ExecStatus.WAITING || s.status === ExecStatus.RUNNING)
|
||||
.map(s => s.id);
|
||||
if (!unCompleteIdList.length) {
|
||||
return;
|
||||
|
||||
@@ -22,6 +22,13 @@ const columns = [
|
||||
align: 'left',
|
||||
minWidth: 238,
|
||||
ellipsis: true,
|
||||
}, {
|
||||
title: '执行用户',
|
||||
dataIndex: 'username',
|
||||
slotName: 'username',
|
||||
align: 'left',
|
||||
width: 128,
|
||||
ellipsis: true,
|
||||
}, {
|
||||
title: '执行状态',
|
||||
dataIndex: 'status',
|
||||
|
||||
@@ -146,13 +146,6 @@
|
||||
@click="emits('openDetail', record.id)">
|
||||
详情
|
||||
</a-button>
|
||||
<!-- 修改 -->
|
||||
<a-button v-permission="['asset:exec-job:update']"
|
||||
type="text"
|
||||
size="mini"
|
||||
@click="emits('openUpdate', record.id)">
|
||||
修改
|
||||
</a-button>
|
||||
<!-- 手动触发 -->
|
||||
<a-popconfirm content="确认要手动触发吗?"
|
||||
position="left"
|
||||
@@ -176,6 +169,24 @@
|
||||
删除
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
<!-- 更多 -->
|
||||
<a-dropdown trigger="hover" :popup-max-height="false">
|
||||
<a-button type="text" size="mini">
|
||||
更多
|
||||
</a-button>
|
||||
<template #content>
|
||||
<!-- 修改任务 -->
|
||||
<a-doption v-permission="['asset:exec-job:update']"
|
||||
@click="emits('openUpdate', record.id)">
|
||||
<span class="more-doption normal">修改任务</span>
|
||||
</a-doption>
|
||||
<!-- 修改执行用户 -->
|
||||
<a-doption v-permission="['asset:exec-job:update-exec-user']"
|
||||
@click="emits('updateExecUser', record)">
|
||||
<span class="more-doption normal">修改执行用户</span>
|
||||
</a-doption>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</a-table>
|
||||
@@ -202,7 +213,7 @@
|
||||
import { copy } from '@/hooks/copy';
|
||||
import { dateFormat } from '@/utils';
|
||||
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openDetail', 'testCron']);
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openDetail', 'updateExecUser', 'testCron']);
|
||||
|
||||
const pagination = useTablePagination();
|
||||
const rowSelection = useRowSelection();
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<a-modal v-model:visible="visible"
|
||||
modal-class="modal-form-large"
|
||||
title-align="start"
|
||||
title="修改执行用户"
|
||||
:align-center="false"
|
||||
:draggable="true"
|
||||
:mask-closable="false"
|
||||
:unmount-on-close="true"
|
||||
:ok-button-props="{ disabled: loading }"
|
||||
:cancel-button-props="{ disabled: loading }"
|
||||
:on-before-ok="handlerOk"
|
||||
@close="handleClose">
|
||||
<a-spin class="full" :loading="loading">
|
||||
<a-form :model="formModel"
|
||||
label-align="right"
|
||||
:auto-label-width="true">
|
||||
<!-- 执行用户 -->
|
||||
<a-form-item field="userId" label="执行用户">
|
||||
<user-selector v-model="formModel.userId"
|
||||
placeholder="请选择执行用户"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'execUserUpdateModal'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecJobUpdateExecUserRequest, ExecJobQueryResponse } from '@/api/exec/exec-job';
|
||||
import { ref } from 'vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { updateExecJobExecUser } from '@/api/exec/exec-job';
|
||||
import UserSelector from '@/components/user/user/selector/index.vue';
|
||||
|
||||
const { toOptions } = useDictStore();
|
||||
const { loadUsers } = useCacheStore();
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { loading, setLoading } = useLoading();
|
||||
|
||||
const formModel = ref<ExecJobUpdateExecUserRequest>({});
|
||||
const job = ref<ExecJobQueryResponse>();
|
||||
|
||||
// 打开
|
||||
const open = (record: ExecJobQueryResponse) => {
|
||||
formModel.value = { id: record.id, userId: record.execUserId };
|
||||
job.value = record;
|
||||
setVisible(true);
|
||||
};
|
||||
|
||||
defineExpose({ open });
|
||||
|
||||
// 确定
|
||||
const handlerOk = async () => {
|
||||
const execUserId = formModel.value.userId;
|
||||
if (!execUserId) {
|
||||
Message.error('请选择执行用户');
|
||||
return false;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
// 更新
|
||||
await updateExecJobExecUser(formModel.value);
|
||||
if (job.value) {
|
||||
job.value.execUserId = execUserId;
|
||||
job.value.execUsername = (await loadUsers()).find(s => s.id === execUserId)?.username || '';
|
||||
}
|
||||
Message.success('修改成功');
|
||||
// 清空
|
||||
handlerClear();
|
||||
} catch (e) {
|
||||
return false;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 关闭
|
||||
const handleClose = () => {
|
||||
handlerClear();
|
||||
};
|
||||
|
||||
// 清空
|
||||
const handlerClear = () => {
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
</style>
|
||||
@@ -5,6 +5,7 @@
|
||||
@open-add="() => drawer.openAdd()"
|
||||
@open-update="(e) => drawer.openUpdate(e)"
|
||||
@open-detail="(e) => detail.open(e)"
|
||||
@update-exec-user="(e) => execUserModal.open(e)"
|
||||
@test-cron="openNextCron" />
|
||||
<!-- 添加修改模态框 -->
|
||||
<exec-job-form-drawer ref="drawer"
|
||||
@@ -16,6 +17,8 @@
|
||||
@gen-cron="(e) => genModal.open(e)" />
|
||||
<!-- 任务详情模态框 -->
|
||||
<exec-job-detail-drawer ref="detail" />
|
||||
<!-- 修改执行用户模态框 -->
|
||||
<exec-user-update-modal ref="execUserModal" />
|
||||
<!-- cron 执行时间模态框 -->
|
||||
<cron-next-modal ref="nextCron" />
|
||||
<!-- cron 生成模态框 -->
|
||||
@@ -43,6 +46,7 @@
|
||||
import { CronNextTimes, dictKeys } from './types/const';
|
||||
import ExecJobTable from './components/exec-job-table.vue';
|
||||
import ExecJobFormDrawer from './components/exec-job-form-drawer.vue';
|
||||
import ExecUserUpdateModal from './components/exec-user-update-modal.vue';
|
||||
import ExecJobDetailDrawer from './components/exec-job-detail-drawer.vue';
|
||||
import AuthorizedHostModal from '@/components/asset/host/authorized-host-modal/index.vue';
|
||||
import ExecTemplateModal from '@/components/exec/template/modal/index.vue';
|
||||
@@ -53,6 +57,7 @@
|
||||
const table = ref();
|
||||
const drawer = ref();
|
||||
const detail = ref();
|
||||
const execUserModal = ref();
|
||||
const nextCron = ref();
|
||||
const genModal = ref();
|
||||
const templateModal = ref();
|
||||
|
||||
@@ -32,6 +32,14 @@ const columns = [
|
||||
minWidth: 238,
|
||||
ellipsis: true,
|
||||
tooltip: true,
|
||||
}, {
|
||||
title: '执行用户',
|
||||
dataIndex: 'execUsername',
|
||||
slotName: 'execUsername',
|
||||
align: 'left',
|
||||
ellipsis: true,
|
||||
tooltip: true,
|
||||
width: 124,
|
||||
}, {
|
||||
title: '任务状态',
|
||||
dataIndex: 'status',
|
||||
|
||||
Reference in New Issue
Block a user