refactor: delete task

master
xiaojunnuo 2021-02-05 18:20:33 +08:00
parent 560519894c
commit b9d5d33aaa
2 changed files with 21 additions and 3 deletions

View File

@ -1,6 +1,5 @@
<template> <template>
<a-drawer <a-drawer
title="编辑任务"
placement="right" placement="right"
:closable="true" :closable="true"
width="600px" width="600px"
@ -8,6 +7,12 @@
:after-visible-change="taskDrawerOnAfterVisibleChange" :after-visible-change="taskDrawerOnAfterVisibleChange"
> >
<template #title>
编辑任务
<a-button @click="taskDelete()">
<template #icon><DeleteOutlined /></template>
</a-button>
</template>
<template v-if="currentTask"> <template v-if="currentTask">
<d-container v-if="currentTask._isAdd" class="task-edit-form"> <d-container v-if="currentTask._isAdd" class="task-edit-form">
<a-row :gutter="10"> <a-row :gutter="10">
@ -169,6 +174,13 @@ function useTaskForm (context) {
taskDrawerClose() taskDrawerClose()
} }
const taskDelete = () => {
if (currentTaskIndex.value != null) {
currentDeploy.value.tasks.splice(currentTaskIndex.value)
}
taskDrawerClose()
}
return { return {
taskTypeSelected, taskTypeSelected,
taskTypeSave, taskTypeSave,
@ -183,6 +195,7 @@ function useTaskForm (context) {
currentTaskIndex, currentTaskIndex,
currentPlugin, currentPlugin,
taskSave, taskSave,
taskDelete,
rules rules
} }
} }

View File

@ -126,7 +126,7 @@
</template> </template>
<template #extra> <template #extra>
<a-button type="danger"> <a-button type="danger" @click="deployDelete(deploy,index)">
<template #icon><DeleteOutlined /></template> <template #icon><DeleteOutlined /></template>
</a-button> </a-button>
</template> </template>
@ -203,8 +203,13 @@ function useDeploy (options) {
const deployOpenEditMode = (deploy) => { const deployOpenEditMode = (deploy) => {
deploy._isEdit = true deploy._isEdit = true
} }
const deployDelete = (deploy, index) => {
options.deploy.splice(index, 1)
}
return { return {
deployAdd, deployCloseEditMode, deployOpenEditMode deployAdd, deployCloseEditMode, deployOpenEditMode, deployDelete
} }
} }