- 좌측 「내 기계」 · 「내 품목」 칸(펼치면 가운데 화면) — 목록(이름 · 규격 · 방식 · 시간당 · 쓰는 곳 · 넣은 · 고친 날 · 찾기) → 양식(821-2 부품 · 바로 넣기 기본 · 저장 때만 서버) - 단가산출 줄 쌓기 기계 고르기에 「내 기계」 묶음 · [새 기계 만들기] · 품셈 기계 줄 「복사해 내 기계로」 - 수식 머리 배지 — 값만 바뀜 = 「새 값 있음」 · 지운 키 = 「지워짐 n」 · [단가 갱신] 확인 창에 바뀐 자원 줄 - 기계 양식 state 에 방식 · 시간당 직접 꼴 · 확인창 글 줄바꿈 그대로 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
2.7 KiB
TypeScript
62 lines
2.7 KiB
TypeScript
/* =============================================================================
|
|
* line_stack_mine.ts
|
|
* 줄 쌓기 기계 줄 「복사해 내 기계로」(PLAN 821-3 · 요구서 796 3 장) — M02 개인 층 단가산출만.
|
|
* 품셈 기계 줄(기계='원문번호') → 그 기계 값을 복사한 내 기계 양식 창 → 저장하면 줄이 그 내 기계로(기계='개인 EQP…')
|
|
* M01 정본은 그대로 · 내 기계 줄(기계='개인 …') · M01 단가산출 기초 = 단추 없음
|
|
* ========================================================================== */
|
|
|
|
import { createButton } from "@ui/ui_template_button";
|
|
import { showToast } from "@ui/ui_template_elements";
|
|
import type { Picked } from "../common_util/common_util_line_stack_pick";
|
|
import { findSimilar, machineArg, mineElement } from "../M02_MasterTemplete/M02_MyMachine_Api";
|
|
import { openMyMachineModal } from "../M02_MasterTemplete/M02_MyMachine_Form";
|
|
import { mt } from "../M02_MasterTemplete/M02_MyMachine_Text";
|
|
import type { StackTake } from "./line_stack_pick";
|
|
|
|
/** 기계 줄 연결 → 품셈 기계 원문번호(내 기계 · 기계 입력 없음 = null) */
|
|
export function m01MachineNo(link: {
|
|
갈래?: string;
|
|
입력?: Record<string, string>;
|
|
}): string | null {
|
|
const arg = link.갈래 === "단가산출" ? link.입력?.기계 : undefined;
|
|
const no = typeof arg === "string" ? arg.trim().replace(/^'|'$/g, "") : "";
|
|
return no && !no.startsWith("개인 ") ? no : null;
|
|
}
|
|
|
|
/** 「복사해 내 기계로」 단추 — 개인 층 SK 품셈 기계 줄만 · 고르면 `done(새 줄 고름)` */
|
|
export function toMineButton(
|
|
take: StackTake | undefined,
|
|
link: { 갈래?: string; 입력?: Record<string, string> },
|
|
done: (p: Picked) => void,
|
|
): HTMLElement | null {
|
|
const no = m01MachineNo(link);
|
|
if (!no || take?.layer !== "personal") return null;
|
|
const b = createButton({
|
|
label: mt("To_Mine"),
|
|
variant: "ghost",
|
|
size: 24,
|
|
iconStart: "copy",
|
|
onClick: async () => {
|
|
const rows = await findSimilar(take.owner, no).catch(() => []);
|
|
const seed = rows.find((r) => r.출처 === "M01" && r.원문번호 === no);
|
|
if (!seed) return showToast(`${mt("Hourly_None")} — ${no}`, "warning");
|
|
openMyMachineModal(
|
|
take.owner,
|
|
(got) => {
|
|
const e = mineElement(got.줄, got.시간당);
|
|
if (!e.로직) return showToast(mt("Pick_Direct"), "warning");
|
|
done({
|
|
키: e.로직,
|
|
이름: e.이름,
|
|
입력: { 기계: machineArg(got.줄.원문번호) },
|
|
...(e.규격 ? { 규격: e.규격 } : {}),
|
|
});
|
|
},
|
|
seed,
|
|
);
|
|
},
|
|
});
|
|
b.dataset.toMine = no;
|
|
return b;
|
|
}
|