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() {
nextTick(() => {
console.log("selectedValue1", modelValue)
const selectedValue = modelValue.value;
console.log("selectedValue", modelValue.value)
if (selectedValue !== null && typeof (selectedValue) !== "undefined") {
const node = proxy.$refs.selectTree.getNode(selectedValue)
if (node) {

View File

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

View File

@@ -1,9 +1,9 @@
<template>
<section class="app-main">
<router-view v-slot="{ Component }">
<router-view v-slot="{ Component ,route}">
<transition name="router-fade" mode="out-in">
<keep-alive :include="cachedViews()">
<component :is="Component" :key="key"/>
<keep-alive :include="cachedViews">
<component :is="Component" :key="route.path"/>
</keep-alive>
</transition>
</router-view>
@@ -11,26 +11,11 @@
</template>
<script lang="ts">
import {defineComponent} from "vue";
import {useRoute} from "vue-router";
<script setup lang="ts">
import {computed} from "vue";
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>

View File

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

View File

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

View File

@@ -38,7 +38,7 @@ export interface TagView extends Partial<RouteLocationNormalized> {
export interface TagsViewState{
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 => {
this.visitedViews = this.visitedViews.filter(v => {
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 => {
const index = this.cachedViews.indexOf(view.name)
if (index > -1) {
@@ -90,10 +90,10 @@ const tagsViewStore = defineStore({
})
})
},
delOthersViews(view: any) {
delOtherViews(view: any) {
return new Promise(resolve => {
this.delOthersVisitedViews(view)
this.delOthersCachedViews(view)
this.delOtherVisitedViews(view)
this.delOtherCachedViews(view)
resolve({
visitedViews: [...this.visitedViews],
cachedViews: [...this.cachedViews]

View File

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

View File

@@ -202,7 +202,7 @@ const state = reactive({
parentId: '',
name: '',
sort: 1,
status: 1
status: 1
},
// 表单参数校验
rules: {
@@ -269,16 +269,17 @@ function resetForm() {
parentId: '',
name: '',
sort: 1,
status: 1
status: 1
}
}
/**
* 添加部门
*/
function handleAdd() {
function handleAdd(row: any) {
resetForm()
loadDeptOptions()
state.formData.parentId = row.id
state.dialog = {
title: '添加部门',
visible: true
@@ -340,7 +341,7 @@ function handleDelete(row: any) {
deleteDept(ids).then(() => {
handleQuery()
ElMessage.success('删除成功')
}).catch(()=> {
}).catch(() => {
console.log(`删除失败`)
})
}).catch(() =>