@lancom/shared 0.0.457 → 0.0.458

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/components/products/products_aside/products-aside.vue +5 -5
  2. package/components/quotes/quote_view/quote-view.scss +76 -22
  3. package/components/quotes/quote_view/quote-view.vue +79 -91
  4. package/components/quotes/quote_view/quote_option_view/quote-option-view.scss +103 -4
  5. package/components/quotes/quote_view/quote_option_view/quote-option-view.vue +202 -26
  6. package/components/quotes/quote_view/quote_view_accept/quote-view-accept.scss +33 -0
  7. package/components/quotes/quote_view/quote_view_accept/quote-view-accept.vue +85 -0
  8. package/components/quotes/quote_view/quote_view_address_form/quote-view-address-form.scss +17 -0
  9. package/components/quotes/quote_view/quote_view_address_form/quote-view-address-form.vue +259 -0
  10. package/components/quotes/quote_view/quote_view_banner/quote-view-banner.scss +67 -0
  11. package/components/quotes/quote_view/quote_view_banner/quote-view-banner.vue +69 -0
  12. package/components/quotes/quote_view/quote_view_billing_information/quote-view-billing-information.scss +5 -0
  13. package/components/quotes/quote_view/quote_view_billing_information/quote-view-billing-information.vue +108 -0
  14. package/components/quotes/quote_view/quote_view_header/quote-view-header.scss +65 -0
  15. package/components/quotes/quote_view/quote_view_header/quote-view-header.vue +69 -0
  16. package/components/quotes/quote_view/quote_view_info/quote-view-info.scss +36 -0
  17. package/components/quotes/quote_view/quote_view_info/quote-view-info.vue +42 -0
  18. package/components/quotes/quote_view/quote_view_invalid_stock_modal/quote-view-invalid-stock-modal.scss +17 -0
  19. package/components/quotes/quote_view/quote_view_invalid_stock_modal/quote-view-invalid-stock-modal.vue +29 -0
  20. package/components/quotes/quote_view/quote_view_menu/quote-view-menu.scss +74 -0
  21. package/components/quotes/quote_view/quote_view_menu/quote-view-menu.vue +102 -0
  22. package/components/quotes/quote_view/quote_view_message/quote-view-message.scss +53 -0
  23. package/components/quotes/quote_view/quote_view_message/quote-view-message.vue +40 -0
  24. package/components/quotes/quote_view/quote_view_mobile_menu/quote-view-mobile-menu.scss +1 -0
  25. package/components/quotes/quote_view/quote_view_mobile_menu/quote-view-mobile-menu.vue +23 -0
  26. package/components/quotes/quote_view/quote_view_payment/quote-view-payment.scss +58 -0
  27. package/components/quotes/quote_view/quote_view_payment/quote-view-payment.vue +191 -0
  28. package/components/quotes/quote_view/quote_view_payment/quote_payment_success/quote-payment-success.scss +40 -0
  29. package/components/quotes/quote_view/quote_view_payment/quote_payment_success/quote-payment-success.vue +50 -0
  30. package/components/quotes/quote_view/quote_view_payment_modal/quote-view-payment-modal.scss +10 -0
  31. package/components/quotes/quote_view/quote_view_payment_modal/quote-view-payment-modal.vue +49 -0
  32. package/components/quotes/quote_view/quote_view_print/quote-view-print.scss +54 -0
  33. package/components/quotes/quote_view/quote_view_print/quote-view-print.vue +74 -0
  34. package/components/quotes/quote_view/quote_view_question/quote-view-question.scss +84 -0
  35. package/components/quotes/quote_view/quote_view_question/quote-view-question.vue +203 -0
  36. package/components/quotes/quote_view/quote_view_questions/quote-view-questions.scss +39 -0
  37. package/components/quotes/quote_view/quote_view_questions/quote-view-questions.vue +50 -0
  38. package/components/quotes/quote_view_preview/quote-view.scss +29 -0
  39. package/components/quotes/quote_view_preview/quote-view.vue +121 -0
  40. package/components/quotes/quote_view_preview/quote_option_view/quote-option-view.scss +10 -0
  41. package/components/quotes/quote_view_preview/quote_option_view/quote-option-view.vue +73 -0
  42. package/package.json +1 -1
  43. package/pages/quotes/view/_id/option/_option.vue +1 -1
  44. package/plugins/crisp.js +13 -0
  45. package/store/products.js +4 -1
  46. /package/components/quotes/{quote_view → quote_view_preview}/quote-view.mixin.js +0 -0
  47. /package/components/quotes/{quote_view → quote_view_preview}/quote_product_color_simple_products/quote-product-color-simple-products.mixin.js +0 -0
  48. /package/components/quotes/{quote_view → quote_view_preview}/quote_product_color_simple_products/quote-product-color-simple-products.scss +0 -0
  49. /package/components/quotes/{quote_view → quote_view_preview}/quote_product_color_simple_products/quote-product-color-simple-products.vue +0 -0
  50. /package/components/quotes/{quote_view → quote_view_preview}/quote_product_color_simple_products/quote_product_color_simple_product/quote-product-color-simple-product.scss +0 -0
  51. /package/components/quotes/{quote_view → quote_view_preview}/quote_product_color_simple_products/quote_product_color_simple_product/quote-product-color-simple-product.vue +0 -0
  52. /package/components/quotes/{quote_view → quote_view_preview}/quote_product_prints/quote-product-prints.scss +0 -0
  53. /package/components/quotes/{quote_view → quote_view_preview}/quote_product_prints/quote-product-prints.vue +0 -0
  54. /package/components/quotes/{quote_view → quote_view_preview}/quote_product_prints/quote_product_print/quote-product-print.scss +0 -0
  55. /package/components/quotes/{quote_view → quote_view_preview}/quote_product_prints/quote_product_print/quote-product-print.vue +0 -0
  56. /package/components/quotes/{quote_view → quote_view_preview}/quote_view_product/quote-view-product.scss +0 -0
  57. /package/components/quotes/{quote_view → quote_view_preview}/quote_view_product/quote-view-product.vue +0 -0
