Browse Source

工具页面功能补充

mh
hanyuqing 3 months ago
parent
commit
350402c8a9
  1. 101
      vue/src/system/GraphStyle.vue

101
vue/src/system/GraphStyle.vue

@ -684,19 +684,15 @@ export default {
this.saveDialogVisible = true;
},
async confirmSave() {
if (!this.saveForm.group_name || !this
.saveForm.group_name.trim()) {
return this.$message.warning("请选择或输入方案名称"
);
if (!this.saveForm.group_name || !this.saveForm.group_name.trim()) {
return ElMessage.warning("请选择或输入方案名称");
}
if (!this.saveForm.canvas_name || !this
.saveForm.canvas_name.trim()) {
return this.$message.warning("请输入配置名称"
);
if (!this.saveForm.canvas_name || !this.saveForm.canvas_name.trim()) {
return ElMessage.warning("请输入配置名称");
}
const payload = {
canvas_name: this.saveForm.canvas_name,
group_name: this.saveForm.group_name,
canvas_name: this.saveForm.canvas_name.trim(),
group_name: this.saveForm.group_name.trim(),
current_label: this.activeTags,
styles: {...this.tagStyles[tagToLabelMap[this.activeTags]]}
};
@ -704,6 +700,8 @@ export default {
if (res.code === 200) {
ElMessage.success("保存成功");
this.saveDialogVisible = false;
this.saveForm.canvas_name = '';
this.saveForm.group_name = '';
this.resetAllTagsToDefault();
this.fetchConfigs();
}
@ -725,51 +723,114 @@ export default {
this.updateAllElements();
ElMessage.info(`已重置【${this.activeTags}】样式`);
},
// --- ---
async deleteSingleConfig(id) {
if (this.usingConfigIds.includes(id)) {
return ElMessage.error("该配置正在应用中,请取消应用或切换方案后再删除");
}
try {
await ElMessageBox.confirm('确定删除此配置吗?', '提示');
const res = await deleteGraphStyle(id);
if (res.code === 200) {
this.usingConfigIds = this.usingConfigIds.filter(cid => cid !== id);
ElMessage.success("删除成功");
this.fetchConfigs();
this.updateAllElements();
}
} catch (err) {}
},
// --- ---
async deleteGroup(groupId) {
const group = this.styleGroups.find(g => g.id === groupId);
if (!group) return;
// 1.
const isGroupUsing = group.configs.some(c => this.usingConfigIds.includes(c.id));
if (isGroupUsing || group.is_active) {
return ElMessage.error("该方案中包含正在应用的配置,无法删除");
}
// 2.
if (this.styleGroups.length <= 1) {
return ElMessage.error("系统至少需保留一个方案,无法全部删除");
}
try {
await ElMessageBox.confirm('确定删除整个方案吗?', '提示');
const res = await deleteGraphStyleGroup(groupId);
if (res.code === 200) {
ElMessage.success("方案已删除");
this.fetchConfigs();
this.updateAllElements();
}
} catch (err) {}
},
// --- ---
async handleUnifiedBatchDelete() {
// 1.
if (this.checkedConfigIds.length === 0 && this.checkedGroupIds.length === 0) {
return ElMessage.warning("请先勾选要删除的项目");
}
// 2.
const isAnyCheckedConfigUsing = this.checkedConfigIds.some(id => this.usingConfigIds.includes(id));
const isAnyCheckedGroupUsing = this.styleGroups
.filter(g => this.checkedGroupIds.includes(g.id))
.some(g => g.configs.some(c => this.usingConfigIds.includes(c.id)));
if (isAnyCheckedConfigUsing || isAnyCheckedGroupUsing) {
return ElMessageBox.alert(
'选中的项目中包含“正在应用”的配置,请先取消应用后再执行删除操作。',
'无法执行删除',
{ type: 'error', confirmButtonText: '我知道了' }
);
}
// 3. ()
if (this.checkedGroupIds.length >= this.styleGroups.length && this.styleGroups.length > 0) {
return ElMessage.error("系统至少需要保留一个方案,请勿全部勾选删除");
}
try {
await ElMessageBox.confirm(
'确定执行批量删除吗?',
'批量删除',
'确定执行批量删除吗?此操作不可恢复。',
'批量删除确认',
{
confirmButtonText: '确定',
confirmButtonText: '确定删除',
cancelButtonText: '取消',
type: 'warning'
}
);
for (const gid of this.checkedGroupIds) await deleteGraphStyleGroup(gid);
if (this.checkedConfigIds.length > 0) await batchDeleteGraphStyle({ids: this.checkedConfigIds});
//
if (this.checkedGroupIds.length > 0) {
for (const gid of this.checkedGroupIds) {
await deleteGraphStyleGroup(gid);
}
}
if (this.checkedConfigIds.length > 0) {
await batchDeleteGraphStyle({ids: this.checkedConfigIds});
}
ElMessage.success("批量删除成功");
this.clearSelection();
this.fetchConfigs();
this.updateAllElements();
} catch (e) {}
} catch (e) {
console.log("用户取消或删除失败", e);
}
},
clearSelection() {
this.checkedConfigIds = [];
this.checkedGroupIds = [];
},
handleResize() {
if (this._graph && this.$refs.graphContainer) this._graph.setSize(this.$refs.graphContainer.clientWidth, this.$refs.graphContainer.clientHeight);
if (this._graph && this.$refs.graphContainer) {
this._graph.setSize(this.$refs.graphContainer.clientWidth, this.$refs.graphContainer.clientHeight);
}
}
}
}

Loading…
Cancel
Save