讲师管理bug

This commit is contained in:
zhangsir
2024-12-31 15:49:48 +08:00
parent 31e4608137
commit c0db544735
2 changed files with 33 additions and 4 deletions

View File

@@ -36,7 +36,7 @@
:columns="columns" :columns="columns"
:data-source="searchTrue?timesList:tableData" :data-source="searchTrue?timesList:tableData"
:pagination="false" :pagination="false"
:scroll="{ x: 'max-content',y:tableData.length? pageHeight : null }" :scroll="{ x: 'max-content',y:searchTrue?timesList.length?pageHeight : null:tableData.length?pageHeight : null, }"
row-key="id" row-key="id"
:loading="loading" :loading="loading"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
@@ -44,8 +44,8 @@
> >
<template #action="{ record }"> <template #action="{ record }">
<div class="action"> <div class="action">
<div style="color: #1890ff;cursor: pointer;" class="btn" v-if="selectedRowKeys.includes(record.id)" @click="removeList(record)">取消选择</div> <div style="color: #1890ff;cursor: pointer;" class="btn" v-if="selectedRowKeys.includes(record.id)" @click.stop="removeList(record)">取消选择</div>
<div style="color: #1890ff;cursor: pointer;" class="btn" v-else @click="addList(record)">选择</div> <div style="color: #1890ff;cursor: pointer;" class="btn" v-else @click.stop="addList(record)">选择</div>
</div> </div>
</template> </template>
</a-table> </a-table>
@@ -79,6 +79,15 @@ const customRow = (record) => {
style:{ style:{
backgroundColor: searchTrue.value && searchList.value.some(item => item.id === record.id) ? '#a6dff9' : '', backgroundColor: searchTrue.value && searchList.value.some(item => item.id === record.id) ? '#a6dff9' : '',
}, },
onClick() {
if(selectedRowKeys.value.some(item => item === record.id)){
selectedRowKeys.value = selectedRowKeys.value.filter(item => item !== record.id)
selectsData.value = selectsData.value.filter(item => item.id !== record.id)
}else{
selectedRowKeys.value.push(record.id)
selectsData.value.push(record)
}
}
}; };
}; };
const pageHeight = computed(() => { const pageHeight = computed(() => {
@@ -116,9 +125,16 @@ const resetData = () => {
dateValue.value = null dateValue.value = null
searchData(false) searchData(false)
} }
let timeout = null
const searchData = (val) => { const searchData = (val) => {
// drawerContent.value.scrollTo({top:200,behavior: 'smooth'}) // drawerContent.value.scrollTo({top:200,behavior: 'smooth'})
searchTrue.value = val searchTrue.value = val
loading.value = true
if(timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
loading.value = false
if(!nameUserNo.value&&!dateValue.value){ if(!nameUserNo.value&&!dateValue.value){
searchList.value = []; searchList.value = [];
timesList.value = tableData.value timesList.value = tableData.value
@@ -152,6 +168,9 @@ const searchData = (val) => {
selectedRowKeys.value = selectedRowKeys.value.filter(id => selectedRowKeys.value = selectedRowKeys.value.filter(id =>
timesLists.some(item => item.id === id) timesLists.some(item => item.id === id)
); );
selectsData.value = selectsData.value.filter(item =>
timesLists.some(item2 => item2.id === item.id)
);
const filteredList = timesLists.filter(item => { const filteredList = timesLists.filter(item => {
const isNameMatch = (item.name + item.userNo).includes(nameUserNo.value); const isNameMatch = (item.name + item.userNo).includes(nameUserNo.value);
return isNameMatch return isNameMatch
@@ -163,6 +182,7 @@ const searchData = (val) => {
if(scrollHeight||scrollHeight==0){ if(scrollHeight||scrollHeight==0){
drawerContent.value?.$el.querySelector('.ant-table-body')?.scrollTo({top:scrollHeight*55,behavior: 'smooth'}) drawerContent.value?.$el.querySelector('.ant-table-body')?.scrollTo({top:scrollHeight*55,behavior: 'smooth'})
} }
}, 500);
} }
const loading = ref(false) const loading = ref(false)
const selectedRowKeys = ref([]) const selectedRowKeys = ref([])
@@ -175,6 +195,7 @@ const emit = defineEmits(['selectedRowKeys','update:visible'])
const addList = (item) => { const addList = (item) => {
selectedRowKeys.value.push(item.id) selectedRowKeys.value.push(item.id)
selectsData.value.push(item) selectsData.value.push(item)
console.log(selectedRowKeys.value)
} }
const expense = ref(0) const expense = ref(0)
watch(()=>selectsData.value.length,(val)=>{ watch(()=>selectsData.value.length,(val)=>{

View File

@@ -258,8 +258,15 @@ const customRow = (record) => {
} }
}; };
}; };
let timeout = null
const searchData = (val) => { const searchData = (val) => {
searchTrue.value = val searchTrue.value = val
loadingData.value = true
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
loadingData.value = false;
if(!nameUserNo.value&&!dateValue.value){ if(!nameUserNo.value&&!dateValue.value){
searchList.value = []; searchList.value = [];
timesList.value = expenseList.value timesList.value = expenseList.value
@@ -303,6 +310,7 @@ const searchData = (val) => {
if(scrollHeight||scrollHeight==0){ if(scrollHeight||scrollHeight==0){
drawerContent.value?.$el.querySelector('.ant-table-body')?.scrollTo({top:scrollHeight*55,behavior: 'smooth'}) drawerContent.value?.$el.querySelector('.ant-table-body')?.scrollTo({top:scrollHeight*55,behavior: 'smooth'})
} }
}, 500);
} }
const resetData = () => { const resetData = () => {
nameUserNo.value = null nameUserNo.value = null
@@ -711,7 +719,7 @@ const config = () => {
.right{ .right{
color: #646C9A; color: #646C9A;
.org{ .org{
max-width: 148px; max-width: 136px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;