fix(captain): 护栏/回复指南编辑按钮不生效
根因: 1. guardrails/guidelines 页面直接导航时 store 无助手记录,getRecord 返回空对象导致列表为空、编辑无数据 2. storeFactoryHelper updateRecord 用 EDIT mutation(仅更新已有记录), store 为空时 API 返回数据被丢弃 修复: - storeFactoryHelper: updateRecord 改用 UPSERT,确保 API 返回记录始终写入 store - guardrails/Index.vue & guidelines/Index.vue: onMounted 时若 store 无记录 则 dispatch captainAssistants/show 拉取单条助手数据
This commit is contained in:
+9
-1
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useAlert } from 'dashboard/composables';
|
||||
@@ -30,6 +30,14 @@ const assistant = computed(() =>
|
||||
store.getters['captainAssistants/getRecord'](assistantId.value)
|
||||
);
|
||||
|
||||
// Fetch the assistant record if it's not already in the store
|
||||
// (e.g. when navigating directly to this page via URL)
|
||||
onMounted(() => {
|
||||
if (!assistant.value?.id) {
|
||||
store.dispatch('captainAssistants/show', assistantId.value);
|
||||
}
|
||||
});
|
||||
|
||||
const searchQuery = ref('');
|
||||
const newInlineRule = ref('');
|
||||
const newDialogRule = ref('');
|
||||
|
||||
+9
-1
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useAlert } from 'dashboard/composables';
|
||||
@@ -30,6 +30,14 @@ const assistant = computed(() =>
|
||||
store.getters['captainAssistants/getRecord'](assistantId.value)
|
||||
);
|
||||
|
||||
// Fetch the assistant record if it's not already in the store
|
||||
// (e.g. when navigating directly to this page via URL)
|
||||
onMounted(() => {
|
||||
if (!assistant.value?.id) {
|
||||
store.dispatch('captainAssistants/show', assistantId.value);
|
||||
}
|
||||
});
|
||||
|
||||
const searchQuery = ref('');
|
||||
const newInlineRule = ref('');
|
||||
const newDialogRule = ref('');
|
||||
|
||||
Reference in New Issue
Block a user