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 { defineComponent } from 'vue';
|
||||||
import orderStorageMixin from '../mixins/orderStorageMixin';
|
import orderStorageMixin from '../mixins/orderStorageMixin';
|
||||||
import { useStore } from '../store/store';
|
import { useStore } from '../store/store';
|
||||||
import { LocalStorageOrder } from '../types/orderTypes';
|
import { LocalStorageOrderLegacy } from '../types/orderTypes';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'OrderList',
|
name: 'OrderList',
|
||||||
@@ -60,7 +60,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
localOrderList: [] as LocalStorageOrder[],
|
localOrderList: [] as LocalStorageOrderLegacy[],
|
||||||
ORDER_VERSION: import.meta.env['VITE_APP_ORDER_VERSION']
|
ORDER_VERSION: import.meta.env['VITE_APP_ORDER_VERSION']
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -77,7 +77,7 @@ export default defineComponent({
|
|||||||
return orderType.split('order')[1];
|
return orderType.split('order')[1];
|
||||||
},
|
},
|
||||||
|
|
||||||
removeOrder(order: LocalStorageOrder) {
|
removeOrder(order: LocalStorageOrderLegacy) {
|
||||||
if (!order) return;
|
if (!order) return;
|
||||||
|
|
||||||
this.removeLocalOrder(order);
|
this.removeLocalOrder(order);
|
||||||
@@ -102,7 +102,7 @@ export default defineComponent({
|
|||||||
for (let key in localStorage) {
|
for (let key in localStorage) {
|
||||||
if (!/^order-/g.test(key)) continue;
|
if (!/^order-/g.test(key)) continue;
|
||||||
|
|
||||||
const orderObj: LocalStorageOrder = JSON.parse(localStorage[key]);
|
const orderObj: LocalStorageOrderLegacy = JSON.parse(localStorage[key]);
|
||||||
if (!orderObj) continue;
|
if (!orderObj) continue;
|
||||||
|
|
||||||
orderList.push(orderObj);
|
orderList.push(orderObj);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ import { useStore } from '../store/store';
|
|||||||
|
|
||||||
import { currentFormattedHours, currentFormattedMinutes } from '../utils/dateUtils';
|
import { currentFormattedHours, currentFormattedMinutes } from '../utils/dateUtils';
|
||||||
import StorageManager from '../managers/storageManager';
|
import StorageManager from '../managers/storageManager';
|
||||||
import { LocalStorageOrder } from '../types/orderTypes';
|
import { LocalStorageOrderLegacy } from '../types/orderTypes';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
@@ -187,7 +187,7 @@ function verifyOrderFields() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function saveOrder() {
|
function saveOrder() {
|
||||||
const orderObj: LocalStorageOrder = {
|
const orderObj: LocalStorageOrderLegacy = {
|
||||||
id: '',
|
id: '',
|
||||||
orderType: store.chosenOrderType,
|
orderType: store.chosenOrderType,
|
||||||
orderBody: store[store.chosenOrderType],
|
orderBody: store[store.chosenOrderType],
|
||||||
@@ -248,7 +248,7 @@ function updateOrder() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const orderObj: LocalStorageOrder = {
|
const orderObj: LocalStorageOrderLegacy = {
|
||||||
id: store.chosenLocalOrderId,
|
id: store.chosenLocalOrderId,
|
||||||
orderType: store.chosenOrderType,
|
orderType: store.chosenOrderType,
|
||||||
orderBody: store[store.chosenOrderType],
|
orderBody: store[store.chosenOrderType],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { useStore } from '../store/store';
|
import { useStore } from '../store/store';
|
||||||
import { LocalStorageOrder } from '../types/orderTypes';
|
import { LocalStorageOrderLegacy } from '../types/orderTypes';
|
||||||
|
|
||||||
function alertWrongOrderFormat() {
|
function alertWrongOrderFormat() {
|
||||||
alert('Wystąpił błąd podczas przetwarzania rozkazu! Informacje mogą być niepoprawne!');
|
alert('Wystąpił błąd podczas przetwarzania rozkazu! Informacje mogą być niepoprawne!');
|
||||||
@@ -15,14 +15,14 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
removeLocalOrder(order: LocalStorageOrder) {
|
removeLocalOrder(order: LocalStorageOrderLegacy) {
|
||||||
localStorage.removeItem(order.id);
|
localStorage.removeItem(order.id);
|
||||||
|
|
||||||
if (this.store.chosenLocalOrderId == order.id) this.store.chosenLocalOrderId = '';
|
if (this.store.chosenLocalOrderId == order.id) this.store.chosenLocalOrderId = '';
|
||||||
// localStorage.setItem('orderCount', (Number(localStorage.getItem('orderCount')) - 1).toString());
|
// localStorage.setItem('orderCount', (Number(localStorage.getItem('orderCount')) - 1).toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
selectLocalOrder(localOrder: LocalStorageOrder) {
|
selectLocalOrder(localOrder: LocalStorageOrderLegacy) {
|
||||||
// const localOrder = JSON.parse(JSON.stringify(order));
|
// const localOrder = JSON.parse(JSON.stringify(order));
|
||||||
const { orderBody: localOrderBody, orderFooter: localOrderFooter } = localOrder;
|
const { orderBody: localOrderBody, orderFooter: localOrderFooter } = localOrder;
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { IOrderN, IOrderO, IOrderS, TOrder } from '../types/orderTypes';
|
import { IOrderData, IOrderN, IOrderO, IOrderS, TOrder } from '../types/orderTypes';
|
||||||
import {
|
import {
|
||||||
currentFormattedDate,
|
currentFormattedDate,
|
||||||
currentFormattedHours,
|
currentFormattedHours,
|
||||||
@@ -24,6 +24,8 @@ export const useStore = defineStore('store', {
|
|||||||
helperModalOpen: false,
|
helperModalOpen: false,
|
||||||
orderDarkMode: false,
|
orderDarkMode: false,
|
||||||
|
|
||||||
|
panelMode: 'OrderMessage',
|
||||||
|
|
||||||
chosenOrderType: 'orderN' as TOrder,
|
chosenOrderType: 'orderN' as TOrder,
|
||||||
chosenLocalOrderId: '',
|
chosenLocalOrderId: '',
|
||||||
|
|
||||||
@@ -339,9 +341,7 @@ export const useStore = defineStore('store', {
|
|||||||
Y: '',
|
Y: '',
|
||||||
Z: ''
|
Z: ''
|
||||||
}
|
}
|
||||||
},
|
} as IOrderData,
|
||||||
|
|
||||||
panelMode: 'OrderMessage',
|
|
||||||
|
|
||||||
orderFooter: {
|
orderFooter: {
|
||||||
stationName: '',
|
stationName: '',
|
||||||
|
|||||||
+46
-1
@@ -1,6 +1,6 @@
|
|||||||
export type TOrder = 'orderO' | 'orderS' | 'orderN';
|
export type TOrder = 'orderO' | 'orderS' | 'orderN';
|
||||||
|
|
||||||
export interface LocalStorageOrder {
|
export interface LocalStorageOrderLegacy {
|
||||||
id: string;
|
id: string;
|
||||||
orderType: TOrder;
|
orderType: TOrder;
|
||||||
orderBody: any;
|
orderBody: any;
|
||||||
@@ -10,6 +10,51 @@ export interface LocalStorageOrder {
|
|||||||
orderVersion?: string;
|
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 {
|
export interface IOrderN {
|
||||||
header: {
|
header: {
|
||||||
orderNo: string;
|
orderNo: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user