kts-components-document-access-point 1.3.22 → 1.3.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-components-document-access-point",
3
- "version": "1.3.22",
3
+ "version": "1.3.26",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "start": "dumi dev",
@@ -64,11 +64,12 @@ export default () => {
64
64
  "value": 2
65
65
  }],
66
66
  },
67
- '[beginCreateTime,endCreateTime]': {
68
- key: "[beginCreateTime,endCreateTime]",
69
- name: "[beginCreateTime,endCreateTime]",
67
+ createTime: {
70
68
  type: "daterange",
71
69
  title: "创建时间",
70
+ 'x-props':{
71
+ extendsFields: ['beginCreateTime', 'endCreateTime'],
72
+ }
72
73
  },
73
74
  // '[beginUpdateTime,endUpdateTime]': {
74
75
  // key: "[beginUpdateTime,endUpdateTime]",
@@ -72,11 +72,12 @@ export default () => {
72
72
  "value": 2
73
73
  }],
74
74
  },
75
- '[beginCreateTime,endCreateTime]': {
76
- key: "[beginCreateTime,endCreateTime]",
77
- name: "[beginCreateTime,endCreateTime]",
75
+ createTime: {
78
76
  type: "daterange",
79
77
  title: "创建时间",
78
+ 'x-props':{
79
+ extendsFields: ['beginCreateTime', 'endCreateTime'],
80
+ }
80
81
  },
81
82
  // '[beginUpdateTime,endUpdateTime]': {
82
83
  // key: "[beginUpdateTime,endUpdateTime]",
@@ -3,6 +3,6 @@ import React from "react";
3
3
 
4
4
  export default () => {
5
5
  return (
6
- <DocumentsCont path='/billwhiteliest'/>
6
+ <DocumentsCont path=''/>
7
7
  );
8
8
  };
@@ -12,21 +12,20 @@ export default async (s: DocumentsEditControllerState, options?: { current?: IPr
12
12
  return
13
13
  }
14
14
 
15
- let obj: any;
16
- // 对象 还是 数组
15
+ const info = current.items ? current.items : current;
16
+
17
+ // let obj: any;
18
+ // 创建 properties (对象 还是 数组)
17
19
  if (current.type === 'object') {
18
20
  if (!current.properties) current.properties = {};
19
- obj = current.properties;
20
21
  } else if (current.type === 'array' && current.items) {
21
22
  if (!current.items.properties) current.items.properties = {};
22
- obj = current.items.properties;
23
23
  }
24
24
 
25
- if (!current.required) current.required = [];
26
-
27
- values.required && current.required.push(values.$name);
25
+ if (!info.required) info.required = [];
26
+ values.required && info.required.push(values.$name);
28
27
 
29
- obj[values.$name] = {
28
+ (info.properties as any)[values.$name] = {
30
29
  alias: values.title,
31
30
  detailed: values.description,
32
31
  $ref: properties.$id,
@@ -1,27 +1,48 @@
1
1
 
2
2
  import DocumentsEditControllerState, { IDataSource } from '../../DocumentsEditControllerState';
3
+ import IProperties from '../../DocumentsEditControllerState/IProperties';
3
4
 
4
5
  export default async (s: DocumentsEditControllerState, options?: IDataSource) => {
5
- if (!options) return;
6
+ if (!options || !s.propertyTableState.current) return;
6
7
 
7
- const properties = s.propertyTableState.current?.items
8
- ? s.propertyTableState.current?.items.properties
9
- : s.propertyTableState.current?.properties;
8
+ const current = s.propertyTableState.current?.items
9
+ ? s.propertyTableState.current?.items
10
+ : s.propertyTableState.current
10
11
 
11
- // 删除必填
12
- (() => {
13
- const p = options.required.indexOf(options.value.$name);
14
- options.required.splice(p, 1);
15
- })()
12
+ _del(current, options.value.$name, options.value.$refName);
16
13
 
17
- // 删除引用
18
- if (!properties) return;
19
- delete properties[options.value.$name];
14
+ function _del(current: IProperties, name: string, refName: string) {
15
+ // 删除必填
16
+ (() => {
17
+ if (!current.required) return;
18
+ const p = current.required.indexOf(name);
19
+ current.required.splice(p, 1);
20
+ })();
21
+
22
+ // 删除引用
23
+ (() => {
24
+ if (!current.properties) return;
25
+ delete current.properties[name];
26
+ s.schema.definitions[refName].$count--;
27
+ })();
28
+
29
+ // 删除孩子
30
+ (() => {
31
+ const items = s.schema.definitions[refName].items;
32
+ const current: IProperties = items ? items : s.schema.definitions[refName];
33
+ const properties = current.properties;
34
+ if (!properties) return;
35
+ for (let name in properties) {
36
+ _del(current, name, properties[name].$refName);
37
+ }
38
+ })();
39
+ }
20
40
 
21
41
  // 删除对象
22
- s.schema.definitions[options.value.$refName].$count--;
23
- if (s.schema.definitions[options.value.$refName].$count <= 0) {
24
- delete s.schema.definitions[options.value.$refName];
42
+ for (let key in s.schema.definitions) {
43
+ if (s.schema.definitions[key].$count <= 0) {
44
+ delete s.schema.definitions[key];
45
+ }
25
46
  }
26
47
 
27
48
  s.schema = { ...s.schema }
@@ -5,24 +5,23 @@ import * as tools from '../../../tools';
5
5
  export default async (s: DocumentsEditControllerState, options: any) => {
6
6
  if (!options) return;
7
7
 
8
- const { editProperties, properties, current } = options;
8
+ const { editProperties, properties } = options;
9
+ const current = options.current.properties ? options.current : options.current.items;
9
10
 
10
11
  // 对象数据
11
12
  current.properties[properties.$name].alias = properties.title;
12
13
  current.properties[properties.$name].detailed = properties.description;
13
14
 
14
-
15
-
16
15
  // 设置必填
17
- const required = current.required as string[];
16
+ const required = (current.required as string[] || (current.required = []));
18
17
  if (properties.required) {
19
18
  if (required.indexOf(properties.$name) < 0) {
20
- current.required.push(properties.$name)
19
+ current.required.push(properties.$name);
21
20
  }
22
21
  } else {
23
22
  const p = required.indexOf(properties.$name)
24
23
  if (p >= 0) {
25
- required.splice(p, 1)
24
+ required.splice(p, 1);
26
25
  }
27
26
  }
28
27
 
@@ -64,7 +63,7 @@ export default async (s: DocumentsEditControllerState, options: any) => {
64
63
  const editProperties_type = editProperties.ref.items ? editProperties.ref.items.type : editProperties.ref.type;
65
64
 
66
65
  const editProperties_format = editProperties.ref.items ? editProperties.ref.items.format : editProperties.ref.format;
67
- const properties_format = properties.items ? properties.items.format : properties.format;
66
+ const properties_format = properties.items ? properties.items.format : properties.format;
68
67
 
69
68
  // 内部规则 修改了类型 清空规则
70
69
  if (editProperties_type !== properties_type || editProperties_format !== properties_format) {
@@ -1,16 +1,16 @@
1
-
2
- import { Switch } from 'kts-components-antd-x4';
3
- import React from 'react';
4
- import { DocumentsEdit } from '../../../';
5
-
6
- export default () => {
7
-
8
- const [readOnly, setReadOnly] = React.useState(false)
9
-
10
- return (
11
- <>
12
- <Switch style={{}} onChange={e => { setReadOnly(e) }} />
13
- <DocumentsEdit readOnly={readOnly} />
14
- </>
15
- );
16
- };
1
+
2
+ import { Switch } from 'kts-components-antd-x4';
3
+ import React from 'react';
4
+ import { DocumentsEdit } from '../../../';
5
+
6
+ export default () => {
7
+
8
+ const [readOnly, setReadOnly] = React.useState(false)
9
+
10
+ return (
11
+ <>
12
+ <Switch style={{}} onChange={e => { setReadOnly(e) }} />
13
+ <DocumentsEdit readOnly={readOnly} />
14
+ </>
15
+ );
16
+ };
@@ -1,10 +1,10 @@
1
- # DocumentsEdit
2
-
3
- ## 普通使用
4
- <code src="./___demo___/conventional/index.tsx" ></code>
5
-
6
- ## 监听问题编号 和 导入数据
7
- <code src="./___demo___/monitor/index.tsx" ></code>
8
-
9
- ## 只读模式
10
- <code src="./___demo___/readOnly/index.tsx" ></code>
1
+ # DocumentsEdit
2
+
3
+ ## 普通使用
4
+ <code src="./___demo___/conventional/index.tsx" ></code>
5
+
6
+ ## 监听问题编号 和 导入数据
7
+ <code src="./___demo___/monitor/index.tsx" ></code>
8
+
9
+ ## 只读模式
10
+ <code src="./___demo___/readOnly/index.tsx" ></code>
@@ -51,19 +51,7 @@ export default () => {
51
51
  type: values.isArray ? 'array' : tools.getType(values.type),
52
52
  format: values.isArray ? undefined : tools.getFormat(values.type),
53
53
  items: tools.getItems({ ...values, $name: name }),
54
- // required: values.required,
55
54
  description: values.description,
56
- // rules: values.isArray ? [{
57
- // _index: 0,
58
- // name: '数组容量校验',
59
- // checkType: 'control',
60
- // message: '数组超过最大容量',
61
- // algorithm: 'array-0',
62
- // minItems: values.minItems ? parseInt(values.minItems) : undefined,
63
- // maxItems: values.maxItems ? parseInt(values.maxItems) : undefined,
64
- // exclusiveMinItems: values.exclusiveMinItems,
65
- // exclusiveMaxItems: values.exclusiveMaxItems,
66
- // }] : [],
67
55
  rules: values.isArray ? [{
68
56
  _index: 0,
69
57
  name: '数组容量校验(Min)',
@@ -88,6 +88,8 @@ export default () => {
88
88
 
89
89
  React.useEffect(() => {
90
90
  if (!editProperties) return;
91
+
92
+ const info = current?.items ? current?.items : current;
91
93
 
92
94
  setIsArray(!!editProperties.ref.items);
93
95
 
@@ -95,11 +97,12 @@ export default () => {
95
97
  $name: editProperties.value.$name,
96
98
  title: editProperties.value.alias,
97
99
  isArray: !!editProperties.ref.items,
98
- required: editProperties.required.indexOf(editProperties.value.$name as any) >= 0,
100
+ required: (info?.required ?? ([] as string[])).indexOf(editProperties.value.$name as any) >= 0,
99
101
  description: editProperties.value.detailed,
100
102
  type: tools.initType(editProperties.ref),
101
103
  })
102
104
 
105
+ // 数组的设置
103
106
  if (!!editProperties.ref.items && editProperties.ref.rules) {
104
107
  const values = { ...editProperties.ref.rules[0], ...editProperties.ref.rules[1] };
105
108
  form.setFieldsValue({
@@ -120,7 +123,7 @@ export default () => {
120
123
  return () => {
121
124
  setIsChangeType(false);
122
125
  }
123
- }, [editProperties, form]);
126
+ }, [editProperties, form, current]);
124
127
 
125
128
  const submitButton = React.useMemo(() => {
126
129
  if (isChangeType) {
@@ -11,9 +11,8 @@ export default (props: { index: number }) => {
11
11
  e.stopPropagation()
12
12
  await controller.wait();
13
13
  await controller.pipeline(async s => {
14
- debugger;
15
14
  if (!s.ruleState.ruleProperties) return;
16
-
15
+
17
16
  if (s.ruleState.ruleProperties.ref.items) {
18
17
  s.ruleState.ruleProperties.ref.items.rules?.splice(props.index, 1);
19
18
  s.ruleState.ruleProperties.ref.items.rules = s.ruleState.ruleProperties.ref.items.rules?.slice() ?? [];
@@ -43,6 +43,8 @@ export default () => {
43
43
  const current = s.propertyTableState.current;
44
44
  if (!current) return [];
45
45
 
46
+ const info = current.items ? current.items : current;
47
+
46
48
  const properties = current.type === 'object'
47
49
  ? current.properties
48
50
  : current.items?.properties
@@ -55,7 +57,7 @@ export default () => {
55
57
  return {
56
58
  value: { ...e[1], $name: e[0] },
57
59
  ref: s.schema.definitions[e[1].$refName],
58
- required: current.required || [],
60
+ required: info.required || [],
59
61
  };
60
62
  });
61
63
  }, [])
@@ -113,17 +113,19 @@ export default () => {
113
113
  mode: "multiple"
114
114
  }
115
115
  },
116
- '[beginCreateTime,endCreateTime]': {
117
- key: "[beginCreateTime,endCreateTime]",
118
- name: "[beginCreateTime,endCreateTime]",
116
+ createTime: {
119
117
  type: "daterange",
120
118
  title: "创建时间",
119
+ 'x-props':{
120
+ extendsFields: ['beginCreateTime', 'endCreateTime'],
121
+ }
121
122
  },
122
- '[beginSendTime,endSendTime]': {
123
- key: "[beginSendTime,endSendTime]",
124
- name: "[beginSendTime,endSendTime]",
123
+ sendTime: {
125
124
  type: "daterange",
126
125
  title: "更新时间",
126
+ 'x-props':{
127
+ extendsFields: ['beginSendTime', 'endSendTime'],
128
+ }
127
129
  },
128
130
  }
129
131
  }
@@ -187,12 +189,12 @@ export default () => {
187
189
  enum: profileEnum,
188
190
  visible: false
189
191
  },
190
-
191
- '[beginCreateTime,endCreateTime]': {
192
- key: "[beginCreateTime,endCreateTime]",
193
- name: "[beginCreateTime,endCreateTime]",
192
+ createTime: {
194
193
  type: "daterange",
195
194
  title: "发布时间",
195
+ 'x-props':{
196
+ extendsFields: ['beginCreateTime', 'endCreateTime'],
197
+ }
196
198
  },
197
199
  // '[beginSendTime,endSendTime]': {
198
200
  // key: "[beginSendTime,endSendTime]",
@@ -102,7 +102,7 @@ export default function validaterule(props: any) {
102
102
  render: (text: any) => moment(text).format('YYYY-MM-DD HH:mm')
103
103
  },
104
104
  {
105
- title: '最近更新时间',
105
+ title: '更新时间',
106
106
  dataIndex: 'updateAt',
107
107
  render: (text: any) => moment(text).format('YYYY-MM-DD HH:mm')
108
108
  },
@@ -1 +1 @@
1
- # DocumentsRule
1
+ # DocumentsRule