diff --git a/orion-ops-ui/src/store/modules/dict/index.ts b/orion-ops-ui/src/store/modules/dict/index.ts index f58eaca1..82d34c5e 100644 --- a/orion-ops-ui/src/store/modules/dict/index.ts +++ b/orion-ops-ui/src/store/modules/dict/index.ts @@ -8,6 +8,7 @@ export default defineStore('dict', { actions: { // 加载字典值 async loadKeys(keys: string[]) { + console.log('loadKeys', keys); // 检查是否存在 const unloadKeys = keys.filter(key => !this.$state.hasOwnProperty(key)); if (!unloadKeys.length) { @@ -18,6 +19,8 @@ export default defineStore('dict', { const { data } = await getDictValueList(unloadKeys); this.$patch(data as object); } catch (e) { + } finally { + console.log('final'); } }, @@ -33,9 +36,11 @@ export default defineStore('dict', { defaultValue = value) { for (let dictValue of this.$state[dict] || []) { if (dictValue.value === value) { + console.log(dictValue[key]); return dictValue[key]; } } + console.log('default', dict); return defaultValue; }, diff --git a/orion-ops-ui/src/views/system/dict-key/index.vue b/orion-ops-ui/src/views/system/dict-key/index.vue index 87ebc7e8..9bbeec1c 100644 --- a/orion-ops-ui/src/views/system/dict-key/index.vue +++ b/orion-ops-ui/src/views/system/dict-key/index.vue @@ -25,11 +25,15 @@ import DictKeyTable from './components/dict-key-table.vue'; import DictKeyFormModal from './components/dict-key-form-modal.vue'; import DictKeyViewModal from './components/dict-key-view-modal.vue'; + import { useDictStore } from '@/store'; + import { dictKeys } from './types/const'; const table = ref(); const modal = ref(); const view = ref(); + useDictStore().loadKeys(dictKeys); + // 添加回调 const modalAddCallback = () => { table.value.addedCallback(); diff --git a/orion-ops-ui/src/views/system/dict-key/types/const.ts b/orion-ops-ui/src/views/system/dict-key/types/const.ts index a8090953..c9b7fe34 100644 --- a/orion-ops-ui/src/views/system/dict-key/types/const.ts +++ b/orion-ops-ui/src/views/system/dict-key/types/const.ts @@ -1,27 +1,38 @@ -import { ValueTypeEnum } from './enum.types'; +// 配置值类型定义 +export const ValueType = { + STRING: 'STRING', + INTEGER: 'INTEGER', + DECIMAL: 'DECIMAL', + BOOLEAN: 'BOOLEAN', + COLOR: 'COLOR', +}; -/** - * 快捷定义字段 - */ -export const definedExtraKeys = [{ - name: 'disabled', - type: ValueTypeEnum.BOOLEAN.value -}, { - name: 'status', - type: ValueTypeEnum.STRING.value -}, { - name: 'type', - type: ValueTypeEnum.STRING.value -}, { - name: 'color', - type: ValueTypeEnum.COLOR.value -}]; +// 快捷定义字段 +export const definedExtraKeys = [ + { + name: 'disabled', + type: ValueType.BOOLEAN + }, { + name: 'status', + type: ValueType.STRING + }, { + name: 'type', + type: ValueType.STRING + }, { + name: 'color', + type: ValueType.COLOR + } +]; -/** - * 内置字段 - */ +// 内置字段 export const innerKeys = ['value', 'label']; +// 菜单配置值类型 字典项 +export const dictValueTypeKey = 'dictValueType'; + +// 加载的字典值 +export const dictKeys = [dictValueTypeKey]; + /** * 额外参数类型 */ diff --git a/orion-ops-ui/src/views/system/dict-value/components/dict-value-form-modal.vue b/orion-ops-ui/src/views/system/dict-value/components/dict-value-form-modal.vue index 0666333c..efc90946 100644 --- a/orion-ops-ui/src/views/system/dict-value/components/dict-value-form-modal.vue +++ b/orion-ops-ui/src/views/system/dict-value/components/dict-value-form-modal.vue @@ -204,16 +204,13 @@ } }; - // 关闭 + // 关闭回调 const handleClose = () => { - handlerClear(); - if (isAddHandle.value) { - // 关闭后设置排序 -10 下次进入的排序字段会保持不变 - formModel.value.sort = (formModel.value.sort || 0) - 10; - } else { - // 关闭后设置排序为 0 下次进入的排序字段为 10 + if (!isAddHandle.value) { + // 修改关闭后设置排序为 0 下次进入的排序字段为 10 formModel.value.sort = 0; } + handlerClear(); }; // 清空 diff --git a/orion-ops-ui/src/views/system/menu/components/menu-table.vue b/orion-ops-ui/src/views/system/menu/components/menu-table.vue index 120c8115..a8d1e12d 100644 --- a/orion-ops-ui/src/views/system/menu/components/menu-table.vue +++ b/orion-ops-ui/src/views/system/menu/components/menu-table.vue @@ -182,7 +182,7 @@