|
|
@@ -1,5 +1,45 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
+ <!-- 顶部栏 -->
|
|
|
+ <div
|
|
|
+ style="
|
|
|
+ height: 64px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 0 16px;
|
|
|
+ justify-content: space-between;
|
|
|
+ background: #fff;
|
|
|
+ border-bottom: 1px solid #f0f0f0;
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <div style="display: flex; align-items: center; gap: 12px">
|
|
|
+ <div style="font-weight: 700; font-size: 18px">AI Agent</div>
|
|
|
+ <div style="color: #888; font-size: 13px">概述</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div style="display: flex; align-items: center; gap: 12px">
|
|
|
+ <el-dropdown
|
|
|
+ style="background: #ff6b6b"
|
|
|
+ split-button
|
|
|
+ type="primary"
|
|
|
+ @click="handleMenuClick(buttonConfig.text)"
|
|
|
+ >
|
|
|
+ {{ buttonConfig.text }}
|
|
|
+ <template #dropdown>
|
|
|
+ <el-dropdown-menu>
|
|
|
+ <el-dropdown-item
|
|
|
+ v-for="item in buttonConfig.items"
|
|
|
+ :key="item"
|
|
|
+ @click="handleMenuClick(item)"
|
|
|
+ >
|
|
|
+ {{ item }}
|
|
|
+ </el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </template>
|
|
|
+ </el-dropdown>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div style="padding: 16px">
|
|
|
<el-card shadow="never" style="padding: 18px">
|
|
|
<el-row :gutter="16" justify="start">
|
|
|
<el-col :span="4" v-for="(card, idx) in cards" :key="idx">
|
|
|
@@ -20,7 +60,7 @@
|
|
|
</el-card>
|
|
|
|
|
|
<el-card style="margin-top: 16px">
|
|
|
- <el-tabs v-model="activeTab">
|
|
|
+ <el-tabs v-model="dashboardStore.activeTab">
|
|
|
<el-tab-pane label="工作流程" name="flows"></el-tab-pane>
|
|
|
<el-tab-pane label="证书" name="certs"></el-tab-pane>
|
|
|
<el-tab-pane label="执行" name="execs"></el-tab-pane>
|
|
|
@@ -50,7 +90,7 @@
|
|
|
</div>
|
|
|
|
|
|
<div>
|
|
|
- <el-button type="text">筛选</el-button>
|
|
|
+ <el-button text>筛选</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -215,11 +255,11 @@
|
|
|
<div style="font-size: 13px; color: #999; margin-bottom: 16px">
|
|
|
变量可用于存储可在多个工作流程中轻松引用的数据。
|
|
|
</div>
|
|
|
- <el-button @click="showVarDialog = true">添加第一个变量</el-button>
|
|
|
+ <el-button @click="dashboardStore.openVarDialog">添加第一个变量</el-button>
|
|
|
</div>
|
|
|
<el-table v-else :data="filteredVariables" style="width: 100%; margin-top: 12px">
|
|
|
- <el-table-column prop="key" label="钥匙" />
|
|
|
- <el-table-column prop="value" label="价值" />
|
|
|
+ <el-table-column prop="key" label="key" />
|
|
|
+ <el-table-column prop="value" label="值" />
|
|
|
<el-table-column prop="usage" label="使用语法" width="150">
|
|
|
<template #default="scope">
|
|
|
<el-tag type="info">{{ scope.row.usage }}</el-tag>
|
|
|
@@ -227,10 +267,10 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="scope" label="范围" width="100">
|
|
|
<template #default="scope">
|
|
|
- <el-tag size="small">{{ scope.row.scope }}</el-tag>
|
|
|
+ <el-tag size="small">{{ scope.row.scope === 'scope' ? '全局' : '' }}</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" width="120" align="right">
|
|
|
+ <el-table-column label="操作" width="200" align="right">
|
|
|
<template #default="scope">
|
|
|
<el-button text size="small" @click="editVariable(scope.row)">编辑</el-button>
|
|
|
<el-button text size="small" type="danger" @click="deleteVariable(scope.row.id)"
|
|
|
@@ -267,7 +307,7 @@
|
|
|
<div style="font-size: 13px; color: #999; margin-bottom: 20px">
|
|
|
使用数据表来保存执行结果、在工作流之间共享数据以及跨进程体估指标。
|
|
|
</div>
|
|
|
- <el-button @click="showTableDialog = true">创建数据表</el-button>
|
|
|
+ <el-button @click="dashboardStore.openTableDialog">创建数据表</el-button>
|
|
|
</div>
|
|
|
<div v-else>
|
|
|
<div
|
|
|
@@ -348,7 +388,7 @@
|
|
|
</div>
|
|
|
|
|
|
<div style="display: flex; gap: 8px; align-items: center">
|
|
|
- <el-tag size="small" type="info">个人的</el-tag>
|
|
|
+ <!-- <el-tag size="small" type="info">个人的</el-tag> -->
|
|
|
<el-dropdown>
|
|
|
<span class="el-dropdown-link">•••</span>
|
|
|
<template #dropdown>
|
|
|
@@ -378,53 +418,59 @@
|
|
|
gap: 12px;
|
|
|
"
|
|
|
>
|
|
|
- <span style="color: #666; font-size: 13px">总计 {{ getTabData.length }}</span>
|
|
|
<el-pagination
|
|
|
background
|
|
|
:page-size="pageSize"
|
|
|
:current-page="currentPage"
|
|
|
+ :page-sizes="[10, 20, 50]"
|
|
|
@update:current-page="currentPage = $event"
|
|
|
+ @update:page-size="pageSize = $event"
|
|
|
:total="getTabData.length"
|
|
|
- layout="prev, pager, next"
|
|
|
+ layout="total, prev, pager, next, sizes"
|
|
|
/>
|
|
|
- <el-select v-model.number="pageSize" size="small" style="width: 100px">
|
|
|
- <el-option label="10/页" :value="10" />
|
|
|
- <el-option label="20/页" :value="20" />
|
|
|
- <el-option label="50/页" :value="50" />
|
|
|
- </el-select>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
|
|
|
<!-- 新变量对话框 -->
|
|
|
- <el-dialog v-model="showVarDialog" title="新变量" width="500px" @close="resetVarForm">
|
|
|
- <el-form :model="varForm">
|
|
|
- <el-form-item label="钥匙" required>
|
|
|
- <el-input v-model="varForm.key" placeholder="请输入姓名" />
|
|
|
+ <el-dialog
|
|
|
+ v-model="dashboardStore.showVarDialog"
|
|
|
+ :title="varDialogTitle"
|
|
|
+ width="500px"
|
|
|
+ @close="resetVarForm"
|
|
|
+ >
|
|
|
+ <el-form ref="varFormRef" :model="varForm" :rules="varFormRules" label-position="top">
|
|
|
+ <el-form-item label="Key" prop="key">
|
|
|
+ <el-input v-model="varForm.key" placeholder="请输入key" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="价值">
|
|
|
+ <el-form-item label="值" prop="value">
|
|
|
<el-input v-model="varForm.value" type="textarea" placeholder="请输入一个值" rows="4" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="范围" required>
|
|
|
+ <el-form-item label="范围" prop="scope">
|
|
|
<el-select v-model="varForm.scope" placeholder="选择">
|
|
|
- <el-option label="全局的" value="全局的" />
|
|
|
+ <el-option label="全局" value="scope" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<div style="text-align: right">
|
|
|
- <el-button @click="showVarDialog = false">取消</el-button>
|
|
|
+ <el-button @click="dashboardStore.closeVarDialog">取消</el-button>
|
|
|
<el-button type="primary" @click="submitVariable">提交</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
<!-- 创建新数据表对话框 -->
|
|
|
- <el-dialog v-model="showTableDialog" title="创建新数据表" width="500px" @close="resetTableForm">
|
|
|
- <el-form :model="tableForm">
|
|
|
- <el-form-item label="数据表名称" required>
|
|
|
+ <el-dialog
|
|
|
+ v-model="dashboardStore.showTableDialog"
|
|
|
+ title="创建新数据表"
|
|
|
+ width="500px"
|
|
|
+ @close="resetTableForm"
|
|
|
+ >
|
|
|
+ <el-form ref="tableFormRef" :model="tableForm" :rules="tableFormRules" label-position="top">
|
|
|
+ <el-form-item label="数据表名称" prop="name">
|
|
|
<el-input v-model="tableForm.name" placeholder="输入数据表名称" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="创建方式">
|
|
|
+ <el-form-item label="创建方式" prop="method">
|
|
|
<el-radio-group v-model="tableForm.method">
|
|
|
<el-radio value="from-scratch">从零开始</el-radio>
|
|
|
<el-radio value="import-csv">导入 CSV 文件</el-radio>
|
|
|
@@ -433,7 +479,7 @@
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<div style="text-align: right">
|
|
|
- <el-button @click="showTableDialog = false">取消</el-button>
|
|
|
+ <el-button @click="dashboardStore.closeTableDialog">取消</el-button>
|
|
|
<el-button type="primary" @click="submitTable">创建</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -444,10 +490,42 @@
|
|
|
<script setup lang="ts">
|
|
|
import { ref, computed } from 'vue'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
-import { Search } from '@element-plus/icons-vue'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+import { Search } from '@element-plus/icons-vue'
|
|
|
+import { useDashboardStore } from '@/stores/dashboard'
|
|
|
|
|
|
const $router = useRouter()
|
|
|
+const dashboardStore = useDashboardStore()
|
|
|
+
|
|
|
+// 根据当前 tab 确定按钮文字和下拉菜单
|
|
|
+const buttonConfig = computed(() => {
|
|
|
+ const tab = dashboardStore.activeTab
|
|
|
+ const configs: Record<string, { text: string; items: string[] }> = {
|
|
|
+ flows: { text: '创建工作流程', items: ['创建凭证', '创建变量', '创建数据表'] },
|
|
|
+ certs: { text: '创建凭证', items: ['创建工作流程', '创建变量', '创建数据表'] },
|
|
|
+ execs: { text: '创建工作流程', items: ['创建凭证', '创建变量', '创建数据表'] },
|
|
|
+ vars: { text: '创建变量', items: ['创建工作流程', '创建凭证', '创建数据表'] },
|
|
|
+ tables: { text: '创建数据表', items: ['创建工作流程', '创建凭证', '创建变量'] }
|
|
|
+ }
|
|
|
+ return configs[tab] || { text: '创建工作流程', items: ['创建凭证', '创建变量', '创建数据表'] }
|
|
|
+})
|
|
|
+
|
|
|
+const handleMenuClick = (text: string) => {
|
|
|
+ const actionMap: Record<string, () => void> = {
|
|
|
+ 创建工作流程: () => $router.push('/workflow/0'),
|
|
|
+ 创建凭证: () => console.log('创建凭证'),
|
|
|
+ 创建变量: () => {
|
|
|
+ dashboardStore.setActiveTab('vars')
|
|
|
+ dashboardStore.openVarDialog()
|
|
|
+ },
|
|
|
+ 创建数据表: () => {
|
|
|
+ dashboardStore.setActiveTab('tables')
|
|
|
+ dashboardStore.openTableDialog()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const action = actionMap[text]
|
|
|
+ if (action) action()
|
|
|
+}
|
|
|
|
|
|
const cards = [
|
|
|
{ title: '生产执行', value: 0 },
|
|
|
@@ -511,12 +589,15 @@ const executions = ref([
|
|
|
}
|
|
|
])
|
|
|
|
|
|
-const variables = ref([])
|
|
|
+const variables = ref<{ id: number; key: string; value: string; usage: string; scope: string }[]>(
|
|
|
+ []
|
|
|
+)
|
|
|
|
|
|
-const tables = ref([])
|
|
|
+const tables = ref<
|
|
|
+ { id: number; name: string; description: string; method: string; size: string; rows: string }[]
|
|
|
+>([])
|
|
|
|
|
|
// 数据表相关
|
|
|
-const showTableDialog = ref(false)
|
|
|
const tablePageInput = ref('')
|
|
|
const tablePageSize = ref('50')
|
|
|
const tableForm = ref({
|
|
|
@@ -531,68 +612,117 @@ const resetTableForm = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const submitTable = () => {
|
|
|
- if (!tableForm.value.name.trim()) {
|
|
|
- ElMessage.error('请输入数据表名称')
|
|
|
- return
|
|
|
- }
|
|
|
- const newTable = {
|
|
|
- id: Math.max(...tables.value.map((t: any) => t.id), 0) + 1,
|
|
|
- name: tableForm.value.name,
|
|
|
- description: tableForm.value.method === 'from-scratch' ? '从零开始创建' : '从 CSV 导入',
|
|
|
- method: tableForm.value.method
|
|
|
+const tableFormRef = ref()
|
|
|
+
|
|
|
+const tableFormRules = {
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入数据表名称', trigger: 'blur' },
|
|
|
+ { min: 1, max: 100, message: '数据表名称长度为 1-100 个字符', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ method: [{ required: true, message: '请选择创建方式', trigger: 'change' }]
|
|
|
+}
|
|
|
+
|
|
|
+const submitTable = async () => {
|
|
|
+ try {
|
|
|
+ await tableFormRef.value?.validate()
|
|
|
+ const newTable = {
|
|
|
+ id: Math.max(...tables.value.map((t: any) => t.id), 0) + 1,
|
|
|
+ name: tableForm.value.name,
|
|
|
+ description: tableForm.value.method === 'from-scratch' ? '从零开始创建' : '从 CSV 导入',
|
|
|
+ method: tableForm.value.method,
|
|
|
+ size: '0MB',
|
|
|
+ rows: '0'
|
|
|
+ }
|
|
|
+ tables.value.push(newTable)
|
|
|
+ dashboardStore.closeTableDialog()
|
|
|
+ resetTableForm()
|
|
|
+ ElMessage.success('数据表已创建')
|
|
|
+ } catch (error) {
|
|
|
+ // 验证失败,form 会自动显示错误信息
|
|
|
}
|
|
|
- tables.value.push(newTable)
|
|
|
- showTableDialog.value = false
|
|
|
- resetTableForm()
|
|
|
- ElMessage.success('数据表已创建')
|
|
|
}
|
|
|
|
|
|
const filter = ref('')
|
|
|
const sort = ref('name')
|
|
|
-const activeTab = ref('flows')
|
|
|
const pageSize = ref(10)
|
|
|
|
|
|
+// 使用 computed 来包装 dashboardStore.activeTab,以便简化模板中的引用
|
|
|
+const activeTab = computed(() => dashboardStore.activeTab)
|
|
|
+
|
|
|
// 变量表单相关
|
|
|
-const showVarDialog = ref(false)
|
|
|
const varFilter = ref('')
|
|
|
const varSort = ref('name')
|
|
|
const varPageSize = ref('25')
|
|
|
const varForm = ref({
|
|
|
+ id: undefined as number | undefined,
|
|
|
key: '',
|
|
|
value: '',
|
|
|
- scope: '全局的'
|
|
|
+ scope: 'scope'
|
|
|
})
|
|
|
|
|
|
const resetVarForm = () => {
|
|
|
varForm.value = {
|
|
|
+ id: undefined,
|
|
|
key: '',
|
|
|
value: '',
|
|
|
- scope: '全局的'
|
|
|
+ scope: 'scope'
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const submitVariable = () => {
|
|
|
- if (!varForm.value.key.trim()) {
|
|
|
- ElMessage.error('请输入钥匙')
|
|
|
- return
|
|
|
- }
|
|
|
- const newVar = {
|
|
|
- id: Math.max(...variables.value.map((v: any) => v.id), 0) + 1,
|
|
|
- key: varForm.value.key,
|
|
|
- value: varForm.value.value,
|
|
|
- usage: `$vars.${varForm.value.key}`,
|
|
|
- scope: varForm.value.scope
|
|
|
+const varFormRef = ref()
|
|
|
+
|
|
|
+const varFormRules = {
|
|
|
+ key: [
|
|
|
+ { required: true, message: '请输入Key', trigger: 'blur' },
|
|
|
+ { min: 1, max: 100, message: 'Key 长度为 1-100 个字符', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ value: [],
|
|
|
+ scope: [{ required: true, message: '请选择范围', trigger: 'change' }]
|
|
|
+}
|
|
|
+
|
|
|
+const submitVariable = async () => {
|
|
|
+ try {
|
|
|
+ await varFormRef.value?.validate()
|
|
|
+ // 编辑已有变量
|
|
|
+ if (varForm.value.id) {
|
|
|
+ const idx = variables.value.findIndex((v: any) => v.id === varForm.value.id)
|
|
|
+ if (idx !== -1) {
|
|
|
+ variables.value[idx] = {
|
|
|
+ id: varForm.value.id,
|
|
|
+ key: varForm.value.key,
|
|
|
+ value: varForm.value.value,
|
|
|
+ usage: `$vars.${varForm.value.key}`,
|
|
|
+ scope: varForm.value.scope
|
|
|
+ }
|
|
|
+ dashboardStore.closeVarDialog()
|
|
|
+ resetVarForm()
|
|
|
+ ElMessage.success('变量已更新')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 新增变量
|
|
|
+ const newVar = {
|
|
|
+ id: Math.max(...variables.value.map((v: any) => v.id), 0) + 1,
|
|
|
+ key: varForm.value.key,
|
|
|
+ value: varForm.value.value,
|
|
|
+ usage: `$vars.${varForm.value.key}`,
|
|
|
+ scope: varForm.value.scope
|
|
|
+ }
|
|
|
+ variables.value.push(newVar)
|
|
|
+ dashboardStore.closeVarDialog()
|
|
|
+ resetVarForm()
|
|
|
+ ElMessage.success('变量已添加')
|
|
|
+ } catch (error) {
|
|
|
+ // 验证失败,form 会自动显示错误信息
|
|
|
}
|
|
|
- variables.value.push(newVar)
|
|
|
- showVarDialog.value = false
|
|
|
- resetVarForm()
|
|
|
- ElMessage.success('变量已添加')
|
|
|
}
|
|
|
|
|
|
+const varDialogTitle = computed(() => (varForm.value.id ? '编辑变量' : '新增'))
|
|
|
+
|
|
|
const editVariable = (variable: any) => {
|
|
|
varForm.value = { ...variable, scope: variable.scope }
|
|
|
- showVarDialog.value = true
|
|
|
+ dashboardStore.openVarDialog()
|
|
|
}
|
|
|
|
|
|
const deleteVariable = (id: number) => {
|