Browse Source

多条件搜索

dev-xx
马远东 1 year ago
parent
commit
8fc7252175
  1. 66
      src/views/distribution/turndelivery/deliveryDiscuss.vue

66
src/views/distribution/turndelivery/deliveryDiscuss.vue

@ -270,7 +270,7 @@
<div class="el_multifunctional">
<el-input
v-model="multifunctional"
placeholder="请输入要搜索的值"
placeholder="请输入要搜索的值,多条件用英文逗号拼接"
clearable
@clear='soclear'
/>
@ -320,7 +320,7 @@
align="center"
>
<template #default="props">
<span :id="props.row[item.prop]" :class="props.row[item.prop] == multifunctional ? 'static-class' : ''">{{
<span :id="props.row[item.prop]" :class="props.row[item.prop] == multifunctional && props.row[item.prop]? 'static-class' : ''">{{
props.row[item.prop] ? props.row[item.prop] : '/'
}}</span>
</template>
@ -1887,34 +1887,62 @@ const soclear=()=>{
SearchFu()
}
function scrollToElementWithPartialId(partialId) {
// function scrollToElementWithPartialId(partialId) {
// //
// document.querySelectorAll('[id]').forEach(function(el) {
// el.style.backgroundColor = ''; //
// el.style.color = ''; //
// });
// // partialId
// const allElements = document.querySelectorAll(`[id*="${partialId}"]`);
// if (allElements.length > 0) {
// //
// const targetElement = allElements[0];
// //
// targetElement.style.backgroundColor = '#ff0000'; //
// targetElement.style.color = '#fff'; //
// //
// targetElement.scrollIntoView();
// }
// }
function scrollToElementWithinTableRow(partialIdString) {
//
document.querySelectorAll('[id]').forEach(function(el) {
el.style.backgroundColor = ''; //
el.style.color = ''; //
const tableRows = document.querySelectorAll('tr');
tableRows.forEach(function(row) {
const cells = row.querySelectorAll('[id]');
cells.forEach(function(cell) {
cell.style.backgroundColor = '#ffffff'; //
cell.style.color = '#000'; //
});
});
// partialId
const allElements = document.querySelectorAll(`[id*="${partialId}"]`);
if (allElements.length > 0) {
//
const targetElement = allElements[0];
//
targetElement.style.backgroundColor = '#ff0000'; //
targetElement.style.color = '#fff'; //
//
targetElement.scrollIntoView();
//
const partialIds = partialIdString.split(',').map(id => id.trim());
// partialId
for (let row of tableRows) {
// partialIds
if (partialIds.every(partialId => row.querySelector(`[id*="${partialId}"]`))) {
//
const cells = row.querySelectorAll('[id]');
cells.forEach(function(cell) {
cell.style.backgroundColor = ''; //
cell.style.color = ''; //
});
//
row.scrollIntoView();
break; //
}
}
}
//
const SearchFu = () => {
if(multifunctional.value){
scrollToElementWithPartialId(multifunctional.value)
scrollToElementWithinTableRow(multifunctional.value)
}else{
document.querySelectorAll('[id]').forEach(function(el) {
el.style.backgroundColor = ''; //
el.style.color = ''; //
el.style.color =''; //
});
}

Loading…
Cancel
Save