@ozdao/prometheus-framework 0.2.35 → 0.2.36
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/main.css +1 -1
- package/dist/prometheus-framework.cjs.js +18 -19
- package/dist/prometheus-framework.es.js +803 -1028
- package/package.json +1 -1
- package/src/components/Button/Button.vue +26 -19
- package/src/components/FieldBig/FieldBig.vue +1 -1
- package/src/components/FieldPhone/FieldPhone.vue +55 -304
- package/src/components/FieldPhone/FieldPhone2.vue +671 -0
- package/src/components/FieldPhone/click-outside.js +16 -11
- package/src/components/Footer/Footer.vue +4 -4
- package/src/components/Header/Header.vue +2 -1
- package/src/components/Select/Select.vue +2 -1
- package/src/modules/chats/components/sections/ChatWindow.vue +3 -1
- package/src/modules/chats/store/chat.store.js +1 -3
- package/src/modules/events/components/pages/EditEvent.vue +2 -1
- package/src/modules/events/components/pages/Event.vue +8 -2
- package/src/modules/events/components/sections/SectionMainGuest.vue +1 -1
- package/src/modules/events/components/sections/SectionSpecialGuests.vue +0 -1
- package/src/modules/events/store/events.js +23 -3
- package/src/modules/globals/mixins/mixins.js +33 -2
- package/src/modules/globals/store/globals.js +1 -0
- package/src/modules/landing/components/sections/HeroGovernance.vue +156 -0
- package/src/modules/marketplace/components/sections/Filters.vue +3 -0
- package/src/modules/marketplace/router/marketplace.js +1 -0
- package/src/modules/orders/components/blocks/StatusHistory.vue +8 -3
- package/src/modules/orders/components/pages/EditOrder.vue +9 -11
- package/src/modules/orders/components/pages/FormOrder.vue +58 -46
- package/src/modules/orders/components/pages/Order.vue +63 -42
- package/src/modules/orders/components/sections/FormOrderDetails.vue +50 -18
- package/src/modules/orders/controllers/orders.controller.js +10 -1
- package/src/modules/orders/models/order.model.js +1 -0
- package/src/modules/orders/store/orders.js +21 -27
- package/src/modules/orders/store/shopcart.js +14 -2
- package/src/modules/organizations/components/sections/DetailsTab.vue +2 -2
- package/src/modules/products/components/sections/FilterProducts.vue +3 -4
- package/src/modules/products/components/sections/HeroRecommendation.vue +29 -2
- package/src/modules/products/components/sections/SectionProduct.vue +14 -9
- package/src/modules/products/controllers/products.controller.js +26 -17
- package/src/modules/products/routes/products.routes.js +6 -6
- package/src/modules/products/store/products.js +10 -10
- package/src/styles/config.scss +10 -3
@@ -27,7 +27,11 @@
|
|
27
27
|
<p class="p-big mn-b-small">Your Order</p>
|
28
28
|
|
29
29
|
<ul class="mn-b-semi">
|
30
|
-
<CardOrderItem
|
30
|
+
<CardOrderItem
|
31
|
+
v-for="product in shopcart.state.positions"
|
32
|
+
:key="product._id"
|
33
|
+
editable="true"
|
34
|
+
:product="product"
|
31
35
|
:increase="product => shopcart.actions.incrementItemQuantity(product._id)"
|
32
36
|
:decrease="product => shopcart.actions.decrementItemQuantity(product._id)"
|
33
37
|
:remove="product => shopcart.actions.removeProduct(product._id)"
|
@@ -36,13 +40,13 @@
|
|
36
40
|
|
37
41
|
<div
|
38
42
|
style="border-bottom: 1px solid #f7f7f7; border-top: 1px solid #f7f7f7;" class="pd-b-medium pd-t-medium mn-b-medium"
|
39
|
-
>
|
43
|
+
>
|
40
44
|
<p class="mn-b-thin">Subtotal: {{returnCurrency()}} {{ cartTotalPrice }} </p>
|
41
|
-
<p class="mn-b-thin">Delivery: {{
|
42
|
-
<p class="h3">Total: {{returnCurrency()}} {{ cartTotalPrice }} </p>
|
45
|
+
<p class="mn-b-thin">Delivery: {{returnCurrency()}} {{ Math.trunc(100 + 20 * orderOrganization[0]?.distance - 7,5 * (orderOrganization[0]?.distance / 10))}} </p>
|
46
|
+
<p class="h3">Total: {{returnCurrency()}} {{ Math.trunc(100 + 20 * orderOrganization[0]?.distance - 7,5 * (orderOrganization[0]?.distance / 10)) + cartTotalPrice.value }} </p>
|
43
47
|
</div>
|
44
48
|
|
45
|
-
<p class='mn-b-thin'>By making this purchase you agree to
|
49
|
+
<p class='mn-b-thin'>By making this purchase you agree to the General Terms and Conditions.</p>
|
46
50
|
<p class='mn-b-small'>I agree that placing the order places me under an obligation to make a payment in accordance with the General Terms and Conditions.</p>
|
47
51
|
<!-- Send order -->
|
48
52
|
<button
|
@@ -51,7 +55,7 @@
|
|
51
55
|
errorName
|
52
56
|
|| errorPhoneOrMessenger
|
53
57
|
|| errorCity
|
54
|
-
||
|
58
|
+
|| errorAddress
|
55
59
|
|| errorDelivery
|
56
60
|
|| errorPayment
|
57
61
|
"
|
@@ -76,78 +80,86 @@
|
|
76
80
|
// Import components
|
77
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
78
82
|
// Block
|
79
|
-
import CardOrderItem
|
83
|
+
import CardOrderItem from '@pf/src/modules/orders/components/blocks/CardOrderItem.vue'
|
80
84
|
// Sections
|
81
|
-
import AskToLogin
|
82
|
-
import Succes
|
83
|
-
import EmptyState
|
84
|
-
import FormOrderDetails
|
85
|
+
import AskToLogin from '@pf/src/modules/orders/components/sections/AskToLogin.vue'
|
86
|
+
import Succes from '@pf/src/modules/orders/components/sections/Succes.vue'
|
87
|
+
import EmptyState from '@pf/src/modules/orders/components/sections/EmptyState.vue'
|
88
|
+
import FormOrderDetails from '@pf/src/modules/orders/components/sections/FormOrderDetails.vue'
|
85
89
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86
90
|
// Import libs
|
87
91
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88
|
-
import { computed, onMounted } from 'vue'
|
92
|
+
import { ref, computed, onMounted, watch } from 'vue'
|
89
93
|
import { useRoute,useRouter } from 'vue-router'
|
90
|
-
|
94
|
+
// Store
|
95
|
+
import * as globals from '@pf/src/modules/globals/store/globals';
|
91
96
|
import * as auth from '@pf/src/modules/auth/store/auth';
|
92
97
|
import * as shopcart from '@pf/src/modules/orders/store/shopcart';
|
98
|
+
import * as organizations from '@pf/src/modules/organizations/store/organizations';
|
93
99
|
import * as orders from '@pf/src/modules/orders/store/orders';
|
94
100
|
import * as users from '@pf/src/modules/users/store/users';
|
95
101
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96
102
|
// Variables and computed
|
97
103
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98
104
|
// Accessing router and store
|
99
|
-
|
100
105
|
const route = useRoute()
|
101
106
|
const router = useRouter()
|
102
|
-
|
103
|
-
|
107
|
+
// COMPUTED
|
104
108
|
const order = computed(() => orders.state.current)
|
105
109
|
const user = computed(() => users.state.current)
|
106
|
-
|
110
|
+
const cartTotalPrice = computed(() => shopcart.getters.cartTotalPrice)
|
111
|
+
// Organization
|
112
|
+
const orderOrganization = ref([])
|
113
|
+
onMounted(async()=> {
|
114
|
+
orderOrganization.value = await organizations.actions.read({
|
115
|
+
_id: shopcart.state.organization,
|
116
|
+
location: globals.state.position?.location,
|
117
|
+
})
|
118
|
+
})
|
119
|
+
///////////////////////////////////////////////////////////////////////////////////////////////////
|
120
|
+
// WATCHERS
|
121
|
+
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122
|
+
watch(() => orders.state.current.delivery.address, async (newFilterValue, oldFilterValue) => {
|
123
|
+
orderOrganization.value = await organizations.actions.read({
|
124
|
+
_id: shopcart.state.organization,
|
125
|
+
location: orders.state.current.delivery.location,
|
126
|
+
})
|
127
|
+
}, { deep: true })
|
107
128
|
/////////////////////////////
|
108
129
|
// Store Verification
|
109
130
|
/////////////////////////////
|
110
131
|
const errorName = computed(() => {
|
111
|
-
|
112
|
-
})
|
132
|
+
if (orders.state.current.user.name?.length < 2) { return true } else { return false }
|
133
|
+
});
|
113
134
|
|
114
135
|
const errorPhoneOrMessenger = computed(() => {
|
115
|
-
const
|
116
|
-
const
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
} else {
|
121
|
-
return false ;
|
122
|
-
}
|
136
|
+
const hasMessengerType = orders.state.current.user.messenger?.type;
|
137
|
+
const hasMessengerValue = orders.state.current.user.messenger?.value?.length > 2;
|
138
|
+
const hasPhone = orders.state.current.user.number?.length > 0;
|
139
|
+
// Ошибка, если нет ни номера телефона, ни корректного типа и значения мессенджера
|
140
|
+
return !hasPhone && !(hasMessengerType && hasMessengerValue);
|
123
141
|
});
|
124
142
|
|
125
|
-
const
|
126
|
-
|
127
|
-
|
128
|
-
} else {
|
129
|
-
|
130
|
-
}
|
131
|
-
})
|
143
|
+
const errorAddress = computed(() => {
|
144
|
+
let error = orders.state.current.delivery.type !== "Pickup" && orders.state.current.delivery.address < 2
|
145
|
+
|
146
|
+
if (error) { return true } else { return false }
|
147
|
+
});
|
132
148
|
|
133
149
|
const errorDelivery = computed(() => {
|
134
|
-
if (orders.state.current.delivery.type) {
|
135
|
-
return false
|
136
|
-
} else {
|
137
|
-
return true
|
138
|
-
}
|
150
|
+
if (orders.state.current.delivery.type) {return false } else {return true }
|
139
151
|
})
|
140
152
|
|
141
153
|
const errorPayment = computed(() => {
|
142
|
-
if (orders.state.current.payment.type) {
|
143
|
-
return false
|
144
|
-
} else {
|
145
|
-
return true
|
146
|
-
}
|
154
|
+
if (orders.state.current.payment.type) { return false } else {return true }
|
147
155
|
})
|
148
|
-
|
149
|
-
|
156
|
+
/////////////////////////////
|
157
|
+
// Methods
|
158
|
+
/////////////////////////////
|
150
159
|
async function handleCreate() {
|
160
|
+
|
161
|
+
orders.state.current.status = 'created';
|
162
|
+
|
151
163
|
let order = await orders.actions.create(shopcart.state.positions, shopcart.state.organization);
|
152
164
|
|
153
165
|
if (order) {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<template>
|
2
|
-
<div class="pd-big">
|
2
|
+
<div v-if="order && orderOrganization" class="pd-big">
|
3
3
|
|
4
4
|
|
5
5
|
|
6
|
-
<div class="mn-b-thin pos-relative w-100 bg-main radius-big pd-big">
|
6
|
+
<div v-if="order" class="mn-b-thin pos-relative w-100 bg-main radius-big pd-big">
|
7
7
|
|
8
8
|
<h2 class="mn-b-small">Order is {{order.status}}</h2>
|
9
9
|
<p class="mn-b-medium w-m-40r p-medium">Your order has been successfully created. Our manager will contact you within five minutes to confirm your order.</p>
|
@@ -53,8 +53,15 @@
|
|
53
53
|
</div>
|
54
54
|
|
55
55
|
<!-- <div class="w-max pd-thin radius-small bg-white-transp-20"> -->
|
56
|
-
<p>Estimated Arrival {{
|
57
|
-
|
56
|
+
<p>Estimated Arrival {{formatDate(calculateDeliveryTime(orderOrganization[0]?.distance, order.createdAt))}}</p>
|
57
|
+
<!-- Estimated in minutes -->
|
58
|
+
<h3>{{
|
59
|
+
orderOrganization[0]?.distance ?
|
60
|
+
Math.ceil((5 + 5 + 3 * orderOrganization[0]?.distance) / 5) * 5
|
61
|
+
+ '-'
|
62
|
+
+ Math.ceil((15 + 5 + 3 * orderOrganization[0]?.distance) / 5) * 5
|
63
|
+
+ ' MIN' : 'Unavailable'
|
64
|
+
}}</h3>
|
58
65
|
<!-- </div> -->
|
59
66
|
|
60
67
|
|
@@ -65,11 +72,12 @@
|
|
65
72
|
|
66
73
|
|
67
74
|
|
68
|
-
<div class="gap-thin cols-2">
|
75
|
+
<div v-if="order" class="gap-thin cols-2">
|
69
76
|
|
70
77
|
<div class="w-100">
|
71
78
|
|
72
79
|
<CardOrganization
|
80
|
+
v-if="orderOrganization"
|
73
81
|
:organization="orderOrganization[0]"
|
74
82
|
:showRating="true"
|
75
83
|
:showFollowers="false"
|
@@ -80,19 +88,19 @@
|
|
80
88
|
<div
|
81
89
|
class="mn-b-thin bg-grey w-100 o-hidden radius-medium "
|
82
90
|
>
|
83
|
-
<div class="pd-small
|
84
|
-
<div>
|
91
|
+
<div class="pd-small flex-nowrap flex">
|
92
|
+
<div class="mn-r-auto">
|
85
93
|
<span class="d-block t-medium p-medium">Your order is</span>
|
86
94
|
<span class=" t-lh-075 h2 d-block mn-b-small">{{order.status}}</span>
|
87
95
|
<p class="pd-t-nano pd-b-nano pd-r-thin pd-l-thin radius-extra bg-black t-white w-max">as on 29 aug 2021, Friday</p>
|
88
96
|
</div>
|
89
|
-
<div class="t-right">
|
97
|
+
<!-- <div class="t-right">
|
90
98
|
Cancel order<br>
|
91
99
|
Exchange item
|
92
100
|
<hr class="mn-b-thin mn-t-thin">
|
93
101
|
For Delivery Queries Contact Us
|
94
102
|
|
95
|
-
</div>
|
103
|
+
</div> -->
|
96
104
|
</div>
|
97
105
|
|
98
106
|
<div class="pd-small cols-2 br-t br-black-transp-10 br-solid">
|
@@ -101,7 +109,17 @@
|
|
101
109
|
</p>
|
102
110
|
|
103
111
|
<p class="w-100 t-right ">
|
104
|
-
{{order.user?.
|
112
|
+
{{order.user?.number}}
|
113
|
+
</p>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
<div v-if="order.user?.messenger.type" class="pd-small cols-2 br-t br-black-transp-10 br-solid">
|
117
|
+
<p class="w-100 t-medium p-medium">
|
118
|
+
{{order.user?.messenger.type}}
|
119
|
+
</p>
|
120
|
+
|
121
|
+
<p class="w-100 t-right ">
|
122
|
+
{{order.user?.messenger.value}}
|
105
123
|
</p>
|
106
124
|
</div>
|
107
125
|
|
@@ -127,14 +145,11 @@
|
|
127
145
|
|
128
146
|
</div>
|
129
147
|
|
130
|
-
<div class="pd-big bg-red">
|
131
|
-
{{orders.state.current.status_history}}
|
132
|
-
</div>
|
133
|
-
|
134
148
|
<StatusHistory
|
135
149
|
v-if="orders.state.current.status_history"
|
136
150
|
:statusHistory="orders.state.current.status_history"
|
137
151
|
:statusCurrent="orders.state.current.status"
|
152
|
+
:edit="route.name === 'AdminOrderEdit'"
|
138
153
|
/>
|
139
154
|
|
140
155
|
<!-- <button
|
@@ -167,11 +182,11 @@
|
|
167
182
|
</div>
|
168
183
|
<div class="pd-small br-solid br-b br-black-transp-10 flex">
|
169
184
|
<p class="mn-r-auto t-transp">Delivery</p>
|
170
|
-
<p>
|
185
|
+
<p>{{returnCurrency()}} {{ Math.trunc(100 + 20 * orderOrganization[0]?.distance - 7,5 * (orderOrganization[0]?.distance / 10))}} </p>
|
171
186
|
</div>
|
172
187
|
<div class="pd-small flex-bottom flex">
|
173
188
|
<p class="mn-r-auto t-transp">In total to pay</p>
|
174
|
-
<p class="p-big t-semi">{{
|
189
|
+
<p class="p-big t-semi">{{returnCurrency()}} {{ Math.trunc(100 + 20 * orderOrganization[0]?.distance - 7,5 * (orderOrganization[0]?.distance / 10)) + cartTotalPrice }}</p>
|
175
190
|
</div>
|
176
191
|
</div>
|
177
192
|
|
@@ -203,6 +218,7 @@
|
|
203
218
|
|
204
219
|
import StatusHistory from '@pf/src/modules/orders/components/blocks/StatusHistory.vue'
|
205
220
|
|
221
|
+
import * as globals from '@pf/src/modules/globals/store/globals'
|
206
222
|
import * as orders from '@pf/src/modules/orders/store/orders'
|
207
223
|
import * as products from '@pf/src/modules/products/store/products'
|
208
224
|
import * as organizations from '@pf/src/modules/organizations/store/organizations'
|
@@ -210,21 +226,24 @@
|
|
210
226
|
const router = useRouter()
|
211
227
|
const route = useRoute()
|
212
228
|
|
213
|
-
|
229
|
+
const order = ref(null)
|
230
|
+
const productsOrganization = ref(null)
|
231
|
+
const orderOrganization = ref(null)
|
214
232
|
|
215
|
-
|
233
|
+
onMounted(async()=>{
|
234
|
+
order.value = await orders.actions.fetchOrder(route.params.order)
|
216
235
|
|
236
|
+
productsOrganization.value = await products.actions.read({
|
237
|
+
organization: order.value.organization
|
238
|
+
});
|
217
239
|
|
218
|
-
|
219
|
-
|
240
|
+
orderOrganization.value = await organizations.actions.read({
|
241
|
+
_id: order.value.organization,
|
242
|
+
location: globals.state.position?.location,
|
243
|
+
});
|
220
244
|
|
221
|
-
|
222
|
-
organization: order.value.organization
|
223
|
-
});
|
245
|
+
})
|
224
246
|
|
225
|
-
orderOrganization.value = await organizations.actions.read({
|
226
|
-
_id: order.value.organization
|
227
|
-
});
|
228
247
|
|
229
248
|
let cartTotalPrice = computed(() => {
|
230
249
|
return Number(order.value.positions.reduce((total, product) => {
|
@@ -266,22 +285,24 @@
|
|
266
285
|
function requestPayment(order) {
|
267
286
|
// store.dispatch("payments/newPayment", order);
|
268
287
|
}
|
269
|
-
|
270
|
-
function
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
288
|
+
|
289
|
+
function calculateDeliveryTime(distance, date) {
|
290
|
+
if (!distance) {
|
291
|
+
return null;
|
292
|
+
}
|
293
|
+
|
294
|
+
const basePreparationTime = 10 * 60 * 1000; // Convert to milliseconds
|
295
|
+
const travelTime = Math.ceil((15 + 5 + 3 * distance) / 5) * 5 * 60 * 1000;
|
296
|
+
|
297
|
+
// Преобразование даты начала в миллисекунды и добавление времени подготовки и доставки
|
298
|
+
const startTime = new Date(date).getTime();
|
299
|
+
const estimatedDeliveryTime = new Date(startTime + basePreparationTime + travelTime);
|
300
|
+
|
301
|
+
console.log(date)
|
302
|
+
console.log(estimatedDeliveryTime)
|
303
|
+
|
304
|
+
return estimatedDeliveryTime;
|
305
|
+
}
|
285
306
|
|
286
307
|
|
287
308
|
</script>
|
@@ -20,14 +20,19 @@
|
|
20
20
|
<!-- Phone -->
|
21
21
|
<FieldPhone
|
22
22
|
v-model:modelValue="order.user.phone"
|
23
|
+
@country="(country) => { order.user.number = country }"
|
24
|
+
:inputOptions="{
|
25
|
+
placeholder: 'Enter contact phone number',
|
26
|
+
type: 'tel',
|
27
|
+
}"
|
28
|
+
:defaultCountry="'TH'"
|
29
|
+
:validCharactersOnly="true"
|
23
30
|
:dropdownOptions="{
|
24
31
|
showDialCodeInSelection: true,
|
25
32
|
showFlags: true,
|
26
33
|
showDialCodeInList: true
|
27
|
-
}"
|
28
|
-
:validation="phoneValidation"
|
34
|
+
}"
|
29
35
|
mode="national"
|
30
|
-
:inputOptions="{placeholder: 'Enter contact phone number'}"
|
31
36
|
class="bg-white pd-small radius-small mn-b-thin"
|
32
37
|
/>
|
33
38
|
|
@@ -42,7 +47,7 @@
|
|
42
47
|
{name: 'WhatsApp', value: 'whatsapp'},
|
43
48
|
{name: 'Line', value: 'line'},
|
44
49
|
]"
|
45
|
-
:select="order.user.messenger.type"
|
50
|
+
@update:select="(option) => order.user.messenger.type = option.value"
|
46
51
|
placeholder="Messenger"
|
47
52
|
size="small"
|
48
53
|
class="
|
@@ -101,17 +106,41 @@
|
|
101
106
|
</div>
|
102
107
|
<!-- Adress-->
|
103
108
|
<Address
|
104
|
-
apiKey="AIzaSyDDR6WgYB7XMt7yTDDzQNEdF_gTdUiq8dI"
|
105
|
-
v-model:address="order.delivery.address"
|
106
109
|
label="Address"
|
107
|
-
|
110
|
+
|
111
|
+
apiKey="AIzaSyDDR6WgYB7XMt7yTDDzQNEdF_gTdUiq8dI"
|
112
|
+
|
113
|
+
:address="order.delivery.address"
|
114
|
+
:location="order.delivery.location"
|
115
|
+
|
116
|
+
placeholder="Enter your address"
|
117
|
+
|
108
118
|
class="
|
109
|
-
bg-white
|
110
|
-
pd-medium
|
111
|
-
radius-small
|
112
|
-
w-100
|
113
|
-
mn-b-thin
|
119
|
+
bg-white radius-tl-medium radius-tr-medium t-black br-grey br-solid br-2px pd-medium
|
114
120
|
"
|
121
|
+
|
122
|
+
@update:location="newLocation => {
|
123
|
+
order.delivery.location = newLocation;
|
124
|
+
}"
|
125
|
+
@update:address="newAddress => {
|
126
|
+
order.delivery.address = newAddress;
|
127
|
+
}"
|
128
|
+
/>
|
129
|
+
|
130
|
+
<LocationMarker
|
131
|
+
apiKey="AIzaSyDDR6WgYB7XMt7yTDDzQNEdF_gTdUiq8dI"
|
132
|
+
|
133
|
+
:address="order.delivery.address"
|
134
|
+
:location="order.delivery.location"
|
135
|
+
|
136
|
+
class="mn-b-thin radius-bl-medium radius-br-medium h-15r o-hidden"
|
137
|
+
|
138
|
+
@update:location="newLocation => {
|
139
|
+
order.delivery.location = newLocation;
|
140
|
+
}"
|
141
|
+
@update:address="newAddress => {
|
142
|
+
order.delivery.address = newAddress;
|
143
|
+
}"
|
115
144
|
/>
|
116
145
|
<Field
|
117
146
|
v-model:field="order.comment"
|
@@ -156,22 +185,21 @@
|
|
156
185
|
</template>
|
157
186
|
|
158
187
|
<script setup="props">
|
159
|
-
import { computed, onMounted } from 'vue'
|
188
|
+
import { computed, onMounted, watch } from 'vue'
|
160
189
|
|
190
|
+
import * as globals from '@pf/src/modules/globals/store/globals';
|
161
191
|
import * as orders from '@pf/src/modules/orders/store/orders';
|
162
192
|
/////////////////////////////
|
163
193
|
// COMPONENT DEPENDENCIES
|
164
194
|
/////////////////////////////
|
165
195
|
import Block from '@pf/src/components/Block/Block.vue'
|
166
196
|
import Field from '@pf/src/components/Field/Field.vue'
|
167
|
-
import FieldPhone from '@pf/src/components/FieldPhone/
|
197
|
+
import FieldPhone from '@pf/src/components/FieldPhone/FieldPhone2.vue'
|
168
198
|
import Select from '@pf/src/components/Select/Select.vue'
|
169
199
|
import Address from '@pf/src/components/Address/Address.vue'
|
170
|
-
import Radio from '@pf/src/components/Radio/Radio.vue'
|
171
|
-
/////////////////////////////
|
172
|
-
// HELPERS
|
173
|
-
/////////////////////////////
|
174
200
|
|
201
|
+
import LocationMarker from "@pf/src/components/LocationMarker/LocationMarker.vue";
|
202
|
+
import Radio from '@pf/src/components/Radio/Radio.vue'
|
175
203
|
/////////////////////////////
|
176
204
|
// CREATED
|
177
205
|
/////////////////////////////
|
@@ -181,6 +209,10 @@ const props = defineProps({
|
|
181
209
|
/////////////////////////////
|
182
210
|
// MOUNTED
|
183
211
|
/////////////////////////////
|
212
|
+
onMounted(() => {
|
213
|
+
if (globals.state.position) props.order.delivery.address = globals.state.position.address
|
214
|
+
if (globals.state.position) props.order.delivery.location = globals.state.position.location
|
215
|
+
})
|
184
216
|
</script>
|
185
217
|
|
186
218
|
<style lang="scss">
|
@@ -53,7 +53,16 @@ const controllerFactory = (db) => {
|
|
53
53
|
const create = async (req, res) => {
|
54
54
|
delete req.body._id;
|
55
55
|
|
56
|
-
req.body.status = 'created'
|
56
|
+
req.body.status = 'created';
|
57
|
+
req.body.status_history = req.body.status_history || [];
|
58
|
+
|
59
|
+
// Добавление записи в историю изменений статусов
|
60
|
+
req.body.status_history.push({
|
61
|
+
status: req.body.status,
|
62
|
+
changedBy: req.userId,
|
63
|
+
timestamp: new Date(),
|
64
|
+
comment: ''
|
65
|
+
});
|
57
66
|
|
58
67
|
try {
|
59
68
|
const formattedMessage = formatOrderMessage(req.body);
|
@@ -9,6 +9,7 @@ module.exports = (db) => {
|
|
9
9
|
_id: { type: Boolean },
|
10
10
|
name: { type: String, trim: true },
|
11
11
|
phone: { type: Object, trim: true },
|
12
|
+
number: { type: String, trim: true },
|
12
13
|
messenger: {
|
13
14
|
type: { type: String, trim: true },
|
14
15
|
value: { type: String, trim: true }
|
@@ -13,13 +13,13 @@ const state = reactive({
|
|
13
13
|
_id: '',
|
14
14
|
organization: '',
|
15
15
|
positions: [],
|
16
|
-
status:
|
16
|
+
status: null,
|
17
17
|
comment: '',
|
18
18
|
|
19
19
|
user: {
|
20
|
-
_id:
|
20
|
+
_id: null,
|
21
21
|
name: '',
|
22
|
-
phone:
|
22
|
+
phone: null,
|
23
23
|
messenger: {
|
24
24
|
type: '',
|
25
25
|
value: ''
|
@@ -45,12 +45,11 @@ const actions = {
|
|
45
45
|
state.current.positions = order
|
46
46
|
state.current.organization = organization
|
47
47
|
|
48
|
-
console.log(state.current)
|
49
|
-
|
50
48
|
const response = await $axios.post('/api/orders/create', state.current);
|
51
49
|
|
52
50
|
state.all.push(response.data);
|
53
|
-
|
51
|
+
|
52
|
+
return response.data;
|
54
53
|
} catch (error) {
|
55
54
|
setError(error);
|
56
55
|
}
|
@@ -59,20 +58,26 @@ const actions = {
|
|
59
58
|
async fetchOrder(orderID) {
|
60
59
|
try {
|
61
60
|
const response = await $axios.get(`/api/orders/${orderID}`);
|
62
|
-
|
61
|
+
|
63
62
|
state.current = response.data;
|
63
|
+
console.log(response.data)
|
64
|
+
return response.data;
|
64
65
|
} catch (error) {
|
65
66
|
setError(error);
|
67
|
+
throw err;
|
66
68
|
}
|
67
69
|
},
|
68
70
|
|
69
|
-
|
71
|
+
async read(orderID) {
|
70
72
|
try {
|
71
73
|
const response = await $axios.get(`/api/orders/read`);
|
72
|
-
|
74
|
+
|
73
75
|
state.all = response.data;
|
74
|
-
|
75
|
-
|
76
|
+
|
77
|
+
return response.data;
|
78
|
+
} catch (err) {
|
79
|
+
setError(err)
|
80
|
+
throw err;
|
76
81
|
}
|
77
82
|
},
|
78
83
|
|
@@ -85,18 +90,17 @@ const actions = {
|
|
85
90
|
if (index !== -1) {
|
86
91
|
state.all[index] = response.data;
|
87
92
|
}
|
93
|
+
|
94
|
+
return response.data;
|
88
95
|
} catch (error) {
|
89
96
|
setError(error);
|
90
97
|
}
|
91
98
|
},
|
92
99
|
|
93
|
-
async
|
100
|
+
async delete(orderID) {
|
94
101
|
try {
|
95
|
-
|
96
|
-
|
97
|
-
if (index !== -1) {
|
98
|
-
state.all[index] = response.data;
|
99
|
-
}
|
102
|
+
await $axios.delete(`/api/orders/${orderID}`);
|
103
|
+
state.all = state.all.filter(o => o._id !== orderID);
|
100
104
|
} catch (error) {
|
101
105
|
setError(error);
|
102
106
|
}
|
@@ -113,18 +117,8 @@ const actions = {
|
|
113
117
|
setError(error);
|
114
118
|
}
|
115
119
|
},
|
116
|
-
|
117
|
-
async delete(orderID) {
|
118
|
-
try {
|
119
|
-
await $axios.delete(`/api/orders/${orderID}`);
|
120
|
-
state.all = state.all.filter(o => o._id !== orderID);
|
121
|
-
} catch (error) {
|
122
|
-
setError(error);
|
123
|
-
}
|
124
|
-
},
|
125
120
|
}
|
126
121
|
|
127
|
-
|
128
122
|
const history = []
|
129
123
|
|
130
124
|
history.push(state)
|
@@ -27,13 +27,19 @@ const actions = {
|
|
27
27
|
|
28
28
|
setShopcart() {
|
29
29
|
try {
|
30
|
-
|
30
|
+
const storedShopcart = localStorage.getItem('shopcart');
|
31
|
+
if (storedShopcart) {
|
32
|
+
const shopcartData = JSON.parse(storedShopcart);
|
33
|
+
state.positions = shopcartData.positions; // Восстанавливаем продукты
|
34
|
+
state.organization = shopcartData.organization; // Восстанавливаем _id организации
|
35
|
+
}
|
31
36
|
} catch (error) {
|
32
37
|
console.error(error);
|
33
38
|
throw error;
|
34
39
|
}
|
35
40
|
},
|
36
41
|
|
42
|
+
|
37
43
|
addProductToCart(product, organization) {
|
38
44
|
const cartItem = state.positions.find(
|
39
45
|
(item) => item._id === product._id
|
@@ -48,12 +54,18 @@ const actions = {
|
|
48
54
|
name: product.name,
|
49
55
|
price: product.price,
|
50
56
|
quantity: 1,
|
57
|
+
org_id: organization, // Добавляем _id организации к каждому продукту
|
51
58
|
});
|
52
59
|
}
|
53
60
|
|
54
|
-
localStorage
|
61
|
+
// Обновляем объект корзины в localStorage, включая _id организации
|
62
|
+
localStorage.setItem('shopcart', JSON.stringify({
|
63
|
+
positions: state.positions,
|
64
|
+
organization: organization // Сохраняем _id организации в корне объекта корзины
|
65
|
+
}));
|
55
66
|
},
|
56
67
|
|
68
|
+
|
57
69
|
removeProduct(_id) {
|
58
70
|
const cartItem = state.positions.find(
|
59
71
|
(item) => item._id === _id
|