import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
const inventoryLedger = readFileSync(new URL("../src/views/InventoryLedgerView.vue", import.meta.url), "utf8");
const purchaseOrder = readFileSync(new URL("../src/views/PurchaseOrderView.vue", import.meta.url), "utf8");
const purchaseReceipt = readFileSync(new URL("../src/views/PurchaseReceiptView.vue", import.meta.url), "utf8");
assert.match(inventoryLedger, /const activeWeightOnly = computed\(\(\) => \["raw", "scrap"\]\.includes\(activeInventoryTab\.value\)\)/);
assert.match(inventoryLedger, /const selectedWeightOnly = computed\(\s*\(\) => \["RAW", "SCRAP"\]\.includes\(selectedWarehouseType\.value\)\s*\)/);
assert.match(inventoryLedger, /const activeQuantityOnly = computed\(\(\) => activeInventoryTab\.value === "auxiliary"\)/);
assert.match(inventoryLedger, /const selectedQuantityOnly = computed\(\(\) => selectedWarehouseType\.value === "AUX"\)/);
assert.match(inventoryLedger, /normalizeWarehouseType\(lot\) === "AUX"[\s\S]*return lotAvailableQty\(lot\) > 0/);
assert.match(inventoryLedger, /
现存重量\(kg\)<\/th>/);
assert.match(inventoryLedger, / | [\s\S]*formatWeight\(balance\.weight_on_hand_kg\)/);
assert.match(inventoryLedger, / | 变动重量\(kg\)<\/th>/);
assert.match(inventoryLedger, /selectedQuantityOnly\.value[\s\S]*return "可用数量"/);
assert.match(inventoryLedger, /isSelectedFinishedWarehouse\.value \|\| selectedQuantityOnly\.value[\s\S]*key: "inbound_qty"/);
assert.match(inventoryLedger, /!\s*selectedQuantityOnly\.value \? \[\s*\{ key: "inbound_weight_kg"/);
assert.match(inventoryLedger, /activeWarehouseType\.value === "AUX"\s*\?\s*Number\(genericForm\.qty \|\| 0\)/);
assert.match(inventoryLedger, /辅料生产出库必须填写用途/);
assert.match(inventoryLedger, /activeWarehouseType === "AUX" \? "单价\(元\/件\)" : "单价\(元\/kg\)"/);
assert.match(inventoryLedger, / | 单位<\/th>/);
assert.match(inventoryLedger, / | \{\{ formatInventoryUnitLabel\(balance\) \}\}<\/td>/);
assert.match(inventoryLedger, /searchFields: \["item_code", "item_name", "specification", "stock_unit_name", "purchase_unit_name", "sales_unit_name", "warehouse_name", "location_name", "operation_label", "source_material_summary"\]/);
assert.match(inventoryLedger, /const specificationLabel = balance\.specification \? ` · \$\{balance\.specification\}` : ""/);
assert.match(inventoryLedger, /const baseLabel = `\$\{balance\.item_code\} · \$\{balance\.item_name\}\$\{specificationLabel\}`/);
assert.match(inventoryLedger, /function formatInventoryUnitLabel\(item\)/);
assert.match(inventoryLedger, /计量单位:\(\[\^;;\]\+\)/);
assert.match(purchaseOrder, /v-model\.number="item\.order_qty"/);
assert.match(purchaseOrder, /order_qty: form\.target_warehouse_type === "AUX" \? Number\(item\.order_qty \|\| 0\) : 0/);
assert.match(purchaseOrder, /order_weight_kg: form\.target_warehouse_type === "AUX" \? 0 : Number\(item\.order_weight_kg \|\| 0\)/);
assert.match(purchaseOrder, /formatOrderTotal\(order\)/);
assert.match(purchaseOrder, /formatPurchaseUnitPriceDisplay\(row\)/);
assert.match(purchaseReceipt, /const selectedPurchaseTargetType = computed/);
assert.match(purchaseReceipt, /v-model\.number="item\.received_qty"/);
assert.match(purchaseReceipt, /received_qty: selectedPurchaseTargetType\.value === "AUX" \? Number\(item\.received_qty \|\| 0\) : 0/);
assert.match(purchaseReceipt, /received_weight_kg: selectedPurchaseTargetType\.value === "AUX" \? 0 : Number\(item\.received_weight_kg \|\| 0\)/);
assert.match(purchaseReceipt, /formatReceiptItemReceived\(row\)/);
console.log("辅料库数量口径前端静态检查通过");
|