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/cvetdv.ru/bitrix/js/sale/checkout/view/element/input/src/ |
Upload File : |
import { BitrixVue } from 'ui.vue'; import { EventEmitter } from 'main.core.events'; import { Type } from 'main.core'; import { EventType, Property as Const } from 'sale.checkout.const'; BitrixVue.component('sale-checkout-view-element-input-property-date', { props: ['item', 'index', 'autocomplete', 'isDateTime'], methods: { onClick() { this.showCalendar(); this.focusOnInput(); }, focusOnInput() { const element = this.$el.children[0]; element.focus(); }, showCalendar() { BX.calendar({ node: this.item.name, field: this.item.name, bTime: this.isDateTime, bUseSecond: false, callback_after: (data) => this.handleDate(data), }); }, handleDate(date) { const dateString = this.prepareDate(date); this.changeValue(dateString); }, prepareDate(date) { if (this.isDateTime === true) { return date.toLocaleString([], { day: '2-digit', month: '2-digit', year: 'numeric', hour: 'numeric', minute: 'numeric', }).replace(',', ''); } else { return date.toLocaleDateString().replace(',', ''); } }, blur() { if (Type.isStringFilled(this.item.value)) { this.changeValue(this.item.value); } }, changeValue(value) { let changeValue = ''; if (Type.isStringFilled(value)) { changeValue = this.validateDate(value) ? this.prepareDate(BX.parseDate(value)) : this.previousValue; } this.setDate(changeValue); this.validate(); }, validateDate(value): boolean { const date = BX.parseDate(value); return date && date.toLocaleDateString() !== 'Invalid Date'; }, validate() { EventEmitter.emit(EventType.property.validate, {index: this.index}); }, setDate(date) { this.item.value = date; this.previousValue = date; }, }, computed: { checkedClassObject() { return { 'is-invalid': this.item.validated === Const.validate.failure, 'is-valid': this.item.validated === Const.validate.successful, }; }, isEmpty() { return this.item.value === ''; }, isRequired() { return this.item.required === 'Y'; }, isAsteriskShown() { return this.isEmpty && this.isRequired; }, }, // language=Vue template: ` <div class="form-wrap form-asterisk"> <input class="form-control form-control-lg" :class="checkedClassObject" @blur="blur" type="text" inputmode="numeric" :name="item.name" @click="onClick" @drop="(e) => e.preventDefault()" @dragstart="(e) => e.preventDefault()" @paste="(e) => e.preventDefault()" :autocomplete="autocomplete" :placeholder="item.name" v-model="item.value" /> <span class="asterisk-item" v-if="isAsteriskShown" > {{item.name}} </span> </div> ` });