You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
2.0 KiB

6 days ago
// 提取 a3-1-1-2-4 添加关联客户弹窗全部 select 选项 + 快速创建客户区结构
import fs from 'node:fs';
const OSS = 'https://lanhu-axure-file.oss-cn-beijing.aliyuncs.com/';
const manifest = JSON.parse(fs.readFileSync('e:/code/crm-backend-matt/.scratch/lanhu-latest/axure-v29.json', 'utf8'));
const page = 'a3-1-1-2-4________.html';
const html = await (await fetch(OSS + manifest.pages[page].html.sign_md5, { headers: { 'User-Agent': 'Mozilla/5.0' } })).text();
fs.writeFileSync('e:/code/crm-backend-matt/.scratch/lanhu-latest/v29-customer-pages/a3-1-1-2-4_raw.html', html, 'utf8');
const decode = (s) => s
.replace(/&#x([0-9A-Fa-f]+);/g, (_, h) => String.fromCodePoint(parseInt(h, 16)))
.replace(/&#(\d+);/g, (_, d) => String.fromCodePoint(parseInt(d, 10)))
.replace(/ /g, ' ');
// 1) 全部 select 及其选项
const sels = html.match(/<select id="(u\d+)_input"[\s\S]*?<\/select>/g) || [];
console.log('=== 全部下拉框(含选项)===');
for (const s of sels) {
const id = s.match(/id="(u\d+)_input"/)[1];
const opts = (s.match(/<option[^>]*>([\s\S]*?)<\/option>/g) || [])
.map(o => decode(o.replace(/<\/?option[^>]*>/g, '').trim()));
console.log(`${id}: ${opts.join(' / ')}`);
}
// 2) u418「快速创建客户」之后到需求批注表之前的控件(快速创建区结构)
console.log('\n=== u405-u465 控件文本(快速创建客户区)===');
const re = /<!--\s*(.*?)\s*-->\s*<div id="(u\d+)"[^>]*>/g;
const items = [];
let m;
while ((m = re.exec(html)) !== null) {
const after = html.slice(m.index, m.index + 1000);
const tr = after.match(new RegExp(`id="${m[2]}_text"[^>]*>[\\s\\S]*?</div>`));
let text = '';
if (tr) text = (tr[0].match(/<p><span>([\s\S]*?)<\/span><\/p>/g) || [])
.map(p => decode(p.replace(/<\/?p>/g, '').replace(/<\/?span>/g, ''))).join(' | ');
items.push({ id: m[2], text: text.trim() });
}
for (const i of items) {
const n = parseInt(i.id.slice(1));
if (n >= 405 && n <= 470 && i.text) console.log(`${i.id} | ${i.text.slice(0, 90)}`);
}