feat: 增加机器位置手动编辑功能及公开查看界面
This commit is contained in:
+31
-1
@@ -1165,6 +1165,36 @@ createApp({
|
||||
}
|
||||
};
|
||||
|
||||
const showEditMachineModal = ref(false);
|
||||
const editMachineForm = reactive({ device_id: '', station_code: '', x: 0, y: 0, z: 0, type: 'TicketMachine' });
|
||||
|
||||
const openEditMachineModal = (id) => {
|
||||
const loc = machineLocations.value[id];
|
||||
if (!loc) return;
|
||||
editMachineForm.device_id = id;
|
||||
editMachineForm.station_code = loc.station_code || loc.station || '';
|
||||
editMachineForm.x = loc.x || 0;
|
||||
editMachineForm.y = loc.y || 0;
|
||||
editMachineForm.z = loc.z || 0;
|
||||
editMachineForm.type = loc.type || 'TicketMachine';
|
||||
showEditMachineModal.value = true;
|
||||
};
|
||||
|
||||
const saveMachineLocation = async () => {
|
||||
try {
|
||||
const payload = { ...editMachineForm };
|
||||
await requestJson(`/api/machine-location/${encodeURIComponent(payload.device_id)}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
}, { expectOk: true });
|
||||
showEditMachineModal.value = false;
|
||||
await fetchMachineLocations();
|
||||
} catch (e) {
|
||||
alert('保存失败: ' + e.message);
|
||||
}
|
||||
};
|
||||
|
||||
const ensureViewData = async (view = currentView.value, { force = false } = {}) => {
|
||||
await fetchCoreData({ force });
|
||||
if (view === 'tickets' && (force || !ticketDataLoaded)) await fetchTicketData();
|
||||
@@ -1780,7 +1810,7 @@ createApp({
|
||||
};
|
||||
|
||||
return {
|
||||
machineLocations, selectedMachineId, getMapX, getMapY,
|
||||
machineLocations, selectedMachineId, getMapX, getMapY, showEditMachineModal, editMachineForm, openEditMachineModal, saveMachineLocation,
|
||||
currentView, viewTitle, sidebarOpen,
|
||||
loadingState, isViewBusy, lastSyncText, currentViewSummary,
|
||||
stations, lines, fares, stats, config, recentLogs, ticketList, ticketStats, orderStats,
|
||||
|
||||
Reference in New Issue
Block a user