|
@@ -2,16 +2,16 @@
|
|
|
import { useLoading } from '/@/utils/loading-util'
|
|
|
import { computed, onMounted, ref, watch } from 'vue'
|
|
|
import DashboardDesigner from '/@/components/assistant/DashboardDesigner.vue'
|
|
|
+import DashboardViewer from '/@/components/assistant/DashboardViewer.vue'
|
|
|
import ComponentLibrary from '/@/components/assistant/ComponentLibrary.vue'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import type { MarkdownDashBoard, Position, Size, Content, AddCardData, ComponentLibraryItem } from '/@/components/assistant/types'
|
|
|
import { LmSession, Message } from '/@/api/assist/type'
|
|
|
import assist from '/@/api/assist'
|
|
|
import MarkdownIt from 'markdown-it'
|
|
|
-import { PieChart } from '@element-plus/icons-vue'
|
|
|
+import { PieChart, View } from '@element-plus/icons-vue'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
-// 预留props,暂时不使用
|
|
|
const route = useRoute()
|
|
|
|
|
|
const id = computed(() => route.query.id as unknown as number)
|
|
@@ -19,6 +19,9 @@ const id = computed(() => route.query.id as unknown as number)
|
|
|
const cards = ref<MarkdownDashBoard[]>([])
|
|
|
const title = ref<string>('新建仪表板')
|
|
|
|
|
|
+// 预览相关状态
|
|
|
+const showPreviewDialog = ref(false)
|
|
|
+
|
|
|
const { loading: loadingDashboard, doLoading: doLoadingDashBoard } = useLoading(async () => {
|
|
|
if (id.value === undefined) {
|
|
|
return
|
|
@@ -380,6 +383,16 @@ const generateMarkdownTable = (tableData: TableData): string => {
|
|
|
return markdown
|
|
|
}
|
|
|
|
|
|
+// 打开预览对话框
|
|
|
+const openPreview = () => {
|
|
|
+ showPreviewDialog.value = true
|
|
|
+}
|
|
|
+
|
|
|
+// 关闭预览对话框
|
|
|
+const closePreview = () => {
|
|
|
+ showPreviewDialog.value = false
|
|
|
+}
|
|
|
+
|
|
|
onMounted( () => {
|
|
|
doLoadingChat()
|
|
|
doLoadingDashBoard()
|
|
@@ -394,6 +407,9 @@ onMounted( () => {
|
|
|
<h2>仪表板设计器 | {{ title }}</h2>
|
|
|
</div>
|
|
|
<div class="toolbar-right">
|
|
|
+ <el-button :icon="View" @click="openPreview" :disabled="loadingDashboard">
|
|
|
+ 预览
|
|
|
+ </el-button>
|
|
|
<el-button type="primary" @click="doLoadingDashboardSubmit" :loading="loadingDashboardSubmit" :disabled="loadingDashboard">
|
|
|
保存仪表板
|
|
|
</el-button>
|
|
@@ -422,6 +438,20 @@ onMounted( () => {
|
|
|
<ComponentLibrary class="library-panel-content" v-loading="loadingLibrary" :library="library" @add-card="addCard" />
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <!-- 预览对话框 -->
|
|
|
+ <el-dialog
|
|
|
+ v-model="showPreviewDialog"
|
|
|
+ title="仪表板预览"
|
|
|
+ width="90%"
|
|
|
+ :before-close="closePreview"
|
|
|
+ append-to-body
|
|
|
+ class="preview-dialog"
|
|
|
+ >
|
|
|
+ <div class="preview-container">
|
|
|
+ <DashboardViewer :cards="renderer" />
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -487,4 +517,19 @@ onMounted( () => {
|
|
|
width: 100%;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/* 预览对话框样式 */
|
|
|
+:deep(.preview-dialog) {
|
|
|
+ .el-dialog__body {
|
|
|
+ padding: 0;
|
|
|
+ height: 70vh;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.preview-container {
|
|
|
+ height: 100%;
|
|
|
+ border: 1px solid var(--el-border-color-light);
|
|
|
+ border-radius: 6px;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
</style>
|