fix: 修复typescript一些编译报错

This commit is contained in:
郝先瑞
2022-01-19 23:40:25 +08:00
parent 16ebb4eb22
commit 9e15f53869
9 changed files with 74 additions and 61 deletions

View File

@@ -84,9 +84,7 @@ const defaultExpandedKey = ref([]);
function initHandle() { function initHandle() {
nextTick(() => { nextTick(() => {
console.log("selectedValue1", modelValue)
const selectedValue = modelValue.value; const selectedValue = modelValue.value;
console.log("selectedValue", modelValue.value)
if (selectedValue !== null && typeof (selectedValue) !== "undefined") { if (selectedValue !== null && typeof (selectedValue) !== "undefined") {
const node = proxy.$refs.selectTree.getNode(selectedValue) const node = proxy.$refs.selectTree.getNode(selectedValue)
if (node) { if (node) {

View File

@@ -30,7 +30,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {computed, reactive, toRefs} from "vue"; import {computed, reactive} from "vue";
import {Plus, Close} from '@element-plus/icons-vue' import {Plus, Close} from '@element-plus/icons-vue'
import {ElMessage} from "element-plus" import {ElMessage} from "element-plus"
import {uploadFile, deleteFile} from "@/api/system/file"; import {uploadFile, deleteFile} from "@/api/system/file";

View File

@@ -1,9 +1,9 @@
<template> <template>
<section class="app-main"> <section class="app-main">
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component ,route}">
<transition name="router-fade" mode="out-in"> <transition name="router-fade" mode="out-in">
<keep-alive :include="cachedViews()"> <keep-alive :include="cachedViews">
<component :is="Component" :key="key"/> <component :is="Component" :key="route.path"/>
</keep-alive> </keep-alive>
</transition> </transition>
</router-view> </router-view>
@@ -11,26 +11,11 @@
</template> </template>
<script lang="ts"> <script setup lang="ts">
import {defineComponent} from "vue"; import {computed} from "vue";
import {useRoute} from "vue-router";
import {tagsViewStoreHook} from '@/store/modules/tagsView' import {tagsViewStoreHook} from '@/store/modules/tagsView'
export default defineComponent({
setup() {
const route = useRoute()
const cachedViews = () => {
return tagsViewStoreHook().cachedViews
}
const key = () => {
return route.path
}
return {
cachedViews,
key
}
}
}) const cachedViews = computed(() => tagsViewStoreHook().cachedViews);
</script> </script>

View File

@@ -53,7 +53,7 @@ const props = defineProps({
} }
}) })
const onlyOneChild = ref({}); const onlyOneChild = ref();
function hasOneShowingChild(children = [] as any, parent: RouteRecordRaw) { function hasOneShowingChild(children = [] as any, parent: RouteRecordRaw) {
if (!children) { if (!children) {

View File

@@ -18,22 +18,28 @@
</scroll-pane> </scroll-pane>
<ul v-show="visible" :style="{left:left+'px',top:top+'px'}" class="contextmenu"> <ul v-show="visible" :style="{left:left+'px',top:top+'px'}" class="contextmenu">
<li @click="refreshSelectedTag(selectedTag)"> <li @click="refreshSelectedTag(selectedTag)">
<refresh-right style="width: 1em; height: 1em;"/> 刷新 <refresh-right style="width: 1em; height: 1em;"/>
刷新
</li> </li>
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)"> <li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">
<close style="width: 1em; height: 1em;"/>关闭 <close style="width: 1em; height: 1em;"/>
关闭
</li> </li>
<li @click="closeOthersTags"> <li @click="closeOtherTags">
<circle-close style="width: 1em; height: 1em;"/>关闭其它 <circle-close style="width: 1em; height: 1em;"/>
关闭其它
</li> </li>
<li v-if="!isFirstView()" @click="closeLeftTags"> <li v-if="!isFirstView()" @click="closeLeftTags">
<back style="width: 1em; height: 1em;"/>关闭左侧 <back style="width: 1em; height: 1em;"/>
关闭左侧
</li> </li>
<li v-if="!isLastView()" @click="closeRightTags"> <li v-if="!isLastView()" @click="closeRightTags">
<right style="width: 1em; height: 1em;"/>关闭右侧 <right style="width: 1em; height: 1em;"/>
关闭右侧
</li> </li>
<li @click="closeAllTags(selectedTag)"> <li @click="closeAllTags(selectedTag)">
<circle-close style="width: 1em; height: 1em;"/>关闭所有 <circle-close style="width: 1em; height: 1em;"/>
关闭所有
</li> </li>
</ul> </ul>
</div> </div>
@@ -68,7 +74,7 @@ const routes = computed(() => usePermissionStoreHook().routes)
const affixTags = ref([]); const affixTags = ref([]);
const visible = ref(false); const visible = ref(false);
const selectedTag = ref({}); const selectedTag = ref({});
const scrollPaneRef = ref(null); const scrollPaneRef = ref();
const left = ref(0); const left = ref(0);
const top = ref(0); const top = ref(0);
@@ -173,15 +179,13 @@ function refreshSelectedTag(view: TagView) {
tagsViewStoreHook().delCachedView(view) tagsViewStoreHook().delCachedView(view)
const {fullPath} = view const {fullPath} = view
nextTick(() => { nextTick(() => {
console.log('fullPath',fullPath)
router.replace({path: '/redirect' + fullPath}).catch(err => { router.replace({path: '/redirect' + fullPath}).catch(err => {
console.warn(err) console.warn(err)
}) })
}) })
} }
function toLastView(visitedViews: TagView[], view: TagView) { function toLastView(visitedViews: TagView[], view?: any) {
const latestView = visitedViews.slice(-1)[0] const latestView = visitedViews.slice(-1)[0]
if (latestView && latestView.fullPath) { if (latestView && latestView.fullPath) {
router.push(latestView.fullPath) router.push(latestView.fullPath)
@@ -198,29 +202,44 @@ function toLastView(visitedViews: TagView[], view: TagView) {
} }
function closeSelectedTag(view: TagView) { function closeSelectedTag(view: TagView) {
tagsViewStoreHook().delView(view).then(({visitedViews}) => { tagsViewStoreHook().delView(view).then((res: any) => {
if (isActive(view)) { if (isActive(view)) {
toLastView(visitedViews, view) toLastView(res.visitedViews, view)
} }
}) })
} }
function closeLeftTags() { function closeLeftTags() {
tagsViewStoreHook().delLeftViews(selectedTag.value).then(({visitedViews}) => { tagsViewStoreHook().delLeftViews(selectedTag.value).then((res: any) => {
if (!visitedViews.find(i => i.fullPath === route.fullPath)) { if (!res.visitedViews.find((item: any) => item.fullPath === route.fullPath)) {
toLastView(visitedViews) toLastView(res.visitedViews)
}
})
}
function closeRightTags() {
tagsViewStoreHook().delRightViews(selectedTag.value).then((res:any) => {
if (!res.visitedViews.find((item:any) => item.fullPath === route.fullPath)) {
toLastView(res.visitedViews)
} }
}) })
} }
function closeRightTags() { function closeOtherTags() {
tagsViewStoreHook().delRightViews(selectedTag.value).then(({visitedViews}) => { tagsViewStoreHook().delOtherViews(selectedTag.value).then(() => {
if (!visitedViews.find(i => i.fullPath === route.fullPath)) { moveToCurrentTag()
toLastView(visitedViews)
}
}) })
} }
function closeAllTags(view: TagView) {
tagsViewStoreHook().delRightViews(selectedTag.value).then((res:any) => {
if (affixTags.value.some((tag:any) => tag.path === route.path)) {
return
}
toLastView(res.visitedViews, view)
})
}
function openMenu(tag: TagView, e: MouseEvent) { function openMenu(tag: TagView, e: MouseEvent) {
const menuMinWidth = 105 const menuMinWidth = 105
const offsetLeft = ctx.$el.getBoundingClientRect().left // container margin left const offsetLeft = ctx.$el.getBoundingClientRect().left // container margin left
@@ -261,6 +280,7 @@ onMounted(() => {
background: #fff; background: #fff;
border-bottom: 1px solid #d8dce5; border-bottom: 1px solid #d8dce5;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04); box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04);
.tags-view-wrapper { .tags-view-wrapper {
.tags-view-item { .tags-view-item {
display: inline-block; display: inline-block;
@@ -275,16 +295,20 @@ onMounted(() => {
font-size: 12px; font-size: 12px;
margin-left: 5px; margin-left: 5px;
margin-top: 4px; margin-top: 4px;
&:first-of-type { &:first-of-type {
margin-left: 15px; margin-left: 15px;
} }
&:last-of-type { &:last-of-type {
margin-right: 15px; margin-right: 15px;
} }
&.active { &.active {
background-color: #42b983; background-color: #42b983;
color: #fff; color: #fff;
border-color: #42b983; border-color: #42b983;
&::before { &::before {
content: ""; content: "";
background: #fff; background: #fff;
@@ -298,6 +322,7 @@ onMounted(() => {
} }
} }
} }
.contextmenu { .contextmenu {
margin: 0; margin: 0;
background: #fff; background: #fff;
@@ -310,10 +335,12 @@ onMounted(() => {
font-weight: 400; font-weight: 400;
color: #333; color: #333;
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3); box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
li { li {
margin: 0; margin: 0;
padding: 7px 16px; padding: 7px 16px;
cursor: pointer; cursor: pointer;
&:hover { &:hover {
background: #eee; background: #eee;
} }
@@ -334,11 +361,13 @@ onMounted(() => {
text-align: center; text-align: center;
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
transform-origin: 100% 50%; transform-origin: 100% 50%;
&:before { &:before {
transform: scale(0.6); transform: scale(0.6);
display: inline-block; display: inline-block;
vertical-align: -3px; vertical-align: -3px;
} }
&:hover { &:hover {
background-color: #b4bccc; background-color: #b4bccc;
color: #fff; color: #fff;

View File

@@ -38,7 +38,7 @@ export interface TagView extends Partial<RouteLocationNormalized> {
export interface TagsViewState{ export interface TagsViewState{
visitedViews: TagView[], visitedViews: TagView[],
cachedViews: (string|undefined)[] cachedViews: (string)[]
} }
// 顶级类型声明 // 顶级类型声明

View File

@@ -45,7 +45,7 @@ const tagsViewStore = defineStore({
}, },
delOthersVisitedViews(view: any) { delOtherVisitedViews(view: any) {
return new Promise(resolve => { return new Promise(resolve => {
this.visitedViews = this.visitedViews.filter(v => { this.visitedViews = this.visitedViews.filter(v => {
return v.meta?.affix || v.path === view.path return v.meta?.affix || v.path === view.path
@@ -54,7 +54,7 @@ const tagsViewStore = defineStore({
}) })
}, },
delOthersCachedViews(view: any) { delOtherCachedViews(view: any) {
return new Promise(resolve => { return new Promise(resolve => {
const index = this.cachedViews.indexOf(view.name) const index = this.cachedViews.indexOf(view.name)
if (index > -1) { if (index > -1) {
@@ -90,10 +90,10 @@ const tagsViewStore = defineStore({
}) })
}) })
}, },
delOthersViews(view: any) { delOtherViews(view: any) {
return new Promise(resolve => { return new Promise(resolve => {
this.delOthersVisitedViews(view) this.delOtherVisitedViews(view)
this.delOthersCachedViews(view) this.delOtherCachedViews(view)
resolve({ resolve({
visitedViews: [...this.visitedViews], visitedViews: [...this.visitedViews],
cachedViews: [...this.cachedViews] cachedViews: [...this.cachedViews]

View File

@@ -79,31 +79,31 @@
<el-table-column align="center" label="订单来源"> <el-table-column align="center" label="订单来源">
<template #default="scope"> <template #default="scope">
<el-tag>{{ scope.row.sourceType | orderSourceFilter }}</el-tag> <el-tag>{{ scope.row.sourceType }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="订单状态"> <el-table-column align="center" label="订单状态">
<template #default="scope"> <template #default="scope">
<el-tag>{{ scope.row.status | orderStatusFilter }}</el-tag> <el-tag>{{ scope.row.status }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" prop="orderPrice" label="订单金额"> <el-table-column align="center" prop="orderPrice" label="订单金额">
<template #default="scope"> <template #default="scope">
{{ scope.row.totalAmount | moneyFormatter }} {{ scope.row.totalAmount }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" prop="payPrice" label="支付金额"> <el-table-column align="center" prop="payPrice" label="支付金额">
<template #default="scope"> <template #default="scope">
{{ scope.row.payAmount | moneyFormatter }} {{ scope.row.payAmount }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="支付方式"> <el-table-column align="center" label="支付方式">
<template #default="scope"> <template #default="scope">
<el-tag>{{ scope.row.payType | payTypeFilter }}</el-tag> <el-tag>{{ scope.row.payType }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>

View File

@@ -276,9 +276,10 @@ function resetForm() {
/** /**
* 添加部门 * 添加部门
*/ */
function handleAdd() { function handleAdd(row: any) {
resetForm() resetForm()
loadDeptOptions() loadDeptOptions()
state.formData.parentId = row.id
state.dialog = { state.dialog = {
title: '添加部门', title: '添加部门',
visible: true visible: true