Last active
October 18, 2024 03:33
-
-
Save mindon/4d899654201fdbabfa54fbfbf35ef0ee to your computer and use it in GitHub Desktop.
腾讯云PG设置某字段多个OR值过滤数据(包含React的input事件激发)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(raw, key) { | |
const d = raw.split('\n').map(line => line.trim()).filter(line => !!line); | |
console.log(key, d.length); | |
if (d.length == 0) return; | |
const tab = document.querySelector('.dmc-mysql-operating-filter .tea-table__body table.tea-table__box'); | |
const nb = tab.querySelector('tr:last-child > td > div > div'); | |
let n = d.length - [].slice.apply(tab.querySelectorAll('tr')).length + 1; | |
while (n > 0) { nb.click();n--;} | |
const trs = [].slice.apply(tab.querySelectorAll('tr')).slice(0, d.length); | |
trs.forEach((tr,i) => [].slice.apply(tr.querySelectorAll('div.tea-segment > button')).forEach(btn => { | |
if (btn.innerText.charAt(0) == 'O') btn.click(); | |
})); | |
let k = 0; | |
const fn = () => { | |
const tr = trs[k]; | |
if (!tr) { console.log('fin'); return; } | |
const inp = tr.querySelector('td:nth-child(3) input.tea-input'); | |
inp.focus(); | |
// --->> input event 设值及激发 for React | |
const valueSetter = Object.getOwnPropertyDescriptor(inp, 'value').set; | |
const prototype = Object.getPrototypeOf(inp); | |
const prototypeValueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set; | |
if (valueSetter && valueSetter !== prototypeValueSetter) { | |
prototypeValueSetter.call(inp, d[k]); | |
} else { | |
valueSetter.call(inp, d[k]); | |
} | |
inp.dispatchEvent(new Event('input', { bubbles: true })); | |
// ---<< | |
console.log(k, d[k], '...'); | |
if(tr.querySelector('td:first-child .tea-dropdown__value').innerText != key) { | |
tr.querySelector('td:first-child .tea-dropdown-btn').click(); | |
setTimeout(() => { | |
[].slice.apply(document.querySelectorAll('#tea-overlay-root .tea-list--option li')).filter(li => li.textContent == 'uuid').pop().click(); | |
k++; | |
fn(); | |
}, 300); | |
} else { | |
k++; | |
fn(); | |
} | |
}; | |
fn(); | |
})(` | |
value1 | |
value2 | |
`, 'name') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment