feat(1.3.0-beta1): 定时任务添加复制按钮, 使用[更多]对操作按钮进行折叠
This commit is contained in:
parent
4a53dd8773
commit
9a3166f150
@ -245,6 +245,15 @@ export function useTableOperate<T extends TableData = TableData>(data: Ref<T[]>,
|
|||||||
openDrawer();
|
openDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleCopy(id: T['id']) {
|
||||||
|
operateType.value = 'add';
|
||||||
|
const findItem = data.value.find(item => item.id === id) || null;
|
||||||
|
editingData.value = jsonClone(findItem);
|
||||||
|
delete editingData.value?.id;
|
||||||
|
|
||||||
|
openDrawer();
|
||||||
|
}
|
||||||
|
|
||||||
/** the checked row keys of table */
|
/** the checked row keys of table */
|
||||||
const checkedRowKeys = ref<string[]>([]);
|
const checkedRowKeys = ref<string[]>([]);
|
||||||
|
|
||||||
@ -272,6 +281,7 @@ export function useTableOperate<T extends TableData = TableData>(data: Ref<T[]>,
|
|||||||
handleAdd,
|
handleAdd,
|
||||||
editingData,
|
editingData,
|
||||||
handleEdit,
|
handleEdit,
|
||||||
|
handleCopy,
|
||||||
checkedRowKeys,
|
checkedRowKeys,
|
||||||
onBatchDeleted,
|
onBatchDeleted,
|
||||||
onDeleted
|
onDeleted
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
import { NButton, NPopconfirm, NTag } from 'naive-ui';
|
import { NButton, NDropdown, NPopconfirm, NTag } from 'naive-ui';
|
||||||
import { useBoolean } from '@sa/hooks';
|
import { useBoolean } from '@sa/hooks';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { fetchBatchDeleteJob, fetchGetJobPage, fetchTriggerJob, fetchUpdateJobStatus } from '@/service/api';
|
import { fetchBatchDeleteJob, fetchGetJobPage, fetchTriggerJob, fetchUpdateJobStatus } from '@/service/api';
|
||||||
@ -177,41 +177,86 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
|
|||||||
key: 'operate',
|
key: 'operate',
|
||||||
title: $t('common.operate'),
|
title: $t('common.operate'),
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 180,
|
width: 120,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
render: row => (
|
render: row => {
|
||||||
<div class="flex-center gap-8px">
|
const options = [
|
||||||
<NPopconfirm onPositiveClick={() => handleTriggerJob(row.id!)}>
|
{
|
||||||
{{
|
label: $t('common.copy'),
|
||||||
default: () => $t('common.confirmExecute'),
|
key: 'copy',
|
||||||
trigger: () => (
|
click: () => copy(row.id!)
|
||||||
<NButton type="error" text ghost size="small">
|
},
|
||||||
{$t('common.execute')}
|
{
|
||||||
</NButton>
|
type: 'divider',
|
||||||
)
|
key: 'd2'
|
||||||
}}
|
},
|
||||||
</NPopconfirm>
|
{
|
||||||
<n-divider vertical />
|
label: $t('common.batchList'),
|
||||||
<NButton type="primary" ghost text size="small" onClick={() => goToBatch(row.id!)}>
|
key: 'batchList',
|
||||||
{$t('common.batchList')}
|
click: () => goToBatch(row.id!)
|
||||||
</NButton>
|
},
|
||||||
<n-divider vertical />
|
{
|
||||||
<NButton type="warning" ghost text size="small" onClick={() => edit(row.id!)}>
|
type: 'divider',
|
||||||
{$t('common.edit')}
|
key: 'd2'
|
||||||
</NButton>
|
},
|
||||||
<n-divider vertical />
|
{
|
||||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
type: 'render',
|
||||||
{{
|
key: 'delete',
|
||||||
default: () => $t('common.confirmDelete'),
|
render: () => (
|
||||||
trigger: () => (
|
<div class="flex-center">
|
||||||
<NButton type="error" text ghost size="small">
|
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||||
{$t('common.delete')}
|
{{
|
||||||
</NButton>
|
default: () => $t('common.confirmDelete'),
|
||||||
)
|
trigger: () => (
|
||||||
}}
|
<NButton quaternary size="small">
|
||||||
</NPopconfirm>
|
{$t('common.delete')}
|
||||||
</div>
|
</NButton>
|
||||||
)
|
)
|
||||||
|
}}
|
||||||
|
</NPopconfirm>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const onSelect = (key: string) => {
|
||||||
|
const fun = options.filter(o => o.key === key)[0].click;
|
||||||
|
if (fun) fun();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class="flex-center gap-8px">
|
||||||
|
<NButton text type="warning" ghost size="small" onClick={() => edit(row.id!)}>
|
||||||
|
{$t('common.edit')}
|
||||||
|
</NButton>
|
||||||
|
|
||||||
|
<n-divider vertical />
|
||||||
|
|
||||||
|
<NPopconfirm onPositiveClick={() => handleTriggerJob(row.id!)}>
|
||||||
|
{{
|
||||||
|
default: () => $t('common.confirmExecute'),
|
||||||
|
trigger: () => (
|
||||||
|
<NButton type="error" text ghost size="small">
|
||||||
|
{$t('common.execute')}
|
||||||
|
</NButton>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</NPopconfirm>
|
||||||
|
|
||||||
|
<n-divider vertical />
|
||||||
|
|
||||||
|
<NDropdown trigger="click" show-arrow={false} options={options} size="small" on-select={onSelect}>
|
||||||
|
{{
|
||||||
|
default: () => (
|
||||||
|
<NButton text type="primary" ghost size="small">
|
||||||
|
更多
|
||||||
|
</NButton>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</NDropdown>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@ -222,6 +267,7 @@ const {
|
|||||||
editingData,
|
editingData,
|
||||||
handleAdd,
|
handleAdd,
|
||||||
handleEdit,
|
handleEdit,
|
||||||
|
handleCopy,
|
||||||
checkedRowKeys,
|
checkedRowKeys,
|
||||||
onDeleted,
|
onDeleted,
|
||||||
onBatchDeleted
|
onBatchDeleted
|
||||||
@ -244,6 +290,10 @@ function edit(id: string) {
|
|||||||
handleEdit(id);
|
handleEdit(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copy(id: string) {
|
||||||
|
handleCopy(id);
|
||||||
|
}
|
||||||
|
|
||||||
async function handleTriggerJob(id: string) {
|
async function handleTriggerJob(id: string) {
|
||||||
const { error } = await fetchTriggerJob(id);
|
const { error } = await fetchTriggerJob(id);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -202,7 +202,7 @@ function createDefaultScriptParams() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleUpdateModelWhenEdit() {
|
function handleUpdateModelWhenEdit() {
|
||||||
if (props.operateType === 'add') {
|
if (props.operateType === 'add' && !props.rowData) {
|
||||||
Object.assign(model, createDefaultModel());
|
Object.assign(model, createDefaultModel());
|
||||||
executorCustomType.value = 0;
|
executorCustomType.value = 0;
|
||||||
httpHeaders.value = [];
|
httpHeaders.value = [];
|
||||||
@ -211,7 +211,7 @@ function handleUpdateModelWhenEdit() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.operateType === 'edit' && props.rowData) {
|
if (props.rowData) {
|
||||||
Object.assign(model, props.rowData);
|
Object.assign(model, props.rowData);
|
||||||
if (model.taskType === 3 && model.argsStr) {
|
if (model.taskType === 3 && model.argsStr) {
|
||||||
Object.assign(dynamicForm, {
|
Object.assign(dynamicForm, {
|
||||||
|
Loading…
Reference in New Issue
Block a user