aldehyde 0.2.319 → 0.2.321

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.
Files changed (47) hide show
  1. package/lib/controls/direct-file-view/index.d.ts.map +1 -1
  2. package/lib/controls/direct-file-view/index.js +8 -4
  3. package/lib/controls/direct-file-view/index.js.map +1 -1
  4. package/lib/controls/entity-select/entity-select.js +1 -1
  5. package/lib/controls/entity-select/entity-select.js.map +1 -1
  6. package/lib/controls/entity-select/popover-entity-select.d.ts.map +1 -1
  7. package/lib/controls/entity-select/popover-entity-select.js +5 -3
  8. package/lib/controls/entity-select/popover-entity-select.js.map +1 -1
  9. package/lib/controls/relation-existion/index.d.ts.map +1 -1
  10. package/lib/controls/relation-existion/index.js +1 -1
  11. package/lib/controls/relation-existion/index.js.map +1 -1
  12. package/lib/form/criteria-form.d.ts.map +1 -1
  13. package/lib/form/criteria-form.js +3 -2
  14. package/lib/form/criteria-form.js.map +1 -1
  15. package/lib/table/relation-table.d.ts.map +1 -1
  16. package/lib/table/relation-table.js +8 -1
  17. package/lib/table/relation-table.js.map +1 -1
  18. package/lib/table/select-table.d.ts +16 -2
  19. package/lib/table/select-table.d.ts.map +1 -1
  20. package/lib/table/select-table.js +102 -29
  21. package/lib/table/select-table.js.map +1 -1
  22. package/lib/tmpl/control-type-supportor.d.ts.map +1 -1
  23. package/lib/tmpl/control-type-supportor.js +2 -0
  24. package/lib/tmpl/control-type-supportor.js.map +1 -1
  25. package/lib/tmpl/interface.d.ts +1 -0
  26. package/lib/tmpl/interface.d.ts.map +1 -1
  27. package/lib/tmpl/interface.js.map +1 -1
  28. package/lib/tree/tree-utils.d.ts +1 -1
  29. package/lib/tree/tree-utils.d.ts.map +1 -1
  30. package/lib/tree/tree-utils.js +5 -4
  31. package/lib/tree/tree-utils.js.map +1 -1
  32. package/lib/units/index.d.ts +1 -1
  33. package/lib/units/index.d.ts.map +1 -1
  34. package/lib/units/index.js +32 -13
  35. package/lib/units/index.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/aldehyde/controls/direct-file-view/index.tsx +8 -2
  38. package/src/aldehyde/controls/entity-select/entity-select.tsx +1 -1
  39. package/src/aldehyde/controls/entity-select/popover-entity-select.tsx +15 -11
  40. package/src/aldehyde/controls/relation-existion/index.tsx +4 -2
  41. package/src/aldehyde/form/criteria-form.tsx +110 -109
  42. package/src/aldehyde/table/relation-table.tsx +134 -127
  43. package/src/aldehyde/table/select-table.tsx +221 -79
  44. package/src/aldehyde/tmpl/control-type-supportor.tsx +2 -0
  45. package/src/aldehyde/tmpl/interface.tsx +3 -2
  46. package/src/aldehyde/tree/tree-utils.tsx +84 -83
  47. package/src/aldehyde/units/index.tsx +25 -9
@@ -1,60 +1,60 @@
1
1
  import React from "react";
2
- import {DataNode} from "antd/es/tree";
3
- import {HydrocarbonService} from "../index";
4
- import {DtmplData, LtmplConfig, LtmplConfigRes, TtmplConfig} from "../tmpl/interface";
2
+ import { DataNode } from "antd/es/tree";
3
+ import { HydrocarbonService } from "../index";
4
+ import { DtmplData, LtmplConfig, LtmplConfigRes, TtmplConfig } from "../tmpl/interface";
5
5
  import HCDataSource from "../tmpl/hc-data-source";
6
6
 
