Merge remote-tracking branch 'origin/main_laptop_1' into sub_laptop_3

This commit is contained in:
2026-11-15 18:31:03 +09:00
101 changed files with 447 additions and 32 deletions
+2 -2
View File
@@ -17,7 +17,7 @@ import { createInputField, createSelectField } from "@ui/ui_template_input";
import { currentLanguageIndex } from "@ui/ui_template_locale";
import { createText } from "@ui/ui_template_text";
import { formatLineMoney, formatMoney } from "../common_util/common_util_money";
import { nameMachines, optionText } from "./formula_doc_options";
import { liveOptions, nameMachines, optionText } from "./formula_doc_options";
import "./calc_sheet.css";
export interface SheetLine {
@@ -164,7 +164,7 @@ export function varRow(spec: SheetInput, value: string, onInput: (v: string) =>
let control: HTMLElement;
if (spec.고르기?.length) {
const list = [...(value ? [] : [""]), ...spec.고르기.map(String)];
const items = () => list.map((o) => ({ value: o, text: optionText(o) })); // 기계 번호 = 이름(요구 692-2)
const items = () => liveOptions(list, value).map((o) => ({ value: o, text: optionText(o) })); // 기계 번호 = 이름(요구 692-2) · 끈 기계 뺌(842-2)
const f = createSelectField({
options: items(),
value,
+17 -6
View File
@@ -9,21 +9,31 @@
import { createButton } from "@ui/ui_template_button";
import { createInputField, createSelectField } from "@ui/ui_template_input";
import { varId, type DocVar, type FormulaDoc } from "../common_util/common_util_formula_doc";
import { cfMachineNames } from "../M02_MasterTemplete/DataFlow/M02_DF_Api";
import { cfMachineNames, cfMachineOff } from "../M02_MasterTemplete/DataFlow/M02_DF_Api";
import { mt } from "../M02_MasterTemplete/M02_MyMachine_Text";
import { ft } from "./formula_doc_text";
const MACHINE = /^\d{4}-\d{4}$/;
let names: Record<string, string> = {};
let off = new Set<string>(); // 842-2 끈 기계 원문번호
const machineInfo = (): Promise<Record<string, string>> =>
Promise.all([cfMachineNames(), cfMachineOff()]).then(
([got, gone]) => ((off = new Set(gone)), got),
);
/** 고르기 글 — 기계 원문번호는 이름 · 규격을 앞에 */
/** 고르기 글 — 기계 원문번호는 이름 · 규격을 앞에 · 끈 기계는 「· 비활성 기계」(842-2) */
export const optionText = (x: string, known: Record<string, string> = names): string =>
known[x] ? `${known[x]} (${x})` : x;
known[x] ? `${known[x]} (${x})${off.has(x) ? ` · ${ft("Machine_Off")}` : ""}` : x;
/** 고르기 목록 — 끈 기계 뺌(지금 고른 값은 남김 · 842-2) */
export const liveOptions = (list: string[], now: string): string[] =>
list.filter((x) => x === now || !off.has(x));
/** 목록이 모두 원문번호(빈 칸 빼고)면 이름을 받아 `redraw`(글만 다시) — 수식 탭 옵션 · 단가산출 상세 옵션 */
export function nameMachines(list: string[], redraw: () => void): void {
const codes = list.filter(Boolean);
if (codes.length && codes.every((x) => MACHINE.test(x)) && codes.some((x) => !(x in names)))
void cfMachineNames().then((got) => {
void machineInfo().then((got) => {
names = got;
redraw();
});
@@ -35,7 +45,7 @@ export function machineText(x: unknown, redraw: () => void): string | null {
if (typeof x !== "string" || !MACHINE.test(x)) return null;
if (!(x in names) && !asked) {
asked = true;
void cfMachineNames().then((got) => {
void machineInfo().then((got) => {
names = { ...names, ...got };
redraw();
});
@@ -59,7 +69,8 @@ export function buildOptions(
const now = k in given ? given[k] : v.연결?.값;
if (kind === "선택") {
const list = (v.연결?.목록 ?? []).map(String);
const items = () => list.map((x) => ({ value: x, text: optionText(x) }));
const items = () =>
liveOptions(list, String(now ?? "")).map((x) => ({ value: x, text: optionText(x) }));
const f = createSelectField({
label,
options: items(),
+1
View File
@@ -49,6 +49,7 @@ const TEXT = {
By_Line: ["식 줄로 정의", "Defined by a line"],
Pick_First: ["찾아 고름", "Search and pick"],
Material: ["재료 고르기", "Material pick"],
Machine_Off: ["비활성 기계", "Inactive machine"],
None: ["없음", "None"],
Open_Sub: ["식 펼침", "Show equation"],
Bad_Sign: ["기호 꼴 아님 · 같은 기호 있음", "Bad or duplicate symbol"],