refactor(module-management): R1 清场——删除无引用的 MenuDetailPanel/IconSelect 与过期 spec,useConfirm 合回 index.vue
This commit is contained in:
1 parent
91237c4a47
commit
2dba857880
5 files changed
+64
-3509
No files matched your search
@@ -3,8 +3,9 @@
|
||||
* 模块管理:模块配置(单分区)。
|
||||
* 模块配置:左侧模块树 + 右侧分节面板(基础/字段/列表/编辑/查询/自动编码/权限/多语言)。
|
||||
* 数据直接经通用 API(loadDataApi / saveObjectApi / nextIdApi / describeApi)读写元数据表。
|
||||
* 树/草稿/保存/确认弹窗逻辑分别抽到 composables/useModuleTree、useModuleConfig、
|
||||
* useModuleSave、useConfirm;本文件只保留模板、状态接线与面板编排。
|
||||
* 树/草稿/保存逻辑分别抽到 composables/useModuleTree、useModuleConfig、
|
||||
* useModuleSave;确认弹窗状态机仅本页使用,直接内联在下方。
|
||||
* 本文件保留模板、状态接线与面板编排。
|
||||
*/
|
||||
import { computed, ref } from 'vue'
|
||||
import { useHotkeys } from '@/composables/useHotkeys'
|
||||
@@ -33,12 +34,12 @@ import {
|
||||
SplitterPanel,
|
||||
Tabs,
|
||||
Modal,
|
||||
Message,
|
||||
} from '@/components/ui'
|
||||
import { buildModuleI18nKey, buildModuleItemI18nKey } from '@/utils/i18n'
|
||||
import { useModuleTree, findModuleNode } from './composables/useModuleTree'
|
||||
import { useModuleConfig } from './composables/useModuleConfig'
|
||||
import { useModuleSave } from './composables/useModuleSave'
|
||||
import { useConfirm } from './composables/useConfirm'
|
||||
import ModuleBasicPanel from './components/ModuleBasicPanel.vue'
|
||||
import ModuleFieldsPanel from './components/ModuleFieldsPanel.vue'
|
||||
import ModuleListConfigPanel from './components/ModuleListConfigPanel.vue'
|
||||
@@ -213,18 +214,66 @@ const { saveModule } = useModuleSave({
|
||||
getFinalI18nItems: () => finalI18nItems.value,
|
||||
})
|
||||
|
||||
const {
|
||||
confirmVisible,
|
||||
confirmState,
|
||||
confirmSaving,
|
||||
showConfirm,
|
||||
onConfirmOk,
|
||||
switchConfirm,
|
||||
switchSaving,
|
||||
onSwitchCancel,
|
||||
onSwitchDiscard,
|
||||
onSwitchSave,
|
||||
} = useConfirm({ saveModule, moduleSelectedId })
|
||||
/* ================= 确认弹窗状态机(仅本页使用,不抽 composable) ================= */
|
||||
/* 通用确认弹窗(ui/modal 为组件式 API) */
|
||||
const confirmVisible = ref(false)
|
||||
const confirmState = ref(null)
|
||||
// 确认操作进行中:按钮转圈、弹窗锁定,等待 onOk 完成后再关闭
|
||||
const confirmSaving = ref(false)
|
||||
|
||||
function showConfirm({ title, content, okText, okType, onOk }) {
|
||||
confirmState.value = { title, content, okText: okText || '确定', okType, onOk }
|
||||
confirmVisible.value = true
|
||||
}
|
||||
|
||||
async function onConfirmOk() {
|
||||
const state = confirmState.value
|
||||
if (!state?.onOk || confirmSaving.value) return
|
||||
confirmSaving.value = true
|
||||
try {
|
||||
await state.onOk()
|
||||
} catch (e) {
|
||||
// onOk 内部已处理错误提示,这里兜底避免未捕获异常
|
||||
Message.error('操作失败:' + (e?.message || e))
|
||||
} finally {
|
||||
confirmSaving.value = false
|
||||
confirmVisible.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/* 切换模块未保存保护(保存并切换 / 放弃修改 / 取消) */
|
||||
const switchConfirm = ref(null) // { pendingId, name }
|
||||
const switchSaving = ref(false)
|
||||
|
||||
function onSwitchCancel() {
|
||||
switchConfirm.value = null
|
||||
switchSaving.value = false
|
||||
}
|
||||
|
||||
function onSwitchDiscard() {
|
||||
const state = switchConfirm.value
|
||||
if (!state) return
|
||||
moduleSelectedId.value = state.pendingId
|
||||
switchConfirm.value = null
|
||||
}
|
||||
|
||||
async function onSwitchSave() {
|
||||
const state = switchConfirm.value
|
||||
if (!state || switchSaving.value) return
|
||||
switchSaving.value = true
|
||||
try {
|
||||
const ok = await saveModule()
|
||||
if (!ok) {
|
||||
// 保存失败(原因已由 saveModule 内部提示):留在当前对象,弹窗不关闭,可重试或放弃
|
||||
Message.warning('保存未完成,已留在当前对象,请处理后再切换')
|
||||
return
|
||||
}
|
||||
moduleSelectedId.value = state.pendingId
|
||||
switchConfirm.value = null
|
||||
} finally {
|
||||
switchSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
filteredModuleTree,
|
||||
|
||||
Reference in new issue
Block a user