fix: MyEvent事件移除

This commit is contained in:
zhangyh
2025-10-22 16:21:59 +08:00
parent 6602945ebd
commit 569ffd2bf3
2 changed files with 85 additions and 74 deletions

View File

@@ -1,16 +1,15 @@
class MyEvent { class MyEvent {
static list = [] static list = []
add(name, call) { add(name, call) {
MyEvent.list.push({ name, call }) MyEvent.list.push({ name, call })
} }
remove(name, call) { remove(name, call) {
MyEvent.list.filter(item=>item.name!=name&&item.call!=call) MyEvent.list = MyEvent.list.filter(item => item.name != name && item.call != call)
} }
emit(name, data) { emit(name, data) {
MyEvent.list.forEach(item => { MyEvent.list.forEach(item => {
if (item.name == name) item.call(data) if (item.name == name) item.call(data)
}); })
} }
} }
export default new MyEvent() export default new MyEvent()

View File

@@ -31,14 +31,24 @@
<div class="operate_list" v-if="column?.Operations"> <div class="operate_list" v-if="column?.Operations">
<div <div
class="operate_item" 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)" @click="turnToDetail(record)"
> >
{{ $t('HistoryPage.Detail') }} {{ $t('HistoryPage.Detail') }}
</div> </div>
<div <div
class="operate_item" 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)" @click="renameCollection(record, index)"
> >
{{ $t('HistoryPage.Edit') }} {{ $t('HistoryPage.Edit') }}
@@ -91,7 +101,7 @@ import TableSearchBar from '@/component/common/TableSearchBar.vue'
import projectSetting from '@/component/home/newProject/setting.vue' import projectSetting from '@/component/home/newProject/setting.vue'
import { useStore } from 'vuex' import { useStore } from 'vuex'
import router from '@/router' import router from '@/router'
import MyEvent from "@/tool/myEvents"; import MyEvent from '@/tool/myEvents'
export default defineComponent({ export default defineComponent({
components: { components: {
@@ -251,7 +261,7 @@ export default defineComponent({
}, },
async mounted() { async mounted() {
MyEvent.add('remChange', this.setPageSize) MyEvent.add('remChange', this.setPageSize)
this.setPageSize(); this.setPageSize()
await this.getHistoryList() await this.getHistoryList()
this.$nextTick(() => { this.$nextTick(() => {
this.calcScrollHeight() this.calcScrollHeight()
@@ -269,14 +279,14 @@ export default defineComponent({
methods: { methods: {
setPageSize(rem) { setPageSize(rem) {
const historyTable = this.$refs.historyTable const historyTable = this.$refs.historyTable
const height = historyTable.offsetHeight; const height = historyTable.offsetHeight
const size = Math.trunc((height - 110) / 54); const size = Math.trunc((height - 110) / 54)
this.pageSize = size || 1 this.pageSize = size || 1
if (rem) { if (rem) {
this.currentPage = 1 this.currentPage = 1
this.getHistoryList() this.getHistoryList()
} }
console.log("==========size:"+size+" rem:"+rem+" height:"+height) console.log('==========size:' + size + ' rem:' + rem + ' height:' + height)
}, },
getClass() { getClass() {
let data = { let data = {
@@ -660,9 +670,11 @@ export default defineComponent({
height: 100%; height: 100%;
.ant-table { .ant-table {
flex: 1; flex: 1;
.ant-table-container,.ant-table-content,table{ // .ant-table-container,
// .ant-table-content,
// table {
// height: 100%; // height: 100%;
} // }
} }
} }
} }
@@ -686,10 +698,10 @@ export default defineComponent({
width: 0 !important; width: 0 !important;
} }
} }
:deep(.ant-table-content) { // :deep(.ant-table-content) {
// max-height: v-bind(historyTableHeight); // max-height: v-bind(historyTableHeight);
// overflow-y: v-bind(scrolled); // overflow-y: v-bind(scrolled);
} // }
:deep(.ant-table-thead > tr > th) { :deep(.ant-table-thead > tr > th) {
// background: #ffffff; // background: #ffffff;
@@ -714,12 +726,12 @@ export default defineComponent({
height: 4rem; height: 4rem;
min-width: 4rem; min-width: 4rem;
line-height: 4rem; line-height: 4rem;
margin-right: .8rem; margin-right: 0.8rem;
} }
:deep(.ant-pagination-options-quick-jumper) { :deep(.ant-pagination-options-quick-jumper) {
height: 4rem; height: 4rem;
line-height: 4rem; line-height: 4rem;
margin-left: .8rem; margin-left: 0.8rem;
font-size: 1.6rem; font-size: 1.6rem;
> input { > input {
width: 7rem; width: 7rem;