@gct-paas/render-web 0.1.6-dev.3 → 0.1.6-dev.30
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/index.min.css +1 -1
- package/dist/loader.esm.min.js +2 -1
- package/es/Event/Events.d.ts +1 -0
- package/es/Event/Events.mjs +7 -3
- package/es/_virtual/_rolldown/runtime.mjs +13 -0
- package/es/components/card-view-render/card-view-render.css +71 -0
- package/es/components/card-view-render/card-view-render.d.ts +38 -0
- package/es/components/card-view-render/card-view-render.mjs +84 -0
- package/es/components/collapse-detail/components/collapse-list.vue.d.ts +24 -0
- package/es/components/collapse-detail/components/collapse-list.vue.mjs +5 -0
- package/es/components/collapse-detail/components/collapse-list.vue_vue_type_script_setup_true_lang.mjs +103 -0
- package/es/components/collapse-detail/components/enum-tag-label.vue.d.ts +6 -0
- package/es/components/collapse-detail/components/enum-tag-label.vue.mjs +5 -0
- package/es/components/collapse-detail/components/enum-tag-label.vue_vue_type_script_setup_true_lang.mjs +61 -0
- package/es/components/collapse-detail/components/instance-status-label.vue.d.ts +34 -0
- package/es/components/collapse-detail/components/instance-status-label.vue.mjs +7 -0
- package/es/components/collapse-detail/components/instance-status-label.vue_vue_type_script_setup_true_lang.mjs +76 -0
- package/es/components/collapse-detail/components/instance-status-label.vue_vue_type_style_index_0_scoped_610b0bb3_lang.css +77 -0
- package/es/components/collapse-detail/components/label-tag.vue.d.ts +6 -0
- package/es/components/collapse-detail/components/label-tag.vue.mjs +7 -0
- package/es/components/collapse-detail/components/label-tag.vue_vue_type_script_setup_true_lang.mjs +34 -0
- package/es/components/collapse-detail/components/label-tag.vue_vue_type_style_index_0_scoped_b25afce5_lang.css +39 -0
- package/es/components/collapse-detail/constants/instance-theme-config.d.ts +64 -0
- package/es/components/collapse-detail/constants/instance-theme-config.mjs +100 -0
- package/es/components/collapse-detail/constants/status.d.ts +36 -0
- package/es/components/collapse-detail/constants/status.mjs +34 -0
- package/es/components/collapse-detail/index.d.ts +3 -0
- package/es/components/collapse-detail/index.mjs +1 -0
- package/es/components/collapse-detail/index.vue.d.ts +37 -0
- package/es/components/collapse-detail/index.vue.mjs +7 -0
- package/es/components/collapse-detail/index.vue_vue_type_script_setup_true_name_collapse-detail_lang.mjs +90 -0
- package/es/components/collapse-detail/index.vue_vue_type_style_index_0_scoped_b4b9903c_lang.css +83 -0
- package/es/components/collapse-detail/typing.d.ts +44 -0
- package/es/components/collapse-detail/typing.mjs +17 -0
- package/es/components/field-search-cascader/field-cascader.vue.d.ts +17 -0
- package/es/components/field-search-cascader/field-cascader.vue.mjs +8 -0
- package/es/components/field-search-cascader/field-cascader.vue_vue_type_script_setup_true_lang.mjs +297 -0
- package/es/components/field-search-cascader/field-cascader.vue_vue_type_style_index_0_scoped_cb5e4d67_lang.css +52 -0
- package/es/components/field-search-cascader/field-cascader.vue_vue_type_style_index_1_lang.css +3 -0
- package/es/components/field-search-cascader/index.d.ts +2 -0
- package/es/components/field-search-cascader/index.mjs +1 -0
- package/es/components/form-component/FieldSelect.mjs +1 -0
- package/es/components/form-component/field-label/ref-card-label-render.vue_vue_type_script_setup_true_lang.mjs +2 -1
- package/es/components/form-component/field-label/tag-label.vue.mjs +2 -2
- package/es/components/form-component/field-label/tag-label.vue_vue_type_script_setup_true_name_TagLabel_lang.mjs +7 -8
- package/es/components/form-component/field-label/{tag-label.vue_vue_type_style_index_0_scoped_6c507fe8_lang.css → tag-label.vue_vue_type_style_index_0_scoped_9ba574f7_lang.css} +4 -4
- package/es/components/form-component/field-label/tag-span.vue.mjs +1 -1
- package/es/components/index.d.ts +7 -0
- package/es/components/index.mjs +9 -0
- package/es/components/layouts/basic-page/basic-page.vue.d.ts +30 -0
- package/es/components/layouts/basic-page/basic-page.vue.mjs +7 -0
- package/es/components/layouts/basic-page/basic-page.vue_vue_type_script_setup_true_name_basic-page_lang.mjs +30 -0
- package/es/components/layouts/basic-page/basic-page.vue_vue_type_style_index_0_scoped_23453a1b_lang.css +20 -0
- package/es/components/layouts/basic-page-render/basic-page-render.vue.d.ts +30 -0
- package/es/components/layouts/basic-page-render/basic-page-render.vue.mjs +7 -0
- package/es/components/layouts/basic-page-render/basic-page-render.vue_vue_type_script_setup_true_name_BasicPageRender_lang.mjs +30 -0
- package/es/components/layouts/basic-page-render/basic-page-render.vue_vue_type_style_index_0_scoped_3c6aba55_lang.css +20 -0
- package/es/components/rich-editor/index.d.ts +2 -0
- package/es/components/rich-editor/index.mjs +1 -0
- package/es/components/rich-editor/rich-editor.vue.d.ts +22 -0
- package/es/components/rich-editor/rich-editor.vue.mjs +5 -0
- package/es/components/rich-editor/rich-editor.vue_vue_type_script_setup_true_lang.mjs +150 -0
- package/es/components/rich-editor/style.css +747 -0
- package/es/constants/xlsx-parser.d.ts +15 -0
- package/es/constants/xlsx-parser.mjs +58 -0
- package/es/enums/xlsx-parser.d.ts +293 -0
- package/es/enums/xlsx-parser.mjs +36 -0
- package/es/hooks/index.d.ts +1 -0
- package/es/hooks/index.mjs +1 -0
- package/es/hooks/useQuickSearch.d.ts +8 -0
- package/es/hooks/useQuickSearch.mjs +96 -0
- package/es/index.d.ts +3 -0
- package/es/index.mjs +13 -1
- package/es/interface/xlsx-parser/base.d.ts +151 -0
- package/es/interface/xlsx-parser/index.d.ts +246 -0
- package/es/locale/auto-register.d.ts +2 -0
- package/es/locale/auto-register.mjs +31 -0
- package/es/locale/sys/appDesigner.d.ts +11 -0
- package/es/locale/sys/appDesigner.mjs +11 -0
- package/es/locale/sys/bi.d.ts +4 -0
- package/es/locale/sys/bi.mjs +6 -0
- package/es/locale/sys/bpmn.d.ts +10 -0
- package/es/locale/sys/bpmn.mjs +12 -0
- package/es/locale/sys/component.d.ts +15 -0
- package/es/locale/sys/component.mjs +15 -0
- package/es/locale/sys/developer.d.ts +6 -0
- package/es/locale/sys/developer.mjs +6 -0
- package/es/locale/sys/edhr.d.ts +19 -0
- package/es/locale/sys/edhr.mjs +15 -0
- package/es/locale/sys/message.d.ts +4 -0
- package/es/locale/sys/message.mjs +6 -0
- package/es/locale/sys/model.d.ts +34 -0
- package/es/locale/sys/model.mjs +38 -0
- package/es/locale/sys/onlineForm.d.ts +8 -0
- package/es/locale/sys/onlineForm.mjs +12 -0
- package/es/locale/sys/pageDesigner.d.ts +7 -0
- package/es/locale/sys/pageDesigner.mjs +9 -0
- package/es/locale/sys.d.ts +10 -0
- package/es/locale/sys.mjs +14 -0
- package/es/modules/app-mqtt/app-mqtt.interface.d.ts +26 -0
- package/es/modules/app-mqtt/app-mqtt.service.d.ts +72 -0
- package/es/modules/app-mqtt/app-mqtt.service.mjs +131 -0
- package/es/modules/app-mqtt/index.d.ts +2 -0
- package/es/modules/app-mqtt/index.mjs +1 -0
- package/es/setup-app.d.ts +2 -0
- package/es/setup-app.mjs +12 -0
- package/es/types/shims-modules.d.ts +11 -0
- package/es/utils/cell-border.d.ts +73 -0
- package/es/utils/cell-border.mjs +203 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.mjs +1 -0
- package/es/utils/xlsx-parser.d.ts +141 -0
- package/es/utils/xlsx-parser.mjs +262 -0
- package/package.json +21 -11
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
//#region src/locale/sys/onlineForm.ts
|
|
3
|
+
var onlineForm_exports = /* @__PURE__ */ __exportAll({ default: () => onlineForm_default });
|
|
4
|
+
var onlineForm_default = {
|
|
5
|
+
fieldKey: "字段KEY",
|
|
6
|
+
disabledStatus: "是否禁用状态",
|
|
7
|
+
formStyle: "表单样式",
|
|
8
|
+
formFields: "表单字段",
|
|
9
|
+
noAssociation: "无关联"
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { onlineForm_exports };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
//#region src/locale/sys/pageDesigner.ts
|
|
3
|
+
var pageDesigner_exports = /* @__PURE__ */ __exportAll({ default: () => pageDesigner_default });
|
|
4
|
+
var pageDesigner_default = {
|
|
5
|
+
searchField: "搜索字段",
|
|
6
|
+
dataLinkage: { rootSelectPlaceholder2: "请选择模型字段" }
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { pageDesigner_exports };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
//#region src/locale/sys.ts
|
|
3
|
+
var sys_exports = /* @__PURE__ */ __exportAll({ default: () => sys_default });
|
|
4
|
+
var sys_default = {
|
|
5
|
+
FieldName: "字段名称",
|
|
6
|
+
requiredOrNot: "是否必填",
|
|
7
|
+
text: "文本",
|
|
8
|
+
tableColumnDate: "时间",
|
|
9
|
+
signatureImage: "签名",
|
|
10
|
+
true: "是",
|
|
11
|
+
checkBarcodeFieldTip: "请关联实体模型后再配置变量类型的条码内容"
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { sys_exports };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 在线人数变化
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @interface IOnlineCountPayload
|
|
6
|
+
*/
|
|
7
|
+
export interface IOnlineCountPayload {
|
|
8
|
+
/**
|
|
9
|
+
* 应用标识
|
|
10
|
+
*
|
|
11
|
+
* @type {string}
|
|
12
|
+
*/
|
|
13
|
+
appId: string;
|
|
14
|
+
/**
|
|
15
|
+
* 在线人数
|
|
16
|
+
*
|
|
17
|
+
* @type {number}
|
|
18
|
+
*/
|
|
19
|
+
count: number;
|
|
20
|
+
/**
|
|
21
|
+
* 具体环境标识
|
|
22
|
+
*
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
env: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SystemMqttService, IMqttClient, MqttCancelSub, MqttSubCallback } from '@gct-paas/core';
|
|
2
|
+
import { IOnlineCountPayload } from './app-mqtt.interface';
|
|
3
|
+
export declare class AppMqttService extends SystemMqttService {
|
|
4
|
+
protected static app_client: IMqttClient | undefined;
|
|
5
|
+
protected static client_id: string;
|
|
6
|
+
/**
|
|
7
|
+
* 用户控制消息 topic
|
|
8
|
+
*
|
|
9
|
+
* @static
|
|
10
|
+
*/
|
|
11
|
+
static readonly USER_CONTROL_TOPIC = "users/control/msg";
|
|
12
|
+
/**
|
|
13
|
+
* 在线人数变化 topic
|
|
14
|
+
*
|
|
15
|
+
* @readonly
|
|
16
|
+
* @static
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
static get ONLINE_COUNT_TOPIC(): string;
|
|
20
|
+
/**
|
|
21
|
+
* 用户被从当前应用踢出 topic
|
|
22
|
+
*
|
|
23
|
+
* @readonly
|
|
24
|
+
* @static
|
|
25
|
+
* @type {string}
|
|
26
|
+
*/
|
|
27
|
+
static get APP_EXIT_TOPIC(): string;
|
|
28
|
+
/**
|
|
29
|
+
* 初始化系统级 MQTT 客户端,需要在用户信息以及应用信息加载完成后调用
|
|
30
|
+
*
|
|
31
|
+
* @static
|
|
32
|
+
* @return {*} {Promise<void>}
|
|
33
|
+
*/
|
|
34
|
+
protected static createMqtt(): Promise<void>;
|
|
35
|
+
protected static subKickOut(): MqttCancelSub;
|
|
36
|
+
/**
|
|
37
|
+
* 订阅系统级 MQTT 消息
|
|
38
|
+
*
|
|
39
|
+
* @static
|
|
40
|
+
* @param {string} topic
|
|
41
|
+
*/
|
|
42
|
+
protected static subscribeApp<T = IObject>(topic: string, callback: MqttSubCallback<T>): MqttCancelSub;
|
|
43
|
+
/**
|
|
44
|
+
* 订阅在线人数变化
|
|
45
|
+
*
|
|
46
|
+
* @static
|
|
47
|
+
* @param {MqttSubCallback<IOnlineCountPayload>} callback
|
|
48
|
+
* @return {*} {MqttCancelSub}
|
|
49
|
+
*/
|
|
50
|
+
static subOnlineCount(callback: MqttSubCallback<IOnlineCountPayload>): MqttCancelSub;
|
|
51
|
+
/**
|
|
52
|
+
* 订阅用户被从当前应用踢出
|
|
53
|
+
*
|
|
54
|
+
* @static
|
|
55
|
+
* @param {MqttSubCallback<void>} callback
|
|
56
|
+
* @return {*} {MqttCancelSub}
|
|
57
|
+
*/
|
|
58
|
+
static subAppExit(): MqttCancelSub;
|
|
59
|
+
/**
|
|
60
|
+
* 发送用户上线消息
|
|
61
|
+
*
|
|
62
|
+
* @static
|
|
63
|
+
* @param {string} clientId
|
|
64
|
+
*/
|
|
65
|
+
static pubOnline(): void;
|
|
66
|
+
/**
|
|
67
|
+
* 发送用户下线消息
|
|
68
|
+
*
|
|
69
|
+
* @static
|
|
70
|
+
*/
|
|
71
|
+
static pubExit(): void;
|
|
72
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { AuthUtil, DEFAULT_MQTT_INSTANCE_ID, SystemMqttService } from "@gct-paas/core";
|
|
2
|
+
//#region src/modules/app-mqtt/app-mqtt.service.ts
|
|
3
|
+
var AppMqttService = class extends SystemMqttService {
|
|
4
|
+
static app_client;
|
|
5
|
+
static client_id = "";
|
|
6
|
+
/**
|
|
7
|
+
* 用户控制消息 topic
|
|
8
|
+
*
|
|
9
|
+
* @static
|
|
10
|
+
*/
|
|
11
|
+
static USER_CONTROL_TOPIC = "users/control/msg";
|
|
12
|
+
/**
|
|
13
|
+
* 在线人数变化 topic
|
|
14
|
+
*
|
|
15
|
+
* @readonly
|
|
16
|
+
* @static
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
static get ONLINE_COUNT_TOPIC() {
|
|
20
|
+
return `${_gct.store.appInfo.id}/${_gct.env.getEnv()}/ONLINE_COUNT`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 用户被从当前应用踢出 topic
|
|
24
|
+
*
|
|
25
|
+
* @readonly
|
|
26
|
+
* @static
|
|
27
|
+
* @type {string}
|
|
28
|
+
*/
|
|
29
|
+
static get APP_EXIT_TOPIC() {
|
|
30
|
+
return `web.${_gct.store.userInfo.userId}/${_gct.env.getEnv()}.${_gct.store.appInfo.id}.${_gct.store.userInfo.ip}.${this.fingerprint}/EXIT`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 初始化系统级 MQTT 客户端,需要在用户信息以及应用信息加载完成后调用
|
|
34
|
+
*
|
|
35
|
+
* @static
|
|
36
|
+
* @return {*} {Promise<void>}
|
|
37
|
+
*/
|
|
38
|
+
static async createMqtt() {
|
|
39
|
+
await super.createMqtt();
|
|
40
|
+
this.client_id = `web.${_gct.store.userInfo.userId}.${_gct.env.getEnv()}.${_gct.store.appInfo.id}.${_gct.store.userInfo.ip}.${this.fingerprint}.${(/* @__PURE__ */ new Date()).getTime()}`;
|
|
41
|
+
const mqttProperties = _gct.store.userInfo?.mqttProperties || {};
|
|
42
|
+
this.app_client = _gct.mqtt.create(DEFAULT_MQTT_INSTANCE_ID, {
|
|
43
|
+
...mqttProperties,
|
|
44
|
+
clientId: this.client_id,
|
|
45
|
+
will: {
|
|
46
|
+
topic: this.USER_CONTROL_TOPIC,
|
|
47
|
+
payload: JSON.stringify({
|
|
48
|
+
clientId: this.client_id,
|
|
49
|
+
msg: "exit"
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
this.subAppExit();
|
|
54
|
+
}
|
|
55
|
+
static subKickOut() {
|
|
56
|
+
return super.subKickOut(() => {
|
|
57
|
+
this.pubLogout();
|
|
58
|
+
this.pubExit();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 订阅系统级 MQTT 消息
|
|
63
|
+
*
|
|
64
|
+
* @static
|
|
65
|
+
* @param {string} topic
|
|
66
|
+
*/
|
|
67
|
+
static subscribeApp(topic, callback) {
|
|
68
|
+
if (!this.app_client) throw new Error("App MQTT client is not initialized");
|
|
69
|
+
return this.app_client.subscribe(topic, (_topic, payload) => {
|
|
70
|
+
try {
|
|
71
|
+
callback(JSON.parse(payload.toString()));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error("解析 MQTT 消息 payload 失败:", error);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 订阅在线人数变化
|
|
79
|
+
*
|
|
80
|
+
* @static
|
|
81
|
+
* @param {MqttSubCallback<IOnlineCountPayload>} callback
|
|
82
|
+
* @return {*} {MqttCancelSub}
|
|
83
|
+
*/
|
|
84
|
+
static subOnlineCount(callback) {
|
|
85
|
+
return this.subscribeApp(this.ONLINE_COUNT_TOPIC, callback);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 订阅用户被从当前应用踢出
|
|
89
|
+
*
|
|
90
|
+
* @static
|
|
91
|
+
* @param {MqttSubCallback<void>} callback
|
|
92
|
+
* @return {*} {MqttCancelSub}
|
|
93
|
+
*/
|
|
94
|
+
static subAppExit() {
|
|
95
|
+
return this.subscribeApp(this.APP_EXIT_TOPIC, () => {
|
|
96
|
+
_gct.message.error(`您已被移出应用【${_gct.store.appInfo.name}】,请稍后再试。`);
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
if (_gct.env.isAppSingle || _gct.env.isSandbox) AuthUtil.getInstance().logout(true);
|
|
99
|
+
else {
|
|
100
|
+
const url = new URL(`${location.origin}/paas-front/portal#/home`);
|
|
101
|
+
window.location.href = url.toString();
|
|
102
|
+
}
|
|
103
|
+
}, 1e3);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 发送用户上线消息
|
|
108
|
+
*
|
|
109
|
+
* @static
|
|
110
|
+
* @param {string} clientId
|
|
111
|
+
*/
|
|
112
|
+
static pubOnline() {
|
|
113
|
+
this.app_client?.publish(this.USER_CONTROL_TOPIC, JSON.stringify({
|
|
114
|
+
clientId: this.client_id,
|
|
115
|
+
msg: "online"
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 发送用户下线消息
|
|
120
|
+
*
|
|
121
|
+
* @static
|
|
122
|
+
*/
|
|
123
|
+
static pubExit() {
|
|
124
|
+
this.app_client?.publish(this.USER_CONTROL_TOPIC, JSON.stringify({
|
|
125
|
+
clientId: this.client_id,
|
|
126
|
+
msg: "exit"
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { AppMqttService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./app-mqtt.service.mjs";
|
package/es/setup-app.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import basic_page_default from "./components/layouts/basic-page/basic-page.vue.mjs";
|
|
2
|
+
import basic_page_render_default from "./components/layouts/basic-page-render/basic-page-render.vue.mjs";
|
|
3
|
+
import "./components/index.mjs";
|
|
4
|
+
import { registerRenderWebLocale } from "./locale/auto-register.mjs";
|
|
5
|
+
//#region src/setup-app.ts
|
|
6
|
+
function renderWebSetupApp(app) {
|
|
7
|
+
registerRenderWebLocale();
|
|
8
|
+
app.component(basic_page_default.__name || basic_page_default.name, basic_page_default);
|
|
9
|
+
app.component(basic_page_render_default.__name || basic_page_render_default.name, basic_page_render_default);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { renderWebSetupApp };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare module '@wangeditor/editor-for-vue' {
|
|
2
|
+
import type { DefineComponent } from 'vue';
|
|
3
|
+
|
|
4
|
+
export const Editor: DefineComponent;
|
|
5
|
+
export const Toolbar: DefineComponent;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare module 'unit-to-px' {
|
|
9
|
+
function toPx(length: string, element?: Element): number;
|
|
10
|
+
export default toPx;
|
|
11
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ICellBorder } from '../interface/xlsx-parser/base';
|
|
2
|
+
import { ICell, IPaper } from '../interface/xlsx-parser';
|
|
3
|
+
/**
|
|
4
|
+
* 获取单元格坐标
|
|
5
|
+
* @param x
|
|
6
|
+
* @param y
|
|
7
|
+
* @param paper
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 获取当前单元格指定方向的单元格
|
|
12
|
+
* @param x
|
|
13
|
+
* @param y
|
|
14
|
+
* @param paper
|
|
15
|
+
*/
|
|
16
|
+
export declare class CellBorder {
|
|
17
|
+
/**
|
|
18
|
+
* 获取指定单元格的指定方向的相邻单元格
|
|
19
|
+
* @author lingxiaoming
|
|
20
|
+
* @date 2024-07-02 04:23:11
|
|
21
|
+
* @static
|
|
22
|
+
* @param {number} x
|
|
23
|
+
* @param {number} y
|
|
24
|
+
* @param {IPaper} paper
|
|
25
|
+
* @param {('top' | 'bottom' | 'left' | 'right')} position
|
|
26
|
+
* @return {*}
|
|
27
|
+
*/
|
|
28
|
+
static getAdjacentCell(x: number, y: number, paper: IPaper, position: 'top' | 'bottom' | 'left' | 'right'): ICell | undefined;
|
|
29
|
+
static setLeft(x: number, y: number, paper: IPaper, bold?: boolean, value?: boolean): void;
|
|
30
|
+
static setRight(x: number, y: number, paper: IPaper, bold?: boolean, value?: boolean): void;
|
|
31
|
+
static setTop(x: number, y: number, paper: IPaper, bold?: boolean, value?: boolean): void;
|
|
32
|
+
static setBottom(x: number, y: number, paper: IPaper, bold?: boolean, value?: boolean): void;
|
|
33
|
+
static clearBorder(x: number, y: number, paper: IPaper): void;
|
|
34
|
+
/**
|
|
35
|
+
* 获取单元格是否有下边框 作用于分页时判断最后一行是否有下边框
|
|
36
|
+
* @param x
|
|
37
|
+
* @param y
|
|
38
|
+
* @param paper
|
|
39
|
+
*/
|
|
40
|
+
static getBottomBorder(x: number, y: number, paper: IPaper): boolean;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param x
|
|
44
|
+
* @param y
|
|
45
|
+
* @param paper
|
|
46
|
+
*/
|
|
47
|
+
static getTopBorder(x: number, y: number, paper: IPaper): boolean;
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @param x
|
|
51
|
+
* @param y
|
|
52
|
+
* @param paper
|
|
53
|
+
*/
|
|
54
|
+
static getLeftBorder(x: number, y: number, paper: IPaper): boolean;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param x
|
|
58
|
+
* @param y
|
|
59
|
+
* @param paper
|
|
60
|
+
*/
|
|
61
|
+
static getRightBorder(x: number, y: number, paper: IPaper): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* 获取单元格的边框信息,合并单元格只有左上角那个一会获得汇总后的边框信息
|
|
64
|
+
* @author lingxiaoming
|
|
65
|
+
* @date 2024-07-04 06:35:10
|
|
66
|
+
* @static
|
|
67
|
+
* @param {number} x
|
|
68
|
+
* @param {number} y
|
|
69
|
+
* @param {IPaper} paper
|
|
70
|
+
* @return {*} {(ICellBorder | undefined)}
|
|
71
|
+
*/
|
|
72
|
+
static getCellBorder(x: number, y: number, paper: IPaper): ICellBorder | undefined;
|
|
73
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { range } from "lodash-es";
|
|
2
|
+
//#region src/utils/cell-border.ts
|
|
3
|
+
/**
|
|
4
|
+
* 获取单元格坐标
|
|
5
|
+
* @param x
|
|
6
|
+
* @param y
|
|
7
|
+
* @param paper
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 获取当前单元格指定方向的单元格
|
|
12
|
+
* @param x
|
|
13
|
+
* @param y
|
|
14
|
+
* @param paper
|
|
15
|
+
*/
|
|
16
|
+
var CellBorder = class {
|
|
17
|
+
/**
|
|
18
|
+
* 获取指定单元格的指定方向的相邻单元格
|
|
19
|
+
* @author lingxiaoming
|
|
20
|
+
* @date 2024-07-02 04:23:11
|
|
21
|
+
* @static
|
|
22
|
+
* @param {number} x
|
|
23
|
+
* @param {number} y
|
|
24
|
+
* @param {IPaper} paper
|
|
25
|
+
* @param {('top' | 'bottom' | 'left' | 'right')} position
|
|
26
|
+
* @return {*}
|
|
27
|
+
*/
|
|
28
|
+
static getAdjacentCell(x, y, paper, position) {
|
|
29
|
+
let targetCell;
|
|
30
|
+
switch (position) {
|
|
31
|
+
case "top":
|
|
32
|
+
targetCell = paper.cells[y - 1 - 1]?.[x - 1];
|
|
33
|
+
break;
|
|
34
|
+
case "bottom":
|
|
35
|
+
targetCell = paper.cells[y + 1 - 1]?.[x - 1];
|
|
36
|
+
break;
|
|
37
|
+
case "left":
|
|
38
|
+
targetCell = paper.cells[y - 1]?.[x - 1 - 1];
|
|
39
|
+
break;
|
|
40
|
+
case "right":
|
|
41
|
+
targetCell = paper.cells[y - 1]?.[x + 1 - 1];
|
|
42
|
+
break;
|
|
43
|
+
default: return;
|
|
44
|
+
}
|
|
45
|
+
if (!targetCell) return;
|
|
46
|
+
return targetCell;
|
|
47
|
+
}
|
|
48
|
+
static setLeft(x, y, paper, bold = false, value = true) {
|
|
49
|
+
const targetCellData = paper.cells[y - 1][x - 1];
|
|
50
|
+
targetCellData.border = {
|
|
51
|
+
...targetCellData.border,
|
|
52
|
+
left: value,
|
|
53
|
+
bold,
|
|
54
|
+
boldLeft: bold
|
|
55
|
+
};
|
|
56
|
+
if (value === false) {
|
|
57
|
+
const leftCell = this.getAdjacentCell(x, y, paper, "left");
|
|
58
|
+
if (leftCell) leftCell.border = {
|
|
59
|
+
...leftCell.border,
|
|
60
|
+
right: false,
|
|
61
|
+
bold: false,
|
|
62
|
+
boldLeft: false
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
static setRight(x, y, paper, bold = false, value = true) {
|
|
67
|
+
const targetCellData = paper.cells[y - 1][x - 1] || {};
|
|
68
|
+
targetCellData.border = {
|
|
69
|
+
...targetCellData.border,
|
|
70
|
+
right: value,
|
|
71
|
+
bold,
|
|
72
|
+
boldRight: bold
|
|
73
|
+
};
|
|
74
|
+
if (value === false) {
|
|
75
|
+
const rightCell = this.getAdjacentCell(x, y, paper, "right");
|
|
76
|
+
if (rightCell) rightCell.border = {
|
|
77
|
+
...rightCell.border,
|
|
78
|
+
left: false,
|
|
79
|
+
bold: false,
|
|
80
|
+
boldRight: bold
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
static setTop(x, y, paper, bold = false, value = true) {
|
|
85
|
+
const targetCellData = paper.cells[y - 1][x - 1];
|
|
86
|
+
targetCellData.border = {
|
|
87
|
+
...targetCellData.border,
|
|
88
|
+
top: value,
|
|
89
|
+
bold,
|
|
90
|
+
boldTop: bold
|
|
91
|
+
};
|
|
92
|
+
if (value === false) {
|
|
93
|
+
const topCell = this.getAdjacentCell(x, y, paper, "top");
|
|
94
|
+
if (topCell) topCell.border = {
|
|
95
|
+
...topCell.border,
|
|
96
|
+
bottom: false,
|
|
97
|
+
bold: false,
|
|
98
|
+
boldTop: false
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
static setBottom(x, y, paper, bold = false, value = true) {
|
|
103
|
+
const targetCellData = paper.cells[y - 1][x - 1];
|
|
104
|
+
targetCellData.border = {
|
|
105
|
+
...targetCellData.border,
|
|
106
|
+
bottom: value,
|
|
107
|
+
bold,
|
|
108
|
+
boldBottom: bold
|
|
109
|
+
};
|
|
110
|
+
if (value === false) {
|
|
111
|
+
const bottomCell = this.getAdjacentCell(x, y, paper, "bottom");
|
|
112
|
+
if (bottomCell) bottomCell.border = {
|
|
113
|
+
...bottomCell.border,
|
|
114
|
+
top: false,
|
|
115
|
+
bold: false,
|
|
116
|
+
boldBottom: false
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
static clearBorder(x, y, paper) {
|
|
121
|
+
this.setLeft(x, y, paper, false, false);
|
|
122
|
+
this.setRight(x, y, paper, false, false);
|
|
123
|
+
this.setTop(x, y, paper, false, false);
|
|
124
|
+
this.setBottom(x, y, paper, false, false);
|
|
125
|
+
const targetCellData = paper.cells[y - 1][x - 1];
|
|
126
|
+
targetCellData.border = void 0;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 获取单元格是否有下边框 作用于分页时判断最后一行是否有下边框
|
|
130
|
+
* @param x
|
|
131
|
+
* @param y
|
|
132
|
+
* @param paper
|
|
133
|
+
*/
|
|
134
|
+
static getBottomBorder(x, y, paper) {
|
|
135
|
+
const mergeCell = paper.mergedCells.find((c) => c.t === y && c.l === x);
|
|
136
|
+
if (mergeCell) return range(mergeCell.l, mergeCell.r).every((v) => !!paper.cells[mergeCell.b - 1][v - 1]?.border?.bottom);
|
|
137
|
+
else return !!paper.cells[y - 1][x - 1].border?.bottom;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @param x
|
|
142
|
+
* @param y
|
|
143
|
+
* @param paper
|
|
144
|
+
*/
|
|
145
|
+
static getTopBorder(x, y, paper) {
|
|
146
|
+
const mergeCell = paper.mergedCells.find((c) => c.t === y && c.l === x);
|
|
147
|
+
if (mergeCell) return range(mergeCell.l, mergeCell.r).every((v) => !!paper.cells[mergeCell.t - 1][v - 1]?.border?.top);
|
|
148
|
+
else return !!paper.cells[y - 1][x - 1].border?.top;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
* @param x
|
|
153
|
+
* @param y
|
|
154
|
+
* @param paper
|
|
155
|
+
*/
|
|
156
|
+
static getLeftBorder(x, y, paper) {
|
|
157
|
+
const mergeCell = paper.mergedCells.find((c) => c.t === y && c.l === x);
|
|
158
|
+
if (mergeCell) {
|
|
159
|
+
console.log(x, y, range(mergeCell.t, mergeCell.b).every((v) => !!paper.cells[v - 1][mergeCell.l - 1]?.border?.left));
|
|
160
|
+
return range(mergeCell.t, mergeCell.b).every((v) => !!paper.cells[v - 1][mergeCell.l - 1]?.border?.left);
|
|
161
|
+
} else return !!paper.cells[y - 1][x - 1].border?.left;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* @param x
|
|
166
|
+
* @param y
|
|
167
|
+
* @param paper
|
|
168
|
+
*/
|
|
169
|
+
static getRightBorder(x, y, paper) {
|
|
170
|
+
const mergeCell = paper.mergedCells.find((c) => c.t === y && c.l === x);
|
|
171
|
+
if (mergeCell) return range(mergeCell.t, mergeCell.b).every((v) => !!paper.cells[v - 1][mergeCell.r - 1]?.border?.right);
|
|
172
|
+
else return !!paper.cells[y - 1][x - 1].border?.right;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 获取单元格的边框信息,合并单元格只有左上角那个一会获得汇总后的边框信息
|
|
176
|
+
* @author lingxiaoming
|
|
177
|
+
* @date 2024-07-04 06:35:10
|
|
178
|
+
* @static
|
|
179
|
+
* @param {number} x
|
|
180
|
+
* @param {number} y
|
|
181
|
+
* @param {IPaper} paper
|
|
182
|
+
* @return {*} {(ICellBorder | undefined)}
|
|
183
|
+
*/
|
|
184
|
+
static getCellBorder(x, y, paper) {
|
|
185
|
+
const mergedCell = (paper.mergedCells ?? []).find((c) => c.l <= x && c.r >= x && c.t <= y && c.b >= y);
|
|
186
|
+
if (mergedCell) {
|
|
187
|
+
if (mergedCell.t === y && mergedCell.l === x) return {
|
|
188
|
+
top: range(mergedCell.l, mergedCell.r + 1).every((v) => !!paper.cells[mergedCell.t - 1][v - 1]?.border?.top),
|
|
189
|
+
bottom: range(mergedCell.l, mergedCell.r + 1).every((v) => !!paper.cells[mergedCell.b - 1][v - 1]?.border?.bottom),
|
|
190
|
+
left: range(mergedCell.t, mergedCell.b + 1).every((v) => !!paper.cells[v - 1][mergedCell.l - 1]?.border?.left),
|
|
191
|
+
right: range(mergedCell.t, mergedCell.b + 1).every((v) => !!paper.cells[v - 1][mergedCell.r - 1]?.border?.right),
|
|
192
|
+
bold: range(mergedCell.l, mergedCell.r + 1).some((v) => !!paper.cells[mergedCell.t - 1][v - 1]?.border?.bold) ?? false,
|
|
193
|
+
boldTop: range(mergedCell.l, mergedCell.r + 1).every((v) => !!paper.cells[mergedCell.t - 1][v - 1]?.border?.boldTop) ?? false,
|
|
194
|
+
boldBottom: range(mergedCell.l, mergedCell.r + 1).every((v) => !!paper.cells[mergedCell.b - 1][v - 1]?.border?.boldBottom) ?? false,
|
|
195
|
+
boldLeft: range(mergedCell.t, mergedCell.b + 1).every((v) => !!paper.cells[v - 1][mergedCell.l - 1]?.border?.boldLeft) ?? false,
|
|
196
|
+
boldRight: range(mergedCell.t, mergedCell.b + 1).every((v) => !!paper.cells[v - 1][mergedCell.r - 1]?.border?.boldRight) ?? false
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
return paper.cells[y - 1][x - 1]?.border || {};
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
//#endregion
|
|
203
|
+
export { CellBorder };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { XlsxParser } from './xlsx-parser';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./xlsx-parser.mjs";
|