|
|
@@ -23,6 +23,11 @@
|
|
|
</template>
|
|
|
</ElTableColumn>
|
|
|
<ElTableColumn prop="progress" label="进度" :formatter="progressFormatter" width="100" />
|
|
|
+ <ElTableColumn label="操作" align="center" width="100">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <ElButton @click="delTask(row)" type="danger">删除</ElButton>
|
|
|
+ </template>
|
|
|
+ </ElTableColumn>
|
|
|
</PagingTable>
|
|
|
</ElCard>
|
|
|
</template>
|
|
|
@@ -33,6 +38,8 @@ import { useTimeFormatter, useEnumFormatter } from '@/utils/formatter'
|
|
|
import { TaskType } from '@/enums'
|
|
|
import { useIntervalFn, useElementSize } from '@vueuse/core'
|
|
|
import { RotateClockwise } from '@vicons/tabler'
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+import { http } from '@/plugins/http'
|
|
|
|
|
|
const emit = defineEmits(['createTask'])
|
|
|
const timeFormatter = useTimeFormatter('yyyy-MM-dd HH:mm:ss')
|
|
|
@@ -57,4 +64,18 @@ const { width, height } = useElementSize(el)
|
|
|
const tableHeight = computed(() => {
|
|
|
return height.value - 105
|
|
|
})
|
|
|
+async function delTask(row) {
|
|
|
+ try {
|
|
|
+ await ElMessageBox.confirm('此操作将永久删除该任务, 是否继续?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ await http.delete(`/tasks/${row.id}`)
|
|
|
+ refresh()
|
|
|
+ } catch (error) {
|
|
|
+ if (error.message === 'cancel') return
|
|
|
+ ElMessage.error(error.message)
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|