@kengic/uni 0.6.1 → 0.6.2-beta.1

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.
@@ -1 +1 @@
1
- export { GetLatestApkVersion, GetLatestApkVersionQuery } from './GetLatestApkVersion';
1
+ export { GetLatestApkVersion, GetLatestApkVersionQuery } from './GetLatestApkVersion';
@@ -1,28 +1,28 @@
1
- // noinspection ES6UnusedImports
2
-
3
- import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
- import * as DEF from '../../../def';
5
- import { keys } from '../../models';
6
-
7
- /** 请求参数. */
8
- export class LogoutQuery {}
9
-
10
- /**
11
- * 退出登录.
12
- *
13
- * @param config 请求配置.
14
- * @param option 请求选项.
15
- */
16
- export function Logout(config?: IRequestConfig<LogoutQuery, {}>, option?: IRequestOptions): Promise<Record<any, any>> {
17
- return httpClient().request(
18
- {
19
- method: Logout.method,
20
- url: `${option?.mock ? '/mock' : ''}${Logout.url}`,
21
- ...(config ?? {}),
22
- },
23
- option,
24
- );
25
- }
26
-
27
- Logout.method = 'GET' as const;
28
- Logout.url = '/sys/logout';
1
+ // noinspection ES6UnusedImports
2
+
3
+ import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
+ import * as DEF from '../../../def';
5
+ import { keys } from '../../models';
6
+
7
+ /** 请求参数. */
8
+ export class LogoutQuery {}
9
+
10
+ /**
11
+ * 退出登录.
12
+ *
13
+ * @param config 请求配置.
14
+ * @param option 请求选项.
15
+ */
16
+ export function Logout(config?: IRequestConfig<LogoutQuery, {}>, option?: IRequestOptions): Promise<Record<any, any>> {
17
+ return httpClient().request(
18
+ {
19
+ method: Logout.method,
20
+ url: `${option?.mock ? '/mock' : ''}${Logout.url}`,
21
+ ...(config ?? {}),
22
+ },
23
+ option,
24
+ );
25
+ }
26
+
27
+ Logout.method = 'GET' as const;
28
+ Logout.url = '/sys/logout';
@@ -1 +1 @@
1
- export { Logout, LogoutQuery } from './Logout';
1
+ export { Logout, LogoutQuery } from './Logout';
@@ -1,92 +1,92 @@
1
- // noinspection ES6UnusedImports
2
-
3
- import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
- import * as DEF from '../../../def';
5
- import { keys } from '../../models';
6
-
7
- /** 请求参数. */
8
- export class ListVOQuery {
9
- /** 是否可用 */
10
- public activeFlg?: number | null;
11
- /** 地址编号 */
12
- public adrId?: string | null;
13
- /** 地址名 */
14
- public adrnam?: string | null;
15
- /** 公司代码 */
16
- public comCod?: string | null;
17
- /** 默认仓库 */
18
- public defWhFlg?: number | null;
19
- /** 主键. */
20
- public id?: string | null;
21
- /** 所属地/国编号 */
22
- public orgcod?: string | null;
23
- /** 永久调整托盘 */
24
- public permAdjLod?: string | null;
25
- /** 永久调整箱 */
26
- public permAdjSub?: string | null;
27
- /** 永久创建托盘 */
28
- public permCreLod?: string | null;
29
- /** 永久创建箱 */
30
- public permCreSub?: string | null;
31
- /** 仓库名称 */
32
- public whDsc?: string | null;
33
- /** 仓库编号 */
34
- public whId?: string | null;
35
- /** 排序字段. */
36
- public column?: string | null;
37
- /** 排序方式. */
38
- public order?: 'asc' | 'desc' | null;
39
- /** 当前页数. */
40
- public pageNo?: number | null;
41
- /** 每页条数. */
42
- public pageSize?: number | null;
43
-
44
- public constructor(obj?: ListVOQuery) {
45
- keys(obj ?? {}).forEach((key: PropertyKey) => {
46
- switch (key) {
47
- case 'activeFlg':
48
- case 'adrId':
49
- case 'adrnam':
50
- case 'comCod':
51
- case 'defWhFlg':
52
- case 'id':
53
- case 'orgcod':
54
- case 'permAdjLod':
55
- case 'permAdjSub':
56
- case 'permCreLod':
57
- case 'permCreSub':
58
- case 'whDsc':
59
- case 'whId':
60
- case 'column':
61
- case 'order':
62
- case 'pageNo':
63
- case 'pageSize':
64
- Reflect.set(this, key, Reflect.get(obj ?? {}, key));
65
- break;
66
- default:
67
- break;
68
- }
69
- });
70
- }
71
- }
72
-
73
- /**
74
- * wh-分页列表查询VO
75
- wh-分页列表查询VO
76
- *
77
- * @param config 请求配置.
78
- * @param option 请求选项.
79
- */
80
- export function ListVO(config?: IRequestConfig<ListVOQuery, {}>, option?: IRequestOptions): Promise<DEF.WMS.IPage<DEF.WMS.WhDTO>> {
81
- return httpClient().request(
82
- {
83
- method: ListVO.method,
84
- url: `${option?.mock ? '/mock' : ''}${ListVO.url}`,
85
- ...(config ?? {}),
86
- },
87
- option,
88
- );
89
- }
90
-
91
- ListVO.method = 'GET' as const;
92
- ListVO.url = '/wh/wh/listVO';
1
+ // noinspection ES6UnusedImports
2
+
3
+ import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
+ import * as DEF from '../../../def';
5
+ import { keys } from '../../models';
6
+
7
+ /** 请求参数. */
8
+ export class ListVOQuery {
9
+ /** 是否可用 */
10
+ public activeFlg?: number | null;
11
+ /** 地址编号 */
12
+ public adrId?: string | null;
13
+ /** 地址名 */
14
+ public adrnam?: string | null;
15
+ /** 公司代码 */
16
+ public comCod?: string | null;
17
+ /** 默认仓库 */
18
+ public defWhFlg?: number | null;
19
+ /** 主键. */
20
+ public id?: string | null;
21
+ /** 所属地/国编号 */
22
+ public orgcod?: string | null;
23
+ /** 永久调整托盘 */
24
+ public permAdjLod?: string | null;
25
+ /** 永久调整箱 */
26
+ public permAdjSub?: string | null;
27
+ /** 永久创建托盘 */
28
+ public permCreLod?: string | null;
29
+ /** 永久创建箱 */
30
+ public permCreSub?: string | null;
31
+ /** 仓库名称 */
32
+ public whDsc?: string | null;
33
+ /** 仓库编号 */
34
+ public whId?: string | null;
35
+ /** 排序字段. */
36
+ public column?: string | null;
37
+ /** 排序方式. */
38
+ public order?: 'asc' | 'desc' | null;
39
+ /** 当前页数. */
40
+ public pageNo?: number | null;
41
+ /** 每页条数. */
42
+ public pageSize?: number | null;
43
+
44
+ public constructor(obj?: ListVOQuery) {
45
+ keys(obj ?? {}).forEach((key: PropertyKey) => {
46
+ switch (key) {
47
+ case 'activeFlg':
48
+ case 'adrId':
49
+ case 'adrnam':
50
+ case 'comCod':
51
+ case 'defWhFlg':
52
+ case 'id':
53
+ case 'orgcod':
54
+ case 'permAdjLod':
55
+ case 'permAdjSub':
56
+ case 'permCreLod':
57
+ case 'permCreSub':
58
+ case 'whDsc':
59
+ case 'whId':
60
+ case 'column':
61
+ case 'order':
62
+ case 'pageNo':
63
+ case 'pageSize':
64
+ Reflect.set(this, key, Reflect.get(obj ?? {}, key));
65
+ break;
66
+ default:
67
+ break;
68
+ }
69
+ });
70
+ }
71
+ }
72
+
73
+ /**
74
+ * wh-分页列表查询VO
75
+ wh-分页列表查询VO
76
+ *
77
+ * @param config 请求配置.
78
+ * @param option 请求选项.
79
+ */
80
+ export function ListVO(config?: IRequestConfig<ListVOQuery, {}>, option?: IRequestOptions): Promise<DEF.WMS.IPage<DEF.WMS.WhDTO>> {
81
+ return httpClient().request(
82
+ {
83
+ method: ListVO.method,
84
+ url: `${option?.mock ? '/mock' : ''}${ListVO.url}`,
85
+ ...(config ?? {}),
86
+ },
87
+ option,
88
+ );
89
+ }
90
+
91
+ ListVO.method = 'GET' as const;
92
+ ListVO.url = '/wh/wh/listVO';
@@ -1 +1 @@
1
- export { ListVO, ListVOQuery } from './ListVO';
1
+ export { ListVO, ListVOQuery } from './ListVO';
@@ -1,3 +1,3 @@
1
- export * as CommonController from './CommonController';
2
- export * as LoginController from './LoginController';
3
- export * as WhController from './WhController';
1
+ export * as CommonController from './CommonController';
2
+ export * as LoginController from './LoginController';
3
+ export * as WhController from './WhController';
@@ -1,2 +1,2 @@
1
- export * as WMSAPI from './Controllers';
2
- export * as WMSDEF from './models';
1
+ export * as WMSAPI from './Controllers';
2
+ export * as WMSDEF from './models';
@@ -1,192 +1,192 @@
1
- export class IPage<T0> {
2
- /** Current. */
3
- public current?: number | null;
4
- /** Pages. */
5
- public pages?: number | null;
6
- /** Records. */
7
- public records?: Array<T0> | null;
8
- /** Size. */
9
- public size?: number | null;
10
- /** Total. */
11
- public total?: number | null;
12
-
13
- public constructor(obj?: IPage<T0>) {
14
- keys(obj ?? {}).forEach((key: PropertyKey) => {
15
- switch (key) {
16
- case 'current':
17
- case 'pages':
18
- case 'records':
19
- case 'size':
20
- case 'total':
21
- Reflect.set(this, key, Reflect.get(obj ?? {}, key));
22
- break;
23
- default:
24
- break;
25
- }
26
- });
27
- }
28
- }
29
-
30
- /** 用户. */
31
- export class SysUser {
32
- /** Activiti Sync. */
33
- public activitiSync?: number | null;
34
- /** 头像. */
35
- public avatar?: string | null;
36
- /** Birthday. */
37
- public birthday?: string | null;
38
- /** Client Id. */
39
- public clientId?: string | null;
40
- /** Create By. */
41
- public createBy?: string | null;
42
- /** Create Time. */
43
- public createTime?: string | null;
44
- /** Del Flag. */
45
- public delFlag?: number | null;
46
- /** Depart Ids. */
47
- public departIds?: string | null;
48
- /** 邮件. */
49
- public email?: string | null;
50
- /** Home Path. */
51
- public homePath?: string | null;
52
- /** Id. */
53
- public id?: string | null;
54
- /** Org Code. */
55
- public orgCode?: string | null;
56
- /** Org Code Txt. */
57
- public orgCodeTxt?: string | null;
58
- /** Password. */
59
- public password?: string | null;
60
- /** 电话. */
61
- public phone?: string | null;
62
- /** Post. */
63
- public post?: string | null;
64
- /** 姓名. */
65
- public realname?: string | null;
66
- /** Rel Tenant Ids. */
67
- public relTenantIds?: string | null;
68
- /** Salt. */
69
- public salt?: string | null;
70
- /** Sex. */
71
- public sex?: number | null;
72
- /** 状态. */
73
- public status?: number | null;
74
- /** Telephone. */
75
- public telephone?: string | null;
76
- /** Update By. */
77
- public updateBy?: string | null;
78
- /** Update Time. */
79
- public updateTime?: string | null;
80
- /** User Identity. */
81
- public userIdentity?: number | null;
82
- /** 账号. */
83
- public username?: string | null;
84
- /** 工号. */
85
- public workNo?: string | null;
86
-
87
- public constructor(obj?: SysUser) {
88
- keys(obj ?? {}).forEach((key: PropertyKey) => {
89
- switch (key) {
90
- case 'activitiSync':
91
- case 'avatar':
92
- case 'birthday':
93
- case 'clientId':
94
- case 'createBy':
95
- case 'createTime':
96
- case 'delFlag':
97
- case 'departIds':
98
- case 'email':
99
- case 'homePath':
100
- case 'id':
101
- case 'orgCode':
102
- case 'orgCodeTxt':
103
- case 'password':
104
- case 'phone':
105
- case 'post':
106
- case 'realname':
107
- case 'relTenantIds':
108
- case 'salt':
109
- case 'sex':
110
- case 'status':
111
- case 'telephone':
112
- case 'updateBy':
113
- case 'updateTime':
114
- case 'userIdentity':
115
- case 'username':
116
- case 'workNo':
117
- Reflect.set(this, key, Reflect.get(obj ?? {}, key));
118
- break;
119
- default:
120
- break;
121
- }
122
- });
123
- }
124
- }
125
-
126
- /** 仓库数据传输对象 */
127
- export class WhDTO {
128
- /** 是否可用 */
129
- public activeFlg?: number | null;
130
- /** 地址编号 */
131
- public adrId?: string | null;
132
- /** 地址名 */
133
- public adrnam?: string | null;
134
- /** 公司代码 */
135
- public comCod?: string | null;
136
- /** 默认仓库 */
137
- public defWhFlg?: number | null;
138
- /** 主键. */
139
- public id?: string | null;
140
- /** 所属地/国编号 */
141
- public orgcod?: string | null;
142
- /** 永久调整托盘 */
143
- public permAdjLod?: string | null;
144
- /** 永久调整箱 */
145
- public permAdjSub?: string | null;
146
- /** 永久创建托盘 */
147
- public permCreLod?: string | null;
148
- /** 永久创建箱 */
149
- public permCreSub?: string | null;
150
- /** 仓库名称 */
151
- public whDsc?: string | null;
152
- /** 仓库编号 */
153
- public whId?: string | null;
154
-
155
- public constructor(obj?: WhDTO) {
156
- keys(obj ?? {}).forEach((key: PropertyKey) => {
157
- switch (key) {
158
- case 'activeFlg':
159
- case 'adrId':
160
- case 'adrnam':
161
- case 'comCod':
162
- case 'defWhFlg':
163
- case 'id':
164
- case 'orgcod':
165
- case 'permAdjLod':
166
- case 'permAdjSub':
167
- case 'permCreLod':
168
- case 'permCreSub':
169
- case 'whDsc':
170
- case 'whId':
171
- Reflect.set(this, key, Reflect.get(obj ?? {}, key));
172
- break;
173
- default:
174
- break;
175
- }
176
- });
177
- }
178
- }
179
-
180
- /**
181
- * 获取对象的属性名数组.
182
- * @param obj 对象.
183
- */
184
- export function keys<C extends object>(obj: C): Array<keyof C> {
185
- const type = typeof obj;
186
-
187
- if (!(obj != null && (type === 'object' || type === 'function'))) {
188
- return [];
189
- }
190
-
191
- return Reflect.ownKeys(obj) as Array<keyof C>;
192
- }
1
+ export class IPage<T0> {
2
+ /** Current. */
3
+ public current?: number | null;
4
+ /** Pages. */
5
+ public pages?: number | null;
6
+ /** Records. */
7
+ public records?: Array<T0> | null;
8
+ /** Size. */
9
+ public size?: number | null;
10
+ /** Total. */
11
+ public total?: number | null;
12
+
13
+ public constructor(obj?: IPage<T0>) {
14
+ keys(obj ?? {}).forEach((key: PropertyKey) => {
15
+ switch (key) {
16
+ case 'current':
17
+ case 'pages':
18
+ case 'records':
19
+ case 'size':
20
+ case 'total':
21
+ Reflect.set(this, key, Reflect.get(obj ?? {}, key));
22
+ break;
23
+ default:
24
+ break;
25
+ }
26
+ });
27
+ }
28
+ }
29
+
30
+ /** 用户. */
31
+ export class SysUser {
32
+ /** Activiti Sync. */
33
+ public activitiSync?: number | null;
34
+ /** 头像. */
35
+ public avatar?: string | null;
36
+ /** Birthday. */
37
+ public birthday?: string | null;
38
+ /** Client Id. */
39
+ public clientId?: string | null;
40
+ /** Create By. */
41
+ public createBy?: string | null;
42
+ /** Create Time. */
43
+ public createTime?: string | null;
44
+ /** Del Flag. */
45
+ public delFlag?: number | null;
46
+ /** Depart Ids. */
47
+ public departIds?: string | null;
48
+ /** 邮件. */
49
+ public email?: string | null;
50
+ /** Home Path. */
51
+ public homePath?: string | null;
52
+ /** Id. */
53
+ public id?: string | null;
54
+ /** Org Code. */
55
+ public orgCode?: string | null;
56
+ /** Org Code Txt. */
57
+ public orgCodeTxt?: string | null;
58
+ /** Password. */
59
+ public password?: string | null;
60
+ /** 电话. */
61
+ public phone?: string | null;
62
+ /** Post. */
63
+ public post?: string | null;
64
+ /** 姓名. */
65
+ public realname?: string | null;
66
+ /** Rel Tenant Ids. */
67
+ public relTenantIds?: string | null;
68
+ /** Salt. */
69
+ public salt?: string | null;
70
+ /** Sex. */
71
+ public sex?: number | null;
72
+ /** 状态. */
73
+ public status?: number | null;
74
+ /** Telephone. */
75
+ public telephone?: string | null;
76
+ /** Update By. */
77
+ public updateBy?: string | null;
78
+ /** Update Time. */
79
+ public updateTime?: string | null;
80
+ /** User Identity. */
81
+ public userIdentity?: number | null;
82
+ /** 账号. */
83
+ public username?: string | null;
84
+ /** 工号. */
85
+ public workNo?: string | null;
86
+
87
+ public constructor(obj?: SysUser) {
88
+ keys(obj ?? {}).forEach((key: PropertyKey) => {
89
+ switch (key) {
90
+ case 'activitiSync':
91
+ case 'avatar':
92
+ case 'birthday':
93
+ case 'clientId':
94
+ case 'createBy':
95
+ case 'createTime':
96
+ case 'delFlag':
97
+ case 'departIds':
98
+ case 'email':
99
+ case 'homePath':
100
+ case 'id':
101
+ case 'orgCode':
102
+ case 'orgCodeTxt':
103
+ case 'password':
104
+ case 'phone':
105
+ case 'post':
106
+ case 'realname':
107
+ case 'relTenantIds':
108
+ case 'salt':
109
+ case 'sex':
110
+ case 'status':
111
+ case 'telephone':
112
+ case 'updateBy':
113
+ case 'updateTime':
114
+ case 'userIdentity':
115
+ case 'username':
116
+ case 'workNo':
117
+ Reflect.set(this, key, Reflect.get(obj ?? {}, key));
118
+ break;
119
+ default:
120
+ break;
121
+ }
122
+ });
123
+ }
124
+ }
125
+
126
+ /** 仓库数据传输对象 */
127
+ export class WhDTO {
128
+ /** 是否可用 */
129
+ public activeFlg?: number | null;
130
+ /** 地址编号 */
131
+ public adrId?: string | null;
132
+ /** 地址名 */
133
+ public adrnam?: string | null;
134
+ /** 公司代码 */
135
+ public comCod?: string | null;
136
+ /** 默认仓库 */
137
+ public defWhFlg?: number | null;
138
+ /** 主键. */
139
+ public id?: string | null;
140
+ /** 所属地/国编号 */
141
+ public orgcod?: string | null;
142
+ /** 永久调整托盘 */
143
+ public permAdjLod?: string | null;
144
+ /** 永久调整箱 */
145
+ public permAdjSub?: string | null;
146
+ /** 永久创建托盘 */
147
+ public permCreLod?: string | null;
148
+ /** 永久创建箱 */
149
+ public permCreSub?: string | null;
150
+ /** 仓库名称 */
151
+ public whDsc?: string | null;
152
+ /** 仓库编号 */
153
+ public whId?: string | null;
154
+
155
+ public constructor(obj?: WhDTO) {
156
+ keys(obj ?? {}).forEach((key: PropertyKey) => {
157
+ switch (key) {
158
+ case 'activeFlg':
159
+ case 'adrId':
160
+ case 'adrnam':
161
+ case 'comCod':
162
+ case 'defWhFlg':
163
+ case 'id':
164
+ case 'orgcod':
165
+ case 'permAdjLod':
166
+ case 'permAdjSub':
167
+ case 'permCreLod':
168
+ case 'permCreSub':
169
+ case 'whDsc':
170
+ case 'whId':
171
+ Reflect.set(this, key, Reflect.get(obj ?? {}, key));
172
+ break;
173
+ default:
174
+ break;
175
+ }
176
+ });
177
+ }
178
+ }
179
+
180
+ /**
181
+ * 获取对象的属性名数组.
182
+ * @param obj 对象.
183
+ */
184
+ export function keys<C extends object>(obj: C): Array<keyof C> {
185
+ const type = typeof obj;
186
+
187
+ if (!(obj != null && (type === 'object' || type === 'function'))) {
188
+ return [];
189
+ }
190
+
191
+ return Reflect.ownKeys(obj) as Array<keyof C>;
192
+ }
package/dist/api/api.ts CHANGED
@@ -1 +1 @@
1
- export { WMSAPI as WMS } from './WMS';
1
+ export { WMSAPI as WMS } from './WMS';
package/dist/api/def.ts CHANGED
@@ -1 +1 @@
1
- export { WMSDEF as WMS } from './WMS';
1
+ export { WMSDEF as WMS } from './WMS';
package/dist/api/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * as API from './api';
2
- export * as DEF from './def';
1
+ export * as API from './api';
2
+ export * as DEF from './def';
@@ -9,7 +9,7 @@ export interface IKgWarehouseState {
9
9
  warehouse: WhDTO | null;
10
10
  }
