feat(M02): 51-14 일위대가 순서 칸 2행 — 위 [위로] [아래로] / 아래 [옵션]·[수정] [삭제] · 단가승격 [옵션] · 일위조합 [수정] 서고 원본 모달
- 순서 칸 = 단추 묶음 두 줄(공용 ui-btn-group 간격) · 카드 갈래는 아래 줄만 - 단가승격 줄 [옵션] = 승격 문서 넣을 값 모달 · [저장] = 서고 저장 길 · 머리 한 줄 알림(쓰는 모든 구조물에 따라감) - 일위조합 줄 [수정] = 사전조합 상세 모달(서고 모드 표 · 옵션 · 수량 · 순서 · 삭제 · 추가) · [저장] = 서고 원본 · 취소 = 버림 물음 - 자기 층 서고만 고침(위 층 = 읽기만) · 닫으면 구조물 일위대가 다시 셈 - 확인 시나리오 resources/tester/ui_checks/51-14_순서칸_2행_옵션수정.js Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MgChuAcyBqUkhHMTXomQC7
This commit is contained in:
@@ -90,6 +90,14 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 순서 칸 2행(51-14) — 위 [위로] [아래로] / 아래 [옵션]·[수정] [삭제] · 줄 사이도 단추 묶음 간격 */
|
||||
.m02-labrow__tools {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: var(--btn-group-gap);
|
||||
}
|
||||
|
||||
/* 옵션 값 줄(44-6) — 이름 ~ 합계에 걸친 한 줄 말줄임(max-width 0 = 표 폭을 안 늘림) · 위 줄과 한 덩이 */
|
||||
.m02-labrow .m02-labrow__optrow td {
|
||||
padding-top: 0;
|
||||
@@ -179,6 +187,11 @@
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
/* 참조 줄 모달(51-14) — 일위조합 [수정] = 사전조합 상세 */
|
||||
.m02-labref {
|
||||
width: min(72rem, calc(100vw - 32px));
|
||||
}
|
||||
|
||||
/* 입력 모달 */
|
||||
.m02-labin {
|
||||
width: min(40rem, calc(100vw - 32px));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 일위대가 상세(39-3) — 구조물 열마다 하나(`labor/<열>.json`) · UI_Main 종류 `labor` 가 이 부품을 붙임
|
||||
* (양식 길 읽기 · [저장] · [다시 읽기]는 UI_Main). 차례 = 정보(단위 · 본뜬) → 담은 로직 → 자재목록 → 다이어그램.
|
||||
* · 담은 로직 줄 누름 = 고름(하이라이트 · 다시 그려도 유지 · 47-5) + 그 줄 바로 아래 하위 행(51-2 · `Labor_Rows`) ·
|
||||
* 같은 줄 다시 누르면 닫힘 · [옵션] = 입력 모달(`Labor_Input`) ·
|
||||
* 같은 줄 다시 누르면 닫힘 · [옵션] = 입력 모달(`Labor_Input`) · 참조 줄 [옵션] · [수정] = 서고 원본 모달(51-14 · `Labor_RefEdit`) ·
|
||||
* [확인] = 화면 캐시만 · 저장은 [저장]
|
||||
* · 금액 = 서버 calc(기준 ③ · 최신 응답만 · 저장 안 함) · 고칠 때마다 뒤에서 다시 셈
|
||||
* · 같은 로직 두 번 · 같은 자재 두 번 막음 · 빈 일위대가도 저장 됨
|
||||
@@ -47,6 +47,7 @@ import {
|
||||
} from "./M02_MasterTemplete_Labor_Diagram";
|
||||
import { openLaborInput, type GoArea } from "./M02_MasterTemplete_Labor_Input";
|
||||
import { openQtyModal } from "./M02_MasterTemplete_Labor_QtyModal";
|
||||
import { openRefEdit } from "./M02_MasterTemplete_Labor_RefEdit";
|
||||
import { openLogicPicker } from "./M02_MasterTemplete_Labor_Pick";
|
||||
import { logicTable, matTable, qtyShort } from "./M02_MasterTemplete_Labor_Rows";
|
||||
import { tc } from "./M02_MasterTemplete_Labor_Text";
|
||||
@@ -174,12 +175,13 @@ export function mountLaborDetail(
|
||||
? {
|
||||
open: pick,
|
||||
option: openRow,
|
||||
ref: openRef,
|
||||
qty: openQty,
|
||||
...(opt.card ? {} : { move }),
|
||||
remove: removeRow,
|
||||
alias: setAlias,
|
||||
}
|
||||
: { open: pick, option: openRow },
|
||||
: { open: pick, option: openRow, ref: openRef },
|
||||
),
|
||||
);
|
||||
const draw = (): void => {
|
||||
@@ -347,6 +349,19 @@ export function mountLaborDetail(
|
||||
});
|
||||
}
|
||||
|
||||
/** 참조 줄 [옵션] · [수정](51-14) — 서고 원본 모달 · 자기 층 서고만 고침(위 층 = 읽기만 · 서버도 막음) ·
|
||||
* 닫으면 다시 셈(원본이 바뀌었을 수 있음) */
|
||||
function openRef(i: number): void {
|
||||
const ref = cur.담은로직[i].참조;
|
||||
if (!ref) return;
|
||||
void openRefEdit({
|
||||
ref,
|
||||
title: `${ref.키} ${lineOf(lineId({ 참조: ref }) ?? "")?.이름 ?? ""}`.trim(),
|
||||
readOnly: !edit || ref.층 !== opt.layer,
|
||||
closed: () => alive && recalc(),
|
||||
});
|
||||
}
|
||||
|
||||
/** 수량산출 칸 누름 — 로직 줄 */
|
||||
function openQty(i: number): void {
|
||||
const row = cur.담은로직[i];
|
||||
|
||||
@@ -19,14 +19,19 @@ const fill = (text: string, value: string): string => text.replace("{value}", va
|
||||
/** 면적산출 상세로 감 — 옮겨 갔으면 참(물음에서 취소 = 거짓) */
|
||||
export type GoArea = () => Promise<boolean>;
|
||||
|
||||
function footer(readOnly: boolean, ok: () => void, close: () => void): HTMLElement {
|
||||
function footer(
|
||||
readOnly: boolean,
|
||||
ok: () => void,
|
||||
close: () => void,
|
||||
okLabel = tc("In_Ok"),
|
||||
): HTMLElement {
|
||||
return el("div", {
|
||||
className: "m02-labin__foot",
|
||||
children: readOnly
|
||||
? [createButton({ label: tc("In_Close"), variant: "ghost", onClick: close })]
|
||||
: [
|
||||
createButton({ label: tc("In_Cancel"), variant: "ghost", onClick: close }),
|
||||
createButton({ label: tc("In_Ok"), variant: "filled", onClick: ok }),
|
||||
createButton({ label: okLabel, variant: "filled", onClick: ok }),
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -45,6 +50,10 @@ export interface LaborInputOptions {
|
||||
memo: string | null;
|
||||
readOnly: boolean;
|
||||
done: (next: LaborInputResult) => void;
|
||||
/** 머리 한 줄 알림(51-14 · 서고 원본 고침) */
|
||||
notice?: string;
|
||||
/** 확인 단추 글(기본 「확인」) */
|
||||
okLabel?: string;
|
||||
}
|
||||
|
||||
/** 담은 로직 줄 입력 모달 */
|
||||
@@ -100,6 +109,15 @@ export function openLaborInput(opt: LaborInputOptions): void {
|
||||
el("div", {
|
||||
className: "m02-inputval",
|
||||
children: [
|
||||
...(opt.notice
|
||||
? [
|
||||
el("p", {
|
||||
className: "m02-labin__muted",
|
||||
text: opt.notice,
|
||||
attrs: { "data-labor-notice": "" },
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
...(lost.length
|
||||
? [
|
||||
el("p", {
|
||||
@@ -120,7 +138,7 @@ export function openLaborInput(opt: LaborInputOptions): void {
|
||||
}),
|
||||
],
|
||||
}),
|
||||
footer(opt.readOnly, ok, close),
|
||||
footer(opt.readOnly, ok, close, opt.okLabel),
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/* =============================================================================
|
||||
* M02_MasterTemplete_Labor_RefEdit.ts
|
||||
* 일위대가 참조 줄 모달(51-14) — 서고 원본(50-3)을 그 자리에서 고침 · [저장] = 서고 저장 길(`saveTemplate`) ·
|
||||
* 그 문서를 쓰는 모든 구조물에 따라감(머리 한 줄 알림) · 그 층을 못 고치면 읽기만.
|
||||
* · 단가승격 [옵션] = 승격 문서 로직 한 줄의 넣을 값 모달(`Labor_Input`)
|
||||
* · 일위조합 [수정] = 사전조합 상세(서고 모드 표 · 안 줄 [옵션] · 수량 · 위로 · 아래로 · 삭제 · 추가)
|
||||
* 닫으면(저장 · 취소 모두) `closed` — 부르는 쪽이 구조물 일위대가 표를 다시 셈.
|
||||
* ========================================================================== */
|
||||
|
||||
import { createButton, el, showConfirmDialog, showToast } from "@ui/ui_template_elements";
|
||||
import { openModal } from "@ui/ui_template_modal";
|
||||
import { readTemplate, saveTemplate, type Layer } from "./M02_MasterTemplete_Api_Fetch";
|
||||
import { fetchLogicInputs, type LaborRow } from "./M02_MasterTemplete_Labor_Api";
|
||||
import type { LaborRef } from "./M02_MasterTemplete_Labor_Calc";
|
||||
import { openLaborInput } from "./M02_MasterTemplete_Labor_Input";
|
||||
import { tc } from "./M02_MasterTemplete_Labor_Text";
|
||||
import { keepKnown } from "./M02_Labor_Values_Model";
|
||||
|
||||
export interface RefEditOptions {
|
||||
ref: LaborRef;
|
||||
/** 「SP-000001 메쌓기」 */
|
||||
title: string;
|
||||
readOnly: boolean;
|
||||
closed: () => void;
|
||||
}
|
||||
|
||||
const fail = (error: unknown, key: "Load_Failed" | "Lib_SaveFailed"): void =>
|
||||
showToast(error instanceof Error ? error.message : tc(key), "error");
|
||||
|
||||
export async function openRefEdit(opt: RefEditOptions): Promise<void> {
|
||||
const kind = opt.ref.키.startsWith("SP-") ? "promote" : "precombo";
|
||||
const layer = opt.ref.층 as Layer;
|
||||
let doc: { 담은로직?: LaborRow[] };
|
||||
let 판: string;
|
||||
try {
|
||||
const got = await readTemplate(layer, kind, opt.ref.키, null);
|
||||
doc = got.문서 as typeof doc;
|
||||
판 = got.판 ?? "";
|
||||
} catch (error) {
|
||||
return fail(error, "Load_Failed");
|
||||
}
|
||||
const save = (body: unknown): Promise<unknown> =>
|
||||
saveTemplate(layer, kind, opt.ref.키, null, 판, body).then(() =>
|
||||
showToast(tc("Saved"), "success"),
|
||||
);
|
||||
const notice = opt.readOnly ? `${tc("Ref_Shared")} · ${tc("Ref_ReadOnly")}` : tc("Ref_Shared");
|
||||
|
||||
if (kind === "promote") {
|
||||
const row = doc.담은로직?.[0];
|
||||
if (!row) return fail(null, "Load_Failed");
|
||||
const logic = row.로직
|
||||
? ((await fetchLogicInputs([row.로직]).catch(() => null))?.로직[0] ?? null)
|
||||
: null;
|
||||
return openLaborInput({
|
||||
title: opt.title,
|
||||
logic,
|
||||
values: row.입력값,
|
||||
memo: row.메모,
|
||||
readOnly: opt.readOnly,
|
||||
notice,
|
||||
okLabel: tc("Save"),
|
||||
done: (next) => {
|
||||
row.입력값 = logic ? keepKnown(logic.입력, next.입력값).kept : next.입력값;
|
||||
row.메모 = next.메모;
|
||||
void save(doc)
|
||||
.catch((error) => fail(error, "Lib_SaveFailed"))
|
||||
.finally(opt.closed);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 사전조합 — 상세와 같은 부품(서로 부르므로 늦게 받음)
|
||||
const { mountLaborDetail } = await import("./M02_MasterTemplete_Labor_Detail");
|
||||
let dirty = false;
|
||||
let handle: ReturnType<typeof mountLaborDetail> | null = null;
|
||||
const finish = (): void => {
|
||||
handle?.destroy();
|
||||
opt.closed();
|
||||
};
|
||||
openModal({
|
||||
title: opt.title,
|
||||
closeLabel: tc("In_Close"),
|
||||
dialogClass: "m02-modal m02-labref",
|
||||
beforeClose: async () => {
|
||||
if (dirty && !(await showConfirmDialog(tc("Ref_Discard")))) return false;
|
||||
finish();
|
||||
return true;
|
||||
},
|
||||
mount: (body, close) => {
|
||||
const host = el("div", { attrs: { "data-labor-ref": opt.ref.키 } });
|
||||
handle = mountLaborDetail(host, doc, {
|
||||
layer,
|
||||
column: opt.ref.키,
|
||||
readOnly: opt.readOnly,
|
||||
onChanged: (d) => (dirty = d && !opt.readOnly),
|
||||
goArea: null,
|
||||
mode: "precombo",
|
||||
});
|
||||
const cancel = createButton({
|
||||
label: tc(opt.readOnly ? "In_Close" : "In_Cancel"),
|
||||
variant: "ghost",
|
||||
onClick: async () => {
|
||||
if (dirty && !(await showConfirmDialog(tc("Ref_Discard")))) return;
|
||||
close();
|
||||
finish();
|
||||
},
|
||||
});
|
||||
const ok = createButton({
|
||||
label: tc("Save"),
|
||||
variant: "filled",
|
||||
onClick: () =>
|
||||
void save(handle?.getDoc()).then(
|
||||
() => {
|
||||
close();
|
||||
finish();
|
||||
},
|
||||
(error) => fail(error, "Lib_SaveFailed"),
|
||||
),
|
||||
});
|
||||
body.append(
|
||||
el("p", {
|
||||
className: "m02-labin__muted",
|
||||
text: notice,
|
||||
attrs: { "data-labor-notice": "" },
|
||||
}),
|
||||
host,
|
||||
el("div", {
|
||||
className: "m02-labin__foot",
|
||||
children: opt.readOnly ? [cancel] : [cancel, ok],
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -6,7 +6,8 @@
|
||||
* 옵션 값(「지역 서울 · 규격 25mm」)은 줄 아래 이름 ~ 합계에 걸친 한 줄 · 맨 아래 합계 줄(전체 합계 강조).
|
||||
* 자재목록 = 코드 · 이름 · 규격 · 수량산출 · 단위 · 가격 다섯(기준 칸 강조) · 기준단가 / 반영 금액(43-3).
|
||||
* 금액은 calc 답(없으면 「…」).
|
||||
* 줄 누름 · 줄 단추(위로 · 아래로 · 옵션 · 삭제 · 묶음 `ui-btn-group`)는 `on` 이 있을 때만(보기 갈래 = 없음) ·
|
||||
* 줄 누름 · 줄 단추는 `on` 이 있을 때만(보기 갈래 = 없음) — 순서 칸 2행(51-14 · 위 [위로] [아래로] / 아래 [옵션] 또는 [수정] · [삭제] ·
|
||||
* 묶음 `ui-btn-group` · 순서 없는 카드 갈래 = 아래 줄만) · 단가승격 줄 = [옵션] · 일위조합 줄 = [수정](`ref` · 서고 원본) ·
|
||||
* 상세는 줄 누름 = 고름(`selected` 줄 하이라이트 · 그 줄 바로 아래 하위 행 · 51-2 · 화살표 없음 51-7) · 넣을 값 모달은 [옵션](47-5).
|
||||
* ========================================================================== */
|
||||
|
||||
@@ -174,6 +175,8 @@ export interface RowHandlers {
|
||||
open: (i: number) => void;
|
||||
/** [옵션] 단추(47-5 · 넣을 값 모달) — 없으면 단추 없음 */
|
||||
option?: (i: number) => void;
|
||||
/** 참조 줄 단추(51-14) — 단가승격 [옵션] · 일위조합 [수정] = 서고 원본 모달 · 없으면 단추 없음 */
|
||||
ref?: (i: number) => void;
|
||||
/** 수량산출 칸 누름(손 입력 · 엑셀에서 고르기) — 없으면 줄 누름과 같음 */
|
||||
qty?: (i: number) => void;
|
||||
move?: (i: number, d: number) => void;
|
||||
@@ -290,9 +293,11 @@ function subRows(line: LaborCalcLine | undefined, wait: boolean, tools: boolean)
|
||||
/** 담은 로직 표 — 보기 갈래는 `on` 없이 */
|
||||
export function logicTable(data: LogicTableData, on?: RowHandlers): HTMLElement {
|
||||
const wait = !data.calc && !data.fail;
|
||||
const { move, remove, option } = on ?? {};
|
||||
const { move, remove, option, ref } = on ?? {};
|
||||
// 옵션 · 삭제만(구조물 조합 카드 · 43-4)이어도 끝 칸 — 순서 단추는 `move` 가 있을 때만
|
||||
const tools = !!(move || remove || option);
|
||||
const tools = !!(move || remove || option || ref);
|
||||
const group = (children: HTMLElement[]): HTMLElement =>
|
||||
el("div", { className: "ui-btn-group", children });
|
||||
const lineOf = (key: string): LaborCalcLine | undefined =>
|
||||
data.calc?.줄.find((l) => lineId(l) === key);
|
||||
const trs = data.rows.flatMap((row, i) => {
|
||||
@@ -362,13 +367,31 @@ export function logicTable(data: LogicTableData, on?: RowHandlers): HTMLElement
|
||||
className: "m02-labrow__move",
|
||||
children: [
|
||||
el("div", {
|
||||
className: "ui-btn-group",
|
||||
className: "m02-labrow__tools",
|
||||
children: [
|
||||
...(move
|
||||
? [small(tc("Up"), () => move(i, -1)), small(tc("Down"), () => move(i, 1))]
|
||||
? [
|
||||
group([
|
||||
small(tc("Up"), () => move(i, -1)),
|
||||
small(tc("Down"), () => move(i, 1)),
|
||||
]),
|
||||
]
|
||||
: []),
|
||||
...(option && !row.참조 ? [small(tc("Labor_Option"), () => option(i))] : []),
|
||||
...(remove ? [small(tc("Remove"), () => remove(i), "danger")] : []),
|
||||
group([
|
||||
...(row.참조
|
||||
? ref
|
||||
? [
|
||||
small(
|
||||
tc(row.참조.키.startsWith("SP-") ? "Labor_Option" : "Labor_Edit"),
|
||||
() => ref(i),
|
||||
),
|
||||
]
|
||||
: []
|
||||
: option
|
||||
? [small(tc("Labor_Option"), () => option(i))]
|
||||
: []),
|
||||
...(remove ? [small(tc("Remove"), () => remove(i), "danger")] : []),
|
||||
]),
|
||||
],
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -35,6 +35,14 @@ const TEXT = {
|
||||
Down: ["아래로", "Down"],
|
||||
Remove: ["삭제", "Delete"],
|
||||
Labor_Option: ["옵션", "Options"],
|
||||
Labor_Edit: ["수정", "Edit"],
|
||||
Ref_Shared: [
|
||||
"서고 원본을 고침 — 이 문서를 쓰는 모든 구조물에 따라감",
|
||||
"Edits the library original — every structure using it follows",
|
||||
],
|
||||
Ref_ReadOnly: ["이 층은 고칠 수 없음 — 읽기만", "Read-only layer"],
|
||||
Lib_SaveFailed: ["저장 못 함", "Save failed"],
|
||||
Ref_Discard: ["저장 안 한 고침을 버리고 닫음?", "Discard unsaved edits?"],
|
||||
Labor_Source: ["원문", "Source"],
|
||||
Labor_SourceHint: [
|
||||
"단가산출 로직 줄을 고르면 그 원문이 보임",
|
||||
|
||||
@@ -86,7 +86,9 @@ def test_일위대가_카드는_상세_카드_갈래():
|
||||
assert "...(opt.card || lib ? [] : [dgBox])," in detail
|
||||
assert "opt.card ? null : addMat" in detail # 49-6 — 카드엔 [자재 추가] 없음 · 상세는 그대로
|
||||
rows = _text("M02_MasterTemplete_Labor_Rows.ts")
|
||||
assert "const tools = !!(move || remove || option);" in rows and "compactTable" not in rows
|
||||
assert (
|
||||
"const tools = !!(move || remove || option || ref);" in rows and "compactTable" not in rows
|
||||
)
|
||||
assert "compact" not in _text("M02_MasterTemplete_Labor_View.ts").split("*/", 1)[1]
|
||||
|
||||
|
||||
@@ -127,7 +129,9 @@ def test_일위대가_줄_고름과_옵션_단추():
|
||||
단추 위로 · 아래로 · 옵션 · 삭제(빨강) · 묶음 간격 = 공용 `ui-btn-group`."""
|
||||
detail = _text("M02_MasterTemplete_Labor_Detail.ts")
|
||||
assert "open: pick," in detail and "option: openRow," in detail
|
||||
assert "{ open: pick, option: openRow }" in detail # 읽기만도 고름 · [옵션] = 보기 모달
|
||||
assert (
|
||||
"{ open: pick, option: openRow, ref: openRef }" in detail
|
||||
) # 읽기만도 고름 · [옵션] = 보기 모달
|
||||
assert "selected: picked" in detail
|
||||
rows = _text("M02_MasterTemplete_Labor_Rows.ts")
|
||||
up, down = rows.index('small(tc("Up")'), rows.index('small(tc("Down")')
|
||||
@@ -141,3 +145,18 @@ def test_일위대가_줄_고름과_옵션_단추():
|
||||
assert t in text
|
||||
css = (ROOT / "ui_template" / "ui_template_general_layout.css").read_text(encoding="utf-8")
|
||||
assert ".ui-btn-group {" in css and "gap: var(--btn-group-gap);" in css
|
||||
|
||||
|
||||
def test_순서칸_2행_참조줄_옵션_수정():
|
||||
"""51-14 — 순서 칸 2행(위 [위로] [아래로] / 아래 [옵션]·[수정] [삭제]) · 단가승격 [옵션] · 일위조합 [수정] =
|
||||
서고 원본 모달(저장 = 서고 저장 길 · 자기 층만 고침) · 닫으면 다시 셈."""
|
||||
rows = _text("M02_MasterTemplete_Labor_Rows.ts")
|
||||
assert 'className: "m02-labrow__tools"' in rows
|
||||
assert '"SP-") ? "Labor_Option" : "Labor_Edit"' in rows
|
||||
detail = _text("M02_MasterTemplete_Labor_Detail.ts")
|
||||
assert "readOnly: !edit || ref.층 !== opt.layer," in detail
|
||||
assert "closed: () => alive && recalc()," in detail
|
||||
ref = _text("M02_MasterTemplete_Labor_RefEdit.ts")
|
||||
assert "saveTemplate(layer, kind, opt.ref.키, null, 판, body)" in ref
|
||||
assert 'mode: "precombo",' in ref and "showConfirmDialog" in ref
|
||||
assert 'Labor_Edit: ["수정"' in _text("M02_MasterTemplete_Labor_Text.ts")
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
/* 51-14 — 일위대가 표 순서 칸 2행(위 [위로] [아래로] / 아래 [옵션]·[수정] [삭제]) · 단가승격 [옵션] · 일위조합 [수정] 모달
|
||||
* 시작 화면: M02 마스터 템플릿 · 마스터 층(#/m02-master-template?open=구조물조합&root=master) · 시스템 관리자 ·
|
||||
* 나무에 item3(단가승격 SP-000001 · 일위조합 SC-000001 줄이 있음)
|
||||
* 부르는 법: orca eval --expression "$(cat 이 파일)" (async 식 · JSON 글을 돌려줌)
|
||||
* 쓰기 없음 — 모달은 모두 [취소]로 닫음 · PUT 수 = 0 확인(서고 저장 안 함)
|
||||
* 기대 수치:
|
||||
* - card.sp / card.sc: groups 1 · labels [옵션, 삭제] / [수정, 삭제]
|
||||
* - detail.sp / detail.sc: groups 2 · top [위로, 아래로] · bottom [옵션, 삭제] / [수정, 삭제] · danger = 삭제
|
||||
* - promote: notice 있음 · foot [취소, 저장] · closed = true
|
||||
* - combo: notice 있음 · add [로직 추가] · foot [취소, 저장] — 모달 안 [로직 추가]로 단가산출 한 줄 넣음(화면만) ·
|
||||
* added.groups 2 · top [위로, 아래로] · bottom [옵션, 삭제] · [취소] = 버림 물음(asked) → 확인 · closed = true · recalc ≥ 1
|
||||
* - puts = 0
|
||||
*/
|
||||
(async () => {
|
||||
const w = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
const until = async (fn, ms = 8000) => {
|
||||
for (let t = 0; t < ms; t += 150) {
|
||||
const v = fn();
|
||||
if (v) return v;
|
||||
await w(150);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
const SC = "참조|system||SC-000001";
|
||||
const SP = "참조|system||SP-000001";
|
||||
const real = window.fetch;
|
||||
let puts = 0;
|
||||
let calcs = 0;
|
||||
window.fetch = (input, init) => {
|
||||
const url = typeof input === "string" ? input : input.url;
|
||||
if ((init?.method ?? "GET").toUpperCase() === "PUT") puts++;
|
||||
if (/\/labor\/item3\/calc/.test(url)) calcs++;
|
||||
return real(input, init);
|
||||
};
|
||||
const txt = (b) => b.innerText.trim();
|
||||
const tools = (tb, key) => {
|
||||
const cell = tb.querySelector(`tr[data-labor-logic="${key}"] .m02-labrow__move`);
|
||||
const groups = [...cell.querySelectorAll(".m02-labrow__tools > .ui-btn-group")];
|
||||
const btn = (g) => [...g.querySelectorAll("button")];
|
||||
const last = groups.at(-1) ? btn(groups.at(-1)).at(-1) : null;
|
||||
return {
|
||||
groups: groups.length,
|
||||
top: groups.length > 1 ? btn(groups[0]).map(txt) : [],
|
||||
bottom: groups.length ? btn(groups.at(-1)).map(txt) : [],
|
||||
danger: last ? last.className : "",
|
||||
_btn: (label) => groups.flatMap(btn).find((b) => txt(b) === label),
|
||||
};
|
||||
};
|
||||
const clean = (t) => {
|
||||
delete t._btn;
|
||||
return t;
|
||||
};
|
||||
const modal = () => [...document.querySelectorAll(".ui-modal")].at(-1) ?? null;
|
||||
const foot = (m) => [...m.querySelectorAll(".m02-labin__foot button")].map(txt);
|
||||
const cancel = async (m) => {
|
||||
[...m.querySelectorAll(".m02-labin__foot button")].find((b) => txt(b) === "취소").click();
|
||||
await w(600);
|
||||
return !document.body.contains(m);
|
||||
};
|
||||
try {
|
||||
const node = await until(() => document.querySelector('[data-node="i|item3"]'));
|
||||
if (!node) return JSON.stringify({ error: "item3 없음 — 폴더를 펼쳐 둘 것" });
|
||||
document.querySelector('[data-node="i|item1"]')?.click(); // 다시 읽게 다른 항목 거침
|
||||
await w(1500);
|
||||
node.click();
|
||||
const card = await until(() =>
|
||||
[...document.querySelectorAll(".m02-struct__card")].find((c) =>
|
||||
c.querySelector(`table.m02-labrow tbody tr[data-labor-logic="${SC}"]`),
|
||||
),
|
||||
);
|
||||
if (!card) return JSON.stringify({ error: "일위조합 줄 카드 없음" });
|
||||
await w(1500);
|
||||
const ct = card.querySelector("table.m02-labrow");
|
||||
const out = { card: { sp: clean(tools(ct, SP)), sc: clean(tools(ct, SC)) } };
|
||||
const edit = [...card.querySelectorAll(".m02-struct__card-tools button")].find(
|
||||
(b) => txt(b) === "수정",
|
||||
);
|
||||
if (!edit) return JSON.stringify({ ...out, error: "일위대가 [수정] 없음" });
|
||||
edit.click();
|
||||
const detail = () =>
|
||||
[...document.querySelectorAll("table.m02-labrow")].find(
|
||||
(t) =>
|
||||
!t.closest(".m02-struct__card, .ui-modal") &&
|
||||
t.querySelector(`tr[data-labor-logic="${SC}"]`),
|
||||
);
|
||||
if (!(await until(detail))) return JSON.stringify({ ...out, error: "상세 표 없음" });
|
||||
await w(2000);
|
||||
const sp = tools(detail(), SP);
|
||||
const sc = tools(detail(), SC);
|
||||
out.detail = { sp: clean({ ...sp }), sc: clean({ ...sc }) };
|
||||
|
||||
// 단가승격 [옵션] — 넣을 값 모달 · 알림 한 줄 · [취소]
|
||||
sp._btn("옵션").click();
|
||||
const pm = await until(() => modal()?.querySelector(".m02-inputval") && modal());
|
||||
out.promote = pm
|
||||
? {
|
||||
title: pm.querySelector(".ui-modal__top h3").innerText,
|
||||
notice: !!pm.querySelector("[data-labor-notice]"),
|
||||
inputs: pm.querySelectorAll("[data-labor-input]").length,
|
||||
foot: foot(pm),
|
||||
closed: await cancel(pm),
|
||||
}
|
||||
: { error: "승격 모달 없음" };
|
||||
|
||||
// 일위조합 [수정] — 사전조합 상세 모달 · [취소] · 닫으면 다시 셈
|
||||
tools(detail(), SC)._btn("수정").click();
|
||||
const cm = await until(() => document.querySelector(".m02-labref"));
|
||||
if (!cm) return JSON.stringify({ ...out, error: "일위조합 모달 없음", puts });
|
||||
await w(1000);
|
||||
out.combo = {
|
||||
title: cm.querySelector(".ui-modal__top h3").innerText,
|
||||
notice: !!cm.querySelector("[data-labor-notice]"),
|
||||
rows0: cm.querySelectorAll("table.m02-labrow tbody tr[data-labor-logic]").length,
|
||||
add: [...cm.querySelectorAll(".m01-logic__section-head button")].map(txt),
|
||||
foot: foot(cm),
|
||||
};
|
||||
// 모달 안 [로직 추가] → 단가산출 첫 줄(화면 캐시만)
|
||||
[...cm.querySelectorAll(".m01-logic__section-head button")]
|
||||
.find((b) => txt(b) === "로직 추가")
|
||||
.click();
|
||||
const pick = await until(
|
||||
() =>
|
||||
[...document.querySelectorAll(".m01-logic__pick .ui-find__row")].find(
|
||||
(r) => r.querySelector(".ui-find__tag")?.innerText.trim() === "단가산출",
|
||||
),
|
||||
30000, // 로직 목록 1천여 줄
|
||||
);
|
||||
if (!pick) return JSON.stringify({ ...out, error: "고르기 줄 없음", puts });
|
||||
pick.click();
|
||||
const added = await until(() =>
|
||||
cm.querySelector("table.m02-labrow tbody tr[data-labor-logic]"),
|
||||
);
|
||||
if (added) {
|
||||
const key = added.getAttribute("data-labor-logic");
|
||||
out.combo.added = clean(tools(cm.querySelector("table.m02-labrow"), key));
|
||||
}
|
||||
const before = calcs;
|
||||
[...cm.querySelectorAll(".m02-labin__foot button")].find((b) => txt(b) === "취소").click();
|
||||
const ask = await until(() => document.querySelector(".ui-confirm"));
|
||||
out.combo.asked = !!ask;
|
||||
[...(ask?.querySelectorAll("button") ?? [])].find((b) => txt(b) === "확인")?.click();
|
||||
await w(600);
|
||||
out.combo.closed = !document.body.contains(cm);
|
||||
await w(1200);
|
||||
out.combo.recalc = calcs - before;
|
||||
out.puts = puts;
|
||||
|
||||
document.querySelector('[data-node="i|item3"]')?.click();
|
||||
await w(800);
|
||||
[...document.querySelectorAll(".ui-modal button, dialog button")]
|
||||
.find((b) => /확인|버림|떠나기/.test(b.innerText))
|
||||
?.click();
|
||||
await w(1200);
|
||||
out.back = !!document.querySelector(".m02-struct__card table.m02-labrow");
|
||||
return JSON.stringify(out);
|
||||
} finally {
|
||||
window.fetch = real;
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user