mirror of
https://github.com/Spythere/genera-tor.git
synced 2026-05-03 13:38:12 +00:00
Zapisywanie rozkazów
This commit is contained in:
@@ -12,7 +12,8 @@ export default defineComponent({
|
||||
methods: {
|
||||
saveOrderToStorage() {
|
||||
let orderObj: LocalStorageOrder = {
|
||||
orderType: this.store.chosenOrderType ,
|
||||
id: '',
|
||||
orderType: this.store.chosenOrderType,
|
||||
orderBody: {},
|
||||
orderFooter: this.store.orderFooter,
|
||||
createdAt: Date.now(),
|
||||
@@ -50,10 +51,60 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
const nextOrderCount = Number(localOrderCount) + 1;
|
||||
orderObj['id'] = `order-${nextOrderCount}`;
|
||||
|
||||
localStorage.setItem('orderCount', `${nextOrderCount}`);
|
||||
localStorage.setItem(`order-${nextOrderCount}`, JSON.stringify(orderObj));
|
||||
|
||||
return 1;
|
||||
},
|
||||
|
||||
removeLocalOrder(order: LocalStorageOrder) {
|
||||
localStorage.removeItem(order.id);
|
||||
localStorage.setItem('orderCount', (Number(localStorage.getItem('orderCount')) - 1).toString());
|
||||
},
|
||||
|
||||
selectLocalOrder(order: LocalStorageOrder) {
|
||||
this.store.chosenOrderType = order.orderType;
|
||||
const localOrder = JSON.parse(JSON.stringify(order));
|
||||
const localOrderBody = localOrder['orderBody'];
|
||||
const localOrderFooter = localOrder['orderFooter'];
|
||||
|
||||
let storeOrderObj;
|
||||
|
||||
switch (order.orderType) {
|
||||
case 'orderN':
|
||||
case 'orderS':
|
||||
storeOrderObj = this.store[order.orderType];
|
||||
for (let orderKey in storeOrderObj) {
|
||||
for (let propKey in (storeOrderObj as any)[orderKey]) {
|
||||
(storeOrderObj as any)[orderKey][propKey] = localOrderBody[orderKey][propKey];
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'orderO':
|
||||
storeOrderObj = this.store[order.orderType];
|
||||
|
||||
storeOrderObj['other'] = localOrderBody['other'];
|
||||
storeOrderObj['header']['date'] = localOrderBody['header']['date'];
|
||||
storeOrderObj['header']['orderNo'] = localOrderBody['header']['orderNo'];
|
||||
storeOrderObj['header']['trainNo'] = localOrderBody['header']['trainNo'];
|
||||
|
||||
for (let i = 0; i < storeOrderObj['orderList'].length; i++) {
|
||||
const orderItem = storeOrderObj['orderList'][i];
|
||||
|
||||
for (let prop in orderItem) {
|
||||
(storeOrderObj['orderList'][i] as any)[prop] = localOrderBody['orderList'][i][prop];
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
for (let key in this.store.orderFooter) {
|
||||
(this.store.orderFooter as any)[key] = localOrderFooter[key];
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user