@pisell/private-materials 3.4.156 → 3.4.158
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +14 -14
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +14 -14
- package/es/index.d.ts +7 -1
- package/es/index.js +5 -1
- package/es/plus/inventory/BindingModal.js +94 -0
- package/es/plus/inventory/InventoryItemManagement.d.ts +7 -0
- package/es/plus/inventory/InventoryItemManagement.js +204 -0
- package/es/plus/inventory/InventoryLocationManagement.d.ts +7 -0
- package/es/plus/inventory/InventoryLocationManagement.js +296 -0
- package/es/plus/inventory/InventoryUnitManagement.d.ts +7 -0
- package/es/plus/inventory/InventoryUnitManagement.js +144 -0
- package/es/plus/inventory/ItemDrawer.js +266 -0
- package/es/plus/inventory/RecordDialog.js +141 -0
- package/es/plus/inventory/StockList.js +132 -0
- package/es/plus/inventory/api.js +66 -0
- package/es/plus/inventory/components.js +172 -0
- package/es/plus/inventory/context.js +118 -0
- package/es/plus/inventory/forms.js +46 -0
- package/es/plus/inventory/hooks.js +235 -0
- package/es/plus/inventory/index.less +559 -0
- package/es/plus/inventory/locales.js +277 -0
- package/es/plus/inventory/types.d.ts +10 -0
- package/es/plus/inventory/utils.js +24 -0
- package/es/plus/pisellSupersetDashboard/README.md +291 -0
- package/es/plus/pisellSupersetDashboard/index.d.ts +15 -0
- package/es/plus/pisellSupersetDashboard/index.js +187 -0
- package/es/plus/pisellSupersetDashboard/index.less +83 -0
- package/es/plus/pisellSupersetDashboard/locales.js +36 -0
- package/es/plus/pisellSupersetDashboard/serve.js +51 -0
- package/es/plus/pisellSupersetDashboard/types.d.ts +17 -0
- package/es/plus/skuOptionsSelection/store/createStore.js +2 -2
- package/lib/index.d.ts +7 -1
- package/lib/index.js +134 -126
- package/lib/plus/inventory/BindingModal.js +96 -0
- package/lib/plus/inventory/InventoryItemManagement.d.ts +7 -0
- package/lib/plus/inventory/InventoryItemManagement.js +206 -0
- package/lib/plus/inventory/InventoryLocationManagement.d.ts +7 -0
- package/lib/plus/inventory/InventoryLocationManagement.js +298 -0
- package/lib/plus/inventory/InventoryUnitManagement.d.ts +7 -0
- package/lib/plus/inventory/InventoryUnitManagement.js +146 -0
- package/lib/plus/inventory/ItemDrawer.js +268 -0
- package/lib/plus/inventory/RecordDialog.js +143 -0
- package/lib/plus/inventory/StockList.js +134 -0
- package/lib/plus/inventory/api.js +66 -0
- package/lib/plus/inventory/components.js +181 -0
- package/lib/plus/inventory/context.js +121 -0
- package/lib/plus/inventory/forms.js +50 -0
- package/lib/plus/inventory/hooks.js +240 -0
- package/lib/plus/inventory/index.less +559 -0
- package/lib/plus/inventory/locales.js +277 -0
- package/lib/plus/inventory/types.d.ts +10 -0
- package/lib/plus/inventory/utils.js +30 -0
- package/lib/plus/pisellSupersetDashboard/README.md +291 -0
- package/lib/plus/pisellSupersetDashboard/index.d.ts +15 -0
- package/lib/plus/pisellSupersetDashboard/index.js +189 -0
- package/lib/plus/pisellSupersetDashboard/index.less +83 -0
- package/lib/plus/pisellSupersetDashboard/locales.js +36 -0
- package/lib/plus/pisellSupersetDashboard/serve.js +52 -0
- package/lib/plus/pisellSupersetDashboard/types.d.ts +17 -0
- package/lowcode/inventory-item-management/meta.ts +20 -0
- package/lowcode/inventory-location-management/meta.ts +20 -0
- package/lowcode/inventory-unit-management/meta.ts +20 -0
- package/lowcode/pisell-superset-dashboard/meta.ts +75 -0
- package/package.json +5 -3
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
+
import useEngineContext from "../../hooks/useEngineContext.js";
|
|
3
|
+
import { SupersetReportError, getSupersetSession } from "./serve.js";
|
|
4
|
+
import locales_default from "./locales.js";
|
|
5
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
6
|
+
import { Spin } from "antd";
|
|
7
|
+
import { locales } from "@pisell/utils";
|
|
8
|
+
import { cloneDeep, isEqual } from "lodash";
|
|
9
|
+
import { LoadingOutlined } from "@ant-design/icons";
|
|
10
|
+
import { embedDashboard } from "@superset-ui/embedded-sdk";
|
|
11
|
+
import "./index.less";
|
|
12
|
+
//#region src/plus/pisellSupersetDashboard/index.tsx
|
|
13
|
+
/** 首次获取会话到 SDK 初始化完成的最长等待时间,单位为毫秒。 */
|
|
14
|
+
const INITIALIZATION_TIMEOUT = 6e4;
|
|
15
|
+
/**
|
|
16
|
+
* Superset 报表组件,负责请求会话、挂载报表、续期、状态展示和资源清理。
|
|
17
|
+
* 切店或退出登录时,宿主必须先卸载旧组件,再更新登录态并重新挂载。
|
|
18
|
+
* @param props 页面报表配置、附加样式类名和根容器样式,详见组件属性类型。
|
|
19
|
+
*/
|
|
20
|
+
function PisellSupersetDashboard({ proCodeProps, className, style }) {
|
|
21
|
+
var _context$appHelper, _context$engine;
|
|
22
|
+
/** 当前宿主引擎上下文,提供请求服务和显示语言。 */
|
|
23
|
+
const context = useEngineContext();
|
|
24
|
+
/** 当前组件使用的宿主客户端;不写入组件包的共享 request 单例。 */
|
|
25
|
+
const client = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.request;
|
|
26
|
+
locales.init(locales_default, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en");
|
|
27
|
+
/** 当前报表的嵌入 UUID,用于向业务后端申请会话。 */
|
|
28
|
+
const dashboardId = proCodeProps === null || proCodeProps === void 0 ? void 0 : proCodeProps.dashboardId;
|
|
29
|
+
/** 原始 UI 配置对象,完整透传给 SDK,保留调用方的扩展字段。 */
|
|
30
|
+
const dashboardUiConfig = proCodeProps === null || proCodeProps === void 0 ? void 0 : proCodeProps.dashboardUiConfig;
|
|
31
|
+
/** UI 配置的深拷贝快照,用于识别嵌套字段变化及原对象上的修改。 */
|
|
32
|
+
const configSnapshot = useRef(cloneDeep(dashboardUiConfig));
|
|
33
|
+
if (!isEqual(configSnapshot.current, dashboardUiConfig)) configSnapshot.current = cloneDeep(dashboardUiConfig);
|
|
34
|
+
/** 内容不变时保持引用稳定,作为报表初始化副作用的依赖。 */
|
|
35
|
+
const stableConfig = configSnapshot.current;
|
|
36
|
+
/** React 管理的宿主容器;每轮初始化在其中创建独立的 SDK 挂载节点。 */
|
|
37
|
+
const host = useRef(null);
|
|
38
|
+
/** 手动重试序号;递增后触发上一轮清理和新一轮初始化。 */
|
|
39
|
+
const [attempt, setAttempt] = useState(0);
|
|
40
|
+
/** 是否正在获取会话或等待 SDK 初始化,不代表图表数据的加载进度。 */
|
|
41
|
+
const [loading, setLoading] = useState(true);
|
|
42
|
+
/** 当前可展示错误;有明确错误消息时优先展示,否则使用国际化文案。 */
|
|
43
|
+
const [error, setError] = useState(null);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setError(null);
|
|
46
|
+
setLoading(true);
|
|
47
|
+
if (typeof dashboardId !== "string" || !dashboardId.trim()) {
|
|
48
|
+
setError({ key: "pisell-superset.missingDashboard" });
|
|
49
|
+
setLoading(false);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!client || typeof client.post !== "function") {
|
|
53
|
+
setError({ key: "pisell-superset.missingRequest" });
|
|
54
|
+
setLoading(false);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
/** 本轮初始化和续期共用的取消控制器,与其他组件实例相互独立。 */
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
/** 本轮专属挂载节点,防止旧异步任务清空新报表的 iframe。 */
|
|
60
|
+
const mountPoint = document.createElement("div");
|
|
61
|
+
mountPoint.className = "pisell-superset-dashboard-mount";
|
|
62
|
+
host.current.appendChild(mountPoint);
|
|
63
|
+
/** 本轮会话是否失效;失效后禁止继续请求或更新组件状态。 */
|
|
64
|
+
let stopped = false;
|
|
65
|
+
/** 已完成初始化的 SDK 实例,用于卸载 iframe 并停止 SDK 续期计时。 */
|
|
66
|
+
let instance;
|
|
67
|
+
/** 首次接口返回的令牌,仅供 SDK 第一次取令牌时消费。 */
|
|
68
|
+
let firstToken;
|
|
69
|
+
/** 初始化超时计时器;初始化完成或会话结束时清除。 */
|
|
70
|
+
let timer;
|
|
71
|
+
/** 使当前会话失效,取消请求并清理令牌、SDK 实例和专属挂载节点。 */
|
|
72
|
+
const dispose = () => {
|
|
73
|
+
stopped = true;
|
|
74
|
+
clearTimeout(timer);
|
|
75
|
+
controller.abort();
|
|
76
|
+
firstToken = void 0;
|
|
77
|
+
instance === null || instance === void 0 || instance.unmount();
|
|
78
|
+
instance = void 0;
|
|
79
|
+
mountPoint.replaceChildren();
|
|
80
|
+
mountPoint.remove();
|
|
81
|
+
};
|
|
82
|
+
/** 校验会话仍然有效,阻止旧回调继续执行或返回迟到的令牌。 */
|
|
83
|
+
const assertActive = () => {
|
|
84
|
+
if (stopped) throw new Error("Superset session disposed");
|
|
85
|
+
};
|
|
86
|
+
/** 统一处理初始化和续期异常;已失效会话的异常不再影响界面。 */
|
|
87
|
+
const fail = (cause) => {
|
|
88
|
+
if (stopped) return;
|
|
89
|
+
dispose();
|
|
90
|
+
/** 从未知异常中提取消息,兼容 Error 及宿主抛出的业务响应对象。 */
|
|
91
|
+
const message = cause === null || cause === void 0 ? void 0 : cause.message;
|
|
92
|
+
setError({
|
|
93
|
+
key: cause instanceof SupersetReportError ? cause.textKey : "pisell-superset.loadFailed",
|
|
94
|
+
message: typeof message === "string" ? message : void 0
|
|
95
|
+
});
|
|
96
|
+
setLoading(false);
|
|
97
|
+
};
|
|
98
|
+
/** 请求新的报表会话,并在请求前后校验生命周期,拒绝过期响应。 */
|
|
99
|
+
const getSession = function() {
|
|
100
|
+
var _ref = _asyncToGenerator(function* () {
|
|
101
|
+
assertActive();
|
|
102
|
+
/** 经业务成功状态及必填字段校验后的报表会话。 */
|
|
103
|
+
const session = yield getSupersetSession(client, dashboardId, controller.signal);
|
|
104
|
+
assertActive();
|
|
105
|
+
return session;
|
|
106
|
+
});
|
|
107
|
+
return function getSession() {
|
|
108
|
+
return _ref.apply(this, arguments);
|
|
109
|
+
};
|
|
110
|
+
}();
|
|
111
|
+
timer = setTimeout(() => {
|
|
112
|
+
fail(new SupersetReportError("pisell-superset.timeout"));
|
|
113
|
+
}, INITIALIZATION_TIMEOUT);
|
|
114
|
+
_asyncToGenerator(function* () {
|
|
115
|
+
/** 首次会话,包含实际嵌入域名、报表 ID 和当前店铺的访客令牌。 */
|
|
116
|
+
const session = yield getSession();
|
|
117
|
+
firstToken = session.guest_token;
|
|
118
|
+
/** SDK 异步创建的实例,确认会话仍有效后才保存到当前作用域。 */
|
|
119
|
+
const embedded = yield embedDashboard({
|
|
120
|
+
id: session.dashboard_id,
|
|
121
|
+
supersetDomain: session.superset_domain,
|
|
122
|
+
mountPoint,
|
|
123
|
+
dashboardUiConfig,
|
|
124
|
+
referrerPolicy: "strict-origin-when-cross-origin",
|
|
125
|
+
fetchGuestToken: function() {
|
|
126
|
+
var _ref2 = _asyncToGenerator(function* () {
|
|
127
|
+
assertActive();
|
|
128
|
+
if (firstToken !== void 0) {
|
|
129
|
+
/** 本次要返回的首次令牌;返回前清空缓存,确保只复用一次。 */
|
|
130
|
+
const token = firstToken;
|
|
131
|
+
firstToken = void 0;
|
|
132
|
+
return token;
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
return (yield getSession()).guest_token;
|
|
136
|
+
} catch (cause) {
|
|
137
|
+
fail(cause);
|
|
138
|
+
throw cause;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
return function fetchGuestToken() {
|
|
142
|
+
return _ref2.apply(this, arguments);
|
|
143
|
+
};
|
|
144
|
+
}()
|
|
145
|
+
});
|
|
146
|
+
if (stopped) {
|
|
147
|
+
embedded.unmount();
|
|
148
|
+
mountPoint.replaceChildren();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
instance = embedded;
|
|
152
|
+
clearTimeout(timer);
|
|
153
|
+
setLoading(false);
|
|
154
|
+
})().catch(fail);
|
|
155
|
+
return dispose;
|
|
156
|
+
}, [
|
|
157
|
+
dashboardId,
|
|
158
|
+
stableConfig,
|
|
159
|
+
client,
|
|
160
|
+
attempt
|
|
161
|
+
]);
|
|
162
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
163
|
+
className: ["pisell-superset-dashboard", className].filter(Boolean).join(" "),
|
|
164
|
+
style,
|
|
165
|
+
"aria-busy": loading
|
|
166
|
+
}, loading && /* @__PURE__ */ React.createElement("div", {
|
|
167
|
+
className: "pisell-superset-dashboard-status pisell-superset-dashboard-loading",
|
|
168
|
+
role: "status"
|
|
169
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
170
|
+
className: "pisell-superset-dashboard-loading-icon",
|
|
171
|
+
"aria-hidden": "true"
|
|
172
|
+
}, /* @__PURE__ */ React.createElement(Spin, { indicator: /* @__PURE__ */ React.createElement(LoadingOutlined, {
|
|
173
|
+
spin: true,
|
|
174
|
+
style: { fontSize: 36 }
|
|
175
|
+
}) })), /* @__PURE__ */ React.createElement("p", { className: "pisell-superset-dashboard-loading-text" }, locales.getText("pisell-superset.loading"))), error && /* @__PURE__ */ React.createElement("div", {
|
|
176
|
+
className: "pisell-superset-dashboard-status",
|
|
177
|
+
role: "alert"
|
|
178
|
+
}, /* @__PURE__ */ React.createElement("p", null, error.message || locales.getText(error.key)), /* @__PURE__ */ React.createElement("button", {
|
|
179
|
+
type: "button",
|
|
180
|
+
onClick: () => setAttempt((value) => value + 1)
|
|
181
|
+
}, locales.getText("pisell-superset.retry"))), /* @__PURE__ */ React.createElement("div", {
|
|
182
|
+
ref: host,
|
|
183
|
+
className: "pisell-superset-dashboard-host"
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
export { PisellSupersetDashboard as default };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// 报表根容器提供默认占位高度,宿主可以通过 style 覆盖尺寸。
|
|
2
|
+
.pisell-superset-dashboard {
|
|
3
|
+
position: relative;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 75vh;
|
|
6
|
+
min-height: 520px;
|
|
7
|
+
|
|
8
|
+
// React 容器、当前会话挂载节点和 SDK iframe 逐层填满可用空间。
|
|
9
|
+
&-host,
|
|
10
|
+
&-mount,
|
|
11
|
+
iframe {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 去掉 iframe 默认边框与行内元素基线留白。
|
|
17
|
+
iframe {
|
|
18
|
+
display: block;
|
|
19
|
+
border: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 加载图标的浅灰圆角底框;图标自身沿用 Ant Design 主题色。
|
|
23
|
+
&-loading-icon {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
width: 56px;
|
|
28
|
+
height: 56px;
|
|
29
|
+
border: 1px solid #eaecf0;
|
|
30
|
+
border-radius: 16px;
|
|
31
|
+
background: #f9fafb;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 加载文案使用次级文字颜色,与组件其他状态提示保持一致。
|
|
35
|
+
&-loading-text {
|
|
36
|
+
color: #667085;
|
|
37
|
+
font-size: 18px;
|
|
38
|
+
font-weight: 500;
|
|
39
|
+
line-height: 22px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 加载与失败状态共用遮罩,覆盖未完成初始化或已清理的报表区域。
|
|
43
|
+
&-status {
|
|
44
|
+
position: absolute;
|
|
45
|
+
inset: 0;
|
|
46
|
+
z-index: 1;
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
gap: 12px;
|
|
52
|
+
padding: 24px;
|
|
53
|
+
text-align: center;
|
|
54
|
+
background: #fff;
|
|
55
|
+
color: #475467;
|
|
56
|
+
|
|
57
|
+
p {
|
|
58
|
+
margin: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 错误状态的手动重试按钮。
|
|
62
|
+
button {
|
|
63
|
+
padding: 8px 16px;
|
|
64
|
+
border: 1px solid #d0d5dd;
|
|
65
|
+
border-radius: 6px;
|
|
66
|
+
background: #fff;
|
|
67
|
+
color: inherit;
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 加载状态的图标与文案采用稍大的垂直间距。
|
|
73
|
+
&-loading {
|
|
74
|
+
gap: 16px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 尊重系统减少动画偏好,保留图标和文字,只关闭旋转动画。
|
|
78
|
+
@media (prefers-reduced-motion: reduce) {
|
|
79
|
+
&-loading-icon .anticon-spin {
|
|
80
|
+
animation: none;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/plus/pisellSupersetDashboard/locales.ts
|
|
2
|
+
/** 报表加载、配置缺失、接口失败和重试相关的国际化文案。 */
|
|
3
|
+
var locales_default = {
|
|
4
|
+
en: {
|
|
5
|
+
"pisell-superset.loading": "Loading report…",
|
|
6
|
+
"pisell-superset.retry": "Reload report",
|
|
7
|
+
"pisell-superset.missingDashboard": "Configure a dashboard embedding ID first.",
|
|
8
|
+
"pisell-superset.missingRequest": "The host has not provided a report request client.",
|
|
9
|
+
"pisell-superset.requestFailed": "Unable to retrieve the report configuration.",
|
|
10
|
+
"pisell-superset.invalidResponse": "The report configuration is incomplete.",
|
|
11
|
+
"pisell-superset.loadFailed": "Report loading or renewal failed. Please reload.",
|
|
12
|
+
"pisell-superset.timeout": "Report initialization timed out. Please reload."
|
|
13
|
+
},
|
|
14
|
+
"zh-CN": {
|
|
15
|
+
"pisell-superset.loading": "正在加载报表…",
|
|
16
|
+
"pisell-superset.retry": "重新加载报表",
|
|
17
|
+
"pisell-superset.missingDashboard": "请先配置报表嵌入 ID。",
|
|
18
|
+
"pisell-superset.missingRequest": "宿主未提供报表请求客户端。",
|
|
19
|
+
"pisell-superset.requestFailed": "获取报表配置失败。",
|
|
20
|
+
"pisell-superset.invalidResponse": "报表配置返回不完整。",
|
|
21
|
+
"pisell-superset.loadFailed": "报表加载或续期失败,请重新加载。",
|
|
22
|
+
"pisell-superset.timeout": "报表初始化超时,请重新加载。"
|
|
23
|
+
},
|
|
24
|
+
"zh-HK": {
|
|
25
|
+
"pisell-superset.loading": "正在載入報表…",
|
|
26
|
+
"pisell-superset.retry": "重新載入報表",
|
|
27
|
+
"pisell-superset.missingDashboard": "請先設定報表嵌入 ID。",
|
|
28
|
+
"pisell-superset.missingRequest": "宿主未提供報表請求客戶端。",
|
|
29
|
+
"pisell-superset.requestFailed": "取得報表設定失敗。",
|
|
30
|
+
"pisell-superset.invalidResponse": "報表設定回傳不完整。",
|
|
31
|
+
"pisell-superset.loadFailed": "報表載入或續期失敗,請重新載入。",
|
|
32
|
+
"pisell-superset.timeout": "報表初始化逾時,請重新載入。"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { locales_default as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
+
//#region src/plus/pisellSupersetDashboard/serve.ts
|
|
3
|
+
/** 带有国际化兜底文案键的报表异常,可附带后端返回的可读消息。 */
|
|
4
|
+
var SupersetReportError = class extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* @param textKey 错误消息缺省时使用的国际化文案键,同时保存为只读属性。
|
|
7
|
+
* @param message 优先展示的错误消息;省略时由组件根据 textKey 取文案。
|
|
8
|
+
*/
|
|
9
|
+
constructor(textKey, message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.textKey = textKey;
|
|
12
|
+
this.name = "SupersetReportError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 获取指定报表的店铺嵌入会话;每次调用都由后端重新申请 Guest Token。
|
|
17
|
+
* @param client 从当前组件宿主上下文取得的请求客户端。
|
|
18
|
+
* @param dashboardId Superset 报表嵌入 UUID。
|
|
19
|
+
* @param signal 当前会话的取消信号。
|
|
20
|
+
* @returns 已校验必填字段的报表会话。
|
|
21
|
+
* @throws 业务失败或响应不完整时抛出报表异常;宿主请求异常保持原样抛出。
|
|
22
|
+
*/
|
|
23
|
+
function getSupersetSession(_x, _x2, _x3) {
|
|
24
|
+
return _getSupersetSession.apply(this, arguments);
|
|
25
|
+
}
|
|
26
|
+
function _getSupersetSession() {
|
|
27
|
+
_getSupersetSession = _asyncToGenerator(function* (client, dashboardId, signal) {
|
|
28
|
+
/** 宿主已解包的业务响应;此处类型断言仅描述结构,后续仍需运行时校验。 */
|
|
29
|
+
const response = yield client.post("/shop/report/superset/embed", { dashboard_id: dashboardId }, {
|
|
30
|
+
isShopApi: true,
|
|
31
|
+
fullResult: true,
|
|
32
|
+
signal
|
|
33
|
+
});
|
|
34
|
+
if ((response === null || response === void 0 ? void 0 : response.status) !== true || response.code !== 200) throw new SupersetReportError("pisell-superset.requestFailed", typeof (response === null || response === void 0 ? void 0 : response.message) === "string" ? response.message : void 0);
|
|
35
|
+
/** 待校验的会话主体;不能假定业务成功就一定包含完整 SDK 参数。 */
|
|
36
|
+
const session = response.data;
|
|
37
|
+
if (!session || ![
|
|
38
|
+
"guest_token",
|
|
39
|
+
"superset_domain",
|
|
40
|
+
"dashboard_id"
|
|
41
|
+
].every((key) => {
|
|
42
|
+
/** 当前必填字段的原始值,只校验、不改写后端返回内容。 */
|
|
43
|
+
const value = session[key];
|
|
44
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
45
|
+
})) throw new SupersetReportError("pisell-superset.invalidResponse");
|
|
46
|
+
return session;
|
|
47
|
+
});
|
|
48
|
+
return _getSupersetSession.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { SupersetReportError, getSupersetSession };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/plus/pisellSupersetDashboard/types.d.ts
|
|
4
|
+
/** Superset 报表组件的公开属性,与宿主 proCode 页面传参结构保持一致。 */
|
|
5
|
+
interface PisellSupersetDashboardProps {
|
|
6
|
+
/** 页面配置;未提供时展示配置缺失提示,不发起业务请求。 */
|
|
7
|
+
proCodeProps?: {
|
|
8
|
+
/** Superset 嵌入配置生成的 UUID,不是普通数字报表 ID 或页面 URL。 */dashboardId: string; /** 原样传给 SDK 的 UI 配置,允许扩展字段;缺省时采用 SDK 默认行为。 */
|
|
9
|
+
dashboardUiConfig?: Record<string, any>;
|
|
10
|
+
};
|
|
11
|
+
/** 附加到组件根容器的样式类名。 */
|
|
12
|
+
className?: string;
|
|
13
|
+
/** 根容器样式,可覆盖默认宽高和最小高度。 */
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { PisellSupersetDashboardProps };
|
|
@@ -22,7 +22,7 @@ const useSyncExternalStoreShim = (subscribe, getSnapshot) => {
|
|
|
22
22
|
}, [subscribe, getSnapshot]);
|
|
23
23
|
return snapshot;
|
|
24
24
|
};
|
|
25
|
-
const useSyncExternalStore = React$1.useSyncExternalStore || useSyncExternalStoreShim;
|
|
25
|
+
const useSyncExternalStore$1 = React$1.useSyncExternalStore || useSyncExternalStoreShim;
|
|
26
26
|
/**
|
|
27
27
|
* 创建一个跨 React 版本兼容的 Store
|
|
28
28
|
* 支持自动浅合并 (Auto Shallow Merge)
|
|
@@ -58,7 +58,7 @@ function createStore(initialState) {
|
|
|
58
58
|
* @param selector 选择器函数,默认返回整个 state
|
|
59
59
|
*/
|
|
60
60
|
const useStore = (selector = (s) => s) => {
|
|
61
|
-
return useSyncExternalStore(subscribe, () => selector(state));
|
|
61
|
+
return useSyncExternalStore$1(subscribe, () => selector(state));
|
|
62
62
|
};
|
|
63
63
|
Object.assign(useStore, {
|
|
64
64
|
getState,
|
package/lib/index.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ import { _default as _default$9 } from "./components/pay/toC/index.js";
|
|
|
23
23
|
import { _default as _default$1 } from "./components/eftpos/index.js";
|
|
24
24
|
import { WalletList } from "./components/walletList/index.js";
|
|
25
25
|
import { BookingDashboard } from "./components/booking/dashboard/index.js";
|
|
26
|
+
import { PisellSupersetDashboardProps } from "./plus/pisellSupersetDashboard/types.js";
|
|
27
|
+
import { PisellSupersetDashboard } from "./plus/pisellSupersetDashboard/index.js";
|
|
26
28
|
import { PisellSelectCustomerModal } from "./components/pisellSelectCustomerModal/index.js";
|
|
27
29
|
import { EventBooking } from "./components/eventBooking/index.js";
|
|
28
30
|
import { EventCard } from "./components/eventBooking/components/eventCard/index.js";
|
|
@@ -84,6 +86,10 @@ import { Registry } from "./components/systemSettings/registry/index.js";
|
|
|
84
86
|
import { SaasRole } from "./plus/saasRole/index.js";
|
|
85
87
|
import { SaasTeamMembersProps } from "./plus/saasTeamMembers/type.js";
|
|
86
88
|
import { SaasTeamMembers } from "./plus/saasTeamMembers/index.js";
|
|
89
|
+
import { InventoryPageProps } from "./plus/inventory/types.js";
|
|
90
|
+
import { InventoryItemManagement } from "./plus/inventory/InventoryItemManagement.js";
|
|
91
|
+
import { InventoryUnitManagement } from "./plus/inventory/InventoryUnitManagement.js";
|
|
92
|
+
import { InventoryLocationManagement } from "./plus/inventory/InventoryLocationManagement.js";
|
|
87
93
|
import { SaasDeviceProfileProps } from "./plus/saasDevice/deviceProfile/types.js";
|
|
88
94
|
import { SaasDeviceProfile } from "./plus/saasDevice/deviceProfile/index.js";
|
|
89
95
|
import { SaasDevicePlanningProps } from "./plus/saasDevice/devicePlanning/model/types.js";
|
|
@@ -122,4 +128,4 @@ import { PisellProResourcePickerModal } from "./plus/pisellProResourcePickerModa
|
|
|
122
128
|
import { PisellFloorMapPaletteViewAllModal } from "./plus/pisellProResourcePickerModal/PisellFloorMapPaletteViewAllModal.js";
|
|
123
129
|
import { PisellCashCounting } from "./components/pisellCashCounting/PisellCashCounting.js";
|
|
124
130
|
import { _default as _default$5 } from "./plus/pisellAdyenDashboard/index.js";
|
|
125
|
-
export { AppointmentBooking, Deposit as AppointmentDeposit, AuthModal, Booking, Addons as BookingAddons, Contacts as BookingContacts, BookingDashboard, Deposit$1 as BookingDeposit, Duration as BookingDuration, Forms as BookingForms, APP as BookingInfo, Notes as BookingNotes, Payments as BookingPayment, Resources as BookingResources, StartTime as BookingStartTime, ChannelAuthSetting, ClientCard, ClientSearch, ComprehensiveSearch, ContactInfo, ContactInfoModal, CustomerAuth, CustomerOAuthConfig, type CustomerOAuthConfigProps, DeviceAuth, type DeviceAuthProps, CupList as EcoCupList, EcoCupProject, CustomerList as EcoCustomerList, _default as EditBookingModal, _default$1 as Eftpos, _default$2 as EftposPay, EventBooking, BookingAvailabilityCalendar as EventBookingAvailabilityCalendar, BookingDetailModal as EventBookingDetailModal, BookingServiceList as EventBookingServiceList, EventCard, PisellProductCard as EventProductCard, ProgressBar as EventProgressBar, PisellResourceCard as EventResourceDisplay, EventResourceUsability, EventScheduleCalendar, PisellSelectHolder as EventSelectHolder, TimeResourceSelector as EventTimeResourceSelector, type FloorMapBookingClickArgs, type FloorMapBookingClickMode, HolderList, KioskSkuDetail, Login, Login2, type LoginProps, OAuthConfig, Onlineshopauth as OnlineShopAuth, OrderList, OrgAdminAuth, type OrgAdminAuthProps, PISELL_RESERVATION_TABLE_PAGE_STORAGE_KEY, PISELL_RESERVATION_VENUE_WALL_PAGE_STORAGE_KEY, POSOperatorAuth, type POSOperatorAuthProps, PanpacificTask, type PanpacificTaskProps, PiPaymentResult, _default$3 as PinModal, _default$4 as PinVerifyModal, _default$5 as PisellAdyenDashboard, PisellCashCounting, PisellFloorMapPaletteViewAllModal, PisellProResourcePickerModal, type PisellProResourcePickerModalProps, type PisellProResourcePickerMode, PisellReservation, PisellReservationBookingPage, PisellReservationCore, type PisellReservationProps, PisellReservationTablePage, type PisellReservationTableRow, PisellSalesGrid, PisellSelectCustomerModal, PisellTopology, PisellTopologyCore, type PisellTopologyProps, PisellVenueControlPage, PisellVenueWallPage, PisellNumberSelector as ProNumberSelector, ProductExtension, _default$6 as ProductStockCheckModal, Register2, type ResourceSelectModeConfig, RuleSetting, SKUOptionsSelection, SaaSAdminAuth, type SaaSAdminAuthProps, SaaSManagermentAuth, SaasAttendance, SaasCreateOrganization, SaasDevicePasscodes, type SaasDevicePasscodesProps, SaasDevicePlanning, type SaasDevicePlanningProps, SaasDeviceProfile, type SaasDeviceProfileProps, SaasLogin, _default$7 as SaasRegister, SaasRole, SaasTeamMembers, type SaasTeamMembersProps, SaleDetail, ScanOrder, type ScanOrderProps, Schedules, SelectFloorMapResourceDialog, type SelectFloorMapResourcePayload, PisellSelectHolder$1 as SelectHolder, Selector, Registry as SettingsRegistry, shoppingCart as ShoppingCart, StepController, SubTotal, TaxSelect, _default$8 as TicketBooking, _default$9 as ToCPay, type TopologyDeviceRow, VenueBooking, AddServiceVariant as VerticalAddService, VerticalClient, WalletEditor, WalletList, PassDetail as WalletPassDetail, WalletPassGallery, WorkspacesList as WorkspaceList, WorkSpaceListDetail as WorkspaceListDetail, PisellReservationBookingPage as default, defaultReservationTableRows, getDefaultReservationFloorMapConfig, PisellSalesManagement as pisellSalesManagement };
|
|
131
|
+
export { AppointmentBooking, Deposit as AppointmentDeposit, AuthModal, Booking, Addons as BookingAddons, Contacts as BookingContacts, BookingDashboard, Deposit$1 as BookingDeposit, Duration as BookingDuration, Forms as BookingForms, APP as BookingInfo, Notes as BookingNotes, Payments as BookingPayment, Resources as BookingResources, StartTime as BookingStartTime, ChannelAuthSetting, ClientCard, ClientSearch, ComprehensiveSearch, ContactInfo, ContactInfoModal, CustomerAuth, CustomerOAuthConfig, type CustomerOAuthConfigProps, DeviceAuth, type DeviceAuthProps, CupList as EcoCupList, EcoCupProject, CustomerList as EcoCustomerList, _default as EditBookingModal, _default$1 as Eftpos, _default$2 as EftposPay, EventBooking, BookingAvailabilityCalendar as EventBookingAvailabilityCalendar, BookingDetailModal as EventBookingDetailModal, BookingServiceList as EventBookingServiceList, EventCard, PisellProductCard as EventProductCard, ProgressBar as EventProgressBar, PisellResourceCard as EventResourceDisplay, EventResourceUsability, EventScheduleCalendar, PisellSelectHolder as EventSelectHolder, TimeResourceSelector as EventTimeResourceSelector, type FloorMapBookingClickArgs, type FloorMapBookingClickMode, HolderList, InventoryItemManagement, type InventoryPageProps as InventoryItemManagementProps, InventoryLocationManagement, type InventoryPageProps as InventoryLocationManagementProps, type InventoryPageProps, InventoryUnitManagement, type InventoryPageProps as InventoryUnitManagementProps, KioskSkuDetail, Login, Login2, type LoginProps, OAuthConfig, Onlineshopauth as OnlineShopAuth, OrderList, OrgAdminAuth, type OrgAdminAuthProps, PISELL_RESERVATION_TABLE_PAGE_STORAGE_KEY, PISELL_RESERVATION_VENUE_WALL_PAGE_STORAGE_KEY, POSOperatorAuth, type POSOperatorAuthProps, PanpacificTask, type PanpacificTaskProps, PiPaymentResult, _default$3 as PinModal, _default$4 as PinVerifyModal, _default$5 as PisellAdyenDashboard, PisellCashCounting, PisellFloorMapPaletteViewAllModal, PisellProResourcePickerModal, type PisellProResourcePickerModalProps, type PisellProResourcePickerMode, PisellReservation, PisellReservationBookingPage, PisellReservationCore, type PisellReservationProps, PisellReservationTablePage, type PisellReservationTableRow, PisellSalesGrid, PisellSelectCustomerModal, PisellSupersetDashboard, type PisellSupersetDashboardProps, PisellTopology, PisellTopologyCore, type PisellTopologyProps, PisellVenueControlPage, PisellVenueWallPage, PisellNumberSelector as ProNumberSelector, ProductExtension, _default$6 as ProductStockCheckModal, Register2, type ResourceSelectModeConfig, RuleSetting, SKUOptionsSelection, SaaSAdminAuth, type SaaSAdminAuthProps, SaaSManagermentAuth, SaasAttendance, SaasCreateOrganization, SaasDevicePasscodes, type SaasDevicePasscodesProps, SaasDevicePlanning, type SaasDevicePlanningProps, SaasDeviceProfile, type SaasDeviceProfileProps, SaasLogin, _default$7 as SaasRegister, SaasRole, SaasTeamMembers, type SaasTeamMembersProps, SaleDetail, ScanOrder, type ScanOrderProps, Schedules, SelectFloorMapResourceDialog, type SelectFloorMapResourcePayload, PisellSelectHolder$1 as SelectHolder, Selector, Registry as SettingsRegistry, shoppingCart as ShoppingCart, StepController, SubTotal, TaxSelect, _default$8 as TicketBooking, _default$9 as ToCPay, type TopologyDeviceRow, VenueBooking, AddServiceVariant as VerticalAddService, VerticalClient, WalletEditor, WalletList, PassDetail as WalletPassDetail, WalletPassGallery, WorkspacesList as WorkspaceList, WorkSpaceListDetail as WorkspaceListDetail, PisellReservationBookingPage as default, defaultReservationTableRows, getDefaultReservationFloorMapConfig, PisellSalesManagement as pisellSalesManagement };
|