feat: 新增IM即时通讯(浮窗)、工作流、打印模块及工作台增强
- IM: 新增浮窗聊天(ImFloatWindow)、管理页(monitor/config/service/message)、SSE推送 - 工作流: 新增待办/我的流程页面及后端服务 - 打印: 新增打印模板、出库单打印(PrintPage)、模板种子脚本 - 工作台: 增强快捷入口与工作台数据 - 修复: TagsView页签关闭、CrudPage通用表格增强 - 移除导航菜单中的即时通讯入口,改为右下角浮窗
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* 任务1 联调收尾:造测试数据(庄口 + 原料出库单)并验证打印数据端点
|
||||
* 用法:node server/scripts/seed-test-outstock.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' };
|
||||
|
||||
// 1. 庄口:有则复用,无则创建
|
||||
let zkId = 0;
|
||||
const zk = await fetch(BASE + '/api/data/RawMaterial_Zhuangkou/all', { headers: h }).then((r) => r.json());
|
||||
const zkItems = (zk.data && zk.data.items) || (Array.isArray(zk.data) ? zk.data : []);
|
||||
if (zkItems.length) {
|
||||
zkId = zkItems[0].id;
|
||||
console.log('复用庄口 id=' + zkId);
|
||||
} else {
|
||||
const code = 'YLZ' + new Date().toISOString().slice(0, 10).replace(/-/g, '') + '-001';
|
||||
const add = await fetch(BASE + '/api/data/RawMaterial_Zhuangkou/add', {
|
||||
method: 'POST',
|
||||
headers: h,
|
||||
body: JSON.stringify({ code, name: '四川凉山-2026春茧', season: '春茧', cocoonType: 0, status: 1 }),
|
||||
}).then((r) => r.json());
|
||||
if (add.code !== 0) throw new Error('建庄口失败: ' + JSON.stringify(add));
|
||||
zkId = add.data && (add.data.id ?? add.data);
|
||||
if (typeof zkId !== 'number') {
|
||||
const page = await fetch(BASE + '/api/data/RawMaterial_Zhuangkou/all', { headers: h }).then((r) => r.json());
|
||||
const items = (page.data && page.data.items) || page.data || [];
|
||||
zkId = items[items.length - 1].id;
|
||||
}
|
||||
console.log('新建庄口 id=' + zkId);
|
||||
}
|
||||
|
||||
// 2. 原料出库单(若无则创建)
|
||||
const all = await fetch(BASE + '/api/data/RawMaterial_OutStock/all', { headers: h }).then((r) => r.json());
|
||||
const items = (all.data && all.data.items) || (Array.isArray(all.data) ? all.data : []);
|
||||
let rowId;
|
||||
if (items.length) {
|
||||
rowId = items[0].id;
|
||||
console.log('复用出库单 id=' + rowId);
|
||||
} else {
|
||||
const billNo = 'CK-' + new Date().toISOString().slice(0, 10).replace(/-/g, '') + '-001';
|
||||
const add = await fetch(BASE + '/api/data/RawMaterial_OutStock/add', {
|
||||
method: 'POST',
|
||||
headers: h,
|
||||
body: JSON.stringify({
|
||||
billNo,
|
||||
zhuangkouId: zkId,
|
||||
outOrgId: 0,
|
||||
outWeight: 125.5,
|
||||
receiver: '张三',
|
||||
outDate: new Date().toISOString().slice(0, 10),
|
||||
outType: 0,
|
||||
status: 1,
|
||||
}),
|
||||
}).then((r) => r.json());
|
||||
if (add.code !== 0) throw new Error('建出库单失败: ' + JSON.stringify(add));
|
||||
rowId = add.data && (add.data.id ?? add.data);
|
||||
console.log('新建出库单 id=' + rowId);
|
||||
}
|
||||
|
||||
// 3. 验证打印数据端点
|
||||
const pd = await fetch(BASE + '/api/print/data/RawMaterial_OutStock/' + rowId, { headers: h }).then((r) => r.json());
|
||||
console.log('PRINTDATA=' + JSON.stringify(pd));
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error('ERR: ' + e.message);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user