@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,189 @@
|
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
3
|
+
const require_useEngineContext = require("../../hooks/useEngineContext.js");
|
|
4
|
+
const require_serve = require("./serve.js");
|
|
5
|
+
const require_locales = require("./locales.js");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
react = require_runtime.__toESM(react);
|
|
8
|
+
let antd = require("antd");
|
|
9
|
+
let _pisell_utils = require("@pisell/utils");
|
|
10
|
+
let lodash = require("lodash");
|
|
11
|
+
let _ant_design_icons = require("@ant-design/icons");
|
|
12
|
+
let _superset_ui_embedded_sdk = require("@superset-ui/embedded-sdk");
|
|
13
|
+
require("./index.less");
|
|
14
|
+
//#region src/plus/pisellSupersetDashboard/index.tsx
|
|
15
|
+
/** 首次获取会话到 SDK 初始化完成的最长等待时间,单位为毫秒。 */
|
|
16
|
+
const INITIALIZATION_TIMEOUT = 6e4;
|
|
17
|
+
/**
|
|
18
|
+
* Superset 报表组件,负责请求会话、挂载报表、续期、状态展示和资源清理。
|
|
19
|
+
* 切店或退出登录时,宿主必须先卸载旧组件,再更新登录态并重新挂载。
|
|
20
|
+
* @param props 页面报表配置、附加样式类名和根容器样式,详见组件属性类型。
|
|
21
|
+
*/
|
|
22
|
+
function PisellSupersetDashboard({ proCodeProps, className, style }) {
|
|
23
|
+
var _context$appHelper, _context$engine;
|
|
24
|
+
/** 当前宿主引擎上下文,提供请求服务和显示语言。 */
|
|
25
|
+
const context = require_useEngineContext.default();
|
|
26
|
+
/** 当前组件使用的宿主客户端;不写入组件包的共享 request 单例。 */
|
|
27
|
+
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;
|
|
28
|
+
_pisell_utils.locales.init(require_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");
|
|
29
|
+
/** 当前报表的嵌入 UUID,用于向业务后端申请会话。 */
|
|
30
|
+
const dashboardId = proCodeProps === null || proCodeProps === void 0 ? void 0 : proCodeProps.dashboardId;
|
|
31
|
+
/** 原始 UI 配置对象,完整透传给 SDK,保留调用方的扩展字段。 */
|
|
32
|
+
const dashboardUiConfig = proCodeProps === null || proCodeProps === void 0 ? void 0 : proCodeProps.dashboardUiConfig;
|
|
33
|
+
/** UI 配置的深拷贝快照,用于识别嵌套字段变化及原对象上的修改。 */
|
|
34
|
+
const configSnapshot = (0, react.useRef)((0, lodash.cloneDeep)(dashboardUiConfig));
|
|
35
|
+
if (!(0, lodash.isEqual)(configSnapshot.current, dashboardUiConfig)) configSnapshot.current = (0, lodash.cloneDeep)(dashboardUiConfig);
|
|
36
|
+
/** 内容不变时保持引用稳定,作为报表初始化副作用的依赖。 */
|
|
37
|
+
const stableConfig = configSnapshot.current;
|
|
38
|
+
/** React 管理的宿主容器;每轮初始化在其中创建独立的 SDK 挂载节点。 */
|
|
39
|
+
const host = (0, react.useRef)(null);
|
|
40
|
+
/** 手动重试序号;递增后触发上一轮清理和新一轮初始化。 */
|
|
41
|
+
const [attempt, setAttempt] = (0, react.useState)(0);
|
|
42
|
+
/** 是否正在获取会话或等待 SDK 初始化,不代表图表数据的加载进度。 */
|
|
43
|
+
const [loading, setLoading] = (0, react.useState)(true);
|
|
44
|
+
/** 当前可展示错误;有明确错误消息时优先展示,否则使用国际化文案。 */
|
|
45
|
+
const [error, setError] = (0, react.useState)(null);
|
|
46
|
+
(0, react.useEffect)(() => {
|
|
47
|
+
setError(null);
|
|
48
|
+
setLoading(true);
|
|
49
|
+
if (typeof dashboardId !== "string" || !dashboardId.trim()) {
|
|
50
|
+
setError({ key: "pisell-superset.missingDashboard" });
|
|
51
|
+
setLoading(false);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (!client || typeof client.post !== "function") {
|
|
55
|
+
setError({ key: "pisell-superset.missingRequest" });
|
|
56
|
+
setLoading(false);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
/** 本轮初始化和续期共用的取消控制器,与其他组件实例相互独立。 */
|
|
60
|
+
const controller = new AbortController();
|
|
61
|
+
/** 本轮专属挂载节点,防止旧异步任务清空新报表的 iframe。 */
|
|
62
|
+
const mountPoint = document.createElement("div");
|
|
63
|
+
mountPoint.className = "pisell-superset-dashboard-mount";
|
|
64
|
+
host.current.appendChild(mountPoint);
|
|
65
|
+
/** 本轮会话是否失效;失效后禁止继续请求或更新组件状态。 */
|
|
66
|
+
let stopped = false;
|
|
67
|
+
/** 已完成初始化的 SDK 实例,用于卸载 iframe 并停止 SDK 续期计时。 */
|
|
68
|
+
let instance;
|
|
69
|
+
/** 首次接口返回的令牌,仅供 SDK 第一次取令牌时消费。 */
|
|
70
|
+
let firstToken;
|
|
71
|
+
/** 初始化超时计时器;初始化完成或会话结束时清除。 */
|
|
72
|
+
let timer;
|
|
73
|
+
/** 使当前会话失效,取消请求并清理令牌、SDK 实例和专属挂载节点。 */
|
|
74
|
+
const dispose = () => {
|
|
75
|
+
stopped = true;
|
|
76
|
+
clearTimeout(timer);
|
|
77
|
+
controller.abort();
|
|
78
|
+
firstToken = void 0;
|
|
79
|
+
instance === null || instance === void 0 || instance.unmount();
|
|
80
|
+
instance = void 0;
|
|
81
|
+
mountPoint.replaceChildren();
|
|
82
|
+
mountPoint.remove();
|
|
83
|
+
};
|
|
84
|
+
/** 校验会话仍然有效,阻止旧回调继续执行或返回迟到的令牌。 */
|
|
85
|
+
const assertActive = () => {
|
|
86
|
+
if (stopped) throw new Error("Superset session disposed");
|
|
87
|
+
};
|
|
88
|
+
/** 统一处理初始化和续期异常;已失效会话的异常不再影响界面。 */
|
|
89
|
+
const fail = (cause) => {
|
|
90
|
+
if (stopped) return;
|
|
91
|
+
dispose();
|
|
92
|
+
/** 从未知异常中提取消息,兼容 Error 及宿主抛出的业务响应对象。 */
|
|
93
|
+
const message = cause === null || cause === void 0 ? void 0 : cause.message;
|
|
94
|
+
setError({
|
|
95
|
+
key: cause instanceof require_serve.SupersetReportError ? cause.textKey : "pisell-superset.loadFailed",
|
|
96
|
+
message: typeof message === "string" ? message : void 0
|
|
97
|
+
});
|
|
98
|
+
setLoading(false);
|
|
99
|
+
};
|
|
100
|
+
/** 请求新的报表会话,并在请求前后校验生命周期,拒绝过期响应。 */
|
|
101
|
+
const getSession = function() {
|
|
102
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
|
|
103
|
+
assertActive();
|
|
104
|
+
/** 经业务成功状态及必填字段校验后的报表会话。 */
|
|
105
|
+
const session = yield require_serve.getSupersetSession(client, dashboardId, controller.signal);
|
|
106
|
+
assertActive();
|
|
107
|
+
return session;
|
|
108
|
+
});
|
|
109
|
+
return function getSession() {
|
|
110
|
+
return _ref.apply(this, arguments);
|
|
111
|
+
};
|
|
112
|
+
}();
|
|
113
|
+
timer = setTimeout(() => {
|
|
114
|
+
fail(new require_serve.SupersetReportError("pisell-superset.timeout"));
|
|
115
|
+
}, INITIALIZATION_TIMEOUT);
|
|
116
|
+
require_asyncToGenerator._asyncToGenerator(function* () {
|
|
117
|
+
/** 首次会话,包含实际嵌入域名、报表 ID 和当前店铺的访客令牌。 */
|
|
118
|
+
const session = yield getSession();
|
|
119
|
+
firstToken = session.guest_token;
|
|
120
|
+
/** SDK 异步创建的实例,确认会话仍有效后才保存到当前作用域。 */
|
|
121
|
+
const embedded = yield (0, _superset_ui_embedded_sdk.embedDashboard)({
|
|
122
|
+
id: session.dashboard_id,
|
|
123
|
+
supersetDomain: session.superset_domain,
|
|
124
|
+
mountPoint,
|
|
125
|
+
dashboardUiConfig,
|
|
126
|
+
referrerPolicy: "strict-origin-when-cross-origin",
|
|
127
|
+
fetchGuestToken: function() {
|
|
128
|
+
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* () {
|
|
129
|
+
assertActive();
|
|
130
|
+
if (firstToken !== void 0) {
|
|
131
|
+
/** 本次要返回的首次令牌;返回前清空缓存,确保只复用一次。 */
|
|
132
|
+
const token = firstToken;
|
|
133
|
+
firstToken = void 0;
|
|
134
|
+
return token;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
return (yield getSession()).guest_token;
|
|
138
|
+
} catch (cause) {
|
|
139
|
+
fail(cause);
|
|
140
|
+
throw cause;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return function fetchGuestToken() {
|
|
144
|
+
return _ref2.apply(this, arguments);
|
|
145
|
+
};
|
|
146
|
+
}()
|
|
147
|
+
});
|
|
148
|
+
if (stopped) {
|
|
149
|
+
embedded.unmount();
|
|
150
|
+
mountPoint.replaceChildren();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
instance = embedded;
|
|
154
|
+
clearTimeout(timer);
|
|
155
|
+
setLoading(false);
|
|
156
|
+
})().catch(fail);
|
|
157
|
+
return dispose;
|
|
158
|
+
}, [
|
|
159
|
+
dashboardId,
|
|
160
|
+
stableConfig,
|
|
161
|
+
client,
|
|
162
|
+
attempt
|
|
163
|
+
]);
|
|
164
|
+
return /* @__PURE__ */ react.default.createElement("div", {
|
|
165
|
+
className: ["pisell-superset-dashboard", className].filter(Boolean).join(" "),
|
|
166
|
+
style,
|
|
167
|
+
"aria-busy": loading
|
|
168
|
+
}, loading && /* @__PURE__ */ react.default.createElement("div", {
|
|
169
|
+
className: "pisell-superset-dashboard-status pisell-superset-dashboard-loading",
|
|
170
|
+
role: "status"
|
|
171
|
+
}, /* @__PURE__ */ react.default.createElement("div", {
|
|
172
|
+
className: "pisell-superset-dashboard-loading-icon",
|
|
173
|
+
"aria-hidden": "true"
|
|
174
|
+
}, /* @__PURE__ */ react.default.createElement(antd.Spin, { indicator: /* @__PURE__ */ react.default.createElement(_ant_design_icons.LoadingOutlined, {
|
|
175
|
+
spin: true,
|
|
176
|
+
style: { fontSize: 36 }
|
|
177
|
+
}) })), /* @__PURE__ */ react.default.createElement("p", { className: "pisell-superset-dashboard-loading-text" }, _pisell_utils.locales.getText("pisell-superset.loading"))), error && /* @__PURE__ */ react.default.createElement("div", {
|
|
178
|
+
className: "pisell-superset-dashboard-status",
|
|
179
|
+
role: "alert"
|
|
180
|
+
}, /* @__PURE__ */ react.default.createElement("p", null, error.message || _pisell_utils.locales.getText(error.key)), /* @__PURE__ */ react.default.createElement("button", {
|
|
181
|
+
type: "button",
|
|
182
|
+
onClick: () => setAttempt((value) => value + 1)
|
|
183
|
+
}, _pisell_utils.locales.getText("pisell-superset.retry"))), /* @__PURE__ */ react.default.createElement("div", {
|
|
184
|
+
ref: host,
|
|
185
|
+
className: "pisell-superset-dashboard-host"
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
exports.default = PisellSupersetDashboard;
|
|
@@ -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
|
+
exports.default = locales_default;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const require_asyncToGenerator = require("../../_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 = require_asyncToGenerator._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
|
+
exports.SupersetReportError = SupersetReportError;
|
|
52
|
+
exports.getSupersetSession = 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 };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
componentName: 'InventoryItemManagement',
|
|
3
|
+
title: '货品管理',
|
|
4
|
+
category: 'SaaS',
|
|
5
|
+
devMode: 'proCode',
|
|
6
|
+
npm: {
|
|
7
|
+
package: '@pisell/private-materials',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
exportName: 'InventoryItemManagement',
|
|
10
|
+
main: 'src/index.tsx',
|
|
11
|
+
destructuring: true,
|
|
12
|
+
},
|
|
13
|
+
configure: { props: [], supports: {}, component: {} },
|
|
14
|
+
snippets: [
|
|
15
|
+
{
|
|
16
|
+
title: '货品管理',
|
|
17
|
+
schema: { componentName: 'InventoryItemManagement', props: {} },
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
componentName: 'InventoryLocationManagement',
|
|
3
|
+
title: '仓储位置管理',
|
|
4
|
+
category: 'SaaS',
|
|
5
|
+
devMode: 'proCode',
|
|
6
|
+
npm: {
|
|
7
|
+
package: '@pisell/private-materials',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
exportName: 'InventoryLocationManagement',
|
|
10
|
+
main: 'src/index.tsx',
|
|
11
|
+
destructuring: true,
|
|
12
|
+
},
|
|
13
|
+
configure: { props: [], supports: {}, component: {} },
|
|
14
|
+
snippets: [
|
|
15
|
+
{
|
|
16
|
+
title: '仓储位置管理',
|
|
17
|
+
schema: { componentName: 'InventoryLocationManagement', props: {} },
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
componentName: 'InventoryUnitManagement',
|
|
3
|
+
title: '货品单位管理',
|
|
4
|
+
category: 'SaaS',
|
|
5
|
+
devMode: 'proCode',
|
|
6
|
+
npm: {
|
|
7
|
+
package: '@pisell/private-materials',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
exportName: 'InventoryUnitManagement',
|
|
10
|
+
main: 'src/index.tsx',
|
|
11
|
+
destructuring: true,
|
|
12
|
+
},
|
|
13
|
+
configure: { props: [], supports: {}, component: {} },
|
|
14
|
+
snippets: [
|
|
15
|
+
{
|
|
16
|
+
title: '货品单位管理',
|
|
17
|
+
schema: { componentName: 'InventoryUnitManagement', props: {} },
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IPublicTypeComponentMetadata,
|
|
3
|
+
IPublicTypeSnippet,
|
|
4
|
+
} from '@alilc/lowcode-types';
|
|
5
|
+
|
|
6
|
+
/** 低代码物料元数据,描述组件标识、导出位置和编辑器属性面板。 */
|
|
7
|
+
const meta: IPublicTypeComponentMetadata = {
|
|
8
|
+
componentName: 'PisellSupersetDashboard',
|
|
9
|
+
title: 'Superset 报表',
|
|
10
|
+
category: 'SaaS',
|
|
11
|
+
devMode: 'proCode',
|
|
12
|
+
npm: {
|
|
13
|
+
package: '@pisell/private-materials',
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
exportName: 'PisellSupersetDashboard',
|
|
16
|
+
main: 'src/index.ts',
|
|
17
|
+
destructuring: true,
|
|
18
|
+
subName: '',
|
|
19
|
+
},
|
|
20
|
+
// 页面配置统一放在 proCodeProps 内,保持编辑器与实际组件 Props 结构一致。
|
|
21
|
+
configure: {
|
|
22
|
+
props: [
|
|
23
|
+
{
|
|
24
|
+
name: 'proCodeProps',
|
|
25
|
+
title: '报表配置',
|
|
26
|
+
setter: {
|
|
27
|
+
componentName: 'ObjectSetter',
|
|
28
|
+
props: {
|
|
29
|
+
config: {
|
|
30
|
+
items: [
|
|
31
|
+
{
|
|
32
|
+
name: 'dashboardId',
|
|
33
|
+
title: '嵌入 UUID',
|
|
34
|
+
setter: 'StringSetter',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'dashboardUiConfig',
|
|
38
|
+
title: 'Dashboard UI 配置',
|
|
39
|
+
// JSON 编辑器允许填写任意 SDK UI 扩展字段。
|
|
40
|
+
setter: 'JsonSetter',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
supports: { style: true, className: true },
|
|
49
|
+
component: {},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** 拖入编辑器时生成的默认片段;报表 ID 留空,需接入方填写实际嵌入 UUID。 */
|
|
54
|
+
const snippets: IPublicTypeSnippet[] = [
|
|
55
|
+
{
|
|
56
|
+
title: 'Superset 报表',
|
|
57
|
+
screenshot: '',
|
|
58
|
+
schema: {
|
|
59
|
+
componentName: 'PisellSupersetDashboard',
|
|
60
|
+
props: {
|
|
61
|
+
proCodeProps: {
|
|
62
|
+
dashboardId: '',
|
|
63
|
+
dashboardUiConfig: {
|
|
64
|
+
filters: { visible: true, expanded: false },
|
|
65
|
+
hideTitle: true,
|
|
66
|
+
hideChartControls: true,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
/** 合并物料描述与默认片段,供低代码构建插件收集。 */
|
|
75
|
+
export default { ...meta, snippets };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/private-materials",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.158",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"*.scss"
|
|
11
11
|
],
|
|
12
12
|
"devDependencies": {
|
|
13
|
+
"@types/lodash": "4.17.23",
|
|
13
14
|
"@alib/build-scripts": "^0.1.32",
|
|
14
15
|
"@alilc/build-plugin-alt": "^1.3.3",
|
|
15
16
|
"@alilc/lowcode-react-renderer": "^1.1.7",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"dist"
|
|
62
63
|
],
|
|
63
64
|
"dependencies": {
|
|
65
|
+
"@superset-ui/embedded-sdk": "0.4.0",
|
|
64
66
|
"@adyen/adyen-platform-experience-web": "1.12.2",
|
|
65
67
|
"antd": "5.10.1",
|
|
66
68
|
"@ant-design/icons": "^5.6.1",
|
|
@@ -81,8 +83,8 @@
|
|
|
81
83
|
"styled-components": "^6.0.0-rc.3",
|
|
82
84
|
"@pisell/utils": "3.0.2",
|
|
83
85
|
"@pisell/materials": "3.3.113",
|
|
84
|
-
"@pisell/
|
|
85
|
-
"@pisell/
|
|
86
|
+
"@pisell/icon": "0.0.11",
|
|
87
|
+
"@pisell/date-picker": "3.0.4"
|
|
86
88
|
},
|
|
87
89
|
"peerDependencies": {
|
|
88
90
|
"react": "^18.0.0",
|