Skip to content

Commit

Permalink
feat: 支持批量删除
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Dec 2, 2023
1 parent a628151 commit 546d4a2
Showing 1 changed file with 31 additions and 33 deletions.
64 changes: 31 additions & 33 deletions src/apps/machine/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ export default class MachineList extends Vue {
// 删除主机
async deleteMachine(idx: number) {
const item = this.machineList[idx]
await NaApi.machine.remove(item.Id)
this.machineList.splice(idx, 1)
async deleteMachine() {
for (let item of this.selectedRow) {
const idx = this.machineList.findIndex(m => m.Id === item.Id)
idx >= 0 && this.machineList.splice(idx, 1)
await NaApi.machine.remove(item.Id)
}
}
// 节点列表
Expand All @@ -71,7 +73,7 @@ export default class MachineList extends Vue {
public tableRowChange(ids: (string | number)[]) {
this.selectedRow = []
for (let id of ids) {
const m = this.machineList.find(item => item.Id === id)
const m = this.machineList.find(v => v.Id === id)
m && this.selectedRow.push(m)
}
}
Expand All @@ -86,7 +88,7 @@ export default class MachineList extends Vue {
{ colKey: 'Model', title: '云账号', ellipsis: true },
{ colKey: 'WorkerId', title: '土豆片', ellipsis: true },
{ colKey: 'Description', title: '备注', ellipsis: true },
{ colKey: 'Operation', title: '操作', width: "220px" }
{ colKey: 'Operation', title: '操作', width: "160px" }
]
}
Expand All @@ -108,12 +110,22 @@ export default class MachineList extends Vue {
记录总数: {{ machineList.length }}
</template>
<template #actions>
<t-button theme="danger" :disabled="selectedRow.length == 0" @click="quickModal.open(selectedRow)">
<template #icon>
<t-icon name="caret-right-small" />
</template>
运行
</t-button>
<t-space>
<t-button theme="warning" :disabled="selectedRow.length == 0" @click="quickModal.open(selectedRow)">
<template #icon>
<t-icon name="caret-right-small" />
</template>
运行
</t-button>
<t-popconfirm content="确定删除?" @confirm="deleteMachine()">
<t-button theme="danger" :disabled="selectedRow.length == 0">
<template #icon>
<t-icon name="delete" />
</template>
删除
</t-button>
</t-popconfirm>
</t-space>
</template>
<t-table :data="machineList" :columns="tableColumns" row-key="Id" hover @select-change="tableRowChange">
<template #Model="{ row }">
Expand All @@ -128,37 +140,23 @@ export default class MachineList extends Vue {
<t-link v-else-if="row.WorkerMeta" theme="danger" hover="color">
未连接
</t-link>
<t-link v-else theme="warning" hover="color">
<t-link v-else theme="warning" hover="color" @click="installModal.open(row)">
未注册
</t-link>
</template>
<template #Operation="{ row, rowIndex }">
<template #Operation="{ row }">
<t-link v-route="'/machine/detail/' + row.Id" theme="primary" hover="color">
管理
</t-link>
<t-link v-if="!workerList[row.WorkerId]" hover="color" disabled>
文件
</t-link>
<t-link v-else v-route="'/machine/fileman/' + row.Id" theme="primary" hover="color">
文件
</t-link>
<t-link theme="success" hover="color" @click="updateModal.open(row)">
<t-link theme="danger" hover="color" @click="updateModal.open(row)">
编辑
</t-link>
<t-link v-if="workerList[row.WorkerId]" theme="warning" hover="color" @click="quickModal.open([row])">
运行
</t-link>
<t-link v-else-if="row.WorkerMeta" theme="danger" hover="color" disabled>
运行
<t-link v-if="!workerList[row.WorkerId]" theme="success" hover="color" disabled>
文件
</t-link>
<t-link v-else hover="color" @click="installModal.open(row)">
注册
<t-link v-else v-route="'/machine/fileman/' + row.Id" theme="success" hover="color">
文件
</t-link>
<t-popconfirm content="确定删除?" @confirm="deleteMachine(rowIndex)">
<t-link theme="danger" hover="color">
删除
</t-link>
</t-popconfirm>
</template>
</t-table>
</t-card>
Expand Down

0 comments on commit 546d4a2

Please sign in to comment.