ai助手1.0
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<div class="selected-tag workflow-tag">
|
||||
<el-icon><Promotion /></el-icon>
|
||||
<span>{{ commonWorkflows.find((w) => w.id === selectedWorkflowId)?.name }}</span>
|
||||
<el-icon class="tag-close" @click="clearWorkflow"><Close /></el-icon>
|
||||
<el-icon v-if="!workflowLocked" class="tag-close" @click="clearWorkflow"><Close /></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -47,9 +47,9 @@
|
||||
</div>
|
||||
|
||||
<!-- 快捷工作流胶囊(输入框下方) -->
|
||||
<div v-if="commonWorkflows.length > 0" class="workflow-shortcuts">
|
||||
<div v-if="visibleWorkflows.length > 0" class="workflow-shortcuts">
|
||||
<button
|
||||
v-for="wf in commonWorkflows"
|
||||
v-for="wf in visibleWorkflows"
|
||||
:key="wf.id"
|
||||
class="shortcut-pill"
|
||||
:class="{ active: selectedWorkflowId === wf.id }"
|
||||
@@ -63,13 +63,14 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { Top, MagicStick, Promotion, Close, Paperclip } from '@element-plus/icons-vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { getWorkflowList } from '/@/api/settings/creation';
|
||||
|
||||
interface Props {
|
||||
sendDisabled?: boolean;
|
||||
workflowLocked?: boolean;
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
@@ -85,6 +86,7 @@ interface Workflow {
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
sendDisabled: false,
|
||||
workflowLocked: false,
|
||||
});
|
||||
const emit = defineEmits<Emits>();
|
||||
const message = ref('');
|
||||
@@ -92,6 +94,13 @@ const isFocused = ref(false);
|
||||
const selectedWorkflowId = ref<string | null>(null);
|
||||
const commonWorkflows = ref<Workflow[]>([]);
|
||||
|
||||
const visibleWorkflows = computed(() => {
|
||||
if (props.workflowLocked && selectedWorkflowId.value) {
|
||||
return commonWorkflows.value.filter((w) => w.id === selectedWorkflowId.value);
|
||||
}
|
||||
return commonWorkflows.value;
|
||||
});
|
||||
|
||||
const fetchWorkflows = async () => {
|
||||
try {
|
||||
const res = await getWorkflowList();
|
||||
@@ -119,6 +128,7 @@ const handleAttachment = () => {
|
||||
};
|
||||
|
||||
const toggleWorkflow = (id: string) => {
|
||||
if (props.workflowLocked) return;
|
||||
const newId = selectedWorkflowId.value === id ? null : id;
|
||||
selectedWorkflowId.value = newId;
|
||||
emit('workflow-select', newId);
|
||||
@@ -131,6 +141,7 @@ const resetAll = () => {
|
||||
};
|
||||
|
||||
const clearWorkflow = () => {
|
||||
if (props.workflowLocked) return;
|
||||
selectedWorkflowId.value = null;
|
||||
emit('workflow-select', null);
|
||||
};
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<h3>{{ workflowDetail.flowName || '工作流表单' }}</h3>
|
||||
<div class="workflow-form-sub">{{ workflowDetail.description || '请填写以下参数' }}</div>
|
||||
</div>
|
||||
<el-button size="small" @click="$emit('close-workflow')">返回对话</el-button>
|
||||
</div>
|
||||
<div class="workflow-form-scroll">
|
||||
<el-form label-position="top" class="workflow-form">
|
||||
@@ -201,10 +200,6 @@ interface Props {
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
activeHistoryId: null,
|
||||
});
|
||||
defineEmits<{
|
||||
(e: 'close-workflow'): void;
|
||||
}>();
|
||||
|
||||
const formValues = reactive<Record<string, any>>({});
|
||||
const fieldFiles = reactive<Record<string, { name: string; url: string }[]>>({});
|
||||
const uploadingFields = reactive<Record<string, boolean>>({});
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
:active-menu="activeMenu"
|
||||
:workflow-detail="selectedWorkflowDetail"
|
||||
:active-history-id="activeHistoryId"
|
||||
@close-workflow="handleCloseWorkflow"
|
||||
/>
|
||||
<InputBar ref="inputBarRef" :send-disabled="isSendDisabled" @send="handleSend" @workflow-select="handleWorkflowSelect" />
|
||||
<InputBar ref="inputBarRef" :send-disabled="isSendDisabled" :workflow-locked="isHistoryWorkflow" @send="handleSend" @workflow-select="handleWorkflowSelect" />
|
||||
</div>
|
||||
|
||||
<!-- 预览弹窗 -->
|
||||
@@ -270,6 +269,7 @@ const workspacePage = ref(1);
|
||||
const hasMoreWorkspace = ref(true);
|
||||
const workspaceLoading = ref(false);
|
||||
const sendingSessions = reactive<Record<string, boolean>>({});
|
||||
const isHistoryWorkflow = ref(false);
|
||||
const inputBarRef = ref<any>(null);
|
||||
|
||||
const isSendDisabled = computed(() => {
|
||||
@@ -318,10 +318,6 @@ const loadMoreWorkspace = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleCloseWorkflow = () => {
|
||||
selectedWorkflowDetail.value = null;
|
||||
inputBarRef.value?.resetAll();
|
||||
};
|
||||
|
||||
const handleMenuChange = (menu: string) => {
|
||||
activeMenu.value = menu;
|
||||
@@ -539,6 +535,7 @@ const handleSelectHistory = async (id: string) => {
|
||||
const res = await getExecutionDetail(session.id);
|
||||
if (res.data) {
|
||||
selectedWorkflowDetail.value = res.data;
|
||||
isHistoryWorkflow.value = true;
|
||||
// 同步回显 InputBar 的工作流选择
|
||||
const ib = inputBarRef.value as any;
|
||||
if (ib?.commonWorkflows && res.data.flowName) {
|
||||
@@ -569,6 +566,7 @@ const createNewSession = () => {
|
||||
activeHistoryId.value = sessionId;
|
||||
activeMenu.value = 'chat';
|
||||
selectedWorkflowDetail.value = null;
|
||||
isHistoryWorkflow.value = false;
|
||||
inputBarRef.value?.resetAll();
|
||||
sessionMessages.value.set(sessionId, []); // 清空消息
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user