feat: 全系统窗体升级 - 配置驱动通用单据页(BillPage)、原料专用单据页、宽屏弹窗及日期转换优化
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* 复现原料出库单保存 500 错误
|
||||
* 用法:node server/scripts/debug-outstock-save.mjs
|
||||
*/
|
||||
const BASE = process.env.F9MES_API || 'http://localhost:5136';
|
||||
const PHONE = '13800000000';
|
||||
const PASSWORD = '123456';
|
||||
|
||||
async function main() {
|
||||
const login = await fetch(BASE + '/api/auth/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ phone: PHONE, password: PASSWORD }),
|
||||
}).then((r) => r.json());
|
||||
if (login.code !== 0) throw new Error('登录失败: ' + JSON.stringify(login));
|
||||
const h = { Authorization: 'Bearer ' + login.data.token, 'Content-Type': 'application/json' };
|
||||
|
||||
// 取第一个庄口
|
||||
const zk = await fetch(BASE + '/api/data/RawMaterial_Zhuangkou/all', { headers: h }).then((r) => r.json());
|
||||
const zkItems = (zk.data && (zk.data.data || zk.data.items)) || (Array.isArray(zk.data) ? zk.data : []);
|
||||
if (!zkItems.length) throw new Error('无庄口');
|
||||
const zhuangkouId = zkItems[0].id;
|
||||
console.log('使用庄口 id=' + zhuangkouId);
|
||||
|
||||
// 取第一个组织(OutOrgId)
|
||||
let outOrgId = 0;
|
||||
try {
|
||||
const org = await fetch(BASE + '/api/data/RawMaterial_Org/all', { headers: h }).then((r) => r.json());
|
||||
const orgItems = (org.data && (org.data.data || org.data.items)) || (Array.isArray(org.data) ? org.data : []);
|
||||
if (orgItems.length) outOrgId = orgItems[0].id;
|
||||
} catch { /* 无组织表则用0 */ }
|
||||
console.log('使用组织 id=' + outOrgId);
|
||||
|
||||
// 生成单号
|
||||
let billNo = 'YLC' + new Date().toISOString().slice(0, 10).replace(/-/g, '') + '-DBG';
|
||||
try {
|
||||
const g = await fetch(BASE + '/api/meta/gencode/RawMaterial_OutStock/billNo', { method: 'POST', headers: h }).then((r) => r.json());
|
||||
if (g.code === 0 && g.data && g.data.value) billNo = g.data.value;
|
||||
} catch (e) { console.log('gencode 失败,使用自造单号', e.message); }
|
||||
console.log('使用单号 ' + billNo);
|
||||
|
||||
// 模拟前端 payload(与 outstock-bill.vue handleSave 完全一致)
|
||||
const payload = {
|
||||
billNo,
|
||||
zhuangkouId,
|
||||
outOrgId,
|
||||
outWeight: 100,
|
||||
receiver: '张三',
|
||||
outDate: '2026-08-16 14:30:00',
|
||||
outType: 0,
|
||||
status: 0,
|
||||
};
|
||||
|
||||
const resp = await fetch(BASE + '/api/data/RawMaterial_OutStock/add', {
|
||||
method: 'POST',
|
||||
headers: h,
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
const text = await resp.text();
|
||||
console.log('HTTP ' + resp.status);
|
||||
console.log('BODY>>>');
|
||||
console.log(text.slice(0, 3000));
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error('ERR: ' + e.message);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
// 验证修复后 iframe 尺寸非 0,且打印内容完整
|
||||
import { createRequire } from 'module'
|
||||
import fs from 'fs'
|
||||
|
||||
const PW = 'C:/Users/范先生/AppData/Roaming/npm/node_modules/@playwright/cli/node_modules/playwright-core'
|
||||
const require = createRequire(PW + '/package.json')
|
||||
const { chromium } = require(PW)
|
||||
|
||||
const B = 'http://localhost:5136'
|
||||
const token = fs.readFileSync(new URL('_token.txt', import.meta.url), 'utf8').trim()
|
||||
const url = `http://localhost:5227/?print=1&template=2&table=RawMaterial_OutStock&row=2&token=${encodeURIComponent(token)}&api=${B}`
|
||||
|
||||
const browser = await chromium.launch({ headless: true, channel: 'msedge' })
|
||||
const page = await browser.newPage()
|
||||
page.on('pageerror', (e) => console.log('[pageerror]', e.message))
|
||||
page.on('console', (m) => { if (m.type() === 'error') console.log('[console]', m.text()) })
|
||||
await page.goto(url, { waitUntil: 'networkidle', timeout: 30000 })
|
||||
|
||||
for (let i = 0; i < 40; i++) {
|
||||
const ok = await page.evaluate(() => {
|
||||
const f = document.querySelector('iframe')
|
||||
return !!(f && f.srcdoc && f.srcdoc.length > 1000)
|
||||
})
|
||||
if (ok) break
|
||||
await new Promise((r) => setTimeout(r, 500))
|
||||
}
|
||||
|
||||
const info = await page.evaluate(() => {
|
||||
const f = document.querySelector('iframe')
|
||||
if (!f) return { hasIframe: false }
|
||||
const rect = f.getBoundingClientRect()
|
||||
const d = f.contentDocument
|
||||
return {
|
||||
hasIframe: true,
|
||||
iframeCss: f.style.cssText,
|
||||
rectW: rect.width,
|
||||
rectH: rect.height,
|
||||
srcdocLen: f.srcdoc.length,
|
||||
pages: d ? d.querySelectorAll('.op-page').length : -1,
|
||||
bodyText: d ? (d.body.textContent || '').replace(/\s+/g, ' ').slice(0, 200) : '',
|
||||
body: d ? d.body.innerHTML.slice(0, 300) : '',
|
||||
}
|
||||
})
|
||||
console.log(JSON.stringify(info, null, 1))
|
||||
await browser.close()
|
||||
console.log('DONE')
|
||||
Reference in New Issue
Block a user