@pisell/pisellos 2.3.58 → 2.3.59
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/core/index.d.ts +7 -0
- package/dist/core/index.js +109 -66
- package/dist/modules/Quotation/index.d.ts +6 -0
- package/dist/modules/Quotation/index.js +75 -19
- package/dist/plugins/request.d.ts +1 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +166 -119
- package/dist/server/modules/floor-plan/index.d.ts +4 -0
- package/dist/server/modules/floor-plan/index.js +240 -98
- package/dist/server/modules/order/index.d.ts +6 -5
- package/dist/server/modules/order/index.js +176 -78
- package/dist/server/modules/products/index.d.ts +2 -0
- package/dist/server/modules/products/index.js +17 -3
- package/dist/server/modules/resource/index.js +21 -13
- package/lib/core/index.d.ts +7 -0
- package/lib/core/index.js +20 -3
- package/lib/modules/Quotation/index.d.ts +6 -0
- package/lib/modules/Quotation/index.js +49 -5
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +69 -15
- package/lib/server/modules/floor-plan/index.d.ts +4 -0
- package/lib/server/modules/floor-plan/index.js +54 -6
- package/lib/server/modules/order/index.d.ts +6 -5
- package/lib/server/modules/order/index.js +105 -23
- package/lib/server/modules/products/index.d.ts +2 -0
- package/lib/server/modules/products/index.js +15 -4
- package/lib/server/modules/resource/index.js +7 -2
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -12,8 +12,15 @@ declare class PisellOSCore implements PisellCore {
|
|
|
12
12
|
context: BusinessContext;
|
|
13
13
|
server: any;
|
|
14
14
|
serverOptions?: ServerOptions;
|
|
15
|
+
private serverModulePromise?;
|
|
15
16
|
constructor(options?: PisellOSOptions);
|
|
16
17
|
private initialize;
|
|
18
|
+
/**
|
|
19
|
+
* 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
|
|
20
|
+
* 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
|
|
21
|
+
*/
|
|
22
|
+
preloadServerModule(): Promise<void>;
|
|
23
|
+
private loadServerModule;
|
|
17
24
|
/**
|
|
18
25
|
* 初始化 Server(公开方法,需要外部显式调用并等待)
|
|
19
26
|
* Server 配置从构造函数传入的 options.server 中获取
|
package/dist/core/index.js
CHANGED
|
@@ -24,8 +24,6 @@ import { EffectsManager } from "../effects";
|
|
|
24
24
|
* pisell OS 核心实现
|
|
25
25
|
*/
|
|
26
26
|
var PisellOSCore = /*#__PURE__*/function () {
|
|
27
|
-
// 保存 Server 配置
|
|
28
|
-
|
|
29
27
|
function PisellOSCore(options) {
|
|
30
28
|
_classCallCheck(this, PisellOSCore);
|
|
31
29
|
_defineProperty(this, "plugins", new Map());
|
|
@@ -37,6 +35,8 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
37
35
|
_defineProperty(this, "server", void 0);
|
|
38
36
|
// Server 实例
|
|
39
37
|
_defineProperty(this, "serverOptions", void 0);
|
|
38
|
+
// 保存 Server 配置
|
|
39
|
+
_defineProperty(this, "serverModulePromise", void 0);
|
|
40
40
|
this.debug = (options === null || options === void 0 ? void 0 : options.debug) || false;
|
|
41
41
|
this.context = (options === null || options === void 0 ? void 0 : options.context) || {};
|
|
42
42
|
|
|
@@ -45,7 +45,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
45
45
|
this.serverOptions = options.server;
|
|
46
46
|
}
|
|
47
47
|
this.initialize(options);
|
|
48
|
-
console.log('
|
|
48
|
+
console.log('constructor123456');
|
|
49
49
|
}
|
|
50
50
|
_createClass(PisellOSCore, [{
|
|
51
51
|
key: "initialize",
|
|
@@ -64,6 +64,49 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
64
64
|
this.log('[PisellOS] 核心初始化完成');
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
|
|
69
|
+
* 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
|
|
70
|
+
*/
|
|
71
|
+
}, {
|
|
72
|
+
key: "preloadServerModule",
|
|
73
|
+
value: (function () {
|
|
74
|
+
var _preloadServerModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
75
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
76
|
+
while (1) switch (_context.prev = _context.next) {
|
|
77
|
+
case 0:
|
|
78
|
+
if (!(this.server || !this.serverOptions)) {
|
|
79
|
+
_context.next = 2;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
return _context.abrupt("return");
|
|
83
|
+
case 2:
|
|
84
|
+
_context.next = 4;
|
|
85
|
+
return this.loadServerModule();
|
|
86
|
+
case 4:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context.stop();
|
|
89
|
+
}
|
|
90
|
+
}, _callee, this);
|
|
91
|
+
}));
|
|
92
|
+
function preloadServerModule() {
|
|
93
|
+
return _preloadServerModule.apply(this, arguments);
|
|
94
|
+
}
|
|
95
|
+
return preloadServerModule;
|
|
96
|
+
}())
|
|
97
|
+
}, {
|
|
98
|
+
key: "loadServerModule",
|
|
99
|
+
value: function loadServerModule() {
|
|
100
|
+
var _this2 = this;
|
|
101
|
+
if (!this.serverModulePromise) {
|
|
102
|
+
this.serverModulePromise = import("../server").catch(function (error) {
|
|
103
|
+
_this2.serverModulePromise = undefined;
|
|
104
|
+
throw error;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return this.serverModulePromise;
|
|
108
|
+
}
|
|
109
|
+
|
|
67
110
|
/**
|
|
68
111
|
* 初始化 Server(公开方法,需要外部显式调用并等待)
|
|
69
112
|
* Server 配置从构造函数传入的 options.server 中获取
|
|
@@ -71,57 +114,57 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
71
114
|
}, {
|
|
72
115
|
key: "initializeServer",
|
|
73
116
|
value: (function () {
|
|
74
|
-
var _initializeServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
117
|
+
var _initializeServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
75
118
|
var ServerModule, Server;
|
|
76
|
-
return _regeneratorRuntime().wrap(function
|
|
77
|
-
while (1) switch (
|
|
119
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
120
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
78
121
|
case 0:
|
|
79
122
|
if (!this.server) {
|
|
80
|
-
|
|
123
|
+
_context2.next = 3;
|
|
81
124
|
break;
|
|
82
125
|
}
|
|
83
126
|
this.log('Server 已经初始化,跳过重复初始化', 'warn');
|
|
84
|
-
return
|
|
127
|
+
return _context2.abrupt("return");
|
|
85
128
|
case 3:
|
|
86
129
|
if (this.serverOptions) {
|
|
87
|
-
|
|
130
|
+
_context2.next = 6;
|
|
88
131
|
break;
|
|
89
132
|
}
|
|
90
133
|
this.log('未提供 Server 配置,无法初始化', 'warn');
|
|
91
|
-
return
|
|
134
|
+
return _context2.abrupt("return");
|
|
92
135
|
case 6:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return
|
|
136
|
+
_context2.prev = 6;
|
|
137
|
+
_context2.next = 9;
|
|
138
|
+
return this.loadServerModule();
|
|
96
139
|
case 9:
|
|
97
|
-
ServerModule =
|
|
140
|
+
ServerModule = _context2.sent;
|
|
98
141
|
Server = ServerModule.default; // 创建 Server 实例
|
|
99
142
|
this.server = new Server(this);
|
|
100
143
|
this.log('Server 实例已创建');
|
|
101
144
|
|
|
102
145
|
// 初始化模块并预加载数据
|
|
103
146
|
if (!this.serverOptions.modules) {
|
|
104
|
-
|
|
147
|
+
_context2.next = 16;
|
|
105
148
|
break;
|
|
106
149
|
}
|
|
107
|
-
|
|
150
|
+
_context2.next = 16;
|
|
108
151
|
return this.server.initialize(this.serverOptions.modules, this.serverOptions.autoInitData !== false, options);
|
|
109
152
|
case 16:
|
|
110
153
|
console.log('[PisellOS] ✅ Server 初始化完成,所有数据已预加载');
|
|
111
154
|
this.log('[PisellOS] Server 初始化完成');
|
|
112
|
-
|
|
155
|
+
_context2.next = 25;
|
|
113
156
|
break;
|
|
114
157
|
case 20:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
console.error('[PisellOS] ❌ Server 初始化失败:',
|
|
118
|
-
this.log("Server \u521D\u59CB\u5316\u5931\u8D25: ".concat(
|
|
119
|
-
throw
|
|
158
|
+
_context2.prev = 20;
|
|
159
|
+
_context2.t0 = _context2["catch"](6);
|
|
160
|
+
console.error('[PisellOS] ❌ Server 初始化失败:', _context2.t0);
|
|
161
|
+
this.log("Server \u521D\u59CB\u5316\u5931\u8D25: ".concat(_context2.t0), 'error');
|
|
162
|
+
throw _context2.t0;
|
|
120
163
|
case 25:
|
|
121
164
|
case "end":
|
|
122
|
-
return
|
|
165
|
+
return _context2.stop();
|
|
123
166
|
}
|
|
124
|
-
},
|
|
167
|
+
}, _callee2, this, [[6, 20]]);
|
|
125
168
|
}));
|
|
126
169
|
function initializeServer(_x) {
|
|
127
170
|
return _initializeServer.apply(this, arguments);
|
|
@@ -154,7 +197,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
154
197
|
}, {
|
|
155
198
|
key: "registerPlugin",
|
|
156
199
|
value: function registerPlugin(plugin, options) {
|
|
157
|
-
var
|
|
200
|
+
var _this3 = this;
|
|
158
201
|
if (this.plugins.has(plugin.name)) {
|
|
159
202
|
this.log("\u63D2\u4EF6 ".concat(plugin.name, " \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6"), 'warn');
|
|
160
203
|
}
|
|
@@ -182,7 +225,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
182
225
|
var result = plugin.initialize();
|
|
183
226
|
if (result instanceof Promise) {
|
|
184
227
|
result.catch(function (err) {
|
|
185
|
-
|
|
228
|
+
_this3.log("\u63D2\u4EF6 ".concat(plugin.name, " \u521D\u59CB\u5316\u5931\u8D25: ").concat(err.message), 'error');
|
|
186
229
|
throw err;
|
|
187
230
|
});
|
|
188
231
|
}
|
|
@@ -208,7 +251,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
208
251
|
}, {
|
|
209
252
|
key: "registerModule",
|
|
210
253
|
value: function registerModule(module, options) {
|
|
211
|
-
var
|
|
254
|
+
var _this4 = this;
|
|
212
255
|
if (this.modules.has(module.name)) {
|
|
213
256
|
this.log("\u6A21\u5757 ".concat(module.name, " \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6"), 'warn');
|
|
214
257
|
}
|
|
@@ -251,7 +294,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
251
294
|
// 预先给模块初始化值系统
|
|
252
295
|
var _createStore = createStore((options === null || options === void 0 ? void 0 : options.initialState) || {}, module.name, function (path, value) {
|
|
253
296
|
console.log('core 检测到模块值更新', module.name, path, value);
|
|
254
|
-
|
|
297
|
+
_this4.effects.emit("".concat(module.name, ":changed"), {
|
|
255
298
|
path: path,
|
|
256
299
|
value: value
|
|
257
300
|
});
|
|
@@ -266,7 +309,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
266
309
|
}, options));
|
|
267
310
|
if (result instanceof Promise) {
|
|
268
311
|
result.catch(function (err) {
|
|
269
|
-
|
|
312
|
+
_this4.log("\u6A21\u5757 ".concat(module.name, " \u521D\u59CB\u5316\u5931\u8D25: ").concat(err.message), 'error');
|
|
270
313
|
throw err;
|
|
271
314
|
});
|
|
272
315
|
}
|
|
@@ -311,100 +354,100 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
311
354
|
}, {
|
|
312
355
|
key: "destroy",
|
|
313
356
|
value: function () {
|
|
314
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
357
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
315
358
|
var _iterator4, _step4, _step4$value, name, module, _iterator5, _step5, _step5$value, _name, plugin;
|
|
316
|
-
return _regeneratorRuntime().wrap(function
|
|
317
|
-
while (1) switch (
|
|
359
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
360
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
318
361
|
case 0:
|
|
319
362
|
// 先销毁模块
|
|
320
363
|
_iterator4 = _createForOfIteratorHelper(this.modules.entries());
|
|
321
|
-
|
|
364
|
+
_context3.prev = 1;
|
|
322
365
|
_iterator4.s();
|
|
323
366
|
case 3:
|
|
324
367
|
if ((_step4 = _iterator4.n()).done) {
|
|
325
|
-
|
|
368
|
+
_context3.next = 17;
|
|
326
369
|
break;
|
|
327
370
|
}
|
|
328
371
|
_step4$value = _slicedToArray(_step4.value, 2), name = _step4$value[0], module = _step4$value[1];
|
|
329
372
|
if (!module.destroy) {
|
|
330
|
-
|
|
373
|
+
_context3.next = 15;
|
|
331
374
|
break;
|
|
332
375
|
}
|
|
333
|
-
|
|
334
|
-
|
|
376
|
+
_context3.prev = 6;
|
|
377
|
+
_context3.next = 9;
|
|
335
378
|
return Promise.resolve(module.destroy());
|
|
336
379
|
case 9:
|
|
337
380
|
this.log("\u6A21\u5757 ".concat(name, " \u5DF2\u9500\u6BC1"));
|
|
338
|
-
|
|
381
|
+
_context3.next = 15;
|
|
339
382
|
break;
|
|
340
383
|
case 12:
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
this.log("\u9500\u6BC1\u6A21\u5757 ".concat(name, " \u65F6\u51FA\u9519: ").concat(
|
|
384
|
+
_context3.prev = 12;
|
|
385
|
+
_context3.t0 = _context3["catch"](6);
|
|
386
|
+
this.log("\u9500\u6BC1\u6A21\u5757 ".concat(name, " \u65F6\u51FA\u9519: ").concat(_context3.t0), 'error');
|
|
344
387
|
case 15:
|
|
345
|
-
|
|
388
|
+
_context3.next = 3;
|
|
346
389
|
break;
|
|
347
390
|
case 17:
|
|
348
|
-
|
|
391
|
+
_context3.next = 22;
|
|
349
392
|
break;
|
|
350
393
|
case 19:
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
_iterator4.e(
|
|
394
|
+
_context3.prev = 19;
|
|
395
|
+
_context3.t1 = _context3["catch"](1);
|
|
396
|
+
_iterator4.e(_context3.t1);
|
|
354
397
|
case 22:
|
|
355
|
-
|
|
398
|
+
_context3.prev = 22;
|
|
356
399
|
_iterator4.f();
|
|
357
|
-
return
|
|
400
|
+
return _context3.finish(22);
|
|
358
401
|
case 25:
|
|
359
402
|
this.modules.clear();
|
|
360
403
|
|
|
361
404
|
// 再销毁插件
|
|
362
405
|
_iterator5 = _createForOfIteratorHelper(this.plugins.entries());
|
|
363
|
-
|
|
406
|
+
_context3.prev = 27;
|
|
364
407
|
_iterator5.s();
|
|
365
408
|
case 29:
|
|
366
409
|
if ((_step5 = _iterator5.n()).done) {
|
|
367
|
-
|
|
410
|
+
_context3.next = 43;
|
|
368
411
|
break;
|
|
369
412
|
}
|
|
370
413
|
_step5$value = _slicedToArray(_step5.value, 2), _name = _step5$value[0], plugin = _step5$value[1];
|
|
371
414
|
if (!plugin.destroy) {
|
|
372
|
-
|
|
415
|
+
_context3.next = 41;
|
|
373
416
|
break;
|
|
374
417
|
}
|
|
375
|
-
|
|
376
|
-
|
|
418
|
+
_context3.prev = 32;
|
|
419
|
+
_context3.next = 35;
|
|
377
420
|
return Promise.resolve(plugin.destroy());
|
|
378
421
|
case 35:
|
|
379
422
|
this.log("\u63D2\u4EF6 ".concat(_name, " \u5DF2\u9500\u6BC1"));
|
|
380
|
-
|
|
423
|
+
_context3.next = 41;
|
|
381
424
|
break;
|
|
382
425
|
case 38:
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
this.log("\u9500\u6BC1\u63D2\u4EF6 ".concat(_name, " \u65F6\u51FA\u9519: ").concat(
|
|
426
|
+
_context3.prev = 38;
|
|
427
|
+
_context3.t2 = _context3["catch"](32);
|
|
428
|
+
this.log("\u9500\u6BC1\u63D2\u4EF6 ".concat(_name, " \u65F6\u51FA\u9519: ").concat(_context3.t2), 'error');
|
|
386
429
|
case 41:
|
|
387
|
-
|
|
430
|
+
_context3.next = 29;
|
|
388
431
|
break;
|
|
389
432
|
case 43:
|
|
390
|
-
|
|
433
|
+
_context3.next = 48;
|
|
391
434
|
break;
|
|
392
435
|
case 45:
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
_iterator5.e(
|
|
436
|
+
_context3.prev = 45;
|
|
437
|
+
_context3.t3 = _context3["catch"](27);
|
|
438
|
+
_iterator5.e(_context3.t3);
|
|
396
439
|
case 48:
|
|
397
|
-
|
|
440
|
+
_context3.prev = 48;
|
|
398
441
|
_iterator5.f();
|
|
399
|
-
return
|
|
442
|
+
return _context3.finish(48);
|
|
400
443
|
case 51:
|
|
401
444
|
this.plugins.clear();
|
|
402
445
|
this.log('PisellOS 核心已销毁');
|
|
403
446
|
case 53:
|
|
404
447
|
case "end":
|
|
405
|
-
return
|
|
448
|
+
return _context3.stop();
|
|
406
449
|
}
|
|
407
|
-
},
|
|
450
|
+
}, _callee3, this, [[1, 19, 22, 25], [6, 12], [27, 45, 48, 51], [32, 38]]);
|
|
408
451
|
}));
|
|
409
452
|
function destroy() {
|
|
410
453
|
return _destroy.apply(this, arguments);
|
|
@@ -9,6 +9,8 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
9
9
|
private request;
|
|
10
10
|
private store;
|
|
11
11
|
private scheduleResolver?;
|
|
12
|
+
private app;
|
|
13
|
+
private quotationListUpdatedListener?;
|
|
12
14
|
constructor(name?: string, version?: string);
|
|
13
15
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
14
16
|
loadQuotations(params?: {
|
|
@@ -16,6 +18,7 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
16
18
|
customer_id?: number | string;
|
|
17
19
|
}): Promise<void>;
|
|
18
20
|
getQuotationList(): QuotationItem[];
|
|
21
|
+
setQuotationListUpdatedListener(listener?: () => void): void;
|
|
19
22
|
getQuotationCustomerScopeInfo(): QuotationCustomerScopeInfo;
|
|
20
23
|
/**
|
|
21
24
|
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
@@ -60,6 +63,9 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
60
63
|
customer_id?: number | string;
|
|
61
64
|
}): Map<string, string | null>;
|
|
62
65
|
setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
|
|
66
|
+
private applyQuotationResponse;
|
|
67
|
+
private notifyQuotationListUpdated;
|
|
68
|
+
private getQuotationCacheKeyData;
|
|
63
69
|
private isQuotationVisibleForCustomer;
|
|
64
70
|
private hasValidCustomerId;
|
|
65
71
|
private normalizeCustomerId;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
4
8
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
5
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
10
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -36,12 +40,15 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
36
40
|
list: []
|
|
37
41
|
});
|
|
38
42
|
_defineProperty(_assertThisInitialized(_this), "scheduleResolver", void 0);
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "app", void 0);
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "quotationListUpdatedListener", void 0);
|
|
39
45
|
return _this;
|
|
40
46
|
}
|
|
41
47
|
_createClass(QuotationModule, [{
|
|
42
48
|
key: "initialize",
|
|
43
49
|
value: function () {
|
|
44
50
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
51
|
+
var _core$getPlugin, _core$getPlugin$getAp;
|
|
45
52
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
46
53
|
while (1) switch (_context.prev = _context.next) {
|
|
47
54
|
case 0:
|
|
@@ -53,10 +60,11 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
53
60
|
}
|
|
54
61
|
throw new Error('QuotationModule 需要 request 插件支持');
|
|
55
62
|
case 4:
|
|
63
|
+
this.app = (_core$getPlugin = core.getPlugin('app')) === null || _core$getPlugin === void 0 || (_core$getPlugin$getAp = _core$getPlugin.getApp) === null || _core$getPlugin$getAp === void 0 ? void 0 : _core$getPlugin$getAp.call(_core$getPlugin);
|
|
56
64
|
this.store = {
|
|
57
65
|
list: []
|
|
58
66
|
};
|
|
59
|
-
case
|
|
67
|
+
case 6:
|
|
60
68
|
case "end":
|
|
61
69
|
return _context.stop();
|
|
62
70
|
}
|
|
@@ -71,8 +79,8 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
71
79
|
key: "loadQuotations",
|
|
72
80
|
value: function () {
|
|
73
81
|
var _loadQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
74
|
-
var
|
|
75
|
-
var query,
|
|
82
|
+
var _this2 = this;
|
|
83
|
+
var query, initialResultApplied, applyRemoteUpdate, res;
|
|
76
84
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
77
85
|
while (1) switch (_context2.prev = _context2.next) {
|
|
78
86
|
case 0:
|
|
@@ -81,19 +89,27 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
81
89
|
if ((params === null || params === void 0 ? void 0 : params.channel) === 'online_store') {
|
|
82
90
|
query.channel = 'online-store';
|
|
83
91
|
}
|
|
84
|
-
|
|
92
|
+
initialResultApplied = false;
|
|
93
|
+
applyRemoteUpdate = function applyRemoteUpdate(response) {
|
|
94
|
+
_this2.applyQuotationResponse(response);
|
|
95
|
+
if (initialResultApplied) {
|
|
96
|
+
_this2.notifyQuotationListUpdated();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
_context2.next = 7;
|
|
85
100
|
return this.request.get('/quotation/available', query, {
|
|
86
|
-
|
|
87
|
-
|
|
101
|
+
cache: {
|
|
102
|
+
type: 'indexDB',
|
|
103
|
+
updateCache: true,
|
|
104
|
+
cacheKeyData: this.getQuotationCacheKeyData(query)
|
|
105
|
+
},
|
|
106
|
+
cacheUpdateChange: applyRemoteUpdate
|
|
88
107
|
});
|
|
89
|
-
case
|
|
108
|
+
case 7:
|
|
90
109
|
res = _context2.sent;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
this.store.list = list;
|
|
96
|
-
case 9:
|
|
110
|
+
this.applyQuotationResponse(res);
|
|
111
|
+
initialResultApplied = true;
|
|
112
|
+
case 10:
|
|
97
113
|
case "end":
|
|
98
114
|
return _context2.stop();
|
|
99
115
|
}
|
|
@@ -109,10 +125,15 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
109
125
|
value: function getQuotationList() {
|
|
110
126
|
return this.store.list;
|
|
111
127
|
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "setQuotationListUpdatedListener",
|
|
130
|
+
value: function setQuotationListUpdatedListener(listener) {
|
|
131
|
+
this.quotationListUpdatedListener = listener;
|
|
132
|
+
}
|
|
112
133
|
}, {
|
|
113
134
|
key: "getQuotationCustomerScopeInfo",
|
|
114
135
|
value: function getQuotationCustomerScopeInfo() {
|
|
115
|
-
var
|
|
136
|
+
var _this3 = this;
|
|
116
137
|
var customerById = new Map();
|
|
117
138
|
var quotationScopes = this.store.list.filter(function (quotation) {
|
|
118
139
|
return Array.isArray(quotation.customer) && quotation.customer.length > 0;
|
|
@@ -122,7 +143,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
122
143
|
var localSeen = new Set();
|
|
123
144
|
var quotationCustomers = quotation.customer || [];
|
|
124
145
|
quotationCustomers.forEach(function (customer) {
|
|
125
|
-
var customerId =
|
|
146
|
+
var customerId = _this3.normalizeCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
126
147
|
if (!customerId || localSeen.has(customerId)) return;
|
|
127
148
|
localSeen.add(customerId);
|
|
128
149
|
customerIds.push(customerId);
|
|
@@ -247,6 +268,41 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
247
268
|
value: function setScheduleResolver(resolver) {
|
|
248
269
|
this.scheduleResolver = resolver;
|
|
249
270
|
}
|
|
271
|
+
}, {
|
|
272
|
+
key: "applyQuotationResponse",
|
|
273
|
+
value: function applyQuotationResponse(response) {
|
|
274
|
+
var _data;
|
|
275
|
+
var source = (response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
|
|
276
|
+
this.store.list = _toConsumableArray(source).sort(function (a, b) {
|
|
277
|
+
return Number(b.sort || 0) - Number(a.sort || 0);
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}, {
|
|
281
|
+
key: "notifyQuotationListUpdated",
|
|
282
|
+
value: function notifyQuotationListUpdated() {
|
|
283
|
+
try {
|
|
284
|
+
var _this$quotationListUp;
|
|
285
|
+
(_this$quotationListUp = this.quotationListUpdatedListener) === null || _this$quotationListUp === void 0 || _this$quotationListUp.call(this);
|
|
286
|
+
} catch (error) {
|
|
287
|
+
console.warn('[QuotationModule] 报价单后台更新回调失败', error);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}, {
|
|
291
|
+
key: "getQuotationCacheKeyData",
|
|
292
|
+
value: function getQuotationCacheKeyData(query) {
|
|
293
|
+
var shopId = '';
|
|
294
|
+
try {
|
|
295
|
+
var _this$app, _this$app$getStorage;
|
|
296
|
+
var storedCore = (_this$app = this.app) === null || _this$app === void 0 || (_this$app = _this$app.storage) === null || _this$app === void 0 || (_this$app$getStorage = _this$app.getStorage) === null || _this$app$getStorage === void 0 ? void 0 : _this$app$getStorage.call(_this$app, 'core');
|
|
297
|
+
var coreInfo = typeof storedCore === 'string' ? JSON.parse(storedCore || '{}') : storedCore || {};
|
|
298
|
+
shopId = String((coreInfo === null || coreInfo === void 0 ? void 0 : coreInfo.id) || '');
|
|
299
|
+
} catch (_unused) {
|
|
300
|
+
// 缓存隔离信息读取失败时仍按请求参数缓存。
|
|
301
|
+
}
|
|
302
|
+
return _objectSpread(_objectSpread({}, query), {}, {
|
|
303
|
+
shop_id: shopId
|
|
304
|
+
});
|
|
305
|
+
}
|
|
250
306
|
}, {
|
|
251
307
|
key: "isQuotationVisibleForCustomer",
|
|
252
308
|
value: function isQuotationVisibleForCustomer(quotation, customerId) {
|
|
@@ -273,17 +329,17 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
273
329
|
key: "isQuotationActiveAt",
|
|
274
330
|
value: function isQuotationActiveAt(quotation, datetime) {
|
|
275
331
|
var _quotation$schedule,
|
|
276
|
-
|
|
332
|
+
_this4 = this;
|
|
277
333
|
if (!((_quotation$schedule = quotation.schedule) !== null && _quotation$schedule !== void 0 && _quotation$schedule.length)) return false;
|
|
278
334
|
var scheduleItems = [];
|
|
279
335
|
quotation.schedule.forEach(function (s) {
|
|
280
|
-
var
|
|
281
|
-
var full = (
|
|
336
|
+
var _this4$scheduleResolv;
|
|
337
|
+
var full = (_this4$scheduleResolv = _this4.scheduleResolver) === null || _this4$scheduleResolv === void 0 ? void 0 : _this4$scheduleResolv.call(_this4, s.id);
|
|
282
338
|
if (full) {
|
|
283
339
|
scheduleItems.push(full);
|
|
284
340
|
return;
|
|
285
341
|
}
|
|
286
|
-
if (
|
|
342
|
+
if (_this4.scheduleResolver) {
|
|
287
343
|
return;
|
|
288
344
|
}
|
|
289
345
|
var fallbackSchedule = _objectSpread(_objectSpread({}, s), {}, {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -263,6 +263,11 @@ declare class Server {
|
|
|
263
263
|
* 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
|
|
264
264
|
*/
|
|
265
265
|
private recomputeAndNotifySubscriber;
|
|
266
|
+
/**
|
|
267
|
+
* 根据餐牌 ID 获取其绑定日程中的全部时间点。
|
|
268
|
+
* 商品查询定时器与 schedule-time-points 路由共用此逻辑。
|
|
269
|
+
*/
|
|
270
|
+
private getMenuScheduleTimePoints;
|
|
266
271
|
/**
|
|
267
272
|
* query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
|
|
268
273
|
*/
|
|
@@ -518,6 +523,10 @@ declare class Server {
|
|
|
518
523
|
private handleOrderDraftSubmit;
|
|
519
524
|
private handlePendingSyncCheckoutOrder;
|
|
520
525
|
private buildPendingSyncCheckoutOrder;
|
|
526
|
+
/**
|
|
527
|
+
* Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
|
|
528
|
+
*/
|
|
529
|
+
private shouldAutoPrintCheckoutReceipt;
|
|
521
530
|
private shouldBuildSmallTicketData;
|
|
522
531
|
private shouldPrintSyncedOrder;
|
|
523
532
|
private hasPaymentStatus;
|