This commit is contained in:
X1627315083@163.com
2026-03-05 15:13:16 +08:00
parent 710bd0c30e
commit b8f840e05f
7 changed files with 54 additions and 32 deletions

View File

@@ -1,5 +1,7 @@
import { ref, computed } from "vue";
import { NODE_TYPE } from '../tools/index.d'
import { ElMessageBox } from 'element-plus'
import { useI18n } from 'vue-i18n'
export interface NodesItem {
id: string
@@ -32,6 +34,7 @@ export class StateManager {
flowManager: any
nodeManager: any
toolManager: any
t: any
// 设置管理器
setManager(options) {
options.eventManager && (this.eventManager = options.eventManager)
@@ -91,6 +94,8 @@ export class StateManager {
return arr
})
this.t = useI18n().t
}
/** 设置激活节点 */
setActiveNodeID(id: string) { this.activeNodeID.value = id }
@@ -100,7 +105,25 @@ export class StateManager {
this.recordState()
}
/** 删除节点 */
deleteNode(id: string) {
async deleteNode(id: string,{ isElMessageBox } = { isElMessageBox: false }) {
let deletePromise:any = true
if (isElMessageBox){
deletePromise = await new Promise<void>((resolve, reject) => {
ElMessageBox.confirm(
this.t('flowCanvas.deleteCardConfirm'),
'',
{
confirmButtonText: this.t('flowCanvas.confirm'),
cancelButtonText: this.t('flowCanvas.cancel'),
}
).then(() => {
resolve(true)
}).catch(() => {
resolve(false)
})
})
}
if (!deletePromise) return console.log('删除操作被取消')
const node = this.getNodeById(id)
if (!node) return console.warn(`没有找到指定id:${id}`)
if (node.data.disableDelete) return console.warn('该节点禁用删除')