2022-11-16 01:44:39 +00:00
|
|
|
import './style.scss';
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-11-16 01:44:39 +00:00
|
|
|
export default new Class({
|
2022-11-15 21:26:48 +00:00
|
|
|
Extends: Hedera.Form,
|
2022-11-16 01:44:39 +00:00
|
|
|
Template: require('./ui.xml'),
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-11-28 08:51:31 +00:00
|
|
|
async open() {
|
2023-02-23 19:19:56 +00:00
|
|
|
await this.loadOrder();
|
|
|
|
if (this.orderId) {
|
|
|
|
await Hedera.Form.prototype.open.call(this);
|
|
|
|
this.$.lot.assign({id: this.orderId});
|
2023-02-23 13:32:13 +00:00
|
|
|
}
|
2023-02-23 19:19:56 +00:00
|
|
|
},
|
2023-02-15 13:07:09 +00:00
|
|
|
|
2023-02-23 19:19:56 +00:00
|
|
|
activate() {
|
|
|
|
this.$.items.setInfo('bi', 'myOrderRow', 'hedera');
|
|
|
|
},
|
|
|
|
|
|
|
|
async onHashChange() {
|
|
|
|
if (!this.isOpen) return;
|
|
|
|
await this.loadOrder();
|
2023-02-23 13:32:13 +00:00
|
|
|
if (this.orderId)
|
|
|
|
this.$.lot.assign({id: this.orderId});
|
2022-11-15 21:26:48 +00:00
|
|
|
},
|
2023-02-23 19:19:56 +00:00
|
|
|
|
|
|
|
async loadOrder() {
|
|
|
|
const basket = new Hedera.Basket(this.app);
|
|
|
|
if (this.hash.$.id) {
|
|
|
|
this.orderId = this.hash.$.id;
|
|
|
|
} else if (await basket.check()) {
|
|
|
|
this.orderId = basket.orderId;
|
|
|
|
}
|
2022-11-15 21:26:48 +00:00
|
|
|
},
|
2015-02-01 03:21:54 +00:00
|
|
|
|
2023-02-23 13:32:13 +00:00
|
|
|
onOrderReady(form) {
|
|
|
|
if (form.row < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (form.$.method != 'PICKUP') {
|
|
|
|
Vn.Node.show(this.$.address);
|
|
|
|
Vn.Node.setText(this.$.method, _('Agency'));
|
|
|
|
} else {
|
|
|
|
Vn.Node.hide(this.$.address);
|
|
|
|
Vn.Node.setText(this.$.method, _('Warehouse'));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-11-15 21:26:48 +00:00
|
|
|
onConfigureClick() {
|
2022-05-24 10:18:44 +00:00
|
|
|
Htk.Toast.showWarning(_('RememberReconfiguringImpact'));
|
2023-01-30 10:08:26 +00:00
|
|
|
this.hash.setAll({
|
|
|
|
form: 'ecomerce/checkout',
|
2023-02-15 13:07:09 +00:00
|
|
|
id: this.orderId
|
2023-01-30 10:08:26 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2023-02-15 13:07:09 +00:00
|
|
|
async onCatalogClick() {
|
|
|
|
const basket = new Hedera.Basket(this.app);
|
|
|
|
await basket.load(this.orderId);
|
|
|
|
},
|
|
|
|
|
2023-01-30 10:08:26 +00:00
|
|
|
onConfirmClick() {
|
|
|
|
this.hash.setAll({
|
|
|
|
form: 'ecomerce/confirm',
|
2023-02-15 13:07:09 +00:00
|
|
|
id: this.orderId
|
2023-01-30 10:08:26 +00:00
|
|
|
});
|
2022-11-15 21:26:48 +00:00
|
|
|
},
|
2015-06-30 12:06:19 +00:00
|
|
|
|
2022-11-15 21:26:48 +00:00
|
|
|
onDeleteClick(form) {
|
2022-05-24 10:18:44 +00:00
|
|
|
if (confirm(_('ReallyDelete')))
|
|
|
|
form.deleteRow();
|
2022-11-15 21:26:48 +00:00
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-11-15 21:26:48 +00:00
|
|
|
subtotal(form) {
|
2022-05-28 15:49:46 +00:00
|
|
|
return form.$.amount * form.$.price;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
});
|