@andrey4emk/npm-app-front-b24 0.1.11 → 0.1.13
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createElementBlock as i, openBlock as o, createElementVNode as
|
|
2
|
-
const N = (l,
|
|
1
|
+
import { createElementBlock as i, openBlock as o, createElementVNode as e, createCommentVNode as f, withDirectives as I, vModelCheckbox as A, createTextVNode as p, toDisplayString as d, Fragment as D, renderList as T, normalizeClass as S } from "vue";
|
|
2
|
+
const N = (l, t) => {
|
|
3
3
|
const c = l.__vccOpts || l;
|
|
4
|
-
for (const [h, r] of
|
|
4
|
+
for (const [h, r] of t)
|
|
5
5
|
c[h] = r;
|
|
6
6
|
return c;
|
|
7
7
|
}, m = {
|
|
@@ -26,7 +26,7 @@ const N = (l, e) => {
|
|
|
26
26
|
computed: {},
|
|
27
27
|
methods: {
|
|
28
28
|
pause(l) {
|
|
29
|
-
return new Promise((
|
|
29
|
+
return new Promise((t) => setTimeout(t, l));
|
|
30
30
|
},
|
|
31
31
|
async eventsList() {
|
|
32
32
|
console.log("Запускаем eventsList");
|
|
@@ -48,8 +48,8 @@ const N = (l, e) => {
|
|
|
48
48
|
// auth_type: "138",
|
|
49
49
|
auth_connector: this.auth_connector
|
|
50
50
|
}), console.log(`Подписались на событие ${l}.`);
|
|
51
|
-
} catch (
|
|
52
|
-
console.error("Ошибка при подписке на события:",
|
|
51
|
+
} catch (t) {
|
|
52
|
+
console.error("Ошибка при подписке на события:", t);
|
|
53
53
|
}
|
|
54
54
|
await this.pause(1e3), await this.getSubscribedEvents();
|
|
55
55
|
},
|
|
@@ -68,32 +68,32 @@ const N = (l, e) => {
|
|
|
68
68
|
event_type: l.offline == 1 ? "offline" : "online",
|
|
69
69
|
auth_connector: l.connector_id
|
|
70
70
|
}), await this.pause(1e3), await this.getSubscribedEvents();
|
|
71
|
-
} catch (
|
|
72
|
-
console.error("Ошибка при отписке от событий:",
|
|
71
|
+
} catch (t) {
|
|
72
|
+
console.error("Ошибка при отписке от событий:", t);
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
async loadOfflineEntitiesList() {
|
|
76
|
-
|
|
76
|
+
console.log("Запустили loadOfflineEntitiesList");
|
|
77
|
+
let t = await $b24.callListMethod(
|
|
77
78
|
"event.offline.list",
|
|
78
79
|
{
|
|
79
80
|
start: 0,
|
|
80
81
|
auth_connector: this.auth_connector
|
|
81
82
|
// clear: 0,
|
|
83
|
+
},
|
|
84
|
+
(c) => {
|
|
85
|
+
console.log(`Загрузка: ${c.toFixed(0)}%`, "debug");
|
|
82
86
|
}
|
|
83
|
-
// (progress) => {
|
|
84
|
-
// console.log(`Загрузка: ${progress.toFixed(0)}%`, "debug");
|
|
85
|
-
// },
|
|
86
|
-
// "units"
|
|
87
87
|
);
|
|
88
|
-
this.entities.list =
|
|
88
|
+
this.entities.list = t.getData(), this.entities.total = t.getData().length;
|
|
89
89
|
},
|
|
90
90
|
async deleteOfflineEntities(l) {
|
|
91
|
-
let
|
|
91
|
+
let t = await $b24.callMethod("event.offline.clear", {
|
|
92
92
|
process_id: l.PROCESS_ID,
|
|
93
93
|
id: [l.ID],
|
|
94
94
|
auth_connector: this.auth_connector
|
|
95
95
|
});
|
|
96
|
-
console.log("Удалили сущности из оффлан событий:",
|
|
96
|
+
console.log("Удалили сущности из оффлан событий:", t.getData()), await this.pause(1e3), await this.loadOfflineEntitiesList();
|
|
97
97
|
},
|
|
98
98
|
async deleteOfflineEntitiesAll() {
|
|
99
99
|
if (!confirm("Вы уверены, что хотите удалить все НЕ обработанные сущности? Это действие необратимо!"))
|
|
@@ -117,13 +117,13 @@ const N = (l, e) => {
|
|
|
117
117
|
let s = await $b24.callBatch(n);
|
|
118
118
|
console.log("Результат batch удаления сущностей:", s.getData());
|
|
119
119
|
}
|
|
120
|
-
let
|
|
120
|
+
let t = await $b24.callMethod("event.offline.clear", {
|
|
121
121
|
process_id: ""
|
|
122
122
|
});
|
|
123
|
-
console.log("Результат финального удаления сущностей с пустым PROCESS_ID:",
|
|
123
|
+
console.log("Результат финального удаления сущностей с пустым PROCESS_ID:", t.getData()), await this.pause(500), await this.loadOfflineEntitiesList();
|
|
124
124
|
},
|
|
125
125
|
isSubscribed(l) {
|
|
126
|
-
return this.subscribedEvents.some((
|
|
126
|
+
return this.subscribedEvents.some((t) => t.event == l);
|
|
127
127
|
},
|
|
128
128
|
autoRefreshEntities() {
|
|
129
129
|
this.autoRefresh && setTimeout(async () => {
|
|
@@ -132,7 +132,7 @@ const N = (l, e) => {
|
|
|
132
132
|
},
|
|
133
133
|
async entityUpdate(l) {
|
|
134
134
|
var c, h, r, n, s, u, b;
|
|
135
|
-
let
|
|
135
|
+
let t = !1;
|
|
136
136
|
console.log("Запущена функция entityUpdate для изменения сущности с ID:", (c = l.EVENT_DATA.FIELDS) == null ? void 0 : c.ID);
|
|
137
137
|
try {
|
|
138
138
|
if ((h = l.EVENT_DATA.FIELDS) != null && h.ENTITY_TYPE_ID && ((r = l.EVENT_DATA.FIELDS) == null ? void 0 : r.ENTITY_TYPE_ID) > 0) {
|
|
@@ -148,9 +148,9 @@ const N = (l, e) => {
|
|
|
148
148
|
title: a.title + "123"
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
|
-
console.log("Результат обновления смарт процесса:", E.getData());
|
|
151
|
+
console.log("Результат обновления смарт процесса:", E.getData()), E.id === a.id ? (console.log("Сущность успешно обновлена."), t = !0) : (console.error("Ошибка при обновлении сущности."), t = !0);
|
|
152
152
|
} else
|
|
153
|
-
|
|
153
|
+
t = !0;
|
|
154
154
|
} else {
|
|
155
155
|
let a = await $b24.callMethod("crm.deal.get", {
|
|
156
156
|
id: (s = l.EVENT_DATA.FIELDS) == null ? void 0 : s.ID
|
|
@@ -162,14 +162,14 @@ const N = (l, e) => {
|
|
|
162
162
|
TITLE: a.TITLE
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
|
-
console.log("Результат обновления сделки:", E.getData()), E = E.getData().result, E === !0 ? console.log("Сущность успешно обновлена.") : (console.error("Ошибка при обновлении сущности."),
|
|
165
|
+
console.log("Результат обновления сделки:", E.getData()), E = E.getData().result, E === !0 ? console.log("Сущность успешно обновлена.") : (console.error("Ошибка при обновлении сущности."), t = !0);
|
|
166
166
|
} else
|
|
167
|
-
|
|
167
|
+
t = !0;
|
|
168
168
|
}
|
|
169
169
|
} catch (a) {
|
|
170
170
|
console.error("Ошибка при обновлении сущности:", a), a = !0;
|
|
171
171
|
}
|
|
172
|
-
|
|
172
|
+
t || await this.deleteOfflineEntities(l);
|
|
173
173
|
}
|
|
174
174
|
},
|
|
175
175
|
watch: {},
|
|
@@ -192,78 +192,78 @@ const N = (l, e) => {
|
|
|
192
192
|
key: 0,
|
|
193
193
|
class: "main"
|
|
194
194
|
}, z = ["onClick", "disabled"], j = { key: 1 }, q = { key: 2 };
|
|
195
|
-
function G(l,
|
|
195
|
+
function G(l, t, c, h, r, n) {
|
|
196
196
|
return o(), i("div", v, [
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
onClick:
|
|
197
|
+
t[14] || (t[14] = e("h1", null, "Страница подписок", -1)),
|
|
198
|
+
e("button", {
|
|
199
|
+
onClick: t[0] || (t[0] = (s) => l.selectTab("tab1"))
|
|
200
200
|
}, "Сущности"),
|
|
201
|
-
|
|
202
|
-
onClick:
|
|
201
|
+
e("button", {
|
|
202
|
+
onClick: t[1] || (t[1] = (s) => l.selectTab("tab2"))
|
|
203
203
|
}, "События"),
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
t[15] || (t[15] = e("br", null, null, -1)),
|
|
205
|
+
t[16] || (t[16] = e("br", null, null, -1)),
|
|
206
|
+
t[17] || (t[17] = e("br", null, null, -1)),
|
|
207
207
|
l.tabs.tab1 ? (o(), i("div", k, [
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
onClick:
|
|
208
|
+
e("div", null, [
|
|
209
|
+
e("button", {
|
|
210
|
+
onClick: t[2] || (t[2] = (...s) => n.loadOfflineEntitiesList && n.loadOfflineEntitiesList(...s)),
|
|
211
211
|
disabled: l.loading
|
|
212
212
|
}, "Обновить", 8, L),
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
e("label", C, [
|
|
214
|
+
I(e("input", {
|
|
215
215
|
type: "checkbox",
|
|
216
|
-
"onUpdate:modelValue":
|
|
217
|
-
onChange:
|
|
216
|
+
"onUpdate:modelValue": t[3] || (t[3] = (s) => r.autoRefresh = s),
|
|
217
|
+
onChange: t[4] || (t[4] = (...s) => n.autoRefreshEntities && n.autoRefreshEntities(...s))
|
|
218
218
|
}, null, 544), [
|
|
219
|
-
[
|
|
219
|
+
[A, r.autoRefresh]
|
|
220
220
|
]),
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
t[6] || (t[6] = e("span", { class: "slider" }, null, -1)),
|
|
222
|
+
t[7] || (t[7] = e("span", { class: "tooltip" }, "Автообновление каждые 3 секунды", -1))
|
|
223
223
|
])
|
|
224
224
|
]),
|
|
225
225
|
r.entities.list.length > 0 ? (o(), i("div", w, [
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
onClick:
|
|
226
|
+
e("p", null, [
|
|
227
|
+
e("button", {
|
|
228
|
+
onClick: t[5] || (t[5] = (...s) => n.deleteOfflineEntitiesAll && n.deleteOfflineEntitiesAll(...s))
|
|
229
229
|
}, "Удалить все"),
|
|
230
230
|
p(" Всего измененных сущностей " + d(r.entities.total), 1)
|
|
231
231
|
]),
|
|
232
232
|
r.entities.list.length ? (o(), i("table", V, [
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
233
|
+
t[9] || (t[9] = e("thead", null, [
|
|
234
|
+
e("tr", null, [
|
|
235
|
+
e("th", null, "#"),
|
|
236
|
+
e("th", null, "Удалить"),
|
|
237
|
+
e("th", null, "Обновить"),
|
|
238
|
+
e("th", null, "PROCESS_ID"),
|
|
239
|
+
e("th", null, "EVENT_NAME"),
|
|
240
|
+
e("th", null, "Ссылка"),
|
|
241
|
+
e("th", null, "EVENT_DATA"),
|
|
242
|
+
e("th", null, "who_update"),
|
|
243
|
+
e("th", null, "entity")
|
|
244
244
|
])
|
|
245
245
|
], -1)),
|
|
246
|
-
|
|
246
|
+
e("tbody", null, [
|
|
247
247
|
(o(!0), i(D, null, T(r.entities.list, (s, u) => {
|
|
248
248
|
var b, a, E, _;
|
|
249
249
|
return o(), i("tr", {
|
|
250
250
|
key: s.PROCESS_ID + "-" + s.ID
|
|
251
251
|
}, [
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
onClick: (
|
|
252
|
+
e("td", null, d(u + 1), 1),
|
|
253
|
+
e("td", null, [
|
|
254
|
+
e("button", {
|
|
255
|
+
onClick: (g) => n.deleteOfflineEntities(s)
|
|
256
256
|
}, "Удалить", 8, O)
|
|
257
257
|
]),
|
|
258
|
-
|
|
258
|
+
e("td", null, [
|
|
259
259
|
(b = s.EVENT_DATA.FIELDS) != null && b.ID && (s.EVENT_NAME == "ONCRMDEALUPDATE" || s.EVENT_NAME.includes("ONCRMDYNAMICITEMUPDATE_")) ? (o(), i("button", {
|
|
260
260
|
key: 0,
|
|
261
|
-
onClick: (
|
|
261
|
+
onClick: (g) => n.entityUpdate(s)
|
|
262
262
|
}, "Изменить", 8, M)) : f("", !0)
|
|
263
263
|
]),
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
e("td", null, d(s.PROCESS_ID), 1),
|
|
265
|
+
e("td", null, d(s.EVENT_NAME), 1),
|
|
266
|
+
e("td", null, [
|
|
267
267
|
(a = s.EVENT_DATA.FIELDS) != null && a.ID && s.EVENT_NAME == "ONCRMDEALUPDATE" ? (o(), i("a", {
|
|
268
268
|
key: 0,
|
|
269
269
|
href: "https://repacheb.bitrix24.ru/crm/deal/details/" + ((E = s.EVENT_DATA.FIELDS) == null ? void 0 : E.ID) + "/",
|
|
@@ -271,11 +271,11 @@ function G(l, e, c, h, r, n) {
|
|
|
271
271
|
rel: "noopener noreferrer"
|
|
272
272
|
}, d((_ = s.EVENT_DATA.FIELDS) == null ? void 0 : _.ID), 9, R)) : f("", !0)
|
|
273
273
|
]),
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
274
|
+
e("td", null, d(s.EVENT_DATA), 1),
|
|
275
|
+
e("td", null, d(s.EVENT_ADDITIONAL.user_id), 1),
|
|
276
|
+
e("td", y, [
|
|
277
|
+
t[8] || (t[8] = e("span", null, "Подробней", -1)),
|
|
278
|
+
e("span", P, d(s), 1)
|
|
279
279
|
])
|
|
280
280
|
]);
|
|
281
281
|
}), 128))
|
|
@@ -284,26 +284,26 @@ function G(l, e, c, h, r, n) {
|
|
|
284
284
|
])) : (o(), i("div", F, "Список сущностей пуст."))
|
|
285
285
|
])) : f("", !0),
|
|
286
286
|
l.tabs.tab2 ? (o(), i("div", Y, [
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
e("div", null, [
|
|
288
|
+
t[11] || (t[11] = e("h3", null, "Подписаны на события:", -1)),
|
|
289
289
|
r.subscribedEvents.length ? (o(), i("table", U, [
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
290
|
+
t[10] || (t[10] = e("thead", null, [
|
|
291
|
+
e("tr", null, [
|
|
292
|
+
e("th", null, "Событие"),
|
|
293
|
+
e("th", null, "connector_id"),
|
|
294
|
+
e("th", null, "offline"),
|
|
295
|
+
e("th", null, "Отписаться")
|
|
296
296
|
])
|
|
297
297
|
], -1)),
|
|
298
|
-
|
|
298
|
+
e("tbody", null, [
|
|
299
299
|
(o(!0), i(D, null, T(r.subscribedEvents, (s) => (o(), i("tr", {
|
|
300
300
|
key: s.id
|
|
301
301
|
}, [
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
302
|
+
e("td", null, d(s.event), 1),
|
|
303
|
+
e("td", null, d(s.connector_id), 1),
|
|
304
|
+
e("td", null, d(s.offline), 1),
|
|
305
|
+
e("td", null, [
|
|
306
|
+
e("button", {
|
|
307
307
|
onClick: (u) => n.unbindSubscribedEvents(s)
|
|
308
308
|
}, "Отписаться от событий", 8, $)
|
|
309
309
|
])
|
|
@@ -311,20 +311,20 @@ function G(l, e, c, h, r, n) {
|
|
|
311
311
|
])
|
|
312
312
|
])) : (o(), i("p", x, "Подписок на события нет."))
|
|
313
313
|
]),
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
e("div", null, [
|
|
315
|
+
t[13] || (t[13] = e("h3", null, "На какие события можно подписаться:", -1)),
|
|
316
316
|
r.events.length ? (o(), i("table", B, [
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
317
|
+
t[12] || (t[12] = e("thead", null, [
|
|
318
|
+
e("tr", null, [
|
|
319
|
+
e("th", null, "Событие"),
|
|
320
|
+
e("th", null, "Подписаться")
|
|
321
321
|
])
|
|
322
322
|
], -1)),
|
|
323
|
-
|
|
323
|
+
e("tbody", null, [
|
|
324
324
|
(o(!0), i(D, null, T(r.events, (s) => (o(), i("tr", { key: s }, [
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
e("td", null, d(s), 1),
|
|
326
|
+
e("td", null, [
|
|
327
|
+
e("button", {
|
|
328
328
|
onClick: (u) => n.subscribeToEvents(s),
|
|
329
329
|
disabled: n.isSubscribed(s),
|
|
330
330
|
class: S({ "disabled-button": n.isSubscribed(s) })
|
|
@@ -339,8 +339,8 @@ function G(l, e, c, h, r, n) {
|
|
|
339
339
|
]);
|
|
340
340
|
}
|
|
341
341
|
const H = /* @__PURE__ */ N(m, [["render", G]]), K = {
|
|
342
|
-
install(l,
|
|
343
|
-
l.component("Subscriptions", H),
|
|
342
|
+
install(l, t = {}) {
|
|
343
|
+
l.component("Subscriptions", H), t.b24 && (l.config.globalProperties.$b24 = t.b24);
|
|
344
344
|
}
|
|
345
345
|
};
|
|
346
346
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.NpmAppFrontB24={},d.Vue))})(this,function(d,e){"use strict";const V=(l,t)=>{const a=l.__vccOpts||l;for(const[m,s]of t)a[m]=s;return a},f={name:"Subscriptions",data(){return{events:[],subscribedEvents:[],entities:{list:[],total:0},autoRefresh:!0,auth_connector:""}},computed:{},methods:{pause(l){return new Promise(t=>setTimeout(t,l))},async eventsList(){console.log("Запускаем eventsList");try{let l=await $b24.callMethod("events",{});this.events=l.getData().result}catch(l){console.error("Ошибка при получении списка событий:",l)}},async subscribeToEvents(l){try{await $b24.callMethod("event.bind",{event:l,event_type:"offline",auth_connector:this.auth_connector}),console.log(`Подписались на событие ${l}.`)}catch(t){console.error("Ошибка при подписке на события:",t)}await this.pause(1e3),await this.getSubscribedEvents()},async getSubscribedEvents(){try{let l=await $b24.callMethod("event.get",{});this.subscribedEvents=l.getData().result,console.log("Подписанные события:",this.subscribedEvents)}catch(l){console.error("Ошибка при получении подписанных событий:",l)}},async unbindSubscribedEvents(l){try{await $b24.callMethod("event.unbind",{event:l.event,event_type:l.offline==1?"offline":"online",auth_connector:l.connector_id}),await this.pause(1e3),await this.getSubscribedEvents()}catch(t){console.error("Ошибка при отписке от событий:",t)}},async loadOfflineEntitiesList(){let t=await $b24.callListMethod("event.offline.list",{start:0,auth_connector:this.auth_connector});this.entities.list=t.getData(),this.entities.total=t.getData().length},async deleteOfflineEntities(l){let t=await $b24.callMethod("event.offline.clear",{process_id:l.PROCESS_ID,id:[l.ID],auth_connector:this.auth_connector});console.log("Удалили сущности из оффлан событий:",t.getData()),await this.pause(1e3),await this.loadOfflineEntitiesList()},async deleteOfflineEntitiesAll(){if(!confirm("Вы уверены, что хотите удалить все НЕ обработанные сущности? Это действие необратимо!"))return;let l=this.entities.total/50+1;console.log("Всего страниц для удаления:",l);for(let a=1;a<=l;a++){let s=(await $b24.callMethod("event.offline.list",{start:0})).getData().result.map(i=>i.PROCESS_ID).filter(i=>i);console.log("PROCESS_ID для удаления:",s);let o={};s.forEach((i,E)=>{o[`clear_${E}`]={method:"event.offline.clear",params:{process_id:i}}}),console.log("batchCommands:",o);let n=await $b24.callBatch(o);console.log("Результат batch удаления сущностей:",n.getData())}let t=await $b24.callMethod("event.offline.clear",{process_id:""});console.log("Результат финального удаления сущностей с пустым PROCESS_ID:",t.getData()),await this.pause(500),await this.loadOfflineEntitiesList()},isSubscribed(l){return this.subscribedEvents.some(t=>t.event==l)},autoRefreshEntities(){this.autoRefresh&&setTimeout(async()=>{await this.loadOfflineEntitiesList(),this.autoRefreshEntities()},3e3)},async entityUpdate(l){var a,m,s,o,n,i,E;let t=!1;console.log("Запущена функция entityUpdate для изменения сущности с ID:",(a=l.EVENT_DATA.FIELDS)==null?void 0:a.ID);try{if((m=l.EVENT_DATA.FIELDS)!=null&&m.ENTITY_TYPE_ID&&((s=l.EVENT_DATA.FIELDS)==null?void 0:s.ENTITY_TYPE_ID)>0){let r=await $b24.callMethod("crm.item.get",{entityTypeId:l.EVENT_DATA.FIELDS.ENTITY_TYPE_ID,id:l.EVENT_DATA.FIELDS.ID});if(r=r.getData().result.item,console.log("Данные смарт процесса до изменения:",r),r.id==((o=l.EVENT_DATA.FIELDS)==null?void 0:o.ID)){let c=await $b24.callMethod("crm.item.update",{entityTypeId:l.EVENT_DATA.FIELDS.ENTITY_TYPE_ID,id:l.EVENT_DATA.FIELDS.ID,fields:{title:r.title+"123"}});console.log("Результат обновления смарт процесса:",c.getData())}else t=!0}else{let r=await $b24.callMethod("crm.deal.get",{id:(n=l.EVENT_DATA.FIELDS)==null?void 0:n.ID});if(r=r.getData().result,console.log("Данные сделки до изменения:",r),r.ID==((i=l.EVENT_DATA.FIELDS)==null?void 0:i.ID)){let c=await $b24.callMethod("crm.deal.update",{id:(E=l.EVENT_DATA.FIELDS)==null?void 0:E.ID,fields:{TITLE:r.TITLE}});console.log("Результат обновления сделки:",c.getData()),c=c.getData().result,c===!0?console.log("Сущность успешно обновлена."):(console.error("Ошибка при обновлении сущности."),t=!0)}else t=!0}}catch(r){console.error("Ошибка при обновлении сущности:",r),r=!0}t||await this.deleteOfflineEntities(l)}},watch:{},mounted(){this.getSubscribedEvents(),this.eventsList(),this.loadOfflineEntitiesList(),this.autoRefreshEntities()}},h={class:"Subscriptions"},D={key:0},p=["disabled"],T={class:"switch tooltipParent",style:{top:"12px"}},k={key:0},_={key:0,class:"main"},g=["onClick"],u=["onClick"],S=["href"],A={class:"tooltipParent",style:{}},I={class:"tooltip"},B={key:1},y={key:1},C={key:0,class:"main"},L=["onClick"],w={key:1},O={key:0,class:"main"},M=["onClick","disabled"],R={key:1},F={key:2};function P(l,t,a,m,s,o){return e.openBlock(),e.createElementBlock("div",h,[t[14]||(t[14]=e.createElementVNode("h1",null,"Страница подписок",-1)),e.createElementVNode("button",{onClick:t[0]||(t[0]=n=>l.selectTab("tab1"))},"Сущности"),e.createElementVNode("button",{onClick:t[1]||(t[1]=n=>l.selectTab("tab2"))},"События"),t[15]||(t[15]=e.createElementVNode("br",null,null,-1)),t[16]||(t[16]=e.createElementVNode("br",null,null,-1)),t[17]||(t[17]=e.createElementVNode("br",null,null,-1)),l.tabs.tab1?(e.openBlock(),e.createElementBlock("div",D,[e.createElementVNode("div",null,[e.createElementVNode("button",{onClick:t[2]||(t[2]=(...n)=>o.loadOfflineEntitiesList&&o.loadOfflineEntitiesList(...n)),disabled:l.loading},"Обновить",8,p),e.createElementVNode("label",T,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":t[3]||(t[3]=n=>s.autoRefresh=n),onChange:t[4]||(t[4]=(...n)=>o.autoRefreshEntities&&o.autoRefreshEntities(...n))},null,544),[[e.vModelCheckbox,s.autoRefresh]]),t[6]||(t[6]=e.createElementVNode("span",{class:"slider"},null,-1)),t[7]||(t[7]=e.createElementVNode("span",{class:"tooltip"},"Автообновление каждые 3 секунды",-1))])]),s.entities.list.length>0?(e.openBlock(),e.createElementBlock("div",k,[e.createElementVNode("p",null,[e.createElementVNode("button",{onClick:t[5]||(t[5]=(...n)=>o.deleteOfflineEntitiesAll&&o.deleteOfflineEntitiesAll(...n))},"Удалить все"),e.createTextVNode(" Всего измененных сущностей "+e.toDisplayString(s.entities.total),1)]),s.entities.list.length?(e.openBlock(),e.createElementBlock("table",_,[t[9]||(t[9]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",null,"#"),e.createElementVNode("th",null,"Удалить"),e.createElementVNode("th",null,"Обновить"),e.createElementVNode("th",null,"PROCESS_ID"),e.createElementVNode("th",null,"EVENT_NAME"),e.createElementVNode("th",null,"Ссылка"),e.createElementVNode("th",null,"EVENT_DATA"),e.createElementVNode("th",null,"who_update"),e.createElementVNode("th",null,"entity")])],-1)),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.entities.list,(n,i)=>{var E,r,c,b;return e.openBlock(),e.createElementBlock("tr",{key:n.PROCESS_ID+"-"+n.ID},[e.createElementVNode("td",null,e.toDisplayString(i+1),1),e.createElementVNode("td",null,[e.createElementVNode("button",{onClick:U=>o.deleteOfflineEntities(n)},"Удалить",8,g)]),e.createElementVNode("td",null,[(E=n.EVENT_DATA.FIELDS)!=null&&E.ID&&(n.EVENT_NAME=="ONCRMDEALUPDATE"||n.EVENT_NAME.includes("ONCRMDYNAMICITEMUPDATE_"))?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:U=>o.entityUpdate(n)},"Изменить",8,u)):e.createCommentVNode("",!0)]),e.createElementVNode("td",null,e.toDisplayString(n.PROCESS_ID),1),e.createElementVNode("td",null,e.toDisplayString(n.EVENT_NAME),1),e.createElementVNode("td",null,[(r=n.EVENT_DATA.FIELDS)!=null&&r.ID&&n.EVENT_NAME=="ONCRMDEALUPDATE"?(e.openBlock(),e.createElementBlock("a",{key:0,href:"https://repacheb.bitrix24.ru/crm/deal/details/"+((c=n.EVENT_DATA.FIELDS)==null?void 0:c.ID)+"/",target:"_blank",rel:"noopener noreferrer"},e.toDisplayString((b=n.EVENT_DATA.FIELDS)==null?void 0:b.ID),9,S)):e.createCommentVNode("",!0)]),e.createElementVNode("td",null,e.toDisplayString(n.EVENT_DATA),1),e.createElementVNode("td",null,e.toDisplayString(n.EVENT_ADDITIONAL.user_id),1),e.createElementVNode("td",A,[t[8]||(t[8]=e.createElementVNode("span",null,"Подробней",-1)),e.createElementVNode("span",I,e.toDisplayString(n),1)])])}),128))])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",B,"Список сущностей пуст."))])):e.createCommentVNode("",!0),l.tabs.tab2?(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",null,[t[11]||(t[11]=e.createElementVNode("h3",null,"Подписаны на события:",-1)),s.subscribedEvents.length?(e.openBlock(),e.createElementBlock("table",C,[t[10]||(t[10]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",null,"Событие"),e.createElementVNode("th",null,"connector_id"),e.createElementVNode("th",null,"offline"),e.createElementVNode("th",null,"Отписаться")])],-1)),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.subscribedEvents,n=>(e.openBlock(),e.createElementBlock("tr",{key:n.id},[e.createElementVNode("td",null,e.toDisplayString(n.event),1),e.createElementVNode("td",null,e.toDisplayString(n.connector_id),1),e.createElementVNode("td",null,e.toDisplayString(n.offline),1),e.createElementVNode("td",null,[e.createElementVNode("button",{onClick:i=>o.unbindSubscribedEvents(n)},"Отписаться от событий",8,L)])]))),128))])])):(e.openBlock(),e.createElementBlock("p",w,"Подписок на события нет."))]),e.createElementVNode("div",null,[t[13]||(t[13]=e.createElementVNode("h3",null,"На какие события можно подписаться:",-1)),s.events.length?(e.openBlock(),e.createElementBlock("table",O,[t[12]||(t[12]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",null,"Событие"),e.createElementVNode("th",null,"Подписаться")])],-1)),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.events,n=>(e.openBlock(),e.createElementBlock("tr",{key:n},[e.createElementVNode("td",null,e.toDisplayString(n),1),e.createElementVNode("td",null,[e.createElementVNode("button",{onClick:i=>o.subscribeToEvents(n),disabled:o.isSubscribed(n),class:e.normalizeClass({"disabled-button":o.isSubscribed(n)})},"Подписаться",10,M)])]))),128))])])):(e.openBlock(),e.createElementBlock("p",R,"Список событий пуст."))])])):e.createCommentVNode("",!0),l.tabs.tab3?(e.openBlock(),e.createElementBlock("div",F)):e.createCommentVNode("",!0)])}const N=V(f,[["render",P]]),Y={install(l,t={}){l.component("Subscriptions",N),t.b24&&(l.config.globalProperties.$b24=t.b24)}};d.Subscriptions=N,d.default=Y,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.NpmAppFrontB24={},d.Vue))})(this,function(d,e){"use strict";const f=(l,t)=>{const a=l.__vccOpts||l;for(const[m,s]of t)a[m]=s;return a},V={name:"Subscriptions",data(){return{events:[],subscribedEvents:[],entities:{list:[],total:0},autoRefresh:!0,auth_connector:""}},computed:{},methods:{pause(l){return new Promise(t=>setTimeout(t,l))},async eventsList(){console.log("Запускаем eventsList");try{let l=await $b24.callMethod("events",{});this.events=l.getData().result}catch(l){console.error("Ошибка при получении списка событий:",l)}},async subscribeToEvents(l){try{await $b24.callMethod("event.bind",{event:l,event_type:"offline",auth_connector:this.auth_connector}),console.log(`Подписались на событие ${l}.`)}catch(t){console.error("Ошибка при подписке на события:",t)}await this.pause(1e3),await this.getSubscribedEvents()},async getSubscribedEvents(){try{let l=await $b24.callMethod("event.get",{});this.subscribedEvents=l.getData().result,console.log("Подписанные события:",this.subscribedEvents)}catch(l){console.error("Ошибка при получении подписанных событий:",l)}},async unbindSubscribedEvents(l){try{await $b24.callMethod("event.unbind",{event:l.event,event_type:l.offline==1?"offline":"online",auth_connector:l.connector_id}),await this.pause(1e3),await this.getSubscribedEvents()}catch(t){console.error("Ошибка при отписке от событий:",t)}},async loadOfflineEntitiesList(){console.log("Запустили loadOfflineEntitiesList");let t=await $b24.callListMethod("event.offline.list",{start:0,auth_connector:this.auth_connector},a=>{console.log(`Загрузка: ${a.toFixed(0)}%`,"debug")});this.entities.list=t.getData(),this.entities.total=t.getData().length},async deleteOfflineEntities(l){let t=await $b24.callMethod("event.offline.clear",{process_id:l.PROCESS_ID,id:[l.ID],auth_connector:this.auth_connector});console.log("Удалили сущности из оффлан событий:",t.getData()),await this.pause(1e3),await this.loadOfflineEntitiesList()},async deleteOfflineEntitiesAll(){if(!confirm("Вы уверены, что хотите удалить все НЕ обработанные сущности? Это действие необратимо!"))return;let l=this.entities.total/50+1;console.log("Всего страниц для удаления:",l);for(let a=1;a<=l;a++){let s=(await $b24.callMethod("event.offline.list",{start:0})).getData().result.map(i=>i.PROCESS_ID).filter(i=>i);console.log("PROCESS_ID для удаления:",s);let n={};s.forEach((i,E)=>{n[`clear_${E}`]={method:"event.offline.clear",params:{process_id:i}}}),console.log("batchCommands:",n);let o=await $b24.callBatch(n);console.log("Результат batch удаления сущностей:",o.getData())}let t=await $b24.callMethod("event.offline.clear",{process_id:""});console.log("Результат финального удаления сущностей с пустым PROCESS_ID:",t.getData()),await this.pause(500),await this.loadOfflineEntitiesList()},isSubscribed(l){return this.subscribedEvents.some(t=>t.event==l)},autoRefreshEntities(){this.autoRefresh&&setTimeout(async()=>{await this.loadOfflineEntitiesList(),this.autoRefreshEntities()},3e3)},async entityUpdate(l){var a,m,s,n,o,i,E;let t=!1;console.log("Запущена функция entityUpdate для изменения сущности с ID:",(a=l.EVENT_DATA.FIELDS)==null?void 0:a.ID);try{if((m=l.EVENT_DATA.FIELDS)!=null&&m.ENTITY_TYPE_ID&&((s=l.EVENT_DATA.FIELDS)==null?void 0:s.ENTITY_TYPE_ID)>0){let r=await $b24.callMethod("crm.item.get",{entityTypeId:l.EVENT_DATA.FIELDS.ENTITY_TYPE_ID,id:l.EVENT_DATA.FIELDS.ID});if(r=r.getData().result.item,console.log("Данные смарт процесса до изменения:",r),r.id==((n=l.EVENT_DATA.FIELDS)==null?void 0:n.ID)){let c=await $b24.callMethod("crm.item.update",{entityTypeId:l.EVENT_DATA.FIELDS.ENTITY_TYPE_ID,id:l.EVENT_DATA.FIELDS.ID,fields:{title:r.title+"123"}});console.log("Результат обновления смарт процесса:",c.getData()),c.id===r.id?(console.log("Сущность успешно обновлена."),t=!0):(console.error("Ошибка при обновлении сущности."),t=!0)}else t=!0}else{let r=await $b24.callMethod("crm.deal.get",{id:(o=l.EVENT_DATA.FIELDS)==null?void 0:o.ID});if(r=r.getData().result,console.log("Данные сделки до изменения:",r),r.ID==((i=l.EVENT_DATA.FIELDS)==null?void 0:i.ID)){let c=await $b24.callMethod("crm.deal.update",{id:(E=l.EVENT_DATA.FIELDS)==null?void 0:E.ID,fields:{TITLE:r.TITLE}});console.log("Результат обновления сделки:",c.getData()),c=c.getData().result,c===!0?console.log("Сущность успешно обновлена."):(console.error("Ошибка при обновлении сущности."),t=!0)}else t=!0}}catch(r){console.error("Ошибка при обновлении сущности:",r),r=!0}t||await this.deleteOfflineEntities(l)}},watch:{},mounted(){this.getSubscribedEvents(),this.eventsList(),this.loadOfflineEntitiesList(),this.autoRefreshEntities()}},h={class:"Subscriptions"},D={key:0},p=["disabled"],T={class:"switch tooltipParent",style:{top:"12px"}},k={key:0},_={key:0,class:"main"},g=["onClick"],u=["onClick"],S=["href"],A={class:"tooltipParent",style:{}},I={class:"tooltip"},B={key:1},y={key:1},L={key:0,class:"main"},C=["onClick"],w={key:1},O={key:0,class:"main"},M=["onClick","disabled"],R={key:1},F={key:2};function P(l,t,a,m,s,n){return e.openBlock(),e.createElementBlock("div",h,[t[14]||(t[14]=e.createElementVNode("h1",null,"Страница подписок",-1)),e.createElementVNode("button",{onClick:t[0]||(t[0]=o=>l.selectTab("tab1"))},"Сущности"),e.createElementVNode("button",{onClick:t[1]||(t[1]=o=>l.selectTab("tab2"))},"События"),t[15]||(t[15]=e.createElementVNode("br",null,null,-1)),t[16]||(t[16]=e.createElementVNode("br",null,null,-1)),t[17]||(t[17]=e.createElementVNode("br",null,null,-1)),l.tabs.tab1?(e.openBlock(),e.createElementBlock("div",D,[e.createElementVNode("div",null,[e.createElementVNode("button",{onClick:t[2]||(t[2]=(...o)=>n.loadOfflineEntitiesList&&n.loadOfflineEntitiesList(...o)),disabled:l.loading},"Обновить",8,p),e.createElementVNode("label",T,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":t[3]||(t[3]=o=>s.autoRefresh=o),onChange:t[4]||(t[4]=(...o)=>n.autoRefreshEntities&&n.autoRefreshEntities(...o))},null,544),[[e.vModelCheckbox,s.autoRefresh]]),t[6]||(t[6]=e.createElementVNode("span",{class:"slider"},null,-1)),t[7]||(t[7]=e.createElementVNode("span",{class:"tooltip"},"Автообновление каждые 3 секунды",-1))])]),s.entities.list.length>0?(e.openBlock(),e.createElementBlock("div",k,[e.createElementVNode("p",null,[e.createElementVNode("button",{onClick:t[5]||(t[5]=(...o)=>n.deleteOfflineEntitiesAll&&n.deleteOfflineEntitiesAll(...o))},"Удалить все"),e.createTextVNode(" Всего измененных сущностей "+e.toDisplayString(s.entities.total),1)]),s.entities.list.length?(e.openBlock(),e.createElementBlock("table",_,[t[9]||(t[9]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",null,"#"),e.createElementVNode("th",null,"Удалить"),e.createElementVNode("th",null,"Обновить"),e.createElementVNode("th",null,"PROCESS_ID"),e.createElementVNode("th",null,"EVENT_NAME"),e.createElementVNode("th",null,"Ссылка"),e.createElementVNode("th",null,"EVENT_DATA"),e.createElementVNode("th",null,"who_update"),e.createElementVNode("th",null,"entity")])],-1)),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.entities.list,(o,i)=>{var E,r,c,b;return e.openBlock(),e.createElementBlock("tr",{key:o.PROCESS_ID+"-"+o.ID},[e.createElementVNode("td",null,e.toDisplayString(i+1),1),e.createElementVNode("td",null,[e.createElementVNode("button",{onClick:U=>n.deleteOfflineEntities(o)},"Удалить",8,g)]),e.createElementVNode("td",null,[(E=o.EVENT_DATA.FIELDS)!=null&&E.ID&&(o.EVENT_NAME=="ONCRMDEALUPDATE"||o.EVENT_NAME.includes("ONCRMDYNAMICITEMUPDATE_"))?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:U=>n.entityUpdate(o)},"Изменить",8,u)):e.createCommentVNode("",!0)]),e.createElementVNode("td",null,e.toDisplayString(o.PROCESS_ID),1),e.createElementVNode("td",null,e.toDisplayString(o.EVENT_NAME),1),e.createElementVNode("td",null,[(r=o.EVENT_DATA.FIELDS)!=null&&r.ID&&o.EVENT_NAME=="ONCRMDEALUPDATE"?(e.openBlock(),e.createElementBlock("a",{key:0,href:"https://repacheb.bitrix24.ru/crm/deal/details/"+((c=o.EVENT_DATA.FIELDS)==null?void 0:c.ID)+"/",target:"_blank",rel:"noopener noreferrer"},e.toDisplayString((b=o.EVENT_DATA.FIELDS)==null?void 0:b.ID),9,S)):e.createCommentVNode("",!0)]),e.createElementVNode("td",null,e.toDisplayString(o.EVENT_DATA),1),e.createElementVNode("td",null,e.toDisplayString(o.EVENT_ADDITIONAL.user_id),1),e.createElementVNode("td",A,[t[8]||(t[8]=e.createElementVNode("span",null,"Подробней",-1)),e.createElementVNode("span",I,e.toDisplayString(o),1)])])}),128))])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",B,"Список сущностей пуст."))])):e.createCommentVNode("",!0),l.tabs.tab2?(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",null,[t[11]||(t[11]=e.createElementVNode("h3",null,"Подписаны на события:",-1)),s.subscribedEvents.length?(e.openBlock(),e.createElementBlock("table",L,[t[10]||(t[10]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",null,"Событие"),e.createElementVNode("th",null,"connector_id"),e.createElementVNode("th",null,"offline"),e.createElementVNode("th",null,"Отписаться")])],-1)),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.subscribedEvents,o=>(e.openBlock(),e.createElementBlock("tr",{key:o.id},[e.createElementVNode("td",null,e.toDisplayString(o.event),1),e.createElementVNode("td",null,e.toDisplayString(o.connector_id),1),e.createElementVNode("td",null,e.toDisplayString(o.offline),1),e.createElementVNode("td",null,[e.createElementVNode("button",{onClick:i=>n.unbindSubscribedEvents(o)},"Отписаться от событий",8,C)])]))),128))])])):(e.openBlock(),e.createElementBlock("p",w,"Подписок на события нет."))]),e.createElementVNode("div",null,[t[13]||(t[13]=e.createElementVNode("h3",null,"На какие события можно подписаться:",-1)),s.events.length?(e.openBlock(),e.createElementBlock("table",O,[t[12]||(t[12]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",null,"Событие"),e.createElementVNode("th",null,"Подписаться")])],-1)),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.events,o=>(e.openBlock(),e.createElementBlock("tr",{key:o},[e.createElementVNode("td",null,e.toDisplayString(o),1),e.createElementVNode("td",null,[e.createElementVNode("button",{onClick:i=>n.subscribeToEvents(o),disabled:n.isSubscribed(o),class:e.normalizeClass({"disabled-button":n.isSubscribed(o)})},"Подписаться",10,M)])]))),128))])])):(e.openBlock(),e.createElementBlock("p",R,"Список событий пуст."))])])):e.createCommentVNode("",!0),l.tabs.tab3?(e.openBlock(),e.createElementBlock("div",F)):e.createCommentVNode("",!0)])}const N=f(V,[["render",P]]),Y={install(l,t={}){l.component("Subscriptions",N),t.b24&&(l.config.globalProperties.$b24=t.b24)}};d.Subscriptions=N,d.default=Y,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED