tadcode-wpsjs 1.3.0 → 1.5.0
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/README.md +3 -3
- package/index.ts +5 -5
- package/package.json +1 -1
- package/types/application/FieldDescriptor.d.ts +88 -0
- package/types/application/FieldDescriptors.d.ts +25 -0
- package/types/application/GanttViewUI.d.ts +27 -0
- package/types/application/RecordRange.d.ts +2 -6
- package/types/application/Records.d.ts +2 -5
- package/types/application/Sheet.d.ts +1 -14
- package/types/application/Sheets.d.ts +2 -1
- package/types/application/View.d.ts +3 -3
- package/types/application/Views.d.ts +2 -3
- package/types/application/Window.d.ts +16 -20
- package/types/application/patch.d.ts +54 -0
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
项目地址:[https://gitcode.com/caisijian/tadcode-wpsjs](https://gitcode.com/caisijian/tadcode-wpsjs)
|
|
6
6
|
|
|
7
|
-
在部署远程代码的情况下,可以远程调用`WpsjsGlobal`,实现对支持`AirScript`的多维表,智能表格等远程操作。如果你对`AirScript`,感兴趣,也能帮助你学习`
|
|
7
|
+
在部署远程代码的情况下,可以远程调用`WpsjsGlobal`,实现对支持`AirScript`的多维表,智能表格等远程操作。如果你对`AirScript`,感兴趣,也能帮助你学习`AirScript`。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
When deploying remote code, you can remotely invoke `WpsjsGlobal` to perform remote operations on multi-dimensional tables, smart tables, and other supported features with `AirScript`. If you're interested in `AirScript`, it can also assist you in learning it.
|
|
10
10
|
|
|
11
11
|
原理是使用代理收集调用信息,之后让远程代码进行调用并且返回结果。
|
|
12
12
|
远程代码在`tadcode-wpsjs/remoteCode`目录的`index.js`文件中。
|
|
@@ -83,7 +83,7 @@ const wpsjsGlobal = initRemoteCallWpsjsGlobal({ scriptToken, webhookURL, })
|
|
|
83
83
|
|
|
84
84
|
const range = wpsjsGlobal.Application.ActiveSheet.RecordRange([1, 2], [1, 2]).Font as unknown as Font
|
|
85
85
|
range.Color = '#ff00ff'
|
|
86
|
-
/*
|
|
86
|
+
/* 注意:赋值操作依旧是远程操作。此函数会拿到最后一次赋值操作的promise */
|
|
87
87
|
await setValueOk()
|
|
88
88
|
```
|
|
89
89
|
|
package/index.ts
CHANGED
|
@@ -94,13 +94,13 @@ const execution = ({ scriptToken, webhookURL, isAsync, argv }: ExecutionConfig)
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
let setValuePromise: any = null
|
|
97
|
-
|
|
97
|
+
/** 赋值操作返回的promise */
|
|
98
98
|
const setValueOk = async () => setValuePromise
|
|
99
|
-
|
|
100
|
-
const setValue = async <T extends Promise<any
|
|
99
|
+
/** 赋值 */
|
|
100
|
+
const setValue = async <T extends Promise<any>, K extends keyof Awaited<T>, V extends Awaited<T>[K]>(
|
|
101
101
|
promiseObj: T,
|
|
102
|
-
p:
|
|
103
|
-
newValue:
|
|
102
|
+
p: K,
|
|
103
|
+
newValue: V,
|
|
104
104
|
) => {
|
|
105
105
|
const obj = promiseObj as Awaited<T>
|
|
106
106
|
const func = obj[rawSymbol] as ProxyTarget
|
package/package.json
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
declare module 'application:datatable' {
|
|
2
|
+
import { ViewType } from 'application:datatable'
|
|
3
|
+
// 基础类型定义
|
|
4
|
+
type FieldType =
|
|
5
|
+
| 'SingleLineText'
|
|
6
|
+
| 'MultiLineText'
|
|
7
|
+
| 'Date'
|
|
8
|
+
| 'SingleSelect'
|
|
9
|
+
| 'Number'
|
|
10
|
+
| 'Rating'
|
|
11
|
+
| 'ID'
|
|
12
|
+
| 'Phone'
|
|
13
|
+
| 'Email'
|
|
14
|
+
| 'Url'
|
|
15
|
+
| 'Checkbox'
|
|
16
|
+
| 'MultipleSelect'
|
|
17
|
+
| 'Complete'
|
|
18
|
+
| 'CellPicture'
|
|
19
|
+
| 'Contact'
|
|
20
|
+
| 'Attachment'
|
|
21
|
+
| 'Note'
|
|
22
|
+
| 'Link'
|
|
23
|
+
| 'OneWayLink'
|
|
24
|
+
| 'Lookup'
|
|
25
|
+
| 'Address'
|
|
26
|
+
| 'Cascade'
|
|
27
|
+
| 'Automations'
|
|
28
|
+
| 'AutoNumber'
|
|
29
|
+
| 'CreatedBy'
|
|
30
|
+
| 'CreatedTime'
|
|
31
|
+
| 'LastModifiedBy'
|
|
32
|
+
| 'LastModifiedTime'
|
|
33
|
+
| 'Formula'
|
|
34
|
+
| 'Button'
|
|
35
|
+
|
|
36
|
+
interface EventContext {
|
|
37
|
+
Destroy(): void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 字段删除事件数据
|
|
41
|
+
interface FieldDeleteEventData {
|
|
42
|
+
sheetId: number
|
|
43
|
+
fieldId: string
|
|
44
|
+
fieldIds: string[]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 字段描述符接口
|
|
48
|
+
interface FieldDescriptor {
|
|
49
|
+
// 属性
|
|
50
|
+
Id: string
|
|
51
|
+
Type: FieldType
|
|
52
|
+
Name: string
|
|
53
|
+
Description: string
|
|
54
|
+
IsSyncField: boolean
|
|
55
|
+
DefaultVal: string
|
|
56
|
+
DefaultValType: any // Enum.DbFieldDefaultValueType
|
|
57
|
+
NumberFormat: string
|
|
58
|
+
IsValueUnique: boolean
|
|
59
|
+
|
|
60
|
+
// 各字段类型的特有属性
|
|
61
|
+
Button?: any
|
|
62
|
+
Address?: any
|
|
63
|
+
Cascade?: any
|
|
64
|
+
Contact?: any
|
|
65
|
+
Date?: any
|
|
66
|
+
Watch?: any
|
|
67
|
+
Formula?: any
|
|
68
|
+
Lookup?: any
|
|
69
|
+
Link?: any
|
|
70
|
+
Automation?: any
|
|
71
|
+
Attachment?: any
|
|
72
|
+
Url?: any
|
|
73
|
+
Number?: any
|
|
74
|
+
Select?: any
|
|
75
|
+
Rating?: any
|
|
76
|
+
|
|
77
|
+
// 方法
|
|
78
|
+
Apply(): any // ApiResult
|
|
79
|
+
Delete(RemoveReversedLink?: boolean): boolean
|
|
80
|
+
|
|
81
|
+
// 事件
|
|
82
|
+
OnUpdate(callback: (data: FieldDescriptor) => void): EventContext
|
|
83
|
+
OnDelete(callback: (data: FieldDeleteEventData) => void): EventContext
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 导出类型
|
|
87
|
+
export type { FieldDescriptor, FieldType }
|
|
88
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare module 'application:datatable' {
|
|
2
|
+
import { ViewType, FieldType, FieldDescriptor } from 'application:datatable'
|
|
3
|
+
|
|
4
|
+
interface EventContext {
|
|
5
|
+
Destroy(): void
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// 字段描述符集合接口
|
|
9
|
+
interface FieldDescriptors {
|
|
10
|
+
// 属性
|
|
11
|
+
Count: number
|
|
12
|
+
|
|
13
|
+
// 方法
|
|
14
|
+
Item(Index: string | number): FieldDescriptor
|
|
15
|
+
FieldDescriptor(Type: string, Name: string): FieldDescriptor
|
|
16
|
+
AddField(FieldDescriptor: FieldDescriptor, Index?: string | number): any
|
|
17
|
+
Delete(FieldId: string, RemoveReversedLink?: boolean): boolean
|
|
18
|
+
|
|
19
|
+
// 事件
|
|
20
|
+
OnCreate(callback: (data: FieldDescriptor) => void): EventContext
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 导出类型
|
|
24
|
+
export type { FieldDescriptors }
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare module 'application:datatable' {
|
|
2
|
+
import { ViewType, FieldType } from 'application:datatable'
|
|
3
|
+
|
|
4
|
+
// 甘特图视图模式
|
|
5
|
+
type GanttViewMode = 'Week' | 'Month' | 'Quarter' | 'Year'
|
|
6
|
+
|
|
7
|
+
interface EventContext {
|
|
8
|
+
Destroy(): void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 甘特图视图UI接口
|
|
12
|
+
interface GanttViewUI {
|
|
13
|
+
// 属性
|
|
14
|
+
GanttGridFold: boolean
|
|
15
|
+
ViewMode: GanttViewMode
|
|
16
|
+
|
|
17
|
+
// 方法
|
|
18
|
+
Today(): boolean
|
|
19
|
+
NextPage(): boolean
|
|
20
|
+
PrevPage(): boolean
|
|
21
|
+
FoldAll(): boolean
|
|
22
|
+
UnFoldAll(): boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 导出类型
|
|
26
|
+
export type { GanttViewUI }
|
|
27
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module 'application:datatable' {
|
|
2
|
-
import type { Criteria } from 'application:datatable'
|
|
2
|
+
import type { Criteria, Patch } from 'application:datatable'
|
|
3
3
|
// 基础类型定义
|
|
4
4
|
type FilterOp = 'And' | 'Or'
|
|
5
5
|
|
|
@@ -44,7 +44,7 @@ declare module 'application:datatable' {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
// RecordRange 接口
|
|
47
|
-
interface RecordRange {
|
|
47
|
+
interface RecordRange extends Patch.RecordRange2 {
|
|
48
48
|
// 属性
|
|
49
49
|
readonly Count: number
|
|
50
50
|
FieldId: any[] // 返回Array
|
|
@@ -68,10 +68,6 @@ declare module 'application:datatable' {
|
|
|
68
68
|
OnUpdate(callback: (data: RecordRange) => void): EventContext
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
interface RecordRange {
|
|
72
|
-
(Index?: number | string | any[], Field?: number | string | any[]): RecordRange
|
|
73
|
-
}
|
|
74
|
-
|
|
75
71
|
// 导出 RecordRange 类型
|
|
76
72
|
export type { RecordRange }
|
|
77
73
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module 'application:datatable' {
|
|
2
|
-
import type { Record } from 'application:datatable'
|
|
2
|
+
import type { Record, Patch } from 'application:datatable'
|
|
3
3
|
// 基础类型定义
|
|
4
4
|
type ViewType = 'Grid' | 'Kanban' | 'Gallery' | 'Form' | 'Query' | 'Gantt'
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ declare module 'application:datatable' {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
// Records 接口
|
|
11
|
-
interface Records {
|
|
11
|
+
interface Records extends Patch.Records {
|
|
12
12
|
// 属性
|
|
13
13
|
readonly Count: number
|
|
14
14
|
|
|
@@ -20,9 +20,6 @@ declare module 'application:datatable' {
|
|
|
20
20
|
FindPrevious(What: string): Record | null
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
interface Records {
|
|
24
|
-
(Index: number | string): Record
|
|
25
|
-
}
|
|
26
23
|
// 导出 Records 类型
|
|
27
24
|
export type { Records }
|
|
28
25
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module 'application:datatable' {
|
|
2
|
-
import type { RecordRange } from 'application:datatable'
|
|
2
|
+
import type { RecordRange, View, Views, FieldDescriptors } from 'application:datatable'
|
|
3
3
|
// 基础类型定义
|
|
4
4
|
type FieldType =
|
|
5
5
|
| 'SingleLineText'
|
|
@@ -25,19 +25,6 @@ declare module 'application:datatable' {
|
|
|
25
25
|
value: string
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// FieldDescriptors 类型(根据文档引用)
|
|
29
|
-
interface FieldDescriptors { }
|
|
30
|
-
|
|
31
|
-
// Views 类型(根据之前Views文档)
|
|
32
|
-
interface Views {
|
|
33
|
-
readonly ActiveView: any
|
|
34
|
-
readonly Count: number
|
|
35
|
-
Add(Type: ViewType, Name: string): any
|
|
36
|
-
Delete(Index: number | string): void
|
|
37
|
-
Item(Index: number | string): any
|
|
38
|
-
ItemById(Id: string): any
|
|
39
|
-
OnCreate(callback: (data: any) => void): EventContext
|
|
40
|
-
}
|
|
41
28
|
|
|
42
29
|
// Sheet 接口
|
|
43
30
|
interface Sheet {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare module 'application:datatable' {
|
|
2
|
+
import { Patch } from 'application:datatable'
|
|
2
3
|
// 基础类型定义
|
|
3
4
|
type SheetType = 'xlEtFlexPaperSheet' | 'xlEtDataBaseSheet' | 'xlDbDashBoardSheet'
|
|
4
5
|
|
|
@@ -59,7 +60,7 @@ declare module 'application:datatable' {
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
// Sheets 接口
|
|
62
|
-
interface Sheets {
|
|
63
|
+
interface Sheets extends Patch.Sheets {
|
|
63
64
|
// 属性
|
|
64
65
|
readonly Count: number
|
|
65
66
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module 'application:datatable' {
|
|
2
|
-
import type { RecordRange, Records } from 'application:datatable'
|
|
2
|
+
import type { RecordRange, Records, Patch } from 'application:datatable'
|
|
3
3
|
// 基础类型定义
|
|
4
4
|
type ViewType = 'Grid' | 'Kanban' | 'Gallery' | 'Form' | 'Query' | 'Gantt' | 'Calendar'
|
|
5
5
|
|
|
@@ -19,7 +19,7 @@ declare module 'application:datatable' {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// View 接口
|
|
22
|
-
interface View {
|
|
22
|
+
interface View extends Patch.View2 {
|
|
23
23
|
// 属性
|
|
24
24
|
Description: string
|
|
25
25
|
readonly Fields: any
|
|
@@ -47,5 +47,5 @@ declare module 'application:datatable' {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// 导出 View 类型
|
|
50
|
-
export type { View }
|
|
50
|
+
export type { View, ViewType }
|
|
51
51
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
declare module 'application:datatable' {
|
|
2
|
-
|
|
3
|
-
type ViewType = 'Grid' | 'Kanban' | 'Gallery' | 'Form' | 'Query' | 'Gantt'
|
|
2
|
+
import { View, Patch, ViewType } from 'application:datatable'
|
|
4
3
|
|
|
5
4
|
interface EventContext {
|
|
6
5
|
Destroy(): void
|
|
@@ -16,7 +15,7 @@ declare module 'application:datatable' {
|
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
// Views 接口
|
|
19
|
-
interface Views {
|
|
18
|
+
interface Views extends Patch.Views {
|
|
20
19
|
// 属性
|
|
21
20
|
readonly ActiveView: View
|
|
22
21
|
readonly Count: number
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
declare module 'application:datatable' {
|
|
2
|
+
import { GanttViewUI } from 'application:datatable'
|
|
2
3
|
// 基础类型定义
|
|
3
4
|
interface HookParams {
|
|
4
|
-
recordId: string
|
|
5
|
-
activeFieldId?: string
|
|
6
|
-
isShowComment?: boolean
|
|
5
|
+
recordId: string
|
|
6
|
+
activeFieldId?: string
|
|
7
|
+
isShowComment?: boolean
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
interface Hook {
|
|
10
|
-
InvokeSingle(callback: (params: HookParams) => boolean): void
|
|
11
|
+
InvokeSingle(callback: (params: HookParams) => boolean): void
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
// Navigator 类型(根据文档引用)
|
|
@@ -25,11 +26,6 @@ declare module 'application:datatable' {
|
|
|
25
26
|
// FormViewUI属性
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
// GanttViewUI 类型(根据文档引用)
|
|
29
|
-
interface GanttViewUI {
|
|
30
|
-
// GanttViewUI属性
|
|
31
|
-
}
|
|
32
|
-
|
|
33
29
|
// GridViewUI 类型(根据文档引用)
|
|
34
30
|
interface GridViewUI {
|
|
35
31
|
// GridViewUI属性
|
|
@@ -38,20 +34,20 @@ declare module 'application:datatable' {
|
|
|
38
34
|
// Window 接口
|
|
39
35
|
interface Window {
|
|
40
36
|
// 属性
|
|
41
|
-
readonly Navigator: Navigator
|
|
42
|
-
readonly NoticeBar: NoticeBar
|
|
43
|
-
readonly FormViewUI: FormViewUI
|
|
44
|
-
readonly GanttViewUI: GanttViewUI
|
|
45
|
-
readonly GridViewUI: GridViewUI
|
|
37
|
+
readonly Navigator: Navigator
|
|
38
|
+
readonly NoticeBar: NoticeBar
|
|
39
|
+
readonly FormViewUI: FormViewUI
|
|
40
|
+
readonly GanttViewUI: GanttViewUI
|
|
41
|
+
readonly GridViewUI: GridViewUI
|
|
46
42
|
|
|
47
43
|
// 方法
|
|
48
|
-
SetLayout(isClassic: boolean): void
|
|
49
|
-
BailHook(CmbId: string): Hook
|
|
50
|
-
DisplayRecord(RecodId?: string): void
|
|
51
|
-
HiddenAllRecord(): void
|
|
52
|
-
InterceptCopyRecordLink?(): void
|
|
44
|
+
SetLayout(isClassic: boolean): void
|
|
45
|
+
BailHook(CmbId: string): Hook
|
|
46
|
+
DisplayRecord(RecodId?: string): void
|
|
47
|
+
HiddenAllRecord(): void
|
|
48
|
+
InterceptCopyRecordLink?(): void // 文档中有列出但无详细说明
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
// 导出 Window 类型
|
|
56
|
-
export type { Window }
|
|
52
|
+
export type { Window }
|
|
57
53
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare module 'application:datatable' {
|
|
2
|
+
import { Sheet, Record, RecordRange, View } from 'application:datatable'
|
|
3
|
+
namespace Patch {
|
|
4
|
+
|
|
5
|
+
interface Sheets {
|
|
6
|
+
(Index: number | string): Sheet
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface Views {
|
|
10
|
+
(Index: number | string): View
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface View2 {
|
|
14
|
+
/**行高 grid特有 */
|
|
15
|
+
RowHeight: 'Short' | 'Medium' | 'Tall' | 'ExtraTall'
|
|
16
|
+
/**冻结的行数 grid特有 */
|
|
17
|
+
FrozenCols: number
|
|
18
|
+
/**开始日期字段ID Gantt Calendar特有 */
|
|
19
|
+
BeginField: string
|
|
20
|
+
/**结束日期字段ID Gantt Calendar特有 */
|
|
21
|
+
EndField: string
|
|
22
|
+
/**结束日期字段ID Gantt Calendar特有 */
|
|
23
|
+
TimelineColor: string
|
|
24
|
+
/**工作时间统计忽略节假日 Gantt特有 */
|
|
25
|
+
IsOnlyWorkDay: boolean
|
|
26
|
+
/**查询字段配置 Query特有 */
|
|
27
|
+
QueryFields: {
|
|
28
|
+
conditionCanBlank: boolean, // 是否必填
|
|
29
|
+
customPrompt: string, // 自定义提示语
|
|
30
|
+
enableScanCodeToInput: boolean, // 是否允许扫码输入
|
|
31
|
+
fieldId: string, // 字段ID
|
|
32
|
+
needSecondCheck: boolean, // 电话字段时是否校验号码
|
|
33
|
+
op: "Equals" | "Contains" | "Specified Value" // 匹配方式,参看下面Description
|
|
34
|
+
}[]
|
|
35
|
+
/**背景图片URL Query特有 */
|
|
36
|
+
BackgroundImage: string
|
|
37
|
+
/**标题字段ID Calendar特有 */
|
|
38
|
+
TitleField: string
|
|
39
|
+
|
|
40
|
+
OnCreate(callback: (data: any) => void): { Destroy(): void }
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface Records {
|
|
45
|
+
(Index: number | string): Record
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface RecordRange2 {
|
|
49
|
+
(Index?: number | string | any[], Field?: number | string | any[]): RecordRange
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { Patch }
|
|
54
|
+
}
|