7
- export interface TtmplNodeConfig extends TtmplConfig{
8
- leafTitleId?:string,
9
- branchTitleId?:string,
10
- rootTitleId?:string,
11
- rootLTmplConfig?:LtmplConfig,
12
- branchLTmplConfig?:LtmplConfig,
13
- leafLTmplConfig?:LtmplConfig,
7
+ export interface TtmplNodeConfig extends TtmplConfig {
8
+ leafTitleId?: string,
9
+ branchTitleId?: string,
10
+ rootTitleId?: string,
11
+ rootLTmplConfig?: LtmplConfig,
12
+ branchLTmplConfig?: LtmplConfig,
13
+ leafLTmplConfig?: LtmplConfig,
14
14
 
15
15
  }
16
16
 
17
- export interface TreeDataNode extends DataNode{
18
- parent:TreeDataNode,
19
- code:string,
20
- name:string,
21
- avatar:any,
22
- level:number,
23
- children:any,
17
+ export interface TreeDataNode extends DataNode {
18
+ parent: TreeDataNode,
19
+ code: string,
20
+ name: string,
21
+ avatar: any,
22
+ level: number,
23
+ children: any,
24
24
  }
25
25
 
26
26
  export default class TreeUtils {
27
27
 
28
28
  static initTtmplNodeConfig = async (config: TtmplConfig) => {
29
29
 
30
- if(!config){
30
+ if (!config) {
31
31
  return null;
32
32
  }
33
- let ttmplNodeConfig:TtmplNodeConfig={...config}
34
- if(ttmplNodeConfig.rootGtmplId){
35
- let res:LtmplConfigRes =await HCDataSource.requestLtmplConfig(null,ttmplNodeConfig.rootGtmplId);
36
- let rootLTmplConfig: LtmplConfig=res.ltmplConfig;
37
- ttmplNodeConfig.rootLTmplConfig=rootLTmplConfig;
38
- ttmplNodeConfig.rootTitleId=rootLTmplConfig.primaryColumn.id;
33
+ let ttmplNodeConfig: TtmplNodeConfig = { ...config }
34
+ if (ttmplNodeConfig.rootGtmplId) {
35
+ let res: LtmplConfigRes = await HCDataSource.requestLtmplConfig(null, ttmplNodeConfig.rootGtmplId);
36
+ let rootLTmplConfig: LtmplConfig = res.ltmplConfig;
37
+ ttmplNodeConfig.rootLTmplConfig = rootLTmplConfig;
38
+ ttmplNodeConfig.rootTitleId = rootLTmplConfig.primaryColumn.id;
39
39
  }
40
- if(ttmplNodeConfig.branchRatmplId){
41
- let res:LtmplConfigRes =await HCDataSource.requestLtmplConfig(null,ttmplNodeConfig.branchRatmplId);
42
- let branchLTmplConfig: LtmplConfig=res.ltmplConfig;
43
- ttmplNodeConfig.branchLTmplConfig=branchLTmplConfig;
44
- ttmplNodeConfig.branchTitleId=branchLTmplConfig.primaryColumn.id;
40
+ if (ttmplNodeConfig.branchRatmplId) {
41
+ let res: LtmplConfigRes = await HCDataSource.requestLtmplConfig(null, ttmplNodeConfig.branchRatmplId);
42
+ let branchLTmplConfig: LtmplConfig = res.ltmplConfig;
43
+ ttmplNodeConfig.branchLTmplConfig = branchLTmplConfig;
44
+ ttmplNodeConfig.branchTitleId = branchLTmplConfig.primaryColumn.id;
45
45
  }
46
- if(ttmplNodeConfig.leafRatmplId){
47
- let res:LtmplConfigRes =await HCDataSource.requestLtmplConfig(null,ttmplNodeConfig.leafRatmplId);
48
- let leafLTmplConfig: LtmplConfig =res.ltmplConfig;
49
- ttmplNodeConfig.leafLTmplConfig=leafLTmplConfig;
50
- ttmplNodeConfig.leafTitleId=leafLTmplConfig.primaryColumn.id;
46
+ if (ttmplNodeConfig.leafRatmplId) {
47
+ let res: LtmplConfigRes = await HCDataSource.requestLtmplConfig(null, ttmplNodeConfig.leafRatmplId);
48
+ let leafLTmplConfig: LtmplConfig = res.ltmplConfig;
49
+ ttmplNodeConfig.leafLTmplConfig = leafLTmplConfig;
50
+ ttmplNodeConfig.leafTitleId = leafLTmplConfig.primaryColumn.id;
51
51
  }
52
52
 
53
53
  return ttmplNodeConfig;
54
54
  }
55
55
 
56
56
 
57
- static mergeRootData = (data, newData) => {
57
+ static mergeRootData = (data, newData) => {
58
58
  if (newData && data) {
59
59
  for (let nd of newData) {
60
60
  for (let d of data) {
@@ -67,7 +67,7 @@ export default class TreeUtils {
67
67
  }
68
68
  };
69
69
 
70
- static reloadData = async (branchCode: string,ttmplNodeConfig,data:TreeDataNode[],expandedKeys:string[]) => {
70
+ static reloadData = async (branchCode: string, ttmplNodeConfig, data: TreeDataNode[], expandedKeys: string[]) => {
71
71
  let newData;
72
72
  if (branchCode == null) {
73
73
  //加载根
@@ -86,12 +86,12 @@ export default class TreeUtils {
86
86
  for (let d of rdatas) {
87
87
  newExpandeds.push(d.key);
88
88
  }
89
- if(expandedKeys){
89
+ if (expandedKeys) {
90
90
  newExpandeds.push(...expandedKeys)
91
91
  };
92
92
 
93
93
  return {
94
- expandedKeys: [...newExpandeds],
94
+ expandedKeys: [...newExpandeds],
95
95
  data: [...data],
96
96
  };
97
97
  }
@@ -123,15 +123,15 @@ export default class TreeUtils {
123
123
  //组织data
124
124
  if (res?.entities) {
125
125
  res.entities.forEach((item, index) => {
126
- data.push(this.toTreeNodeData(item,config.rootTitleId,null,false,"R"));
126
+ data.push(this.toTreeNodeData(item, config.rootTitleId, null, false, "R", config));
127
127
  })
128
128
  }
129
129
  return data;
130
130
  }
131
131
 
132
- static pushNodeData = (parentNode: TreeDataNode, config: TtmplNodeConfig,brancEntities:any[],leafEntities:any[]) => {
132
+ static pushNodeData = (parentNode: TreeDataNode, config: TtmplNodeConfig, brancEntities: any[], leafEntities: any[]) => {
133
133
  //先查询branch
134
- parentNode.children.splice(0,parentNode.children.length);
134
+ parentNode.children.splice(0, parentNode.children.length);
135
135
  if (brancEntities) {
136
136
  brancEntities.forEach((item, index) => {
137
137
  parentNode.children.push(this.toBanchTreeNodeData(item, config, parentNode));
@@ -151,45 +151,46 @@ export default class TreeUtils {
151
151
  if (parentNodes.length > 0) {
152
152
  //先查询branch
153
153
  let brancEntities: any[];
154
- if(config.branchRatmplId){
155
- let res = await HydrocarbonService.requestLtmplQueryTop(null, config.branchRatmplId, {mainCode: parentNodes[0].code});
156
- brancEntities = res.entities;
154
+ if (config.branchRatmplId) {
155
+ let res = await HydrocarbonService.requestLtmplQueryTop(null, config.branchRatmplId, { mainCode: parentNodes[0].code });
156
+ brancEntities = res.entities;
157
157
  }
158
158
  let leafEntities: any[];
159
- if(config.leafRatmplId){
160
- let res1 = await HydrocarbonService.requestLtmplQueryTop(null, config.leafRatmplId, {mainCode: parentNodes[0].code});
159
+ if (config.leafRatmplId) {
160
+ let res1 = await HydrocarbonService.requestLtmplQueryTop(null, config.leafRatmplId, { mainCode: parentNodes[0].code });
161
161
  leafEntities = res1.entities;
162
162
  }
163
163
 
164
- for(let parentNode of parentNodes){
165
- this.pushNodeData(parentNode, config,brancEntities,leafEntities);
164
+ for (let parentNode of parentNodes) {
165
+ this.pushNodeData(parentNode, config, brancEntities, leafEntities);
166
166
  }
167
167
  }
168
168
  }
169
169
 
170
170
 
171
- static toLeafTreeNodeData = (item: DtmplData,config:TtmplNodeConfig, parent: TreeDataNode ) => {
172
- let d= this.toTreeNodeData(item,config.leafTitleId,parent,true,"B");
171
+ static toLeafTreeNodeData = (item: DtmplData, config: TtmplNodeConfig, parent: TreeDataNode) => {
172
+ let d = this.toTreeNodeData(item, config.leafTitleId, parent, true, "B");
173
173
  return d;
174
174
  }
175
175
 
176
- static toBanchTreeNodeData = (item: DtmplData,config:TtmplNodeConfig, parent: TreeDataNode) => {
177
- let d= this.toTreeNodeData(item,config.branchTitleId,parent,false,"L");
176
+ static toBanchTreeNodeData = (item: DtmplData, config: TtmplNodeConfig, parent: TreeDataNode) => {
177
+ let d = this.toTreeNodeData(item, config.branchTitleId, parent, false, "L", config);
178
178
  return d;
179
179
  }
180
180
 
181
- static toTreeNodeData = (item: DtmplData,titleId:string, parent: TreeDataNode,isLeaf:boolean,keyPrex
182
- :string) => {
181
+ static toTreeNodeData = (item: DtmplData, titleId: string, parent: TreeDataNode, isLeaf: boolean, keyPrex
182
+ : string, config?: TtmplNodeConfig) => {
183
183
  let name = item.fieldMap[titleId];
184
+ // leafRatmplId为null,所有节点都可以选择;leafRatmplId有值,只能选择叶子节点
184
185
  let d = {
185
186
  code: item.code,
186
- key: keyPrex + parent?.code+item.code,
187
- value:keyPrex + parent?.code+item.code,
187
+ key: keyPrex + parent?.code + item.code,
188
+ value: keyPrex + parent?.code + item.code,
188
189
  name,
189
- title: <><span>{name?name:item.code}</span></>,
190
+ title: <><span>{name ? name : item.code}</span></>,
190
191
  children: [],
191
192
  isLeaf,
192
- selectable:isLeaf,
193
+ selectable: isLeaf || !config.leafRatmplId,
193
194
  parent,
194
195
  };
195
196
 
@@ -202,8 +203,8 @@ export default class TreeUtils {
202
203
  let tagNodes: TreeDataNode[] = [];
203
204
 
204
205
  children.forEach((no) => {
205
- let n = {...no};
206
- let v=n.searchValue?n.searchValue:n.name;
206
+ let n = { ...no };
207
+ let v = n.searchValue ? n.searchValue : n.name;
207
208
  if (v.indexOf(searchValue) >= 0) {
208
209
  newNodes.push(n);
209
210
  }
@@ -212,7 +213,7 @@ export default class TreeUtils {
212
213
  if (retNodes.length > 0) {
213
214
  n.children = retNodes;
214
215
  //补充父没有的
215
- if ((n.searchValue?n.searchValue:n.name).indexOf(searchValue) < 0) {
216
+ if ((n.searchValue ? n.searchValue : n.name).indexOf(searchValue) < 0) {
216
217
  newNodes.push(n);
217
218
  }
218
219
  } else {
@@ -227,17 +228,17 @@ export default class TreeUtils {
227
228
  return newNodes;
228
229
  }
229
230
 
230
- static getNodesOfArrayNode=(nodes:any[], nodeCodes: string[])=>{
231
+ static getNodesOfArrayNode = (nodes: any[], nodeCodes: string[]) => {
231
232
  let newNodes: TreeDataNode[] = [];
232
- if(!nodeCodes || nodeCodes.length==0 || !nodes){
233
+ if (!nodeCodes || nodeCodes.length == 0 || !nodes) {
233
234
  return newNodes;
234
235
  }
235
236
 
236
237
  //let tagNodes: TreeDataNode[] = [];
237
238
  nodes.forEach((no) => {
238
- let n = {...no};
239
- let v=no.code;
240
- let vn=no.name;
239
+ let n = { ...no };
240
+ let v = no.code;
241
+ let vn = no.name;
241
242
  if (nodeCodes.includes(v) || nodeCodes.includes(vn)) {
242
243
  newNodes.push(n);
243
244
  }
@@ -254,26 +255,26 @@ export default class TreeUtils {
254
255
  }
255
256
  })
256
257
  return newNodes;
257
- }
258
+ }
258
259
 
259
260
  static getNodes = (node, nodeCodes: string[]) => {
260
- let children:any[]=undefined;
261
- if(node.children) {
261
+ let children: any[] = undefined;
262
+ if (node.children) {
262
263
  children = [...node.children];
263
264
  }
264
- return this.getNodesOfArrayNode(children,nodeCodes);
265
+ return this.getNodesOfArrayNode(children, nodeCodes);
265
266
  }
266
267
 
267
268
  static getNodesOfKey = (node, nodeCodes: string[]) => {
268
- let children:any[] = [...node.children];
269
+ let children: any[] = [...node.children];
269
270
  let newNodes: TreeDataNode[] = [];
270
- if(!nodeCodes || nodeCodes.length==0){
271
+ if (!nodeCodes || nodeCodes.length == 0) {
271
272
  return newNodes;
272
273
  }
273
274
  //let tagNodes: TreeDataNode[] = [];
274
275
  children.forEach((no) => {
275
- let n = {...no};
276
- let v=no.key;
276
+ let n = { ...no };
277
+ let v = no.key;
277
278
  if (nodeCodes.includes(v)) {
278
279
  newNodes.push(n);
279
280
  }
@@ -292,15 +293,15 @@ export default class TreeUtils {
292
293
  return newNodes;
293
294
  }
294
295
 
295
- static getNodeKeys(node, nodeCodes: string[]){
296
- let newNodes: TreeDataNode[] ;
297
- if(Array.isArray(node)){
298
- newNodes=this.getNodesOfArrayNode(node,nodeCodes);
299
- }else{
300
- newNodes=this.getNodes(node,nodeCodes);
296
+ static getNodeKeys(node, nodeCodes: string[]) {
297
+ let newNodes: TreeDataNode[];
298
+ if (Array.isArray(node)) {
299
+ newNodes = this.getNodesOfArrayNode(node, nodeCodes);
300
+ } else {
301
+ newNodes = this.getNodes(node, nodeCodes);
301
302
  }
302
- let keys:string[]=[];
303
- newNodes.forEach(n=>{
303
+ let keys: string[] = [];
304
+ newNodes.forEach(n => {
304
305
  // @ts-ignore
305
306
  keys.push(n.key);
306
307
  })
@@ -308,7 +309,7 @@ export default class TreeUtils {
308
309
  }
309
310
 
310
311
  static filterTree = (nodes: any[], searchValue: string) => {
311
- let root = {code: "", config: undefined, key: undefined, children: [...nodes]};
312
+ let root = { code: "", config: undefined, key: undefined, children: [...nodes] };
312
313
  this.filterNode(root, searchValue);
313
314
  return root.children;
314
315
  }
@@ -528,15 +528,31 @@ export default {
528
528
  window.location.hash = version === "v2" ? "#/login2/" : "#/login/";
529
529
  }
530
530
  },
531
- downloadFile(url, fileName) {
531
+ async downloadFile(url, fileName) {
532
532
  try {
533
- let a = document.createElement("a");
534
- a.download = fileName;
535
- a.href = url;
536
- //a.target= "_blank";
537
- document.body.appendChild(a);
538
- a.click();
539
- document.body.removeChild(a);
533
+ // 检查是否跨域
534
+ if (new URL(url).origin !== window.location.origin) {
535
+ // 跨域资源使用Fetch API方式
536
+ const response = await fetch(url);
537
+ const blob = await response.blob();
538
+ const blobUrl = window.URL.createObjectURL(blob);
539
+ let a = document.createElement('a');
540
+ a.href = blobUrl;
541
+ a.download = fileName;
542
+ document.body.appendChild(a);
543
+ a.click();
544
+ // 清理
545
+ window.URL.revokeObjectURL(blobUrl);
546
+ document.body.removeChild(a);
547
+ } else {
548
+ let a = document.createElement("a");
549
+ a.download = fileName;
550
+ a.href = url;
551
+ //a.target= "_blank";
552
+ document.body.appendChild(a);
553
+ a.click();
554
+ document.body.removeChild(a);
555
+ }
540
556
  } catch (e) {
541
557
  console.log(e);
542
558
  }
@@ -766,7 +782,7 @@ export default {
766
782
  configParamTrans(value: string, itemType: string) {
767
783
  if (value && value.startsWith && value.startsWith("$$current")) {
768
784
  return TmplConfigAnalysis.current(value, this.getDayjsFormat(itemType));
769
- } else if (value && value.startsWith("$$user.code")) {
785
+ } else if (value && value.startsWith && value.startsWith("$$user.code")) {
770
786
  let userInfo: UserInfo = this.getCurrentUserInfo();
771
787
  if (userInfo) {
772
788
  return userInfo.id + "@R@";