Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/ilovecveti.ru/bitrix/js/catalog/product-form/src/templates/fields/ |
Upload File : |
import {Loc, Runtime, Text} from 'main.core'; import {Vue} from "ui.vue"; import {config} from "../../config"; import type {BaseEvent} from "main.core.events"; Vue.component(config.templateFieldPrice, { /** * @emits 'onChangePrice' {price: number} * @emits 'saveCatalogField' {} */ props: { selectorId: String, price: Number, editable: Boolean, hasError: Boolean, options: Object, }, created() { this.onInputPriceHandler = Runtime.debounce(this.onInputPrice, 500, this); }, mounted() { BX.UI.Hint.init(); }, methods: { onInputPrice(event: BaseEvent): void { if (!this.editable) { return; } event.target.value = event.target.value.replace(/[^.,\d]/g,''); if (event.target.value === '') { event.target.value = 0; } const lastSymbol = event.target.value.substr(-1); if (lastSymbol === ',') { event.target.value = event.target.value.replace(',', "."); } let newPrice = Text.toNumber(event.target.value); if (lastSymbol === '.' || lastSymbol === ',') { return; } if (newPrice < 0) { newPrice *= -1; } this.$emit('onChangePrice', newPrice); }, }, computed: { localize() { return Vue.getFilteredPhrases('CATALOG_'); }, currencySymbol() { return this.options.currencySymbol || ''; }, hintText() { if (!this.editable && !this.options?.isCatalogPriceEditEnabled) { return Loc.getMessage('CATALOG_FORM_PRICE_ACCESS_DENIED_HINT'); } return null; }, }, // language=Vue template: ` <div class="catalog-pf-product-input-wrapper" :class="{ 'ui-ctl-danger': hasError, '.catalog-pf-product-input-wrapper--disabled': !editable }" :data-hint="hintText" data-hint-no-icon > <input type="text" class="catalog-pf-product-input catalog-pf-product-input--align-right" v-bind:class="{ 'catalog-pf-product-input--disabled': !editable }" v-model.lazy="price" @input="onInputPriceHandler" :disabled="!editable" data-name="price" :data-value="price" > <div class="catalog-pf-product-input-info" v-html="currencySymbol"></div> </div> ` });