删除卡片会删除卡片链路所有生成节点,版本树新增点击遮罩关闭版本树
This commit is contained in:
@@ -119,37 +119,69 @@ export class StateManager {
|
||||
this.exportFlow()
|
||||
}
|
||||
/** 删除节点 */
|
||||
async deleteNode(id: string, { isElMessageBox } = { isElMessageBox: false }) {
|
||||
const node = this.getNodeById(id)
|
||||
if (!node) return console.warn(`没有找到指定id:${id}`)
|
||||
if (node.data.disableDelete) return console.warn('该节点禁用删除')
|
||||
let deletePromise: any = true
|
||||
if (isElMessageBox) {
|
||||
deletePromise = await new Promise<void>((resolve, reject) => {
|
||||
ElMessageBox.confirm(
|
||||
t('flowCanvas.deleteCardConfirm'),
|
||||
'',
|
||||
{
|
||||
confirmButtonText: t('flowCanvas.confirm'),
|
||||
cancelButtonText: t('flowCanvas.cancel'),
|
||||
}
|
||||
).then(() => {
|
||||
resolve(true)
|
||||
}).catch(() => {
|
||||
resolve(false)
|
||||
})
|
||||
})
|
||||
}
|
||||
if (!deletePromise) return console.log('删除操作被取消')
|
||||
async deleteNode(id: string) {
|
||||
|
||||
this.nodes.value = this.nodes.value.filter((node: NodesItem) => node.id !== id)
|
||||
this.recordState()
|
||||
this.exportFlow()
|
||||
}
|
||||
/** 获取节点 */
|
||||
getNodeById(id: string) { return this.nodes.value.find((node: NodesItem) => node.id === id) }
|
||||
/** 获取下级节点 */
|
||||
getSubordNodeById(id: string) { return this.nodes.value.find((node: NodesItem) => node.data.superiorID === id) }
|
||||
getLastNode() { console.log(this.nodes.value); return this.nodes.value[this.nodes.value.length - 1] }
|
||||
|
||||
/** 获取上级生成节点的图片 */
|
||||
getSuperiorNodeImage(superiorID: string) {
|
||||
const superiorNode = this.getNodeById(superiorID)
|
||||
if(!superiorNode){
|
||||
ElMessage.error(t('flowCanvas.cannotFindSuperiorImage'))
|
||||
return null
|
||||
}
|
||||
const superiorNodeUrl = superiorNode.data.data.imageProcessTasks.filter((item)=>{
|
||||
return item.taskId == superiorNode.data.data.selectTaskId
|
||||
})[0]?.url
|
||||
return superiorNodeUrl
|
||||
}
|
||||
/** 获取下级所有子级节点 */
|
||||
async getSubordinateAllNodes(id: string,{ isElMessageBox } = { isElMessageBox: false }) {
|
||||
const node = this.getNodeById(id)
|
||||
if (!node) return console.warn(`没有找到指定id:${id}`)
|
||||
if (node.data.disableDelete) return ElMessage.error(t('flowCanvas.initialNodeProhibited'))
|
||||
|
||||
const result = [node]
|
||||
const findChildren = (parentId: string) => {
|
||||
const children = this.nodes.value.filter(item => item.data.superiorID === parentId)
|
||||
children.forEach(child => {
|
||||
if(child.data.type !== NODE_DATATYPE.RESULT_IMAGE){
|
||||
result.push(child)
|
||||
}
|
||||
findChildren(child.id)
|
||||
})
|
||||
}
|
||||
let deletePromise: any = true
|
||||
if (isElMessageBox && result.length > 1) {
|
||||
deletePromise = await new Promise<void>((resolve, reject) => {
|
||||
ElMessageBox.confirm(
|
||||
t('flowCanvas.deleteSubordinateCard'),
|
||||
'',
|
||||
{
|
||||
confirmButtonText: t('flowCanvas.confirm'),
|
||||
cancelButtonText: t('flowCanvas.cancel'),
|
||||
}
|
||||
).then(() => {resolve(true)
|
||||
}).catch(() => {
|
||||
resolve(false)
|
||||
})
|
||||
})
|
||||
}
|
||||
if(!deletePromise) return console.log('删除操作被取消')
|
||||
|
||||
this.deleteNode(id)
|
||||
result.forEach(item => {
|
||||
this.deleteNode(item.id)
|
||||
})
|
||||
this.recordState()
|
||||
this.exportFlow()
|
||||
}
|
||||
/** 设置工具 */
|
||||
setTool(tool: string) { this.tool.value = tool }
|
||||
/** 设置光标 */
|
||||
|
||||
Reference in New Issue
Block a user