11
11
 
12
- export type IKgWarehouseStoreDefinition = StoreDefinition<
12
+ export type IUseKgWarehouseStore = StoreDefinition<
13
13
  'KgWarehouse',
14
14
  IKgWarehouseState,
15
15
  {
@@ -20,7 +20,7 @@ export type IKgWarehouseStoreDefinition = StoreDefinition<
20
20
  }
21
21
  >;
22
22
 
23
- export type IKgWarehouseStore = ReturnType<IKgWarehouseStoreDefinition>;
23
+ export type IKgWarehouseStore = ReturnType<IUseKgWarehouseStore>;
24
24
 
25
25
  export const useKgWarehouseStore = defineStore('KgWarehouse', {
26
26
  state: (): IKgWarehouseState => ({
@@ -8,3 +8,5 @@ const STORAGE_KEYS = {
8
8
  };
9
9
 
10
10
  export { STORAGE_KEYS };
11
+
12
+ export * from './index.vm';
@@ -0,0 +1,69 @@
1
+ /** 高级查询的操作符. */
2
+ export enum KG_DYNAMIC_QUERY_OPERATOR {
3
+ /** 等于. */
4
+ EQ = 'EQ',
5
+
6
+ /** 不等于. */
7
+ NE = 'NE',
8
+
9
+ /** 大于. */
10
+ GT = 'GT',
11
+
12
+ /** 小于. */
13
+ LT = 'LT',
14
+
15
+ /** 大于等于. */
16
+ GTE = 'GTE',
17
+
18
+ /** 小于等于. */
19
+ LTE = 'LTE',
20
+
21
+ /** 以之开始. */
22
+ START_WITH = 'START',
23
+
24
+ /** 以之结束. */
25
+ END_WITH = 'END',
26
+
27
+ /** 包含. */
28
+ CONTAIN = 'CONTAIN',
29
+
30
+ /** 属于. */
31
+ IN = 'IN',
32
+
33
+ /** 范围之内. */
34
+ BETWEEN = 'BETWEEN',
35
+ }
36
+
37
+ /** 请求头部. */
38
+ export enum KG_HTTP_HEADERS {
39
+ /** 界面标识. */
40
+ KG_FORM_ID = 'Kg-Form-Id',
41
+
42
+ KG_BUTTON_VAR_NAME = 'Kg-Button-Var-Name',
43
+
44
+ /** 是否启用高级查询. */
45
+ KG_IS_DYNAMIC_QUERY = 'Kg-Is-Dynamic-Query',
46
+
47
+ /** 查询语句中的 WHERE 片段. */
48
+ KG_QUERY_WHERE_SQL = 'Kg-Query-Where-Sql',
49
+
50
+ /** 查询语句中的 ORDER BY 片段. */
51
+ KG_QUERY_ORDER_BY_SQL = 'Kg-Query-Order-By-Sql',
52
+
53
+ /** 查询语句中的 OFFSET 片段. */
54
+ KG_QUERY_OFFSET_SQL = 'Kg-Query-Offset-Sql',
55
+
56
+ /** 查询语句中的 WHERE + ORDER BY + OFFSET 片段. */
57
+ KG_QUERY_SQL = 'Kg-Query-Sql',
58
+
59
+ /**
60
+ * <p>高级查询时, 每个查询字段的操作符(=,>,<...).</p>
61
+ * <p>是一个 JSON 字符串, 由后端进行解析. 其中的 key 表示查询字段的名称, 其中的 value 表示查询字段的操作符.</p>
62
+ */
63
+ KG_QUERY_OPERATOR = 'Kg-Query-Operator',
64
+
65
+ /**
66
+ * 仓库编号.
67
+ */
68
+ KG_WAREHOUSE = 'Kg-Warehouse',
69
+ }
@@ -1,5 +1,7 @@
1
1
  import { useAppStore } from '../store/app.store';
2
2
  import { Kg } from '../util';
3
+ import { KG_DYNAMIC_QUERY_OPERATOR, KG_HTTP_HEADERS } from '../const';
4
+ import { useKgWarehouse } from '../component/KgWarehouse/index.hooks';
3
5
 
4
6
  /*
5
7
  * 对请求做统一的拦截.
@@ -50,18 +52,30 @@ type IHttpClient = {
50
52
 
51
53
  /** 请求配置. */
52
54
  type IRequestOptions = Omit<UniApp.RequestOptions, 'url'> & {
55
+ /**
56
+ * 不放入 WHERE SQL 中的参数.
57
+ */
58
+ dynamicQueryExcludeProperties?: Array<string>;
59
+
60
+ /**
61
+ * 如果该参数不为空, 表示该请求启用了高级查询, 该参数包含各个字段的高级查询操作符.
62
+ */
63
+ dynamicQueryOperatorModel?: Record<string, KG_DYNAMIC_QUERY_OPERATOR>;
64
+
53
65
  /** 是否不显示错误消息提示. */
54
- suppressError?: boolean;
66
+ isSuppressError?: boolean;
67
+
55
68
  /** 是否处理请求结果. */
56
69
  isTransformResponse?: boolean;
70
+
57
71
  /** 是否使用模拟数据. */
58
72
  mock?: boolean;
59
73
  };
60
74
 
61
75
  /** 请求参数. */
62
- interface IRequestConfig<TQ = {}, TB = {}> {
63
- params?: TQ;
64
- data?: TB;
76
+ interface IRequestConfig<T1 = {}, T2 = {}> {
77
+ params?: T1;
78
+ data?: T2;
65
79
  }
66
80
 
67
81
  /**
@@ -91,20 +105,20 @@ function handleSuccess<T = any>(
91
105
  * @param response
92
106
  * @param resolve
93
107
  * @param reject
94
- * @param suppressError 是否不显示错误消息提示.
108
+ * @param isSuppressError 是否不显示错误消息提示.
95
109
  */
96
110
  function handleError<T = any>(
97
111
  response: UniApp.RequestSuccessCallbackResult,
98
112
  resolve: (value: T | PromiseLike<T>) => void,
99
113
  reject: (reason?: any) => void,
100
- suppressError: boolean,
114
+ isSuppressError: boolean,
101
115
  ) {
102
116
  // @ts-ignore
103
117
  if (response.errMsg === 'request:fail') {
104
118
  return;
105
119
  }
106
120
 
107
- if (!suppressError) {
121
+ if (!isSuppressError) {
108
122
  // @ts-ignore
109
123
  const message = (response.data as any)?.message || response?.errMsg || '请求出错';
110
124
  uni.showToast({ title: message, icon: 'none', duration: 3000 });
@@ -124,10 +138,12 @@ const _httpClient: IHttpClient = {
124
138
  options?: IRequestOptions,
125
139
  ) {
126
140
  const { method, url, params, data } = config;
141
+
127
142
  return new Promise<T>((resolve, reject) => {
143
+ let _url = url;
144
+
128
145
  // 对于 POST 请求, uni.request() 会统一将参数放到 body 参数里面而不是 query 参数里面,
129
146
  // 因此如果 POST 请求包含 query 参数, 需要手动拼接到 url 后面.
130
- let _url = url;
131
147
  if (['POST', 'PUT', 'DELETE'].includes(method) && params) {
132
148
  try {
133
149
  const queryString = Object.keys(params)
@@ -142,11 +158,73 @@ const _httpClient: IHttpClient = {
142
158
  }
143
159
  }
144
160
 
161
+ let header: any = options?.header;
162
+
163
+ if (!header) {
164
+ header = {};
165
+ }
166
+
167
+ const KG_IS_DYNAMIC_QUERY = KG_HTTP_HEADERS.KG_IS_DYNAMIC_QUERY;
168
+ const KG_QUERY_WHERE_SQL = KG_HTTP_HEADERS.KG_QUERY_WHERE_SQL;
169
+ const KG_QUERY_ORDER_BY_SQL = KG_HTTP_HEADERS.KG_QUERY_ORDER_BY_SQL;
170
+ const KG_QUERY_OFFSET_SQL = KG_HTTP_HEADERS.KG_QUERY_OFFSET_SQL;
171
+ const KG_QUERY_SQL = KG_HTTP_HEADERS.KG_QUERY_SQL;
172
+ const KG_QUERY_OPERATOR = KG_HTTP_HEADERS.KG_QUERY_OPERATOR;
173
+
174
+ // 启用高级查询
175
+ if (options?.dynamicQueryOperatorModel) {
176
+ let params: any = {};
177
+
178
+ if (config.method === 'GET') {
179
+ params = config.params;
180
+ } else if (config.method === 'POST' && !config.data && config.params) {
181
+ params = config.params;
182
+ } else if (config.method === 'POST' && config.data) {
183
+ params = config.data;
184
+ }
185
+
186
+ const { sql, whereSql, orderBySql, offsetSql, operatorJSON } = Kg.getQueryHeaders({
187
+ dynamicQueryExcludeProperties: options?.dynamicQueryExcludeProperties,
188
+ dynamicQueryOperatorModel: options?.dynamicQueryOperatorModel,
189
+ params: params,
190
+ });
191
+
192
+ header = {
193
+ ...(header ?? {}),
194
+ [KG_IS_DYNAMIC_QUERY]: true,
195
+ [KG_QUERY_OFFSET_SQL]: offsetSql,
196
+ [KG_QUERY_OPERATOR]: operatorJSON,
197
+ [KG_QUERY_ORDER_BY_SQL]: orderBySql,
198
+ [KG_QUERY_SQL]: sql,
199
+ [KG_QUERY_WHERE_SQL]: whereSql,
200
+ };
201
+ }
202
+
203
+ if (header[KG_QUERY_WHERE_SQL]) {
204
+ header[KG_QUERY_WHERE_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG_QUERY_WHERE_SQL])));
205
+ }
206
+
207
+ if (header[KG_QUERY_ORDER_BY_SQL]) {
208
+ header[KG_QUERY_ORDER_BY_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG_QUERY_ORDER_BY_SQL])));
209
+ }
210
+
211
+ if (header[KG_QUERY_OFFSET_SQL]) {
212
+ header[KG_QUERY_OFFSET_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG_QUERY_OFFSET_SQL])));
213
+ }
214
+
215
+ if (header[KG_QUERY_SQL]) {
216
+ header[KG_QUERY_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG_QUERY_SQL])));
217
+ }
218
+
219
+ // 仓库编号
220
+ const warehouseId = useKgWarehouse().warehouse.value?.whId ?? '';
221
+ header[KG_HTTP_HEADERS.KG_WAREHOUSE] = encodeURIComponent(warehouseId);
222
+
145
223
  uni.request({
146
224
  ...(options ?? {}),
147
- method,
225
+ method: method,
148
226
  url: _url,
149
- header: options?.header ?? {},
227
+ header: header,
150
228
  data: { ...(params ?? {}), ...(data ?? {}) },
151
229
  success(response) {
152
230
  switch (response.statusCode) {
@@ -167,11 +245,11 @@ const _httpClient: IHttpClient = {
167
245
 
168
246
  case 405:
169
247
  response.data.message = `${response.data.code}: ${response.data.message}`;
170
- handleError<T>(response, resolve, reject, options?.suppressError ?? false);
248
+ handleError<T>(response, resolve, reject, options?.isSuppressError ?? false);
171
249
  break;
172
250
 
173
251
  case 500:
174
- handleError<T>(response, resolve, reject, options?.suppressError ?? false);
252
+ handleError<T>(response, resolve, reject, options?.isSuppressError ?? false);
175
253
  break;
176
254
  }
177
255
  }
@@ -189,12 +267,12 @@ const _httpClient: IHttpClient = {
189
267
  break;
190
268
 
191
269
  default:
192
- handleError<T>(response, resolve, reject, options?.suppressError ?? false);
270
+ handleError<T>(response, resolve, reject, options?.isSuppressError ?? false);
193
271
  break;
194
272
  }
195
273
  },
196
274
  fail(err) {
197
- handleError<T>(err as any, resolve, reject, options?.suppressError ?? false);
275
+ handleError<T>(err as any, resolve, reject, options?.isSuppressError ?? false);
198
276
  },
199
277
  });
