work make
This commit is contained in:
parent
39c9ccdf01
commit
9ca41cb629
18
app.js
18
app.js
@ -35,6 +35,17 @@ const Work = DB({
|
||||
return ["", workObj];
|
||||
}
|
||||
});
|
||||
/**@type {(work:WorkData)=>void} */
|
||||
const WorkMake =(work)=>
|
||||
{
|
||||
const part = Part.find(work.part);
|
||||
part.work.unshift(work);
|
||||
part.time = work.time;
|
||||
const itr = deskId=>Scan(Desk.find(deskId));
|
||||
part.need.forEach(itr);
|
||||
part.make.forEach(itr);
|
||||
};
|
||||
|
||||
|
||||
/** @typedef {"all"|"one"} DeskMode*/
|
||||
/** @typedef {[need:Record<string, number>, make:string[], ...role:string[]]} DeskJSON */
|
||||
@ -79,6 +90,7 @@ const Scan =(desk)=>
|
||||
}
|
||||
}
|
||||
|
||||
console.log("scan", dirtyNeed, dirtyMake);
|
||||
return [dirtyNeed, dirtyMake];
|
||||
};
|
||||
const Desk = DB({
|
||||
@ -92,9 +104,7 @@ const Desk = DB({
|
||||
|
||||
make.forEach(partId=>Part.find(partId).make.push(id));
|
||||
Object.keys(need).forEach(partId=>Part.find(partId).need.push(id));
|
||||
|
||||
const check = Scan(deskObj);
|
||||
console.log(check);
|
||||
Scan(deskObj);
|
||||
|
||||
return [id, deskObj];
|
||||
}
|
||||
@ -103,3 +113,5 @@ const Desk = DB({
|
||||
await Part.load();
|
||||
await Work.load();
|
||||
await Desk.load();
|
||||
|
||||
WorkMake({part:"p3", user:"u1", time:new Date().getTime(), data:"NEW!"});
|
||||
|
||||
19
test.test.ts
19
test.test.ts
@ -1,19 +0,0 @@
|
||||
|
||||
const check =<T extends object | null, Ret, Args extends [...string[], T]>(settings:{load:(...args:Args)=>Ret, save:(internal:Ret)=>Args})=>
|
||||
{
|
||||
return {} as [never, ...Args][Args["length"]];
|
||||
}
|
||||
|
||||
function load(a1:string, a2:string, a3:string, a4:Record<string, number>)
|
||||
{
|
||||
return [1, 2, 3]
|
||||
}
|
||||
|
||||
type LoadArgs = Parameters<typeof load>;
|
||||
|
||||
function save(n:number[])
|
||||
{
|
||||
return ["a", "b", "c", { x: 1, y: 2 }] as LoadArgs
|
||||
}
|
||||
|
||||
const c1 = check({load, save});
|
||||
Loading…
Reference in New Issue
Block a user