mirror of
https://github.com/Spythere/genera-tor.git
synced 2026-05-03 05:28:13 +00:00
refactor: new order typings
This commit is contained in:
@@ -52,7 +52,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import orderStorageMixin from '../mixins/orderStorageMixin';
|
||||
import { useStore } from '../store/store';
|
||||
import { LocalStorageOrder } from '../types/orderTypes';
|
||||
import { LocalStorageOrderLegacy } from '../types/orderTypes';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'OrderList',
|
||||
@@ -60,7 +60,7 @@ export default defineComponent({
|
||||
|
||||
data() {
|
||||
return {
|
||||
localOrderList: [] as LocalStorageOrder[],
|
||||
localOrderList: [] as LocalStorageOrderLegacy[],
|
||||
ORDER_VERSION: import.meta.env['VITE_APP_ORDER_VERSION']
|
||||
};
|
||||
},
|
||||
@@ -77,7 +77,7 @@ export default defineComponent({
|
||||
return orderType.split('order')[1];
|
||||
},
|
||||
|
||||
removeOrder(order: LocalStorageOrder) {
|
||||
removeOrder(order: LocalStorageOrderLegacy) {
|
||||
if (!order) return;
|
||||
|
||||
this.removeLocalOrder(order);
|
||||
@@ -102,7 +102,7 @@ export default defineComponent({
|
||||
for (let key in localStorage) {
|
||||
if (!/^order-/g.test(key)) continue;
|
||||
|
||||
const orderObj: LocalStorageOrder = JSON.parse(localStorage[key]);
|
||||
const orderObj: LocalStorageOrderLegacy = JSON.parse(localStorage[key]);
|
||||
if (!orderObj) continue;
|
||||
|
||||
orderList.push(orderObj);
|
||||
|
||||
@@ -73,7 +73,7 @@ import { useStore } from '../store/store';
|
||||
|
||||
import { currentFormattedHours, currentFormattedMinutes } from '../utils/dateUtils';
|
||||
import StorageManager from '../managers/storageManager';
|
||||
import { LocalStorageOrder } from '../types/orderTypes';
|
||||
import { LocalStorageOrderLegacy } from '../types/orderTypes';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -187,7 +187,7 @@ function verifyOrderFields() {
|
||||
}
|
||||
|
||||
function saveOrder() {
|
||||
const orderObj: LocalStorageOrder = {
|
||||
const orderObj: LocalStorageOrderLegacy = {
|
||||
id: '',
|
||||
orderType: store.chosenOrderType,
|
||||
orderBody: store[store.chosenOrderType],
|
||||
@@ -248,7 +248,7 @@ function updateOrder() {
|
||||
return;
|
||||
}
|
||||
|
||||
const orderObj: LocalStorageOrder = {
|
||||
const orderObj: LocalStorageOrderLegacy = {
|
||||
id: store.chosenLocalOrderId,
|
||||
orderType: store.chosenOrderType,
|
||||
orderBody: store[store.chosenOrderType],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useStore } from '../store/store';
|
||||
import { LocalStorageOrder } from '../types/orderTypes';
|
||||
import { LocalStorageOrderLegacy } from '../types/orderTypes';
|
||||
|
||||
function alertWrongOrderFormat() {
|
||||
alert('Wystąpił błąd podczas przetwarzania rozkazu! Informacje mogą być niepoprawne!');
|
||||
@@ -15,14 +15,14 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
removeLocalOrder(order: LocalStorageOrder) {
|
||||
removeLocalOrder(order: LocalStorageOrderLegacy) {
|
||||
localStorage.removeItem(order.id);
|
||||
|
||||
if (this.store.chosenLocalOrderId == order.id) this.store.chosenLocalOrderId = '';
|
||||
// localStorage.setItem('orderCount', (Number(localStorage.getItem('orderCount')) - 1).toString());
|
||||
},
|
||||
|
||||
selectLocalOrder(localOrder: LocalStorageOrder) {
|
||||
selectLocalOrder(localOrder: LocalStorageOrderLegacy) {
|
||||
// const localOrder = JSON.parse(JSON.stringify(order));
|
||||
const { orderBody: localOrderBody, orderFooter: localOrderFooter } = localOrder;
|
||||
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { IOrderN, IOrderO, IOrderS, TOrder } from '../types/orderTypes';
|
||||
import { IOrderData, IOrderN, IOrderO, IOrderS, TOrder } from '../types/orderTypes';
|
||||
import {
|
||||
currentFormattedDate,
|
||||
currentFormattedHours,
|
||||
@@ -24,6 +24,8 @@ export const useStore = defineStore('store', {
|
||||
helperModalOpen: false,
|
||||
orderDarkMode: false,
|
||||
|
||||
panelMode: 'OrderMessage',
|
||||
|
||||
chosenOrderType: 'orderN' as TOrder,
|
||||
chosenLocalOrderId: '',
|
||||
|
||||
@@ -339,9 +341,7 @@ export const useStore = defineStore('store', {
|
||||
Y: '',
|
||||
Z: ''
|
||||
}
|
||||
},
|
||||
|
||||
panelMode: 'OrderMessage',
|
||||
} as IOrderData,
|
||||
|
||||
orderFooter: {
|
||||
stationName: '',
|
||||
|
||||
+46
-1
@@ -1,6 +1,6 @@
|
||||
export type TOrder = 'orderO' | 'orderS' | 'orderN';
|
||||
|
||||
export interface LocalStorageOrder {
|
||||
export interface LocalStorageOrderLegacy {
|
||||
id: string;
|
||||
orderType: TOrder;
|
||||
orderBody: any;
|
||||
@@ -10,6 +10,51 @@ export interface LocalStorageOrder {
|
||||
orderVersion?: string;
|
||||
}
|
||||
|
||||
export interface IStorageOrderData {
|
||||
id: string;
|
||||
orderVersion: string;
|
||||
createdAt: number;
|
||||
updatedAt?: number;
|
||||
orderData: IOrderData;
|
||||
}
|
||||
|
||||
export interface IOrderData {
|
||||
header: IOrderHeader;
|
||||
instructions: IOrderInstruction[];
|
||||
footer: IOrderFooter;
|
||||
}
|
||||
|
||||
export interface IOrderHeader {
|
||||
A: string;
|
||||
B: string;
|
||||
C: string;
|
||||
D: string;
|
||||
}
|
||||
|
||||
export interface IOrderFooter {
|
||||
V: string;
|
||||
W: string;
|
||||
Y: string;
|
||||
Z: string;
|
||||
}
|
||||
|
||||
export interface IOrderFieldItem {
|
||||
active: false;
|
||||
values: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface IOrderInstruction {
|
||||
key: string;
|
||||
name: string;
|
||||
active: boolean;
|
||||
inputFields: Record<string, string>;
|
||||
optionalFieldNames: string[];
|
||||
textDirectives: string[];
|
||||
|
||||
selectFields?: Record<string, Record<string, string[]>>;
|
||||
listFields?: IOrderFieldItem[];
|
||||
}
|
||||
|
||||
export interface IOrderN {
|
||||
header: {
|
||||
orderNo: string;
|
||||
|
||||
Reference in New Issue
Block a user