复制注释复制到手抖?该给数据架构系统上个自动化了!

几十几百个字段的复制粘贴?不存在!!!

直接复制以下代码,到浏览器控制台执行。

(function() {
    function fillInput(input, value) {
        // 方式1: 绕过 Vue setter,原生赋值 + 触发事件
        try {
            Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(input, value);
            input.dispatchEvent(new Event('input', { bubbles: true }));
            input.dispatchEvent(new Event('change', { bubbles: true }));
            input.dispatchEvent(new Event('blur', { bubbles: true }));
        } catch(e) {
            console.warn('方式1失败: ' + e.message);
        }

        // 方式2: 找 Vue 组件直接 emit(终极方案)
        try {
            var node = input;
            var vueComp = null;
            while (node && node !== document.body) {
                vueComp = node.__vueParentComponent;
                if (vueComp) break;
                node = node.parentElement;
            }
            if (vueComp) {
                vueComp.emit('update:modelValue', value);
            }
        } catch(e) {
            console.warn('方式2失败: ' + e.message);
        }
    }

    var rows = document.querySelectorAll('tr.el-table__row');
    var count = 0;

    rows.forEach(function(tr) {
        var cells = tr.querySelectorAll('td.el-table__cell');
        if (cells.length < 2) return;
        var span = cells[cells.length - 1].querySelector('span');
        if (!span) return;
        var name = span.textContent.trim();
        var field_input = cells[0].querySelector('input.el-input__inner');
        var table_input = cells[2].querySelector('input.el-input__inner');

        try {
            field_input.focus();
        } catch(e) {
            console.warn('未找到字段input');
        }
        fillInput(field_input, name);
        try {
            table_input.focus();
        } catch(e) {
            console.warn('未找到表input');
        }
        fillInput(table_input, name);
        count++;
        console.log(count + '. ' + name);
    });

    console.log('完成,共填了 ' + count + ' 个');
})();
posted @ 2026-05-12 14:23  干翻苍穹  阅读(51)  评论(0)    收藏  举报