eservices-core 1.0.523 → 1.0.524
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.
- package/dist/classes/new/List.d.ts +20 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +157 -1
- package/dist/services/billing-service.d.ts +49 -0
- package/dist/services/documents-service.d.ts +3 -0
- package/dist/services/equipment-service.d.ts +8 -0
- package/dist/utils/debounce.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import EventEmitter from "jenesius-event-emitter";
|
|
2
|
+
import { Ref } from "vue";
|
|
2
3
|
import { IFilters } from "../../utils/Filter";
|
|
3
4
|
declare const LIST_ROW_KEY = "_______LIST_______ROW_______INDEX________NAME_______";
|
|
4
5
|
export declare class List<T = {}> extends EventEmitter {
|
|
@@ -143,10 +144,29 @@ export declare function useListConfig(list: List): Partial<IListCell>[];
|
|
|
143
144
|
* @description Возвращает реактивный экземпляр сортировки списка
|
|
144
145
|
* */
|
|
145
146
|
export declare function useListOrder(list: List): IListOrder;
|
|
147
|
+
/**
|
|
148
|
+
* @description Хук для работы с поиском. [Документация +]
|
|
149
|
+
* */
|
|
150
|
+
export declare function useListSearch<T>(array: T[] | Ref<T[]>): {
|
|
151
|
+
search: Ref<string>;
|
|
152
|
+
searchArray: import("vue").ComputedRef<T[]>;
|
|
153
|
+
};
|
|
146
154
|
/**
|
|
147
155
|
* @description Возвращает реактивный массив фильтров для списка
|
|
148
156
|
* */
|
|
149
157
|
export declare function useListFilter(list: List): IFilters;
|
|
158
|
+
/**
|
|
159
|
+
* @description Данный хук используется для того, чтобы создать выборку из массива.
|
|
160
|
+
* Допустим у нас есть:
|
|
161
|
+
* [
|
|
162
|
+
* { id: 1, label: 'J' },
|
|
163
|
+
* { id: 2, label: 'N' },
|
|
164
|
+
* { id: 3, label: 'S }
|
|
165
|
+
* ]
|
|
166
|
+
* Данный хук позволяет хранить и работать с выделенными элементами.
|
|
167
|
+
* @param storedItems - Реактивный объект значений. Может передаваться как ref и как reactive
|
|
168
|
+
*/
|
|
169
|
+
export declare function useListSelect<T>(storedItems: Ref<T[]> | T[]): (T[] | import("vue").ComputedRef<boolean> | ((value?: T) => void))[];
|
|
150
170
|
export declare type ListCellType = 'date' | 'dateWithTime' | 'dateTime' | 'toggle' | 'select' | 'number';
|
|
151
171
|
export interface IDefaultListData {
|
|
152
172
|
[LIST_ROW_KEY]: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ import uuidv4 from "./utils/uuid";
|
|
|
54
54
|
import Request from "./utils/Request";
|
|
55
55
|
import { prettyMoney } from "./utils/pretty-value";
|
|
56
56
|
import parseError from "./utils/parse-error";
|
|
57
|
+
import debounce from "./utils/debounce";
|
|
57
58
|
import useFormMetadata from "./hooks/use-form-metadata";
|
|
58
59
|
import useFormAction from "./hooks/use-form-action";
|
|
59
60
|
import useFormLabel from "./hooks/use-form-label";
|
|
@@ -62,10 +63,13 @@ import useCustomerState from "./hooks/use-customer-state";
|
|
|
62
63
|
import { useTableRequest, useTableState } from "./classes/table/Table";
|
|
63
64
|
import { useCommunication } from "./classes/Communication";
|
|
64
65
|
import useFormRequest from "./hooks/use-form-request";
|
|
65
|
-
import
|
|
66
|
+
import documentsService from "./services/documents-service";
|
|
67
|
+
import billingService from "./services/billing-service";
|
|
68
|
+
import { List, useListRead, useListState, useListOrder, useListFilter, useListConfig, useProvideList, useListSelect, IListCell, IListOrder, IListFilter, useListSearch } from "./classes/new/List";
|
|
66
69
|
import { useWizard } from "./hooks/use-wizard";
|
|
70
|
+
import equipmentService from "./services/equipment-service";
|
|
67
71
|
import { SYMBOL_ROW } from "./classes/table/Table";
|
|
68
|
-
export {
|
|
72
|
+
export { debounce, billingService, documentsService,
|
|
69
73
|
/**
|
|
70
74
|
* @deprecated
|
|
71
75
|
* */
|
|
@@ -73,7 +77,7 @@ clickOutside,
|
|
|
73
77
|
/**
|
|
74
78
|
* @deprecated
|
|
75
79
|
* */
|
|
76
|
-
requestHandler, useSocket, setupSocket, useListRead, IListOrder, IListFilter };
|
|
80
|
+
requestHandler, useSocket, setupSocket, useListRead, useListSearch, IListOrder, IListFilter, equipmentService, useListSelect };
|
|
77
81
|
export { ApplicationManager, Manager, NotificationSystem, Table, CoreError, List, ProcessWrap, Communication, ListConfig };
|
|
78
82
|
export { fileService, processWizardService, viewService, authService, dataService, communicationService, metadataService, invitationService, ruleValidationService, openService, actionService };
|
|
79
83
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* eservices-core v1.0.
|
|
2
|
+
* eservices-core v1.0.524
|
|
3
3
|
* (c) 2023 ESERVICES
|
|
4
4
|
*/
|
|
5
5
|
'use strict';
|
|
@@ -3286,6 +3286,25 @@ function useListOrder(list) {
|
|
|
3286
3286
|
});
|
|
3287
3287
|
return order;
|
|
3288
3288
|
}
|
|
3289
|
+
/**
|
|
3290
|
+
* @description Хук для работы с поиском. [Документация +]
|
|
3291
|
+
* */
|
|
3292
|
+
function useListSearch(array) {
|
|
3293
|
+
const search = vue.ref("");
|
|
3294
|
+
const searchArray = vue.computed(() => {
|
|
3295
|
+
// Convert search sting to lower case.
|
|
3296
|
+
const parsedSearch = search.value.toLowerCase();
|
|
3297
|
+
return vue.unref(array).filter(item => {
|
|
3298
|
+
if (!search.value.length)
|
|
3299
|
+
return true;
|
|
3300
|
+
return Object.values(item).join().toLowerCase().includes(parsedSearch);
|
|
3301
|
+
});
|
|
3302
|
+
});
|
|
3303
|
+
return {
|
|
3304
|
+
search,
|
|
3305
|
+
searchArray
|
|
3306
|
+
};
|
|
3307
|
+
}
|
|
3289
3308
|
/**
|
|
3290
3309
|
* @description Возвращает реактивный массив фильтров для списка
|
|
3291
3310
|
* */
|
|
@@ -3296,6 +3315,49 @@ function useListFilter(list) {
|
|
|
3296
3315
|
list.read();
|
|
3297
3316
|
});
|
|
3298
3317
|
return filters;
|
|
3318
|
+
}
|
|
3319
|
+
/**
|
|
3320
|
+
* @description Данный хук используется для того, чтобы создать выборку из массива.
|
|
3321
|
+
* Допустим у нас есть:
|
|
3322
|
+
* [
|
|
3323
|
+
* { id: 1, label: 'J' },
|
|
3324
|
+
* { id: 2, label: 'N' },
|
|
3325
|
+
* { id: 3, label: 'S }
|
|
3326
|
+
* ]
|
|
3327
|
+
* Данный хук позволяет хранить и работать с выделенными элементами.
|
|
3328
|
+
* @param storedItems - Реактивный объект значений. Может передаваться как ref и как reactive
|
|
3329
|
+
*/
|
|
3330
|
+
function useListSelect(storedItems) {
|
|
3331
|
+
const array = vue.reactive([]);
|
|
3332
|
+
function includes(elem) {
|
|
3333
|
+
return array.includes(elem);
|
|
3334
|
+
}
|
|
3335
|
+
function select(value) {
|
|
3336
|
+
if (!includes(value))
|
|
3337
|
+
array.push(value);
|
|
3338
|
+
}
|
|
3339
|
+
function deselect(value) {
|
|
3340
|
+
const index = array.findIndex(a => a === value);
|
|
3341
|
+
if (index === -1)
|
|
3342
|
+
return;
|
|
3343
|
+
array.splice(index, 1);
|
|
3344
|
+
}
|
|
3345
|
+
function toggle(value) {
|
|
3346
|
+
const items = vue.unref(storedItems);
|
|
3347
|
+
if (value === undefined) {
|
|
3348
|
+
if (array.length === 0)
|
|
3349
|
+
items.forEach(select);
|
|
3350
|
+
else
|
|
3351
|
+
items.forEach(deselect);
|
|
3352
|
+
return;
|
|
3353
|
+
}
|
|
3354
|
+
includes(value) ? deselect(value) : select(value);
|
|
3355
|
+
}
|
|
3356
|
+
const fully = vue.computed(() => {
|
|
3357
|
+
const items = vue.unref(storedItems);
|
|
3358
|
+
return array.length === items.length && items.length !== 0;
|
|
3359
|
+
});
|
|
3360
|
+
return [array, toggle, fully, select, deselect];
|
|
3299
3361
|
}
|
|
3300
3362
|
|
|
3301
3363
|
class Table extends List {
|
|
@@ -5131,6 +5193,15 @@ function uuidv4() {
|
|
|
5131
5193
|
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16));
|
|
5132
5194
|
}
|
|
5133
5195
|
|
|
5196
|
+
function debounce(fn, delay = 1000) {
|
|
5197
|
+
let timeout = 0;
|
|
5198
|
+
return (...args) => {
|
|
5199
|
+
// @ts-ignore
|
|
5200
|
+
clearTimeout(timeout);
|
|
5201
|
+
timeout = setTimeout(() => fn(args), delay);
|
|
5202
|
+
};
|
|
5203
|
+
}
|
|
5204
|
+
|
|
5134
5205
|
function useFormMetadata(form, rules, id) {
|
|
5135
5206
|
form.on(jenesiusVueForm.Form.EVENT_READ, () => {
|
|
5136
5207
|
if (!form.name)
|
|
@@ -5448,6 +5519,64 @@ function useFormRequest(form, formParams) {
|
|
|
5448
5519
|
return { shadowFormState, initShadow };
|
|
5449
5520
|
}
|
|
5450
5521
|
|
|
5522
|
+
class documentsService {
|
|
5523
|
+
static getRequiredDocuments(entity, primaryKey, statusCode) {
|
|
5524
|
+
const params = new URLSearchParams({
|
|
5525
|
+
entity,
|
|
5526
|
+
primaryKey,
|
|
5527
|
+
statusCode
|
|
5528
|
+
});
|
|
5529
|
+
return fetch(`/close-api/views/required-documents?${params.toString()}`)
|
|
5530
|
+
.then(res => res.json());
|
|
5531
|
+
}
|
|
5532
|
+
}
|
|
5533
|
+
|
|
5534
|
+
class billingService {
|
|
5535
|
+
static url() {
|
|
5536
|
+
return `close-api/billing`;
|
|
5537
|
+
}
|
|
5538
|
+
static getBillingMetadata(entityName) {
|
|
5539
|
+
return fetch(`/${billingService.url()}/calculator/${entityName}`);
|
|
5540
|
+
}
|
|
5541
|
+
static calculate(entity, values) {
|
|
5542
|
+
return Request(`/${billingService.url()}/calculator`, {
|
|
5543
|
+
method: 'POST',
|
|
5544
|
+
headers: {
|
|
5545
|
+
'Content-Type': 'application/json'
|
|
5546
|
+
},
|
|
5547
|
+
body: JSON.stringify({
|
|
5548
|
+
entity, values
|
|
5549
|
+
})
|
|
5550
|
+
})
|
|
5551
|
+
.then((res) => {
|
|
5552
|
+
if (res && res.status === 1)
|
|
5553
|
+
return res;
|
|
5554
|
+
if (Array.isArray(res.notes))
|
|
5555
|
+
throw new Error(res.notes[0]);
|
|
5556
|
+
throw CoreError.ApiNotAvailable();
|
|
5557
|
+
});
|
|
5558
|
+
}
|
|
5559
|
+
static parseMetadataField(field) {
|
|
5560
|
+
function parseType(data) {
|
|
5561
|
+
switch (data.type) {
|
|
5562
|
+
case "ValueType": {
|
|
5563
|
+
switch (data.dataType) {
|
|
5564
|
+
case "Integer": return "number";
|
|
5565
|
+
default: return data.dataType;
|
|
5566
|
+
}
|
|
5567
|
+
}
|
|
5568
|
+
case "EntityReference": return data.dataType;
|
|
5569
|
+
}
|
|
5570
|
+
}
|
|
5571
|
+
return {
|
|
5572
|
+
name: field.name,
|
|
5573
|
+
label: field.title,
|
|
5574
|
+
required: field.required,
|
|
5575
|
+
type: parseType(field)
|
|
5576
|
+
};
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
|
|
5451
5580
|
function checkCompleted(res) {
|
|
5452
5581
|
return res.statusName === 'Completed';
|
|
5453
5582
|
}
|
|
@@ -5594,6 +5723,27 @@ function checkFieldsForValues(fields, values) {
|
|
|
5594
5723
|
return true;
|
|
5595
5724
|
}
|
|
5596
5725
|
|
|
5726
|
+
const serviceUrl = `/close-api/proxy/Equipment/Search`;
|
|
5727
|
+
class equipmentService {
|
|
5728
|
+
static search(searchText, categoryId, useType, statusCode, options) {
|
|
5729
|
+
const params = new URLSearchParams();
|
|
5730
|
+
params.append('pattern', searchText || "");
|
|
5731
|
+
if (categoryId)
|
|
5732
|
+
params.append('categoryId', categoryId);
|
|
5733
|
+
if (useType)
|
|
5734
|
+
params.append('useType', String(useType));
|
|
5735
|
+
if (statusCode)
|
|
5736
|
+
params.append('statusCode', statusCode);
|
|
5737
|
+
if (options) {
|
|
5738
|
+
params.append('limit', String(options.limit));
|
|
5739
|
+
params.append('offset', String(options.offset));
|
|
5740
|
+
}
|
|
5741
|
+
const url = `/${serviceUrl}?${params.toString()}`;
|
|
5742
|
+
return fetch(url)
|
|
5743
|
+
.then(res => res.json());
|
|
5744
|
+
}
|
|
5745
|
+
}
|
|
5746
|
+
|
|
5597
5747
|
const utils = {
|
|
5598
5748
|
clickOutside,
|
|
5599
5749
|
requestHandler,
|
|
@@ -5642,10 +5792,14 @@ exports.WidgetSpinner = script$w;
|
|
|
5642
5792
|
exports.WidgetTable = script$8;
|
|
5643
5793
|
exports.actionService = ActionService;
|
|
5644
5794
|
exports.authService = authService;
|
|
5795
|
+
exports.billingService = billingService;
|
|
5645
5796
|
exports.clickOutside = clickOutside;
|
|
5646
5797
|
exports.communicationService = communicationService;
|
|
5647
5798
|
exports.dataService = dataService;
|
|
5799
|
+
exports.debounce = debounce;
|
|
5648
5800
|
exports["default"] = index;
|
|
5801
|
+
exports.documentsService = documentsService;
|
|
5802
|
+
exports.equipmentService = equipmentService;
|
|
5649
5803
|
exports.fileService = fileService;
|
|
5650
5804
|
exports.invitationService = InvitationService;
|
|
5651
5805
|
exports.metadataService = metadataService;
|
|
@@ -5667,6 +5821,8 @@ exports.useListConfig = useListConfig;
|
|
|
5667
5821
|
exports.useListFilter = useListFilter;
|
|
5668
5822
|
exports.useListOrder = useListOrder;
|
|
5669
5823
|
exports.useListRead = useListRead;
|
|
5824
|
+
exports.useListSearch = useListSearch;
|
|
5825
|
+
exports.useListSelect = useListSelect;
|
|
5670
5826
|
exports.useListState = useListState;
|
|
5671
5827
|
exports.useManagerState = useManagerState;
|
|
5672
5828
|
exports.useProvideList = useProvideList;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export default class billingService {
|
|
2
|
+
private static url;
|
|
3
|
+
static getBillingMetadata(entityName: string): Promise<Response>;
|
|
4
|
+
static calculate(entity: string, values: any): Promise<any>;
|
|
5
|
+
static parseMetadataField(field: IBillingField): {
|
|
6
|
+
name: string;
|
|
7
|
+
label: string;
|
|
8
|
+
required: true;
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface IBillingField {
|
|
13
|
+
"name": string;
|
|
14
|
+
"title": string;
|
|
15
|
+
"note": string;
|
|
16
|
+
"type": string;
|
|
17
|
+
"dataType": string;
|
|
18
|
+
"refObjectType": string;
|
|
19
|
+
"refEntityName": string;
|
|
20
|
+
"refChoiceName": string;
|
|
21
|
+
"required": true;
|
|
22
|
+
"presentationType": string;
|
|
23
|
+
}
|
|
24
|
+
interface IBillingApplicationItem {
|
|
25
|
+
amount: number;
|
|
26
|
+
description?: string;
|
|
27
|
+
feeCatalogId: string;
|
|
28
|
+
feeCode: string;
|
|
29
|
+
feeId: number;
|
|
30
|
+
feeName: string;
|
|
31
|
+
properties: null;
|
|
32
|
+
quantity: number;
|
|
33
|
+
taxAmount: null | number;
|
|
34
|
+
taxRate: null | number;
|
|
35
|
+
unitPrice: number;
|
|
36
|
+
}
|
|
37
|
+
export interface IBillingApplication {
|
|
38
|
+
currencyCode: string;
|
|
39
|
+
currencyName: string;
|
|
40
|
+
currencySymbol: string;
|
|
41
|
+
items: IBillingApplicationItem[];
|
|
42
|
+
notes: null | string[];
|
|
43
|
+
status: string;
|
|
44
|
+
statusCode: number;
|
|
45
|
+
totalAmount: number;
|
|
46
|
+
totalTaxAmount: number;
|
|
47
|
+
totalWithTaxAmount: number;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default class equipmentService {
|
|
2
|
+
static search(searchText: string, categoryId: string, useType: boolean, statusCode?: string, options?: IEquipmentSearchParams): Promise<any>;
|
|
3
|
+
}
|
|
4
|
+
interface IEquipmentSearchParams {
|
|
5
|
+
limit?: number;
|
|
6
|
+
offset?: number;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function debounce(fn: (...args: any) => any, delay?: number): (...args: any) => void;
|