mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-23 05:40:20 +08:00
Merge remote-tracking branch 'origin/zhuo_dev' into leng_dev
# Conflicts: # src/views/gen/table/preview.vue
This commit is contained in:
commit
2249bb2c7a
@ -308,6 +308,12 @@
|
|||||||
padding: 15px 20px;
|
padding: 15px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 日历
|
||||||
|
.el-calendar-table .el-calendar-day {
|
||||||
|
height: 50px;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Table 表格 element plus 2.2.0 版本
|
/* Table 表格 element plus 2.2.0 版本
|
||||||
------------------------------- */
|
------------------------------- */
|
||||||
// 表格修改默认颜色
|
// 表格修改默认颜色
|
||||||
|
@ -1,54 +1,58 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog title="代码预览" v-model="visible" width="90%" top="3vh" append-to-body :close-on-click-modal="false">
|
<el-dialog title="代码预览" v-model="visible" width="90%" top="3vh" append-to-body :close-on-click-modal="false">
|
||||||
<splitpanes>
|
<splitpanes>
|
||||||
<pane size="25">
|
<pane size="25">
|
||||||
<el-scrollbar height="calc(100vh - 300px)" class="mt20">
|
<el-scrollbar height="calc(100vh - 300px)" class="mt20">
|
||||||
<el-tree
|
<el-tree
|
||||||
ref="treeRef"
|
ref="treeRef"
|
||||||
node-key="id"
|
node-key="id"
|
||||||
:data="preview.fileTree"
|
:data="preview.fileTree"
|
||||||
:expand-on-click-node="false"
|
:expand-on-click-node="false"
|
||||||
highlight-current
|
highlight-current
|
||||||
@node-click="handleNodeClick"
|
@node-click="handleNodeClick"
|
||||||
/>
|
/>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</pane>
|
</pane>
|
||||||
<pane>
|
<pane>
|
||||||
<el-tabs v-model="preview.activeName">
|
<el-tabs v-model="preview.activeName">
|
||||||
<el-tab-pane
|
<el-tab-pane
|
||||||
v-for="item in previewCodegen"
|
v-for="item in previewCodegen"
|
||||||
:label="item.codePath.substring(item.codePath.lastIndexOf('/') + 1)"
|
:label="item.codePath.substring(item.codePath.lastIndexOf('/') + 1)"
|
||||||
:name="item.codePath"
|
:name="item.codePath"
|
||||||
:key="item.codePath"
|
:key="item.codePath"
|
||||||
>
|
>
|
||||||
<el-scrollbar height="calc(100vh - 300px)">
|
<el-button style="position: absolute; top: 10px; right: 20px; z-index: 9" type="primary" @click="copyText(item.code)">复制代码</el-button>
|
||||||
<highlightjs autodetect :code="item.code"/>
|
<el-scrollbar height="calc(100vh - 300px)">
|
||||||
</el-scrollbar>
|
<highlightjs autodetect :code="item.code" />
|
||||||
</el-tab-pane>
|
</el-scrollbar>
|
||||||
</el-tabs>
|
</el-tab-pane>
|
||||||
</pane>
|
</el-tabs>
|
||||||
</splitpanes>
|
</pane>
|
||||||
</el-dialog>
|
</splitpanes>
|
||||||
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts" name="preview">
|
<script setup lang="ts" name="preview">
|
||||||
import {useGeneratorPreviewApi} from '/@/api/gen/table';
|
import { useGeneratorPreviewApi } from '/@/api/gen/table';
|
||||||
import {handleTree} from '/@/utils/other';
|
import { handleTree } from '/@/utils/other';
|
||||||
|
import commonFunction from '/@/utils/commonFunction';
|
||||||
|
|
||||||
|
const { copyText } = commonFunction();
|
||||||
|
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
// ======== 显示页面 ========
|
// ======== 显示页面 ========
|
||||||
const preview = reactive({
|
const preview = reactive({
|
||||||
open: false,
|
open: false,
|
||||||
titel: '代码预览',
|
titel: '代码预览',
|
||||||
fileTree: [],
|
fileTree: [],
|
||||||
activeName: '',
|
activeName: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const previewCodegen = ref([]);
|
const previewCodegen = ref([]);
|
||||||
const fileTreeOriginal = ref([] as any[]);
|
const fileTreeOriginal = ref([] as any[]);
|
||||||
|
|
||||||
const openDialog = async (id: string) => {
|
const openDialog = async (id: string) => {
|
||||||
await getGenCodeFile(id);
|
await getGenCodeFile(id);
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
@ -58,29 +62,29 @@ const loading = ref(false);
|
|||||||
* @param id 需要渲染的资源 ID。
|
* @param id 需要渲染的资源 ID。
|
||||||
*/
|
*/
|
||||||
const getGenCodeFile = (id: string) => {
|
const getGenCodeFile = (id: string) => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
fileTreeOriginal.value = [];
|
fileTreeOriginal.value = [];
|
||||||
useGeneratorPreviewApi(id)
|
useGeneratorPreviewApi(id)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
previewCodegen.value = res;
|
previewCodegen.value = res;
|
||||||
for (let index in res) {
|
for (let index in res) {
|
||||||
fileTreeOriginal.value.push(res[index].codePath);
|
fileTreeOriginal.value.push(res[index].codePath);
|
||||||
}
|
}
|
||||||
// 默认选中第一个 选项卡
|
// 默认选中第一个 选项卡
|
||||||
preview.activeName = res[0].codePath;
|
preview.activeName = res[0].codePath;
|
||||||
const files = handleFiles(fileTreeOriginal);
|
const files = handleFiles(fileTreeOriginal);
|
||||||
preview.fileTree = handleTree(files, 'id', 'parentId', 'children', '/');
|
preview.fileTree = handleTree(files, 'id', 'parentId', 'children', '/');
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNodeClick = async (data: any, node: any) => {
|
const handleNodeClick = async (data: any, node: any) => {
|
||||||
if (node && !node.isLeaf) {
|
if (node && !node.isLeaf) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
preview.activeName = data.id;
|
preview.activeName = data.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,41 +93,41 @@ const handleNodeClick = async (data: any, node: any) => {
|
|||||||
* @returns {*[]}
|
* @returns {*[]}
|
||||||
*/
|
*/
|
||||||
const handleFiles = (fileTreeOriginal: any) => {
|
const handleFiles = (fileTreeOriginal: any) => {
|
||||||
const exists = {};
|
const exists = {};
|
||||||
const files = [] as any[];
|
const files = [] as any[];
|
||||||
|
|
||||||
// 遍历每个元素
|
// 遍历每个元素
|
||||||
for (const data of fileTreeOriginal.value) {
|
for (const data of fileTreeOriginal.value) {
|
||||||
let paths = [];
|
let paths = [];
|
||||||
if (data.includes('\\')) {
|
if (data.includes('\\')) {
|
||||||
paths = data.split('\\');
|
paths = data.split('\\');
|
||||||
} else {
|
} else {
|
||||||
paths = data.split('/');
|
paths = data.split('/');
|
||||||
}
|
}
|
||||||
let fullPath = ''; // 从头开始的路径,用于生成 id
|
let fullPath = ''; // 从头开始的路径,用于生成 id
|
||||||
// 遍历每个 path, 拼接成树
|
// 遍历每个 path, 拼接成树
|
||||||
for (let i = 0; i < paths.length; i++) {
|
for (let i = 0; i < paths.length; i++) {
|
||||||
// 已经添加到 files 中,则跳过
|
// 已经添加到 files 中,则跳过
|
||||||
const oldFullPath = fullPath;
|
const oldFullPath = fullPath;
|
||||||
// 下面的 replaceAll 的原因,是因为上面包处理了,导致和 tabs 不匹配,所以 replaceAll 下
|
// 下面的 replaceAll 的原因,是因为上面包处理了,导致和 tabs 不匹配,所以 replaceAll 下
|
||||||
fullPath = fullPath.length === 0 ? paths[i] : fullPath.replaceAll('.', '/') + '/' + paths[i];
|
fullPath = fullPath.length === 0 ? paths[i] : fullPath.replaceAll('.', '/') + '/' + paths[i];
|
||||||
if (exists[fullPath]) {
|
if (exists[fullPath]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 添加到 files 中
|
// 添加到 files 中
|
||||||
exists[fullPath] = true;
|
exists[fullPath] = true;
|
||||||
files.push({
|
files.push({
|
||||||
id: fullPath,
|
id: fullPath,
|
||||||
label: paths[i],
|
label: paths[i],
|
||||||
parentId: oldFullPath || '/',
|
parentId: oldFullPath || '/',
|
||||||
templateName: data.k,
|
templateName: data.k,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
};
|
};
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
openDialog,
|
openDialog,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -6,8 +6,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<el-row :gutter="10" v-if="favoriteRoutes.length > 0">
|
<el-row :gutter="10" v-if="favoriteRoutes.length > 0">
|
||||||
<el-col :span="6" :key="shortcut.id" v-for="shortcut in favoriteRoutes">
|
<el-col class="shortcutCard" :span="6" :key="shortcut.id" v-for="(shortcut, index) in favoriteRoutes">
|
||||||
|
<div class="shortcutCardClose" @click="handleCloseFavorite(shortcut)">×</div>
|
||||||
<shortcutCard :icon="shortcut.meta?.icon" :label="shortcut.name" @click="handleRoute(shortcut.path)" />
|
<shortcutCard :icon="shortcut.meta?.icon" :label="shortcut.name" @click="handleRoute(shortcut.path)" />
|
||||||
|
<!-- <el-icon v-if="index == currentIndex"><CircleCloseFilled /></el-icon> -->
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-empty :description="$t('home.addFavoriteRoutesTip')" v-else />
|
<el-empty :description="$t('home.addFavoriteRoutesTip')" v-else />
|
||||||
@ -44,4 +46,31 @@ const handleRoute = (path: string) => {
|
|||||||
const handleCloseFavorite = (item: any) => {
|
const handleCloseFavorite = (item: any) => {
|
||||||
storesTagsViewRoutes.delFavoriteRoutes(item); // 从收藏路由列表中删除指定路由
|
storesTagsViewRoutes.delFavoriteRoutes(item); // 从收藏路由列表中删除指定路由
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* */
|
||||||
|
let currentIndex = ref();
|
||||||
|
|
||||||
|
/* */
|
||||||
|
const handleShowCloseBtn = (item: any, index: any) => {
|
||||||
|
currentIndex.value = index;
|
||||||
|
};
|
||||||
|
/* */
|
||||||
|
const handleHideCloseBtn = () => {
|
||||||
|
currentIndex.value = null;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.shortcutCard {
|
||||||
|
position: relative;
|
||||||
|
.shortcutCardClose {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 50%;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
color: #6d6b6b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-calendar v-model="calendar">
|
<el-card class="box-card" style="height: 100%; overflow: auto">
|
||||||
<template #date-cell="{ data }">
|
<template #header> 日程 </template>
|
||||||
<div class="calendar-cell" @click="handleSchedule(data)">
|
<el-calendar v-model="calendar">
|
||||||
{{ data.day.split('-').slice(2).join('-') }}
|
<template #date-cell="{ data }">
|
||||||
<div class="box-yello" v-if="filterCellSelected(data)"></div>
|
<div class="calendar-cell" @click="handleSchedule(data)">
|
||||||
</div>
|
{{ data.day.split('-').slice(2).join('-') }}
|
||||||
</template>
|
<div class="box-yello" v-if="filterCellSelected(data)"></div>
|
||||||
</el-calendar>
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-calendar>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
<!-- 新增日程的表单 -->
|
<!-- 新增日程的表单 -->
|
||||||
<schedule-form ref="scheduleFormRef" @refresh="initscheduleList(formatDate(calendar, 'YYYY-mm'))" />
|
<schedule-form ref="scheduleFormRef" @refresh="initscheduleList(formatDate(calendar, 'YYYY-mm'))" />
|
||||||
|
Loading…
Reference in New Issue
Block a user