@@ -0,0 +1,53 @@
1
+ @import "@/assets/scss/variables";
2
+
3
+ .QuoteViewMessage {
4
+ &__title {
5
+ background-color: $green;
6
+ color: $black;
7
+ padding: 17px 21px;
8
+ font-weight: 800;
9
+ font-size: 36px;
10
+ line-height: 49px;
11
+ display: inline-block;
12
+ @media (max-width: $bp-extra-small-max) {
13
+ padding: 7px 11px;
14
+ font-size: 21px;
15
+ line-height: 32px;
16
+ }
17
+ }
18
+ &__text {
19
+ font-weight: 600;
20
+ font-size: 22px;
21
+ line-height: 30px;
22
+ color: $gray_main;
23
+ padding-top: 20px;
24
+ @media (max-width: $bp-extra-small-max) {
25
+ padding-top: 0px;
26
+ font-size: 16px;
27
+ line-height: 21px;
28
+ }
29
+ p {
30
+ margin-top: 20px;
31
+ }
32
+ }
33
+ &__sign {
34
+ margin-top: 36px;
35
+ background-image: url(~/static/images//oren_sign.png);
36
+ background-position: center center;
37
+ background-repeat: no-repeat;
38
+ background-size: cover;
39
+ width: 136px;
40
+ height: 66px;
41
+ }
42
+ &__author {
43
+ font-weight: 600;
44
+ font-size: 20px;
45
+ line-height: 27px;
46
+ margin-top: 16px;
47
+ color: $gray_main;
48
+ @media (max-width: $bp-extra-small-max) {
49
+ font-size: 15px;
50
+ line-height: 20px;
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <div class="QuoteViewMessage__wrapper">
3
+ <div
4
+ v-if="address"
5
+ class="QuoteViewMessage__title">
6
+ Dear {{ address.fullName }},
7
+ </div>
8
+ <div class="QuoteViewMessage__text">
9
+ <rich-text :text="quote.message" />
10
+ </div>
11
+ <div class="QuoteViewMessage__sign"></div>
12
+ <div
13
+ v-if="quote.user"
14
+ class="QuoteViewMessage__author">
15
+ {{ quote.user.fullName }} | Account Manager at Workdepot
16
+ </div>
17
+ </div>
18
+ </template>
19
+
20
+ <script>
21
+ import { mapGetters } from 'vuex';
22
+ import RichText from '@lancom/shared/components/common/rich-text';
23
+
24
+ export default {
25
+ name: 'QuoteViewMessage',
26
+ components: {
27
+ RichText
28
+ },
29
+ computed: {
30
+ ...mapGetters('quote', ['quote']),
31
+ address() {
32
+ return this.quote.billingAddress || this.quote.address;
33
+ }
34
+ }
35
+ };
36
+ </script>
37
+
38
+ <style lang="scss" scoped>
39
+ @import 'quote-view-message.scss';
40
+ </style>
@@ -0,0 +1 @@
1
+ @import "@/assets/scss/variables";
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <div class="QuoteViewMobileMenu__wrapper">
3
+ <quote-view-info class="QuoteView__info" />
4
+ <quote-view-menu @selected="$emit('close')" />
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+ import QuoteViewInfo from './../quote_view_info/quote-view-info';
10
+ import QuoteViewMenu from './../quote_view_menu/quote-view-menu';
11
+
12
+ export default {
13
+ name: 'QuoteViewMobileMenu',
14
+ components: {
15
+ QuoteViewInfo,
16
+ QuoteViewMenu
17
+ }
18
+ };
19
+ </script>
20
+
21
+ <style lang="scss" scoped>
22
+ @import 'quote-view-mobile-menu.scss';
23
+ </style>
@@ -0,0 +1,58 @@
1
+ @import "@/assets/scss/variables";
2
+
3
+ .QuoteViewPayment {
4
+ &__wrapper {
5
+ padding: 0px 50px 50px 50px;
6
+ position: relative;
7
+ @media (max-width: $bp-extra-small-max) {
8
+ padding: 0px;
9
+ }
10
+ }
11
+ &__error {
12
+ font-weight: bold;
13
+ font-size: 14px;
14
+ padding: 18px 10px;
15
+ text-align: center;
16
+ color: $white;
17
+ background: #EA3434;
18
+ margin-bottom: 10px;
19
+ }
20
+ &__spinner {
21
+ position: absolute;
22
+ top: 0;
23
+ right: 0;
24
+ bottom: 0;
25
+ left: 0;
26
+ opacity: 0.6;
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ z-index: 5;
31
+ }
32
+ &__header {
33
+ border-bottom: 2px solid $gray;
34
+ padding-bottom: 30px;
35
+ text-align: center;
36
+ &-title {
37
+ font-weight: 800;
38
+ font-size: 36px;
39
+ line-height: 49px;
40
+ }
41
+ &-description {
42
+ font-size: 16px;
43
+ line-height: 120%;
44
+ color: $black;
45
+ opacity: 0.6;
46
+ margin-top: 14px;
47
+ }
48
+ }
49
+ &__controls {
50
+ margin: 14px 40px 0 40px;
51
+ @media (max-width: $bp-extra-small-max) {
52
+ margin: 14px 0px 0 0px;
53
+ }
54
+ }
55
+ &__control {
56
+ margin-top: 26px;
57
+ }
58
+ }
@@ -0,0 +1,191 @@
1
+ <template>
2
+ <div class="QuoteViewPayment__wrapper">
3
+ <div
4
+ v-if="processing"
5
+ class="QuoteViewPayment__spinner">
6
+ <spinner />
7
+ </div>
8
+ <div v-if="order && !order.failedCharge">
9
+ <quote-payment-success
10
+ v-if="order.paid"
11
+ :order="order"
12
+ btn-label="go to homepage"
13
+ @ok="goHome" />
14
+ <quote-payment-success
15
+ v-else
16
+ :order="order"
17
+ message="thanks for your acceptance"
18
+ description="You will be emailed a tax invoice shortly!"
19
+ @ok="goHome" />
20
+ </div>
21
+ <div v-else-if="isPayment">
22
+ <payment-card
23
+ v-if="quote"
24
+ ref="paymentCart"
25
+ :amount="proceedOption.totalGST"
26
+ :order="quote">
27
+ </payment-card>
28
+ <div
29
+ v-if="errorMessage"
30
+ class="QuoteViewPayment__error">
31
+ {{ errorMessage }}
32
+ </div>
33
+ <btn
34
+ class="lc_uppercase"
35
+ btn-class="green"
36
+ btn-label="MAKE PAYMENT"
37
+ :btn-block="true"
38
+ @onclick="convertToOrderWithPayment">
39
+ <i
40
+ slot="icon-after"
41
+ class="icon-arrow-right"></i>
42
+ </btn>
43
+ </div>
44
+ <div v-else>
45
+ <div class="QuoteViewPayment__header">
46
+ <div class="QuoteViewPayment__header-title">
47
+ Payment method
48
+ </div>
49
+ <div class="QuoteViewPayment__header-description">
50
+ Сhoose the method you want to pay for items.
51
+ </div>
52
+ </div>
53
+ <div class="QuoteViewPayment__controls lc_uppercase">
54
+ <div class="QuoteViewPayment__control">
55
+ <btn
56
+ btn-class="white"
57
+ btn-label="pay now using a credit card"
58
+ :btn-block="true"
59
+ @onclick="isPayment = true">
60
+ <i
61
+ slot="icon-after"
62
+ class="icon-arrow-right"></i>
63
+ </btn>
64
+ </div>
65
+ <div class="QuoteViewPayment__control">
66
+ <btn
67
+ btn-class="white"
68
+ btn-label="pay upon receipt of tax invoice"
69
+ :btn-block="true"
70
+ @onclick="convertToOrder(proceedOption)">
71
+ <i
72
+ slot="icon-after"
73
+ class="icon-arrow-right"></i>
74
+ </btn>
75
+ </div>
76
+ <div class="QuoteViewPayment__control">
77
+ <btn
78
+ btn-class="white"
79
+ btn-label="purchase order (AUS Government Organisation)"
80
+ :btn-block="true"
81
+ :btn-disabled="!quote.purchaseOrderAllowed"
82
+ @onclick="convertToPOOrder(proceedOption)"
83
+ style="font-size: 14px;">
84
+ <i
85
+ slot="icon-after"
86
+ class="icon-arrow-right"></i>
87
+ </btn>
88
+ </div>
89
+ </div>
90
+ </div>
91
+ </div>
92
+ </template>
93
+
94
+ <script>
95
+ import api from '@lancom/shared/assets/js/api';
96
+ import gapis from '@lancom/shared/assets/js/utils/gapis';
97
+ import { mapGetters, mapMutations } from 'vuex';
98
+ import PaymentCard from '@lancom/shared/components/common/payment/payment_card/payment-card';
99
+ import QuoteViewMixin from '@lancom/shared/components/quotes/quote_view_preview/quote-view.mixin';
100
+ import QuotePaymentSuccess from './quote_payment_success/quote-payment-success';
101
+
102
+ export default {
103
+ name: 'QuoteViewPayment',
104
+ components: {
105
+ QuotePaymentSuccess,
106
+ PaymentCard
107
+ },
108
+ mixins: [
109
+ QuoteViewMixin
110
+ ],
111
+ data() {
112
+ return {
113
+ isPayment: false,
114
+ errorMessage: null
115
+ };
116
+ },
117
+ computed: {
118
+ ...mapGetters(['country', 'payment']),
119
+ ...mapGetters('quote', ['proceedOption'])
120
+ },
121
+ mounted() {
122
+ if (this.$route.query.checkPayment) {
123
+ this.isPayment = true;
124
+ if (this.order?.failedCharge) {
125
+ this.handleErrors({ error_description: this.order.failedCharge });
126
+ }
127
+ }
128
+ },
129
+ methods: {
130
+ ...mapMutations('quote', ['setOrder']),
131
+ goHome() {
132
+ this.$router.push('/');
133
+ },
134
+ handleErrors(err) {
135
+ console.log(err);
136
+ // err.messages.forEach(({ message }) => this.$toastr.e(message));
137
+ const defaultMessage = 'Payment error';
138
+ this.errorMessage = (err.messages ? err.messages.map(({ message }) => message).join(', ') : (err.error_description)) || defaultMessage;
139
+ },
140
+ convertToPOOrder(option) {
141
+ this.convertToOrder({
142
+ ...option,
143
+ paymentMethod: 'purchase order',
144
+ paymentStatus: 'purchase order'
145
+ });
146
+ },
147
+ async convertToOrderWithPayment() {
148
+ try {
149
+ this.errorMessage = null;
150
+ this.processing = true;
151
+ const card = await this.$refs.paymentCart.tokenize();
152
+ if (card) {
153
+ const order = this.order || await this.createOrder({ ...this.proceedOption, paymentMethod: 'card' });
154
+
155
+ const payload = {
156
+ card,
157
+ shop: this.shop._id,
158
+ country: this.country?._id,
159
+ payment: this.payment,
160
+ path: window.location.pathname,
161
+ recaptchaToken: await this.getRecaptcha('order_payment')
162
+ };
163
+ const result = await api.createOrderPayment(order._id, payload);
164
+ if (result.redirect_url) {
165
+ window.location.href = result.redirect_url;
166
+ return;
167
+ }
168
+ this.order = result;
169
+ this.setOrder(this.order);
170
+ // gtm.purchase(this.order);
171
+ gapis.surveyOptin(this.order, this.shop);
172
+ }
173
+ this.clear();
174
+ } catch (e) {
175
+ if (e.response) {
176
+ const { message } = (e.response && e.response.data) || e;
177
+ this.handleErrors({ messages: [{ message }] });
178
+ } else {
179
+ this.handleErrors(e);
180
+ }
181
+ } finally {
182
+ this.processing = false;
183
+ }
184
+ }
185
+ }
186
+ };
187
+ </script>
188
+
189
+ <style lang="scss" scoped>
190
+ @import 'quote-view-payment.scss';
191
+ </style>
@@ -0,0 +1,40 @@
1
+ @import "@/assets/scss/variables";
2
+
3
+ .QuotePaymentSuccess {
4
+ &__wrapper {
5
+ display: flex;
6
+ flex-direction: column;
7
+ align-items: center;
8
+ }
9
+ &__icon {
10
+ width: 88px;
11
+ height: 88px;
12
+ border-radius: 44px;
13
+ background-color: $green;
14
+ color: $black;
15
+ font-size: 44px;
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ }
20
+ &__message {
21
+ font-weight: 800;
22
+ font-size: 36px;
23
+ line-height: 49px;
24
+ margin-top: 20px;
25
+ text-align: center;
26
+ }
27
+ &__description {
28
+ font-weight: normal;
29
+ font-size: 16px;
30
+ line-height: 120%;
31
+ color: $black;
32
+ opacity: 0.6;
33
+ margin-top: 20px;
34
+ text-align: center;
35
+ }
36
+ &__control {
37
+ margin-top: 35px;
38
+ min-width: 226px;
39
+ }
40
+ }
@@ -0,0 +1,50 @@
1
+ <template>
2
+ <div class="QuotePaymentSuccess__wrapper">
3
+ <div class="QuotePaymentSuccess__icon">
4
+ <i class="icon-ok"></i>
5
+ </div>
6
+ <div class="QuotePaymentSuccess__message lc_uppercase">
7
+ {{ message }}
8
+ </div>
9
+ <div v-if="order" class="lc_regular18 lc_grey1 mt-5">
10
+ Order {{ order.code }}
11
+ </div>
12
+ <div class="QuotePaymentSuccess__description">
13
+ {{ description }}
14
+ </div>
15
+ <div class="QuotePaymentSuccess__control lc_uppercase">
16
+ <btn
17
+ btn-class="green"
18
+ :btn-label="btnLabel"
19
+ :btn-block="true"
20
+ @onclick="$emit('ok')" />
21
+ </div>
22
+ </div>
23
+ </template>
24
+
25
+ <script>
26
+ export default {
27
+ name: 'QuotePaymentSuccess',
28
+ props: {
29
+ order: {
30
+ type: Object
31
+ },
32
+ message: {
33
+ type: String,
34
+ default: 'Thank you!'
35
+ },
36
+ description: {
37
+ type: String,
38
+ default: 'Thanks for your order! You will receive an order confirmation email shortly.'
39
+ },
40
+ btnLabel: {
41
+ type: String,
42
+ default: 'OK!'
43
+ }
44
+ }
45
+ };
46
+ </script>
47
+
48
+ <style lang="scss" scoped>
49
+ @import 'quote-payment-success.scss';
50
+ </style>
@@ -0,0 +1,10 @@
1
+ @import "@/assets/scss/variables";
2
+
3
+ .QuoteViewPaymentModal {
4
+ &__wrapper {
5
+ border-radius: 0px;
6
+ @media (max-width: $bp-extra-small-max) {
7
+ min-height: 100vh;
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,49 @@
1
+ <template>
2
+ <div class="lc_modal__wrapper QuoteViewPaymentModal__wrapper">
3
+ <div class="lc_modal__header pull-left">
4
+ <i
5
+ class="icon-cancel lc_modal__close--dark"
6
+ @click="$emit('close')"></i>
7
+ </div>
8
+ <div class="lc_modal__content">
9
+ <quote-view-address-form
10
+ v-if="!canPay"
11
+ :quote="quote"
12
+ @submit="canPay = true" />
13
+ <quote-view-payment
14
+ v-else
15
+ @ok="$emit('close')" />
16
+ </div>
17
+ </div>
18
+ </template>
19
+
20
+ <script>
21
+ import { mapGetters } from 'vuex';
22
+ import QuoteViewPayment from './../quote_view_payment/quote-view-payment';
23
+ import QuoteViewAddressForm from './../quote_view_billing_information/quote-view-billing-information';
24
+
25
+ export default {
26
+ name: 'QuoteViewPaymentModal',
27
+ components: {
28
+ QuoteViewPayment,
29
+ QuoteViewAddressForm
30
+ },
31
+ data() {
32
+ return {
33
+ canPay: false
34
+ };
35
+ },
36
+ computed: {
37
+ ...mapGetters('quote', ['quote'])
38
+ },
39
+ mounted() {
40
+ if (this.$route.query.checkPayment) {
41
+ this.canPay = true;
42
+ }
43
+ }
44
+ };
45
+ </script>
46
+
47
+ <style lang="scss" scoped>
48
+ @import 'quote-view-payment-modal.scss';
49
+ </style>
@@ -0,0 +1,54 @@
1
+ @import "@/assets/scss/variables";
2
+ .QuoteViewPrint {
3
+ &__wrapper {
4
+ position: relative;
5
+ }
6
+ &__field {
7
+ display: flex !important;
8
+ align-items: center;
9
+ cursor: pointer;
10
+ }
11
+ &__inner {
12
+ min-width: 72px;
13
+ width: 33%;
14
+ height: 100%;
15
+ border-radius: 2px;
16
+ box-shadow: $elevation1;
17
+ }
18
+ &__value {
19
+ color: $grey_1;
20
+ text-transform: uppercase;
21
+ margin-left: 20px;
22
+ flex-grow: 1;
23
+ cursor: pointer;
24
+ display: flex;
25
+ }
26
+ &__caret {
27
+ color: $grey_5;
28
+ font-size: 18px;
29
+ cursor: pointer;
30
+ }
31
+ &__dropdown {
32
+ position: absolute;
33
+ z-index: 101;
34
+ top: 40px;
35
+ margin-left: -100px;
36
+ width: 250px;
37
+ // transform: translateY(-50%);
38
+ padding: 10px;
39
+ box-shadow: 0 0 2px grey;
40
+ background-color: white;
41
+ }
42
+ &__field {
43
+ display: flex;
44
+ justify-content: space-between;
45
+ cursor: pointer;
46
+ &-item {
47
+ padding: 7px 10px;
48
+ cursor: pointer;
49
+ &:hover {
50
+ background-color: $grey_3;
51
+ }
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <div class="QuoteViewPrint__wrapper">
3
+ <div
4
+ class="QuoteViewPrint__field"
5
+ @click="open()">
6
+ <div class="lc_regular16 QuoteViewPrint__value">
7
+ <spinner v-if="generating" /> Save PDF
8
+ </div>
9
+ <i class="icon-angle-down QuoteViewPrint__caret"></i>
10
+ </div>
11
+ <div
12
+ v-if="isOpen"
13
+ v-click-outside="close"
14
+ class="QuoteViewPrint__dropdown">
15
+ <div>
16
+ <div
17
+ v-for="option of options"
18
+ :key="option._id"
19
+ class="QuoteViewPrint__field-item"
20
+ @click="downloadQuoteOption(option)">
21
+ Option {{ option.index }}
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </template>
27
+
28
+ <script>
29
+ import { mapGetters } from 'vuex';
30
+ import api from '@lancom/shared/assets/js/api';
31
+
32
+ export default {
33
+ name: 'QuoteViewPrint',
34
+ data() {
35
+ return {
36
+ isOpen: false,
37
+ generating: false
38
+ };
39
+ },
40
+ computed: {
41
+ ...mapGetters('quote', ['quote', 'options'])
42
+ },
43
+ methods: {
44
+ open() {
45
+ if (!this.generating) {
46
+ this.isOpen = !this.isOpen;
47
+ }
48
+ },
49
+ close() {
50
+ this.isOpen = false;
51
+ },
52
+ async downloadQuoteOption(option) {
53
+ try {
54
+ this.generating = true;
55
+ this.close();
56
+ const { pdf } = await api.generateQuotePDF(this.quote._id, option._id);
57
+ const res = await fetch(pdf);
58
+ const blob = await res.blob();
59
+ const a = document.createElement('a');
60
+ a.href = URL.createObjectURL(blob);
61
+ a.setAttribute('download', `${this.quote.code}-${option.index}`);
62
+ a.click();
63
+ } catch (e) {
64
+ } finally {
65
+ this.generating = false;
66
+ }
67
+ }
68
+ }
69
+ };
70
+ </script>
71
+
72
+ <style lang="scss">
73
+ @import 'quote-view-print';
74
+ </style>