From 028dd71456356c5b686ec2dc7bf6ff98545c7de2 Mon Sep 17 00:00:00 2001 From: 639852 Date: Thu, 8 Aug 2024 04:35:22 +0400 Subject: [PATCH] - Added nocloud invoices --- src/components/cloud/create/calculator.vue | 12 +- src/components/cloud/create/customAddons.vue | 159 ++++++++++++++++++ src/components/cloud/create/ovhAddons.vue | 15 +- .../cloud/modules/ione/panels/addons.vue | 151 +---------------- .../cloud/modules/keyweb/panels/addons.vue | 75 ++++++--- .../cloud/modules/keyweb/panels/os.vue | 41 +++-- .../cloud/modules/ovh cloud/panels/addons.vue | 19 +++ .../cloud/modules/ovh cloud/panels/os.vue | 3 +- .../cloud/modules/ovh cloud/panels/plan.vue | 5 +- .../modules/ovh dedicated/panels/addons.vue | 77 +++++---- .../modules/ovh dedicated/panels/plan.vue | 55 +++--- .../cloud/modules/ovh vps/panels/addons.vue | 65 ++++--- src/components/cloud/vdc/ipsPrice.vue | 2 +- src/components/invoice/invoiceItem.vue | 82 ++++----- src/components/invoice/transactionItem.vue | 40 ++--- src/components/services/custom/index.vue | 60 ++++--- src/components/services/domains/order.vue | 2 +- src/routes/cloud/vdcCloud.vue | 4 +- src/stores/addons.js | 19 +-- src/stores/app.js | 16 ++ src/stores/invoices.js | 86 +++++++--- 21 files changed, 585 insertions(+), 403 deletions(-) create mode 100644 src/components/cloud/create/customAddons.vue create mode 100644 src/components/cloud/modules/ovh cloud/panels/addons.vue diff --git a/src/components/cloud/create/calculator.vue b/src/components/cloud/create/calculator.vue index f6401a4b..6a296f0a 100644 --- a/src/components/cloud/create/calculator.vue +++ b/src/components/cloud/create/calculator.vue @@ -21,7 +21,7 @@ justify="space-between" style="font-size: 1.1rem" > - {{ capitalize($t(key)) }}{{ getAddonsValue(key) }}: + {{ capitalize(getAddonsTitle(key)) }}{{ getAddonsValue(key) }}: {{ +(price * currency.rate).toFixed(2) }} {{ currency.code }} @@ -126,6 +126,7 @@ import { EditorContainer } from 'nocloud-ui' import { useCloudStore } from '@/stores/cloud.js' import useCloudPrices from '@/hooks/cloud/prices.js' +import { useAddonsStore } from '@/stores/addons.js' import { useCurrency } from '@/hooks/utils' import { checkPayg } from '@/functions.js' @@ -145,6 +146,7 @@ const emits = defineEmits(['update:tarification']) const i18n = useI18n() const { currency } = useCurrency() const cloudStore = useCloudStore() +const addonsStore = useAddonsStore() const [product] = inject('useProduct', () => [])() const [options] = inject('useOptions', () => [])() @@ -193,6 +195,14 @@ function getAddonsValue (key) { return isFinite(value) ? ` (${value} Gb)` : '' } +function getAddonsTitle (key) { + if (cloudStore.plan.type === 'ione') { + return addonsStore.addons.find(({ uuid }) => uuid === key)?.title ?? key + } else { + return i18n.t(key) + } +} + async function createOrder () { const instance = { config: options.config, billingPlan: cloudStore.plan } const price = productFullPrice.value diff --git a/src/components/cloud/create/customAddons.vue b/src/components/cloud/create/customAddons.vue new file mode 100644 index 00000000..1731732a --- /dev/null +++ b/src/components/cloud/create/customAddons.vue @@ -0,0 +1,159 @@ + + + + + + + diff --git a/src/components/cloud/create/ovhAddons.vue b/src/components/cloud/create/ovhAddons.vue index 23bb67c4..df86caea 100644 --- a/src/components/cloud/create/ovhAddons.vue +++ b/src/components/cloud/create/ovhAddons.vue @@ -50,7 +50,7 @@ watch(() => props.addons, (value) => { if (!data.ovhConfig) return if (data.ovhConfig.addons.length < 1) return - options.config.addons.forEach((addon) => { + options.addons.forEach((addon) => { const keys = Object.keys(value) const key = keys.find((el) => addon.includes(el)) @@ -61,7 +61,7 @@ watch(() => props.addons, (value) => { function setAddon (code, addon, key) { const addonsPrices = JSON.parse(JSON.stringify(price.addons)) - const addonsCodes = JSON.parse(JSON.stringify(options.config.addons)) + const addonsCodes = JSON.parse(JSON.stringify(options.addons)) if (code === '-1') { delete addonsPrices[key] @@ -76,13 +76,20 @@ function setAddon (code, addon, key) { } setPrice('addons', addonsPrices) - setOptions('config.addons', addonsCodes) + setOptions('addons', addonsCodes) } +// function selectorMode (addons) { +// const values = Object.values(addons) + +// if (values.length < 1) return null +// return values.every(({ multiple }) => multiple) ? 'multiple' : null +// } + function addonName (addons) { const keys = Object.keys(addons) - return options.config.addons.find((el) => keys.includes(el)) ?? '-1' + return options.addons.find((el) => keys.includes(el)) ?? '-1' } function addonPrice ({ periods }) { diff --git a/src/components/cloud/modules/ione/panels/addons.vue b/src/components/cloud/modules/ione/panels/addons.vue index aaabb654..f2515eec 100644 --- a/src/components/cloud/modules/ione/panels/addons.vue +++ b/src/components/cloud/modules/ione/panels/addons.vue @@ -1,49 +1,9 @@ - - diff --git a/src/components/cloud/modules/keyweb/panels/addons.vue b/src/components/cloud/modules/keyweb/panels/addons.vue index 5e866cfc..23d70557 100644 --- a/src/components/cloud/modules/keyweb/panels/addons.vue +++ b/src/components/cloud/modules/keyweb/panels/addons.vue @@ -9,6 +9,10 @@ :value="getAddon(addon)" @update:value="setAddon($event, addon[$event], key)" > + + {{ $t('ip.none') }} + + {{ item.title }} ({{ item.price }} {{ currency.code }}) @@ -20,10 +24,10 @@ diff --git a/src/components/cloud/modules/keyweb/panels/os.vue b/src/components/cloud/modules/keyweb/panels/os.vue index b8d64360..d4efdc08 100644 --- a/src/components/cloud/modules/keyweb/panels/os.vue +++ b/src/components/cloud/modules/keyweb/panels/os.vue @@ -99,8 +99,9 @@ import { inject, ref, watch, nextTick } from 'vue' import { storeToRefs } from 'pinia' import passwordMeter from 'vue-simple-password-meter' -import { getTarification } from '@/functions.js' import { useCloudStore } from '@/stores/cloud.js' +import { useAddonsStore } from '@/stores/addons.js' + import imagesList from '@/components/ui/images.vue' const props = defineProps({ @@ -112,30 +113,46 @@ const props = defineProps({ }) const cloudStore = useCloudStore() +const addonsStore = useAddonsStore() const images = ref([]) const { authData } = storeToRefs(useCloudStore()) +const [product] = inject('useProduct', () => [])() const [options, setOptions] = inject('useOptions', () => [])() const [price, setPrice] = inject('usePriceOVH', () => [])() +watch(() => addonsStore.addons, setImages) watch(() => props.productSize, setImages) if (props.productSize) setImages() async function setImages () { await nextTick() - const values = Object.values(cloudStore.plan.products ?? {}) - const product = values.find(({ title, period }) => - title === props.productSize && getTarification(period) === props.mode - ) - - if (!product) return - product.meta.os.sort() - images.value = product.meta.os.map((el) => { - const { title, price, meta } = cloudStore.plan - .resources.find(({ key }) => key === el) ?? {} - return { key: el, type: meta.type, name: title, desc: title, price } + if (!product.value) return + const filtered = addonsStore.addons.filter(({ uuid }) => + cloudStore.plan.addons.includes(uuid) || product.value.addons?.includes(uuid) + ) + const list = [] + + filtered.forEach((item) => { + const { uuid, title, periods, meta, system, group, public: enabled } = item + const isEqualGroup = group === cloudStore.plan.uuid + const isIncluded = meta.type?.toJson().includes('OS') + + if (title.toLowerCase().includes('disabled')) return + if (!system || !isIncluded) return + if (!enabled || !isEqualGroup) return + + list.push({ + key: uuid, + name: title, + desc: title, + type: meta.type?.toJson(), + price: periods[product.value.period] + }) }) + + images.value = list } function setOS (item, index) { diff --git a/src/components/cloud/modules/ovh cloud/panels/addons.vue b/src/components/cloud/modules/ovh cloud/panels/addons.vue new file mode 100644 index 00000000..eebf411e --- /dev/null +++ b/src/components/cloud/modules/ovh cloud/panels/addons.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/src/components/cloud/modules/ovh cloud/panels/os.vue b/src/components/cloud/modules/ovh cloud/panels/os.vue index 2e9cbec6..d9f52ac8 100644 --- a/src/components/cloud/modules/ovh cloud/panels/os.vue +++ b/src/components/cloud/modules/ovh cloud/panels/os.vue @@ -82,7 +82,8 @@ const plusIcon = defineAsyncComponent( const props = defineProps({ mode: { type: String, required: true }, - productSize: { type: String, required: true } + productSize: { type: String, required: true }, + isFlavorsLoading: { type: Boolean, default: false } }) watch(() => props.productSize, setImages) diff --git a/src/components/cloud/modules/ovh cloud/panels/plan.vue b/src/components/cloud/modules/ovh cloud/panels/plan.vue index 6f95aed0..9bea800a 100644 --- a/src/components/cloud/modules/ovh cloud/panels/plan.vue +++ b/src/components/cloud/modules/ovh cloud/panels/plan.vue @@ -66,8 +66,11 @@ import { useRoute } from 'vue-router' import { useCloudStore } from '@/stores/cloud.js' const props = defineProps({ + mode: { type: String, required: true }, + plans: { type: Array, required: true }, products: { type: Array, required: true }, - mode: { type: String, required: true } + productSize: { type: String, required: true }, + isFlavorsLoading: { type: Boolean, default: false } }) const emits = defineEmits(['update:periods', 'update:product-size']) diff --git a/src/components/cloud/modules/ovh dedicated/panels/addons.vue b/src/components/cloud/modules/ovh dedicated/panels/addons.vue index 18041c52..dc3aff96 100644 --- a/src/components/cloud/modules/ovh dedicated/panels/addons.vue +++ b/src/components/cloud/modules/ovh dedicated/panels/addons.vue @@ -5,50 +5,63 @@