mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
完成编辑和新建的跳转
This commit is contained in:
parent
1ae9197d89
commit
4647caf383
@ -2,7 +2,7 @@ import { ResultEnum } from '@/enums/httpEnum'
|
|||||||
|
|
||||||
export enum ChartEnum {
|
export enum ChartEnum {
|
||||||
// 图表创建
|
// 图表创建
|
||||||
CHART_HOME = '/chart/home/:id',
|
CHART_HOME = '/chart/home/:id(.*)*',
|
||||||
CHART_HOME_NAME = 'ChartHome',
|
CHART_HOME_NAME = 'ChartHome',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
import { ResultEnum } from '@/enums/httpEnum'
|
import { ResultEnum } from '@/enums/httpEnum'
|
||||||
import { ErrorPageNameMap, PageEnum } from '@/enums/pageEnum'
|
import { ErrorPageNameMap, PageEnum } from '@/enums/pageEnum'
|
||||||
|
import { RouteLocation } from 'vue-router'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { docPath, giteeSourceCodePath } from '@/settings/pathConst'
|
import { docPath, giteeSourceCodePath } from '@/settings/pathConst'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 根据名字跳转路由
|
* * 根据名字跳转路由
|
||||||
* @param pageName
|
* @param pageName
|
||||||
|
* @param isReplace
|
||||||
|
* @param windowOpen
|
||||||
*/
|
*/
|
||||||
export const routerTurnByName = (pageName: string, isReplace?: boolean, windowOpen?: boolean) => {
|
export const routerTurnByName = (
|
||||||
|
pageName: string,
|
||||||
|
isReplace?: boolean,
|
||||||
|
windowOpen?: boolean
|
||||||
|
) => {
|
||||||
if (windowOpen) {
|
if (windowOpen) {
|
||||||
const path = router.resolve({
|
const path = fetchPathByName(pageName, 'href')
|
||||||
name: pageName
|
openNewWindow(path)
|
||||||
})
|
|
||||||
openNewWindow(path.href)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (isReplace) {
|
if (isReplace) {
|
||||||
@ -26,6 +31,49 @@ export const routerTurnByName = (pageName: string, isReplace?: boolean, windowOp
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 根据名称获取路由信息
|
||||||
|
* @param pageName
|
||||||
|
* @param pageName
|
||||||
|
*/
|
||||||
|
export const fetchPathByName = (pageName: string, p?: string) => {
|
||||||
|
const pathData = router.resolve({
|
||||||
|
name: pageName
|
||||||
|
})
|
||||||
|
return p ? (pathData as any)[p] : pathData
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 根据路径跳转路由
|
||||||
|
* @param { String } path
|
||||||
|
* @param { Array } query
|
||||||
|
* @param isReplace
|
||||||
|
*/
|
||||||
|
export const routerTurnByPath = (
|
||||||
|
path: string,
|
||||||
|
query?: Array<string | number>,
|
||||||
|
isReplace?: boolean,
|
||||||
|
windowOpen?: boolean
|
||||||
|
) => {
|
||||||
|
let fullPath = ''
|
||||||
|
if (query?.length) {
|
||||||
|
fullPath = `${path}/${query.join('/')}`
|
||||||
|
}
|
||||||
|
if (windowOpen) {
|
||||||
|
openNewWindow(fullPath)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (isReplace) {
|
||||||
|
router.replace({
|
||||||
|
path: fullPath
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
router.push({
|
||||||
|
path: fullPath
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 错误页重定向
|
* * 错误页重定向
|
||||||
* @param icon
|
* @param icon
|
||||||
@ -49,7 +97,7 @@ export const logout = () => {
|
|||||||
* * 新开页面
|
* * 新开页面
|
||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
export const openNewWindow = (url: string) => {
|
export const openNewWindow = (url: string) => {
|
||||||
window.open(url, 'blank')
|
window.open(url, 'blank')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,4 +116,3 @@ export const openDoc = () => {
|
|||||||
export const openGiteeSourceCode = () => {
|
export const openGiteeSourceCode = () => {
|
||||||
openNewWindow(giteeSourceCodePath)
|
openNewWindow(giteeSourceCodePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
<n-tooltip v-else placement="bottom" trigger="hover">
|
<n-tooltip v-else placement="bottom" trigger="hover">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<n-button size="small">
|
<n-button size="small" @click="handleSelect(item.key)">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<component :is="item.icon" />
|
<component :is="item.icon" />
|
||||||
</template>
|
</template>
|
||||||
@ -98,7 +98,7 @@ const {
|
|||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
||||||
const emit = defineEmits(['delete', 'resize'])
|
const emit = defineEmits(['delete', 'resize', 'edit'])
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
cardData: Object
|
cardData: Object
|
||||||
@ -163,6 +163,9 @@ const handleSelect = (key: string) => {
|
|||||||
case 'delete':
|
case 'delete':
|
||||||
deleteHanlde()
|
deleteHanlde()
|
||||||
break
|
break
|
||||||
|
case 'edit':
|
||||||
|
editHandle()
|
||||||
|
break
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
@ -174,6 +177,11 @@ const deleteHanlde = () => {
|
|||||||
emit('delete', props.cardData)
|
emit('delete', props.cardData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 编辑处理
|
||||||
|
const editHandle = () => {
|
||||||
|
emit('edit', props.cardData)
|
||||||
|
}
|
||||||
|
|
||||||
// 放大处理
|
// 放大处理
|
||||||
const resizeHandle = () => {
|
const resizeHandle = () => {
|
||||||
emit('resize', props.cardData)
|
emit('resize', props.cardData)
|
||||||
|
@ -1,27 +1,34 @@
|
|||||||
import { ref, Ref } from 'vue'
|
import { ref, Ref } from 'vue'
|
||||||
|
import { ChartEnum } from '@/enums/pageEnum'
|
||||||
|
import { fetchPathByName, routerTurnByPath } from '@/utils'
|
||||||
export const useModalDataInit = () => {
|
export const useModalDataInit = () => {
|
||||||
const modalShow = ref<boolean>(false)
|
const modalShow = ref<boolean>(false)
|
||||||
|
// TODO 补充 modalData 类型格式
|
||||||
const modalData = ref<object | unknown>(null)
|
const modalData = ref<object | unknown>(null)
|
||||||
|
|
||||||
// 关闭 modal
|
// 关闭 modal
|
||||||
const closeModal = () => {
|
const closeModal = () => {
|
||||||
modalShow.value = false
|
modalShow.value = false
|
||||||
modalData.value = null
|
modalData.value = null
|
||||||
console.log('close')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开 modal
|
// 打开 modal
|
||||||
const resizeHandle = (cardData: Ref<object | unknown>) => {
|
const resizeHandle = (cardData: Ref<object | unknown>) => {
|
||||||
console.log(cardData)
|
|
||||||
modalShow.value = true
|
modalShow.value = true
|
||||||
modalData.value = cardData
|
modalData.value = cardData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 打开 modal
|
||||||
|
const editHandle = (cardData: Ref<object | unknown>) => {
|
||||||
|
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
|
||||||
|
routerTurnByPath(path, [(<any>cardData).id], undefined, true)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
modalData,
|
modalData,
|
||||||
modalShow,
|
modalShow,
|
||||||
closeModal,
|
closeModal,
|
||||||
resizeHandle
|
resizeHandle,
|
||||||
|
editHandle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,16 @@
|
|||||||
:cardData="item"
|
:cardData="item"
|
||||||
@resize="resizeHandle"
|
@resize="resizeHandle"
|
||||||
@delete="deleteHandle($event, index)"
|
@delete="deleteHandle($event, index)"
|
||||||
|
@edit="editHandle"
|
||||||
/>
|
/>
|
||||||
</n-grid-item>
|
</n-grid-item>
|
||||||
</n-grid>
|
</n-grid>
|
||||||
</div>
|
</div>
|
||||||
<ModalCard v-model:show="modalShow" :cardData="modalData" @close="closeModal" />
|
<ModalCard
|
||||||
|
v-model:show="modalShow"
|
||||||
|
:cardData="modalData"
|
||||||
|
@close="closeModal"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -27,10 +32,14 @@ import { useModalDataInit } from './hooks/useModal.hook'
|
|||||||
import { useDataListInit } from './hooks/useData.hook'
|
import { useDataListInit } from './hooks/useData.hook'
|
||||||
|
|
||||||
const { CopyIcon, EllipsisHorizontalCircleSharpIcon } = icon.ionicons5
|
const { CopyIcon, EllipsisHorizontalCircleSharpIcon } = icon.ionicons5
|
||||||
|
|
||||||
const { modalData, modalShow, closeModal, resizeHandle } = useModalDataInit()
|
|
||||||
|
|
||||||
const { list, deleteHandle } = useDataListInit()
|
const { list, deleteHandle } = useDataListInit()
|
||||||
|
const {
|
||||||
|
modalData,
|
||||||
|
modalShow,
|
||||||
|
closeModal,
|
||||||
|
resizeHandle,
|
||||||
|
editHandle
|
||||||
|
} = useModalDataInit()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -5,28 +5,40 @@
|
|||||||
<div class="top-content">
|
<div class="top-content">
|
||||||
<n-carousel class="top-content-carousel" show-arrow>
|
<n-carousel class="top-content-carousel" show-arrow>
|
||||||
<n-card title="模板1" hoverable>
|
<n-card title="模板1" hoverable>
|
||||||
<img
|
<n-space>
|
||||||
class="carousel-img"
|
<img
|
||||||
src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel1.jpeg"
|
class="carousel-img"
|
||||||
/>
|
src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel3.jpeg"
|
||||||
|
/>
|
||||||
|
<n-text>这里是介绍拉巴拉巴拉巴拉</n-text>
|
||||||
|
</n-space>
|
||||||
</n-card>
|
</n-card>
|
||||||
<n-card title="模板2" hoverable>
|
<n-card title="模板2" hoverable>
|
||||||
<img
|
<n-space>
|
||||||
class="carousel-img"
|
<img
|
||||||
src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel2.jpeg"
|
class="carousel-img"
|
||||||
/>
|
src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel2.jpeg"
|
||||||
|
/>
|
||||||
|
<n-text>这里是介绍拉巴拉巴拉巴拉</n-text>
|
||||||
|
</n-space>
|
||||||
</n-card>
|
</n-card>
|
||||||
<n-card title="模板2" hoverable>
|
<n-card title="模板2" hoverable>
|
||||||
<img
|
<n-space>
|
||||||
class="carousel-img"
|
<img
|
||||||
src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel3.jpeg"
|
class="carousel-img"
|
||||||
/>
|
src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel3.jpeg"
|
||||||
|
/>
|
||||||
|
<n-text>这里是介绍拉巴拉巴拉巴拉</n-text>
|
||||||
|
</n-space>
|
||||||
</n-card>
|
</n-card>
|
||||||
<n-card title="模板2" hoverable>
|
<n-card title="模板2" hoverable>
|
||||||
<img
|
<n-space>
|
||||||
class="carousel-img"
|
<img
|
||||||
src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel4.jpeg"
|
class="carousel-img"
|
||||||
/>
|
src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel4.jpeg"
|
||||||
|
/>
|
||||||
|
<n-text>这里是介绍拉巴拉巴拉巴拉</n-text>
|
||||||
|
</n-space>
|
||||||
</n-card>
|
</n-card>
|
||||||
</n-carousel>
|
</n-carousel>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user