fix: MyEvent事件移除
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
|
||||
class MyEvent{
|
||||
static list = []
|
||||
add(name,call){
|
||||
MyEvent.list.push({name,call})
|
||||
}
|
||||
remove(name,call){
|
||||
MyEvent.list.filter(item=>item.name!=name&&item.call!=call)
|
||||
}
|
||||
emit(name,data){
|
||||
MyEvent.list.forEach(item => {
|
||||
if(item.name == name)item.call(data)
|
||||
});
|
||||
}
|
||||
class MyEvent {
|
||||
static list = []
|
||||
add(name, call) {
|
||||
MyEvent.list.push({ name, call })
|
||||
}
|
||||
remove(name, call) {
|
||||
MyEvent.list = MyEvent.list.filter(item => item.name != name && item.call != call)
|
||||
}
|
||||
emit(name, data) {
|
||||
MyEvent.list.forEach(item => {
|
||||
if (item.name == name) item.call(data)
|
||||
})
|
||||
}
|
||||
}
|
||||
export default new MyEvent()
|
||||
@@ -24,21 +24,31 @@
|
||||
bordered: false,
|
||||
showQuickJumper: true,
|
||||
showSizeChanger: false,
|
||||
size:'small'
|
||||
size: 'small'
|
||||
}"
|
||||
>
|
||||
<template #bodyCell="{ column, text, record, index }">
|
||||
<div class="operate_list" v-if="column?.Operations">
|
||||
<div
|
||||
class="operate_item"
|
||||
:class="{ 'operate_item_hidden': !(record.process ==='SERIES_DESIGN' || record.process ==='SINGLE_DESIGN') }"
|
||||
:class="{
|
||||
operate_item_hidden: !(
|
||||
record.process === 'SERIES_DESIGN' ||
|
||||
record.process === 'SINGLE_DESIGN'
|
||||
)
|
||||
}"
|
||||
@click="turnToDetail(record)"
|
||||
>
|
||||
{{ $t('HistoryPage.Detail') }}
|
||||
</div>
|
||||
<div
|
||||
class="operate_item"
|
||||
:class="{ 'operate_item_hidden': !(record.process ==='SERIES_DESIGN' || record.process ==='SINGLE_DESIGN') }"
|
||||
:class="{
|
||||
operate_item_hidden: !(
|
||||
record.process === 'SERIES_DESIGN' ||
|
||||
record.process === 'SINGLE_DESIGN'
|
||||
)
|
||||
}"
|
||||
@click="renameCollection(record, index)"
|
||||
>
|
||||
{{ $t('HistoryPage.Edit') }}
|
||||
@@ -91,7 +101,7 @@ import TableSearchBar from '@/component/common/TableSearchBar.vue'
|
||||
import projectSetting from '@/component/home/newProject/setting.vue'
|
||||
import { useStore } from 'vuex'
|
||||
import router from '@/router'
|
||||
import MyEvent from "@/tool/myEvents";
|
||||
import MyEvent from '@/tool/myEvents'
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@@ -250,8 +260,8 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
MyEvent.add('remChange',this.setPageSize)
|
||||
this.setPageSize();
|
||||
MyEvent.add('remChange', this.setPageSize)
|
||||
this.setPageSize()
|
||||
await this.getHistoryList()
|
||||
this.$nextTick(() => {
|
||||
this.calcScrollHeight()
|
||||
@@ -260,24 +270,24 @@ export default defineComponent({
|
||||
this.getClass()
|
||||
},
|
||||
beforeUnmount() {
|
||||
MyEvent.remove('remChange',this.setPageSize)
|
||||
MyEvent.remove('remChange', this.setPageSize)
|
||||
if (this.resizeObserver) {
|
||||
this.resizeObserver.disconnect()
|
||||
this.resizeObserver = null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setPageSize(rem){
|
||||
const historyTable = this.$refs.historyTable
|
||||
const height = historyTable.offsetHeight;
|
||||
const size = Math.trunc((height - 110) / 54);
|
||||
this.pageSize = size || 1
|
||||
if(rem){
|
||||
this.currentPage = 1
|
||||
this.getHistoryList()
|
||||
}
|
||||
console.log("==========size:"+size+" rem:"+rem+" height:"+height)
|
||||
},
|
||||
setPageSize(rem) {
|
||||
const historyTable = this.$refs.historyTable
|
||||
const height = historyTable.offsetHeight
|
||||
const size = Math.trunc((height - 110) / 54)
|
||||
this.pageSize = size || 1
|
||||
if (rem) {
|
||||
this.currentPage = 1
|
||||
this.getHistoryList()
|
||||
}
|
||||
console.log('==========size:' + size + ' rem:' + rem + ' height:' + height)
|
||||
},
|
||||
getClass() {
|
||||
let data = {
|
||||
classificationIdList: [],
|
||||
@@ -438,10 +448,10 @@ export default defineComponent({
|
||||
renameCollection(record: any, index: number) {
|
||||
// let searchLabel: any = this.$refs.searchLabel
|
||||
// searchLabel.init(record, index)
|
||||
this.$refs.projectSetting.init(record,'edit')
|
||||
this.$refs.projectSetting.init(record, 'edit')
|
||||
},
|
||||
handleConfirmEdit({ data }) {
|
||||
// router.push(`/home?history=${data.id}`)
|
||||
// router.push(`/home?history=${data.id}`)
|
||||
this.getHistoryList()
|
||||
},
|
||||
retrieveHome(record: any) {
|
||||
@@ -640,30 +650,32 @@ export default defineComponent({
|
||||
padding: 3rem 0 0;
|
||||
box-sizing: border-box;
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.history_table_content {
|
||||
margin-top: 2.6rem;
|
||||
width: 100%;
|
||||
background: #f5f5f5;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
// height: calc(100% - 4rem);
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
// height: calc(100% - 4rem);
|
||||
// padding-bottom: 3rem;
|
||||
|
||||
:deep(.ant-table-wrapper) {
|
||||
height: 100%;
|
||||
.ant-spin-nested-loading {
|
||||
&,
|
||||
&,
|
||||
.ant-spin-container {
|
||||
height: 100%;
|
||||
.ant-table{
|
||||
flex: 1;
|
||||
.ant-table-container,.ant-table-content,table{
|
||||
// height: 100%;
|
||||
}
|
||||
}
|
||||
.ant-table {
|
||||
flex: 1;
|
||||
// .ant-table-container,
|
||||
// .ant-table-content,
|
||||
// table {
|
||||
// height: 100%;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -686,11 +698,11 @@ export default defineComponent({
|
||||
width: 0 !important;
|
||||
}
|
||||
}
|
||||
:deep(.ant-table-content) {
|
||||
// max-height: v-bind(historyTableHeight);
|
||||
// overflow-y: v-bind(scrolled);
|
||||
}
|
||||
|
||||
// :deep(.ant-table-content) {
|
||||
// max-height: v-bind(historyTableHeight);
|
||||
// overflow-y: v-bind(scrolled);
|
||||
// }
|
||||
|
||||
:deep(.ant-table-thead > tr > th) {
|
||||
// background: #ffffff;
|
||||
background: transparent;
|
||||
@@ -705,28 +717,28 @@ export default defineComponent({
|
||||
.ant-table-pagination-right {
|
||||
justify-content: center;
|
||||
}
|
||||
:deep(.ant-pagination-prev),
|
||||
:deep(.ant-pagination-next),
|
||||
:deep(.ant-pagination-jump-prev),
|
||||
:deep(.ant-pagination-jump-next),
|
||||
:deep(.ant-pagination-item){
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
min-width: 4rem;
|
||||
line-height: 4rem;
|
||||
margin-right: .8rem;
|
||||
}
|
||||
:deep(.ant-pagination-options-quick-jumper){
|
||||
height: 4rem;
|
||||
line-height: 4rem;
|
||||
margin-left: .8rem;
|
||||
font-size: 1.6rem;
|
||||
> input{
|
||||
width: 7rem;
|
||||
height: 4rem;
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
}
|
||||
:deep(.ant-pagination-prev),
|
||||
:deep(.ant-pagination-next),
|
||||
:deep(.ant-pagination-jump-prev),
|
||||
:deep(.ant-pagination-jump-next),
|
||||
:deep(.ant-pagination-item) {
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
min-width: 4rem;
|
||||
line-height: 4rem;
|
||||
margin-right: 0.8rem;
|
||||
}
|
||||
:deep(.ant-pagination-options-quick-jumper) {
|
||||
height: 4rem;
|
||||
line-height: 4rem;
|
||||
margin-left: 0.8rem;
|
||||
font-size: 1.6rem;
|
||||
> input {
|
||||
width: 7rem;
|
||||
height: 4rem;
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
}
|
||||
.ant-table-pagination-right {
|
||||
padding-right: 3.5rem;
|
||||
}
|
||||
@@ -764,7 +776,7 @@ export default defineComponent({
|
||||
font-weight: 400;
|
||||
color: #007ee5;
|
||||
cursor: pointer;
|
||||
|
||||
|
||||
&.operate_item_hidden {
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
|
||||
Reference in New Issue
Block a user