200
278
  });
package/dist/util/kg.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { isArray, isObjectLike } from 'lodash-es';
1
+ import { cloneDeep, isArray, isNil, isObjectLike, reduce } from 'lodash-es';
2
2
  import { toRaw, unref } from 'vue';
3
3
  import { API } from '../api';
4
4
  import { useKgWarehouse } from '../component';
5
5
  import { useAppStore } from '../store/app.store';
6
+ import { KG_DYNAMIC_QUERY_OPERATOR } from '../const';
6
7
 
7
8
  /**
8
9
  * 通用工具.
@@ -159,4 +160,273 @@ export class Kg {
159
160
  return value;
160
161
  }
161
162
  }
163
+
164
+ /**
165
+ * <p>获取根据查询条件拼接后的 SQL 语句片段.</p>
166
+ *
167
+ * @param param.dynamicQueryExcludeProperties 各个字段的高级查询操作符.
168
+ * @param param.dynamicQueryOperatorModel 各个字段的高级查询操作符.
169
+ * @param param.params 请求参数.
170
+ */
171
+ public static getQueryHeaders(param: {
172
+ dynamicQueryExcludeProperties: Array<string> | null | undefined;
173
+ dynamicQueryOperatorModel: Record<string, any> | null | undefined;
174
+ params: Record<string, any> | null | undefined;
175
+ }) {
176
+ const { params, dynamicQueryExcludeProperties, dynamicQueryOperatorModel } = param ?? {};
177
+
178
+ let _params = cloneDeep(toRaw(unref(params ?? {})));
179
+
180
+ // 参数不是一个对象,
181
+ if (!_params || !isObjectLike(_params)) {
182
+ return { offsetSql: '', operatorJSON: '', orderBySql: '', sql: '', whereSql: '' };
183
+ }
184
+
185
+ // 特殊字段, 这些特殊字段的值不做处理, 保持原样
186
+ const SPECIAL_FIELD_KEYS = ['pageNo', 'pageSize', 'column', 'order'];
187
+
188
+ const _paramsForWhereSql: Record<string, any> = {};
189
+ Object.keys(_params)
190
+ .sort()
191
+ .forEach((key) => {
192
+ // 特殊字段, 不放进 WHERE SQL 中
193
+ if (SPECIAL_FIELD_KEYS.includes(key)) {
194
+ return;
195
+ }
196
+
197
+ // 要排除的字段, 不放进 WHERE SQL 中
198
+ if (dynamicQueryExcludeProperties?.includes(key)) {
199
+ return;
200
+ }
201
+
202
+ // 辅助属性, 用于业务逻辑, 不放进 WHERE SQL 中,
203
+ if (key.endsWith('_obj')) {
204
+ return;
205
+ }
206
+
207
+ let _key = key;
208
+ const value = _params[key];
209
+ let operator: string = dynamicQueryOperatorModel?.[key] ?? KG_DYNAMIC_QUERY_OPERATOR.EQ;
210
+
211
+ switch (true) {
212
+ // array
213
+ case Array.isArray(value): {
214
+ if (value.length === 0) {
215
+ _paramsForWhereSql[key] = undefined;
216
+ break;
217
+ }
218
+
219
+ const _value = value.map((i: any) => `N'${String(i)}'`).join(', ');
220
+
221
+ _paramsForWhereSql[key] = ` AND (${_key} IN (${_value}))`;
222
+ break;
223
+ }
224
+
225
+ // object
226
+ case isObjectLike(value): {
227
+ throw new Error('不支持的参数类型.');
228
+ }
229
+
230
+ // string
231
+ case typeof value === 'string': {
232
+ // 空白字符
233
+ if (value.trim() === '') {
234
+ _paramsForWhereSql[key] = undefined;
235
+ break;
236
+ }
237
+
238
+ let _strValue = value;
239
+
240
+ switch (operator) {
241
+ case KG_DYNAMIC_QUERY_OPERATOR.NE: {
242
+ _strValue = ` AND (${_key} <> N'${_strValue}')`;
243
+ break;
244
+ }
245
+
246
+ case KG_DYNAMIC_QUERY_OPERATOR.START_WITH: {
247
+ _strValue = ` AND (${_key} LIKE N'${_strValue}%')`;
248
+ break;
249
+ }
250
+
251
+ case KG_DYNAMIC_QUERY_OPERATOR.END_WITH: {
252
+ _strValue = ` AND (${_key} LIKE N'%${_strValue}')`;
253
+ break;
254
+ }
255
+
256
+ case KG_DYNAMIC_QUERY_OPERATOR.CONTAIN: {
257
+ _strValue = ` AND (${_key} LIKE N'%${_strValue}%')`;
258
+ break;
259
+ }
260
+
261
+ case KG_DYNAMIC_QUERY_OPERATOR.EQ:
262
+ default: {
263
+ _strValue = ` AND (${_key} = N'${_strValue}')`;
264
+ break;
265
+ }
266
+ }
267
+
268
+ _paramsForWhereSql[key] = _strValue;
269
+
270
+ break;
271
+ }
272
+
273
+ // number
274
+ case typeof value === 'number': {
275
+ let _strValue = '';
276
+
277
+ switch (operator) {
278
+ case KG_DYNAMIC_QUERY_OPERATOR.NE: {
279
+ _strValue = ` AND (${_key} <> ${value})`;
280
+ break;
281
+ }
282
+
283
+ case KG_DYNAMIC_QUERY_OPERATOR.LT: {
284
+ _strValue = ` AND (${_key} < ${value})`;
285
+ break;
286
+ }
287
+
288
+ case KG_DYNAMIC_QUERY_OPERATOR.LTE: {
289
+ _strValue = ` AND (${_key} <= ${value})`;
290
+ break;
291
+ }
292
+
293
+ case KG_DYNAMIC_QUERY_OPERATOR.GT: {
294
+ _strValue = ` AND (${_key} > ${value})`;
295
+ break;
296
+ }
297
+
298
+ case KG_DYNAMIC_QUERY_OPERATOR.GTE: {
299
+ _strValue = ` AND (${_key} >= ${value})`;
300
+ break;
301
+ }
302
+
303
+ case KG_DYNAMIC_QUERY_OPERATOR.EQ:
304
+ default: {
305
+ _strValue = ` AND (${_key} = ${value})`;
306
+ break;
307
+ }
308
+ }
309
+
310
+ _paramsForWhereSql[key] = _strValue;
311
+
312
+ break;
313
+ }
314
+
315
+ // boolean
316
+ case typeof value === 'boolean': {
317
+ let _strValue = '';
318
+
319
+ switch (operator) {
320
+ case KG_DYNAMIC_QUERY_OPERATOR.NE: {
321
+ _strValue = ` AND (${_key} <> ${value ? 1 : 0})`;
322
+ break;
323
+ }
324
+
325
+ case KG_DYNAMIC_QUERY_OPERATOR.EQ:
326
+ default: {
327
+ _strValue = ` AND (${_key} = ${value ? 1 : 0})`;
328
+ break;
329
+ }
330
+ }
331
+
332
+ _paramsForWhereSql[key] = _strValue;
333
+
334
+ break;
335
+ }
336
+
337
+ // null, undefined
338
+ default: {
339
+ _paramsForWhereSql[key] = value;
340
+
341
+ break;
342
+ }
343
+ }
344
+ });
345
+
346
+ const whereSqlSegment = reduce(
347
+ _paramsForWhereSql,
348
+ (sql, value) => {
349
+ if (!value) {
350
+ return sql;
351
+ }
352
+
353
+ return sql + value;
354
+ },
355
+ '',
356
+ );
357
+
358
+ //region WHERE
359
+ // ----------------------------------------------------------------------------------------------------
360
+ let whereSql = `WHERE (1 = 1)${whereSqlSegment}`;
361
+ whereSql = encodeURIComponent(whereSql);
362
+ //endregion
363
+
364
+ //region ORDER BY
365
+ // ----------------------------------------------------------------------------------------------------
366
+ let orderBySql = '';
367
+
368
+ {
369
+ let _column = _params.column;
370
+
371
+ if (_column) {
372
+ orderBySql = `ORDER BY ${_column}`;
373
+
374
+ if (_params.order === 'asc') {
375
+ orderBySql += ' ASC';
376
+ } else if (_params.order === 'desc') {
377
+ orderBySql += ' DESC';
378
+ }
379
+
380
+ orderBySql = encodeURIComponent(orderBySql.trim());
381
+ }
382
+ }
383
+ //endregion
384
+
385
+ //region OFFSET
386
+ // ----------------------------------------------------------------------------------------------------
387
+ let offsetSql = '';
388
+
389
+ // 分页
390
+ if (!isNil(_params.pageNo)) {
391
+ const pageIndex = Number.parseInt(_params.pageNo);
392
+ if (Number.isNaN(pageIndex) || pageIndex <= 0) {
393
+ throw new Error('参数 pageNo 非法.');
394
+ }
395
+
396
+ const pageSize = Number.parseInt(_params.pageSize);
397
+ if (Number.isNaN(pageSize) || pageSize <= 0) {
398
+ throw new Error('参数 pageSize 非法.');
399
+ }
400
+
401
+ offsetSql = ` OFFSET ${(pageIndex - 1) * pageSize} ROWS FETCH NEXT ${pageSize} ROWS ONLY`;
402
+ }
403
+ //endregion
404
+
405
+ return {
406
+ /**
407
+ * OFFSET.
408
+ */
409
+ offsetSql: offsetSql,
410
+
411
+ /**
412
+ * 查询操作符的 JSON 字符串.
413
+ */
414
+ operatorJSON: JSON.stringify(dynamicQueryOperatorModel ?? {}),
415
+
416
+ /**
417
+ * ORDER BY.
418
+ */
419
+ orderBySql: orderBySql,
420
+
421
+ /**
422
+ * WHERE + ORDRE BY + OFFSET.
423
+ */
424
+ sql: `${whereSql} ${orderBySql}${offsetSql}`.trim(),
425
+
426
+ /**
427
+ * WHERE .
428
+ */
429
+ whereSql: whereSql,
430
+ };
431
+ }
162
432
  }
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@kengic/uni",
3
- "version": "0.6.1",
3
+ "version": "0.6.2-beta.1",
4
4
  "scripts": {
5
5
  "build": "npm run switch-node-version && rimraf dist && vue-tsc && vite build",
6
6
  "------ -------------------------------------------": "",
7
- "publish:all:beta": "npm run bump-version:beta && npm run publish:all",
8
- "publish:all:patch": "npm run bump-version:patch && npm run publish:all",
9
- "publish:all:minor": "npm run bump-version:minor && npm run publish:all",
10
7
  "publish:all:major": "npm run bump-version:major && npm run publish:all",
8
+ "publish:all:minor": "npm run bump-version:minor && npm run publish:all",
9
+ "publish:all:patch": "npm run bump-version:patch && npm run publish:all",
10
+ "publish:all:beta": "npm run bump-version:beta && npm run publish:all",
11
11
  "--------------------------------------------------": "",
12
12
  "gen:apis:WMS": "npm run switch-node-version && kengic-pont generate-apis --config kg.config.ts --origin WMS",
13
13
  "- ------------------------------------------------": "",
14
- "bump-to:luotao.wms-pda--dev-1.0": "npm run switch-node-version && node scripts/bump-to.luotao.wms-pda--dev-1.0.mjs --experimental-default-type=module",
15
14
  "copy-to:luotao.wms-pda--dev-1.0": "npm run build && node scripts/copy-to.luotao.wms-pda--dev-1.0.mjs --experimental-default-type=module",
16
- "bump-to:luotao.wms-pda--focus": "npm run switch-node-version && node scripts/bump-to.luotao.wms-pda--focus.mjs --experimental-default-type=module",
17
15
  "copy-to:luotao.wms-pda--focus": "npm run build && node scripts/copy-to.luotao.wms-pda--focus.mjs --experimental-default-type=module",
16
+ "bump-to:luotao.wms-pda--dev-1.0": "npm run switch-node-version && node scripts/bump-to.luotao.wms-pda--dev-1.0.mjs --experimental-default-type=module",
17
+ "bump-to:luotao.wms-pda--focus": "npm run switch-node-version && node scripts/bump-to.luotao.wms-pda--focus.mjs --experimental-default-type=module",
18
18
  "-- -----------------------------------------------": "",
19
- "cnpm:sync": "cnpm sync @kengic/uni",
19
+ "cnpm:sync": "npx cnpm --yes sync @kengic/uni",
20
20
  "--- ----------------------------------------------": "",
21
21
  "switch-node-version": "nvm use 20.11.0 && corepack enable && corepack prepare pnpm@7.30.5 --activate",
22
22
  "---- ---------------------------------------------": "",