mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
feat: 机器脚本入参支持选择框
This commit is contained in:
@@ -107,11 +107,11 @@ const themeConfigModule: Module<ThemeConfigState, RootStateTypes> = {
|
|||||||
layout: 'classic',
|
layout: 'classic',
|
||||||
|
|
||||||
// ssh终端字体颜色
|
// ssh终端字体颜色
|
||||||
terminalForeground: '#c5c8c6',
|
terminalForeground: '#7e9192',
|
||||||
// ssh终端背景色
|
// ssh终端背景色
|
||||||
terminalBackground: '#121212',
|
terminalBackground: '#002833',
|
||||||
// ssh终端cursor色
|
// ssh终端cursor色
|
||||||
terminalCursor: '#f0cc09',
|
terminalCursor: '#268F81',
|
||||||
terminalFontSize: 15,
|
terminalFontSize: 15,
|
||||||
terminalFontWeight: 'normal',
|
terminalFontWeight: 'normal',
|
||||||
|
|
||||||
|
|||||||
@@ -68,11 +68,6 @@
|
|||||||
<el-table-column prop="username" label="用户名" min-width="90"></el-table-column>
|
<el-table-column prop="username" label="用户名" min-width="90"></el-table-column>
|
||||||
<el-table-column prop="projectName" label="项目" min-width="120"></el-table-column>
|
<el-table-column prop="projectName" label="项目" min-width="120"></el-table-column>
|
||||||
<el-table-column prop="remark" label="备注" min-width="250" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="remark" label="备注" min-width="250" show-overflow-tooltip></el-table-column>
|
||||||
<el-table-column prop="ip" label="hasCli" width="70">
|
|
||||||
<template #default="scope">
|
|
||||||
{{ `${scope.row.hasCli ? '是' : '否'}` }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="createTime" label="创建时间" min-width="165">
|
<el-table-column prop="createTime" label="创建时间" min-width="165">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
{{ $filters.dateFormat(scope.row.createTime) }}
|
{{ $filters.dateFormat(scope.row.createTime) }}
|
||||||
@@ -255,6 +250,11 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const closeCli = async (row: any) => {
|
const closeCli = async (row: any) => {
|
||||||
|
await ElMessageBox.confirm(`确定关闭该机器客户端连接?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
});
|
||||||
await machineApi.closeCli.request({ id: row.id });
|
await machineApi.closeCli.request({ id: row.id });
|
||||||
ElMessage.success('关闭成功');
|
ElMessage.success('关闭成功');
|
||||||
search();
|
search();
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
:before-close="cancel"
|
:before-close="cancel"
|
||||||
:show-close="true"
|
:show-close="true"
|
||||||
:destroy-on-close="true"
|
:destroy-on-close="true"
|
||||||
width="800px"
|
width="900px"
|
||||||
>
|
>
|
||||||
<el-form :model="form" ref="scriptForm" label-width="70px">
|
<el-form :model="form" ref="scriptForm" label-width="70px" size="small">
|
||||||
<el-form-item prop="method" label="名称">
|
<el-form-item prop="method" label="名称">
|
||||||
<el-input v-model.trim="form.name" placeholder="请输入名称"></el-input>
|
<el-input v-model.trim="form.name" placeholder="请输入名称"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -29,13 +29,17 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<el-form-item :key="param" v-for="(param, index) in params" prop="params" :label="`参数${index + 1}`">
|
<el-form-item :key="param" v-for="(param, index) in params" prop="params" :label="`参数${index + 1}`">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="6"><el-input v-model="param.model" placeholder="内容中用{{.model}}替换"></el-input></el-col>
|
<el-col :span="5"><el-input v-model="param.model" placeholder="内容中用{{.model}}替换"></el-input></el-col>
|
||||||
<el-divider :span="1" direction="vertical" border-style="dashed" />
|
<el-divider :span="1" direction="vertical" border-style="dashed" />
|
||||||
<el-col :span="6"><el-input v-model="param.name" placeholder="字段名"></el-input></el-col>
|
<el-col :span="4"><el-input v-model="param.name" placeholder="字段名"></el-input></el-col>
|
||||||
<el-divider :span="1" direction="vertical" border-style="dashed" />
|
<el-divider :span="1" direction="vertical" border-style="dashed" />
|
||||||
<el-col :span="6"><el-input v-model="param.placeholder" placeholder="字段说明"></el-input></el-col>
|
<el-col :span="4"><el-input v-model="param.placeholder" placeholder="字段说明"></el-input></el-col>
|
||||||
<el-divider :span="1" direction="vertical" border-style="dashed" />
|
<el-divider :span="1" direction="vertical" border-style="dashed" />
|
||||||
<el-col :span="3"><el-button @click="onDeleteParam(index)" size="small" type="danger">删除</el-button></el-col>
|
<el-col :span="4">
|
||||||
|
<el-input v-model="param.options" placeholder="可选值 ,分割"></el-input>
|
||||||
|
</el-col>
|
||||||
|
<el-divider :span="1" direction="vertical" border-style="dashed" />
|
||||||
|
<el-col :span="2"><el-button @click="onDeleteParam(index)" size="small" type="danger">删除</el-button></el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
@@ -46,13 +50,12 @@
|
|||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<el-button @click="cancel()" :disabled="submitDisabled" size="small">关 闭</el-button>
|
<el-button @click="cancel()" :disabled="submitDisabled">关 闭</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
v-auth="'machine:script:save'"
|
v-auth="'machine:script:save'"
|
||||||
type="primary"
|
type="primary"
|
||||||
:loading="btnLoading"
|
:loading="btnLoading"
|
||||||
@click="btnOk"
|
@click="btnOk"
|
||||||
size="small"
|
|
||||||
:disabled="submitDisabled"
|
:disabled="submitDisabled"
|
||||||
>保 存</el-button
|
>保 存</el-button
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -76,7 +76,24 @@
|
|||||||
<el-dialog title="脚本参数" v-model="scriptParamsDialog.visible" width="400px">
|
<el-dialog title="脚本参数" v-model="scriptParamsDialog.visible" width="400px">
|
||||||
<el-form ref="paramsForm" :model="scriptParamsDialog.params" label-width="70px" size="small">
|
<el-form ref="paramsForm" :model="scriptParamsDialog.params" label-width="70px" size="small">
|
||||||
<el-form-item v-for="item in scriptParamsDialog.paramsFormItem" :key="item.name" :prop="item.model" :label="item.name" required>
|
<el-form-item v-for="item in scriptParamsDialog.paramsFormItem" :key="item.name" :prop="item.model" :label="item.name" required>
|
||||||
<el-input v-model="scriptParamsDialog.params[item.model]" :placeholder="item.placeholder" autocomplete="off"></el-input>
|
<el-input
|
||||||
|
v-if="!item.options"
|
||||||
|
v-model="scriptParamsDialog.params[item.model]"
|
||||||
|
:placeholder="item.placeholder"
|
||||||
|
autocomplete="off"
|
||||||
|
clearable
|
||||||
|
></el-input>
|
||||||
|
<el-select
|
||||||
|
v-else
|
||||||
|
v-model="scriptParamsDialog.params[item.model]"
|
||||||
|
:placeholder="item.placeholder"
|
||||||
|
filterable
|
||||||
|
autocomplete="off"
|
||||||
|
clearable
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<el-option v-for="option in item.options.split(',')" :key="option" :label="option" :value="option" />
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -88,7 +105,6 @@
|
|||||||
|
|
||||||
<el-dialog title="执行结果" v-model="resultDialog.visible" width="50%">
|
<el-dialog title="执行结果" v-model="resultDialog.visible" width="50%">
|
||||||
<div style="white-space: pre-line; padding: 10px; color: #000000">
|
<div style="white-space: pre-line; padding: 10px; color: #000000">
|
||||||
<!-- {{ resultDialog.result }} -->
|
|
||||||
<el-input v-model="resultDialog.result" :rows="20" type="textarea" />
|
<el-input v-model="resultDialog.result" :rows="20" type="textarea" />
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@@ -196,7 +212,6 @@ export default defineComponent({
|
|||||||
// 如果存在参数,则弹窗输入参数后执行
|
// 如果存在参数,则弹窗输入参数后执行
|
||||||
if (script.params) {
|
if (script.params) {
|
||||||
state.scriptParamsDialog.paramsFormItem = JSON.parse(script.params);
|
state.scriptParamsDialog.paramsFormItem = JSON.parse(script.params);
|
||||||
console.log(state.scriptParamsDialog.paramsFormItem);
|
|
||||||
if (state.scriptParamsDialog.paramsFormItem && state.scriptParamsDialog.paramsFormItem.length > 0) {
|
if (state.scriptParamsDialog.paramsFormItem && state.scriptParamsDialog.paramsFormItem.length > 0) {
|
||||||
state.scriptParamsDialog.visible = true;
|
state.scriptParamsDialog.visible = true;
|
||||||
return;
|
return;
|
||||||
@@ -271,8 +286,6 @@ export default defineComponent({
|
|||||||
const closeTermnial = () => {
|
const closeTermnial = () => {
|
||||||
state.terminalDialog.visible = false;
|
state.terminalDialog.visible = false;
|
||||||
state.terminalDialog.machineId = 0;
|
state.terminalDialog.machineId = 0;
|
||||||
// const t: any = this.$refs['terminal']
|
|
||||||
// t.closeAll()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -298,8 +311,6 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submitSuccess = () => {
|
const submitSuccess = () => {
|
||||||
// this.delChoose()
|
|
||||||
// this.search()
|
|
||||||
getScripts();
|
getScripts();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -329,6 +340,7 @@ export default defineComponent({
|
|||||||
context.emit('update:machineId', null);
|
context.emit('update:machineId', null);
|
||||||
context.emit('cancel');
|
context.emit('cancel');
|
||||||
state.scriptTable = [];
|
state.scriptTable = [];
|
||||||
|
state.scriptParamsDialog.paramsFormItem = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -65,11 +65,10 @@ export default defineComponent({
|
|||||||
fontFamily: 'JetBrainsMono, monaco, Consolas, Lucida Console, monospace',
|
fontFamily: 'JetBrainsMono, monaco, Consolas, Lucida Console, monospace',
|
||||||
cursorBlink: true,
|
cursorBlink: true,
|
||||||
disableStdin: false,
|
disableStdin: false,
|
||||||
letterSpacing: -1,
|
|
||||||
theme: {
|
theme: {
|
||||||
foreground: getThemeConfig.value.terminalForeground || '#c5c8c6', //字体
|
foreground: getThemeConfig.value.terminalForeground || '#7e9192', //字体
|
||||||
background: getThemeConfig.value.terminalBackground || '#121212', //背景色
|
background: getThemeConfig.value.terminalBackground || '#002833', //背景色
|
||||||
cursor: getThemeConfig.value.terminalCursor || '#f0cc09', //设置光标
|
cursor: getThemeConfig.value.terminalCursor || '#268F81', //设置光标
|
||||||
} as any,
|
} as any,
|
||||||
});
|
});
|
||||||
const fitAddon = new FitAddon();
|
const fitAddon = new FitAddon();
|
||||||
|
|||||||
Reference in New Issue
Block a user