feat: KKT dto_device_id — multiple KKTs per DTO instance
- EquipmentPage: added "ID устройства в ДТО" field (config.dto_device_id), shown on device card as #1 - api.ts: typed config.dto_device_id in WorkstationDevice Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -302,6 +302,7 @@ const workstationRoutes: FastifyPluginAsync = async (fastify) => {
|
|||||||
dto_port: device.dto_port,
|
dto_port: device.dto_port,
|
||||||
dto_user: device.config?.dto_user,
|
dto_user: device.config?.dto_user,
|
||||||
dto_pass: device.config?.dto_pass,
|
dto_pass: device.config?.dto_pass,
|
||||||
|
dto_device_id: device.config?.dto_device_id,
|
||||||
},
|
},
|
||||||
}) as { ok: boolean; error?: string; message?: string }
|
}) as { ok: boolean; error?: string; message?: string }
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -1006,7 +1006,7 @@ export interface WorkstationDevice {
|
|||||||
networkPort?: number
|
networkPort?: number
|
||||||
comPort?: string
|
comPort?: string
|
||||||
purpose: 'fiscal' | 'kitchen' | 'bar' | 'receipt' | 'other'
|
purpose: 'fiscal' | 'kitchen' | 'bar' | 'receipt' | 'other'
|
||||||
config: Record<string, unknown>
|
config: Record<string, unknown> & { dto_user?: string; dto_pass?: string; dto_device_id?: string }
|
||||||
fiscalMode?: boolean
|
fiscalMode?: boolean
|
||||||
dtoPort?: number
|
dtoPort?: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ function DeviceForm({
|
|||||||
const [dtoPort, setDtoPort] = useState(String(initial?.dtoPort ?? 16732))
|
const [dtoPort, setDtoPort] = useState(String(initial?.dtoPort ?? 16732))
|
||||||
const [dtoUser, setDtoUser] = useState(String(initial?.config?.dto_user ?? '30'))
|
const [dtoUser, setDtoUser] = useState(String(initial?.config?.dto_user ?? '30'))
|
||||||
const [dtoPass, setDtoPass] = useState(String(initial?.config?.dto_pass ?? '30'))
|
const [dtoPass, setDtoPass] = useState(String(initial?.config?.dto_pass ?? '30'))
|
||||||
|
const [dtoDeviceId, setDtoDeviceId] = useState(String(initial?.config?.dto_device_id ?? ''))
|
||||||
const [saving, setSaving] = useState(false)
|
const [saving, setSaving] = useState(false)
|
||||||
const [availablePorts, setAvailablePorts] = useState<{ port: string; description?: string }[] | null>(null)
|
const [availablePorts, setAvailablePorts] = useState<{ port: string; description?: string }[] | null>(null)
|
||||||
const [portsLoading, setPortsLoading] = useState(false)
|
const [portsLoading, setPortsLoading] = useState(false)
|
||||||
@@ -230,7 +231,7 @@ function DeviceForm({
|
|||||||
purpose: purpose as WorkstationDevice['purpose'],
|
purpose: purpose as WorkstationDevice['purpose'],
|
||||||
fiscalMode: type === 'kkt' ? fiscalMode : undefined,
|
fiscalMode: type === 'kkt' ? fiscalMode : undefined,
|
||||||
dtoPort: type === 'kkt' && fiscalMode ? Number(dtoPort) : undefined,
|
dtoPort: type === 'kkt' && fiscalMode ? Number(dtoPort) : undefined,
|
||||||
config: type === 'kkt' && fiscalMode ? { dto_user: dtoUser, dto_pass: dtoPass } : undefined,
|
config: type === 'kkt' && fiscalMode ? { dto_user: dtoUser, dto_pass: dtoPass, dto_device_id: dtoDeviceId.trim() || undefined } : undefined,
|
||||||
})
|
})
|
||||||
setSaving(false)
|
setSaving(false)
|
||||||
}
|
}
|
||||||
@@ -295,15 +296,27 @@ function DeviceForm({
|
|||||||
</div>
|
</div>
|
||||||
{fiscalMode && (
|
{fiscalMode && (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-slate-500 mb-1">Порт АТОЛ ДТО</label>
|
<label className="block text-xs font-medium text-slate-500 mb-1">Порт АТОЛ ДТО</label>
|
||||||
<input
|
<input
|
||||||
value={dtoPort}
|
value={dtoPort}
|
||||||
onChange={e => setDtoPort(e.target.value)}
|
onChange={e => setDtoPort(e.target.value)}
|
||||||
className="w-32 input text-sm font-mono"
|
className="w-full input text-sm font-mono"
|
||||||
placeholder="16732"
|
placeholder="16732"
|
||||||
/>
|
/>
|
||||||
<p className="text-xs text-slate-400 mt-1">По умолчанию 16732. Для нескольких касс — разные порты.</p>
|
<p className="text-xs text-slate-400 mt-1">По умолчанию 16732</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="block text-xs font-medium text-slate-500 mb-1">ID устройства в ДТО</label>
|
||||||
|
<input
|
||||||
|
value={dtoDeviceId}
|
||||||
|
onChange={e => setDtoDeviceId(e.target.value)}
|
||||||
|
className="w-full input text-sm font-mono"
|
||||||
|
placeholder="1"
|
||||||
|
/>
|
||||||
|
<p className="text-xs text-slate-400 mt-1">Из /api/v2/devices</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-2 gap-3">
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<div>
|
<div>
|
||||||
@@ -694,6 +707,9 @@ function WorkstationCard({
|
|||||||
{device.type === 'kkt' && device.fiscalMode !== false && device.dtoPort && device.dtoPort !== 16732 && (
|
{device.type === 'kkt' && device.fiscalMode !== false && device.dtoPort && device.dtoPort !== 16732 && (
|
||||||
<span className="text-xs text-slate-400 font-mono">DTO:{device.dtoPort}</span>
|
<span className="text-xs text-slate-400 font-mono">DTO:{device.dtoPort}</span>
|
||||||
)}
|
)}
|
||||||
|
{device.type === 'kkt' && device.fiscalMode !== false && device.config?.dto_device_id && (
|
||||||
|
<span className="text-xs text-slate-400 font-mono">#{device.config.dto_device_id}</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user