@cniot/mdd-editor 0.2.0-beta.9 → 0.3.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.
Files changed (75) hide show
  1. package/README.MD +308 -11
  2. package/build/index.cjs.js +27 -19
  3. package/build/index.es.js +3731 -446
  4. package/build/style.css +1 -1
  5. package/package.json +1 -1
  6. package/src/ai/LocalAIDrawer.jsx +217 -0
  7. package/src/ai/bridgeClient.js +168 -0
  8. package/src/ai/pageIR.js +148 -0
  9. package/src/components/address-select/formily.jsx +1 -1
  10. package/src/components/ajax-schema-form/formily-table-form-proxy.jsx +1 -1
  11. package/src/components/ajax-schema-form/formily.jsx +1 -1
  12. package/src/components/ajax-schema-form/table-form-proxy.jsx +1 -1
  13. package/src/components/ajax-schema-form/table-form.jsx +1 -1
  14. package/src/components/data-source-select/formily.jsx +1 -1
  15. package/src/components/dynamic-value/base/formily.jsx +1 -1
  16. package/src/components/dynamic-value/date/formily.jsx +1 -1
  17. package/src/components/formily-select/index.tsx +1 -1
  18. package/src/components/params-select/formily.jsx +1 -1
  19. package/src/components/time-range/formily.jsx +1 -1
  20. package/src/hooks/useSchema.jsx +5 -5
  21. package/src/hooks/useSwagger.jsx +2 -2
  22. package/src/schema/base-schema/AjaxSchema.js +1 -1
  23. package/src/schema/base-schema/AjaxSchemaQueue.js +1 -1
  24. package/src/schema/blocks/edit-table.js +57 -0
  25. package/src/schema/blocks/filter.js +49 -0
  26. package/src/schema/blocks/form.js +49 -0
  27. package/src/schema/blocks/index.js +32 -10
  28. package/src/schema/blocks/table.js +3 -4
  29. package/src/schema/detail/detail-item.js +5 -5
  30. package/src/schema/detail/index.js +26 -18
  31. package/src/schema/edit-table/header-toolbar.js +1 -1
  32. package/src/schema/edit-table/index.js +10 -5
  33. package/src/schema/edit-table/table.js +10 -2
  34. package/src/schema/formily-form/data-source.js +1 -1
  35. package/src/schema/formily-form/form-schema.js +1 -1
  36. package/src/schema/formily-form/index.js +8 -8
  37. package/src/schema/formily-form-v2/form-info.js +2 -2
  38. package/src/schema/formily-form-v2/form-items.js +1 -1
  39. package/src/schema/formily-form-v2/index.js +3 -3
  40. package/src/schema/ftp/data-source.js +1 -1
  41. package/src/schema/ftp/filter.js +2 -2
  42. package/src/schema/ftp/header-toolbar.js +1 -1
  43. package/src/schema/ftp/index.js +4 -4
  44. package/src/schema/ftp/middle-item.js +1 -1
  45. package/src/schema/ftp/table.js +9 -3
  46. package/src/schema/util.js +3 -3
  47. package/src/services/index.js +1 -1
  48. package/src/template/blocks/EditTable.jsx +62 -0
  49. package/src/template/blocks/Filter.jsx +137 -0
  50. package/src/template/blocks/Form.jsx +136 -0
  51. package/src/template/blocks/Table.jsx +4 -4
  52. package/src/template/const.js +18 -4
  53. package/src/template/detail/DetailItems.jsx +6 -1
  54. package/src/template/detail/components/Actions.jsx +1 -1
  55. package/src/template/detail/components/DetailCard.jsx +8 -5
  56. package/src/template/detail/components/DetailColumns.jsx +193 -113
  57. package/src/template/detail/components/DetailCustom.jsx +2 -2
  58. package/src/template/detail/components/DetailTable.jsx +13 -8
  59. package/src/template/detail/components/MultiAjaxSchemaForm.jsx +1 -1
  60. package/src/template/edit-table/HeaderToolbar.jsx +3 -2
  61. package/src/template/edit-table/Table.jsx +56 -3
  62. package/src/template/formily-form-v2/FormInfo.jsx +1 -1
  63. package/src/template/formily-form-v2/FormItems.jsx +4 -8
  64. package/src/template/formilyform/components/AsyncDataSourceSetter/index.tsx +1 -1
  65. package/src/template/formilyform/components/SubmitActionSetter/index.tsx +1 -1
  66. package/src/template/ftp/DataSource.jsx +1 -1
  67. package/src/template/ftp/Filter.jsx +14 -7
  68. package/src/template/ftp/HeaderToolbar.jsx +8 -4
  69. package/src/template/ftp/Middle.jsx +11 -7
  70. package/src/template/ftp/Table.jsx +143 -12
  71. package/src/template/simple-ftp/Table.jsx +2 -2
  72. package/src/toolbar.jsx +76 -14
  73. package/src/utils/buildFieldsToCompJson.js +3 -3
  74. package/src/utils/persistentStorage.js +1 -1
  75. package/src/utils/swagger/api2SchemaFromSwagger.js +7 -7
@@ -1,10 +1,10 @@
1
- import { EVENT_KEY } from '@src/common/const';
1
+ import { EVENT_KEY } from '$src/common/const';
2
2
  import Schema from '../Schema';
3
3
  import { Message } from '@cainiaofe/cn-ui';
4
4
  import DetailItem from './detail-item';
5
5
  import AjaxSchema from '../base-schema/AjaxSchema';
6
- import buildSwaggerApiJson from '@src/utils/buildSwaggerApiJson';
7
- import buildFieldsToCompJson from '@src/utils/buildFieldsToCompJson';
6
+ import buildSwaggerApiJson from '$src/utils/buildSwaggerApiJson';
7
+ import buildFieldsToCompJson from '$src/utils/buildFieldsToCompJson';
8
8
 
9
9
  export default class DetailSchema extends Schema {
10
10
  /**
@@ -20,6 +20,8 @@ export default class DetailSchema extends Schema {
20
20
  hasAnchor = false,
21
21
  children,
22
22
  initDataSource,
23
+ fullHeight,
24
+ whiteBackground,
23
25
  ...more
24
26
  } = isCompleteSchema ? props.body : props;
25
27
  super(more);
@@ -27,6 +29,8 @@ export default class DetailSchema extends Schema {
27
29
  this.hasBackBtn = hasBackBtn;
28
30
  this.backText = backText;
29
31
  this.hasAnchor = hasAnchor; // 是否带电梯
32
+ this.fullHeight = fullHeight;
33
+ this.whiteBackground = whiteBackground;
30
34
  this.initChildren(children, initDataSource);
31
35
 
32
36
  this.initDataSource = initDataSource ? new AjaxSchema(initDataSource) : {};
@@ -39,21 +43,21 @@ export default class DetailSchema extends Schema {
39
43
  /* eslint-disable */
40
44
  this.children = children
41
45
  ? children
42
- .map((item) => {
43
- if (!item) return null;
44
- return new DetailItem(item);
45
- })
46
- .filter(Boolean)
46
+ .map((item) => {
47
+ if (!item) return null;
48
+ return new DetailItem(item);
49
+ })
50
+ .filter(Boolean)
47
51
  : [
48
- new DetailItem({
49
- groupId: '',
50
- type: 'detail-card',
51
- label: '基础信息',
52
- col: 3,
53
- columns: [],
54
- source: [initDataSource],
55
- }),
56
- ];
52
+ new DetailItem({
53
+ groupId: '',
54
+ type: 'detail-card',
55
+ label: '基础信息',
56
+ col: 3,
57
+ columns: [],
58
+ source: [initDataSource],
59
+ }),
60
+ ];
57
61
  }
58
62
 
59
63
  // 基础信息change key 主要是 hasBackBtn 和 backText
@@ -126,7 +130,7 @@ export default class DetailSchema extends Schema {
126
130
  // 根据schema初始化对象, 二次打开
127
131
  initFromCache(schema) {
128
132
  const { body, ...more } = schema;
129
- const { hasBackBtn, backText, hasAnchor, children } = body;
133
+ const { hasBackBtn, backText, hasAnchor, fullHeight, whiteBackground, children } = body;
130
134
 
131
135
  // 先关闭storage的更新
132
136
  // if (this.willDetach) {
@@ -136,6 +140,8 @@ export default class DetailSchema extends Schema {
136
140
  this.baseInfoChange('hasBackBtn', hasBackBtn);
137
141
  this.baseInfoChange('backText', backText);
138
142
  this.baseInfoChange('hasAnchor', hasAnchor);
143
+ this.baseInfoChange('fullHeight,', fullHeight);
144
+ this.baseInfoChange('whiteBackground,', whiteBackground);
139
145
  this.initChildren(children);
140
146
 
141
147
  this.refreshChildrenListener();
@@ -186,6 +192,8 @@ export default class DetailSchema extends Schema {
186
192
  hasBackBtn: this.hasBackBtn,
187
193
  backText: this.backText,
188
194
  hasAnchor: this.hasAnchor,
195
+ fullHeight: this.fullHeight,
196
+ whiteBackground: this.whiteBackground,
189
197
  children: this.children.map((item) => item.getJSON()),
190
198
  };
191
199
  }
@@ -1,4 +1,4 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
2
 
3
3
  export default class HeaderToolbar extends JSONWatch {
4
4
  constructor(operationFields = []) {
@@ -1,14 +1,14 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
2
- import { EVENT_KEY } from '@src/common/const';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
+ import { EVENT_KEY } from '$src/common/const';
3
3
  import Schema from '../Schema';
4
4
  import { Message } from '@cainiaofe/cn-ui';
5
5
  import Table from './table';
6
6
  import AjaxSchema from '../base-schema/AjaxSchema';
7
7
  import HeaderToolbar from './header-toolbar';
8
- import buildSwaggerApiJson from '@src/utils/buildSwaggerApiJson';
9
- import buildFieldsToCompJson from '@src/utils/buildFieldsToCompJson';
8
+ import buildSwaggerApiJson from '$src/utils/buildSwaggerApiJson';
9
+ import buildFieldsToCompJson from '$src/utils/buildFieldsToCompJson';
10
10
 
11
- export default class FtpSchema extends Schema {
11
+ export default class EditTableSchema extends Schema {
12
12
  /**
13
13
  * @param {*} props
14
14
  * type:"edit-table",
@@ -31,6 +31,7 @@ export default class FtpSchema extends Schema {
31
31
  hasAddRow = true,
32
32
  hasDeleteRow = true,
33
33
  headerToolbar = [],
34
+ maxRowLength,
34
35
  ...more
35
36
  } = isCompleteSchema ? props.body : props;
36
37
  super(more);
@@ -41,6 +42,7 @@ export default class FtpSchema extends Schema {
41
42
  this.deleteBtnText = deleteBtnText;
42
43
  this.hasSaveBtn = hasSaveBtn;
43
44
  this.hasAddRow = hasAddRow;
45
+ this.maxRowLength = maxRowLength;
44
46
  this.hasDeleteRow = hasDeleteRow;
45
47
 
46
48
  this.initApi = new AjaxSchema(initApi);
@@ -102,6 +104,7 @@ export default class FtpSchema extends Schema {
102
104
  hasAddRow,
103
105
  hasDeleteRow,
104
106
  headerToolbar,
107
+ maxRowLength,
105
108
  } = body;
106
109
 
107
110
  // 先关闭storage的更新
@@ -119,6 +122,7 @@ export default class FtpSchema extends Schema {
119
122
  this.saveBtnText = saveBtnText;
120
123
  this.hasSaveBtn = hasSaveBtn;
121
124
  this.hasAddRow = hasAddRow;
125
+ this.maxRowLength = maxRowLength;
122
126
  this.hasDeleteRow = hasDeleteRow;
123
127
 
124
128
  // 再开启change监听
@@ -191,6 +195,7 @@ export default class FtpSchema extends Schema {
191
195
  deleteBtnText: this.deleteBtnText,
192
196
  hasSaveBtn: this.hasSaveBtn,
193
197
  hasAddRow: this.hasAddRow,
198
+ maxRowLength: this.maxRowLength,
194
199
  hasDeleteRow: this.hasDeleteRow,
195
200
  initApi: this.initApi.getJSON(),
196
201
  submitApi: this.submitApi.getJSON(),
@@ -1,4 +1,4 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
2
 
3
3
  export default class TableSchema extends JSONWatch {
4
4
  constructor(props) {
@@ -9,12 +9,16 @@ export default class TableSchema extends JSONWatch {
9
9
  primaryKey = 'id',
10
10
  tree = false, // 开启树形
11
11
  showIndex = false, // 是否显示序号
12
- hideCommonToolbar = false, // 是否影藏通用顶部操作区
12
+ hideCommonToolbar = true, // 是否隐藏通用顶部操作区
13
+ useVirtual = true, // 开启虚拟滚动
14
+ columnsAutoWidth = true, // 开启列宽自适应
13
15
  pagination = {
14
16
  defaultPageSize: 20, // 默认分页大小
15
17
  paging: true, // 开启分页
16
18
  disableGlobalConfig: false, // 禁用全局分页配置
17
19
  },
20
+ maxHeight,
21
+ storageKey = Date.now(),
18
22
  } = props || {};
19
23
  super({
20
24
  columns,
@@ -25,6 +29,10 @@ export default class TableSchema extends JSONWatch {
25
29
  tree,
26
30
  showIndex,
27
31
  hideCommonToolbar,
32
+ useVirtual,
33
+ columnsAutoWidth,
34
+ maxHeight,
35
+ storageKey,
28
36
  });
29
37
  }
30
38
 
@@ -1,4 +1,4 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
2
 
3
3
  export default class DataSourceSchema extends JSONWatch {
4
4
  constructor(api) {
@@ -1,4 +1,4 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
2
 
3
3
  export default class FormSchema extends JSONWatch {
4
4
  constructor(props) {
@@ -1,13 +1,13 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
2
  import Schema from '../Schema';
3
3
  import DataSource from './data-source';
4
- import FormSchema from '@src/schema/formily-form/form-schema';
5
- import buildSwagerApiJosn from '@src/utils/buildSwaggerApiJson';
6
- import { schemaScenarioList } from '@src/services';
7
- import { makeSchema, list2Schema } from '@src/utils/formilyUtil';
8
- import { EVENT_KEY } from '@src/common/const';
9
- import buildFieldsToCompJson from '@src/utils/buildFieldsToCompJson';
10
- import buildSwaggerApiJson from '@src/utils/buildSwaggerApiJson';
4
+ import FormSchema from '$src/schema/formily-form/form-schema';
5
+ import buildSwagerApiJosn from '$src/utils/buildSwaggerApiJson';
6
+ import { schemaScenarioList } from '$src/services';
7
+ import { makeSchema, list2Schema } from '$src/utils/formilyUtil';
8
+ import { EVENT_KEY } from '$src/common/const';
9
+ import buildFieldsToCompJson from '$src/utils/buildFieldsToCompJson';
10
+ import buildSwaggerApiJson from '$src/utils/buildSwaggerApiJson';
11
11
  import upperFirst from 'lodash/upperFirst';
12
12
 
13
13
  const fieldsComp2FormilyComp = (str) => {
@@ -1,5 +1,5 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
2
- import { getDefaultFomrLabelAlign } from '@src/utils';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
+ import { getDefaultFomrLabelAlign } from '$src/utils';
3
3
 
4
4
  // 表单基础信息配置
5
5
  export default class FormInfo extends JSONWatch {
@@ -1,4 +1,4 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
2
 
3
3
  // 表单项配置
4
4
  export default class FormItems extends JSONWatch {
@@ -1,11 +1,11 @@
1
- import { EVENT_KEY } from '@src/common/const';
1
+ import { EVENT_KEY } from '$src/common/const';
2
2
  import Schema from '../Schema';
3
3
  import FormInfo from './form-info';
4
4
  import FormItems from './form-items';
5
5
  import AjaxSchema from '../base-schema/AjaxSchema';
6
6
  import AjaxSchemaQueue from '../base-schema/AjaxSchemaQueue';
7
- import buildSwaggerApiJson from '@src/utils/buildSwaggerApiJson';
8
- import buildFieldsToCompJson from '@src/utils/buildFieldsToCompJson';
7
+ import buildSwaggerApiJson from '$src/utils/buildSwaggerApiJson';
8
+ import buildFieldsToCompJson from '$src/utils/buildFieldsToCompJson';
9
9
 
10
10
  export default class FormilyFormV2Schema extends Schema {
11
11
  static FormInfo = FormInfo;
@@ -1,4 +1,4 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
2
 
3
3
  export default class DataSourceSchema extends JSONWatch {
4
4
  constructor(props) {
@@ -1,5 +1,5 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
2
- import { getDefaultFomrLabelAlign } from '@src/utils';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
+ import { getDefaultFomrLabelAlign } from '$src/utils';
3
3
 
4
4
  export default class Filter extends JSONWatch {
5
5
  constructor(props) {
@@ -1,4 +1,4 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
2
 
3
3
  export default class HeaderToolbar extends JSONWatch {
4
4
  constructor(operationFields = []) {
@@ -1,5 +1,5 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
2
- import { EVENT_KEY } from '@src/common/const';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
+ import { EVENT_KEY } from '$src/common/const';
3
3
  import Schema from '../Schema';
4
4
  import { Message } from '@cainiaofe/cn-ui';
5
5
  import Table from './table';
@@ -8,8 +8,8 @@ import Filter from './filter';
8
8
  // import Tab from './tab';
9
9
  // import DataSource from './data-source';
10
10
  import AjaxSchema from '../base-schema/AjaxSchema';
11
- import buildSwaggerApiJson from '@src/utils/buildSwaggerApiJson';
12
- import buildFieldsToCompJson from '@src/utils/buildFieldsToCompJson';
11
+ import buildSwaggerApiJson from '$src/utils/buildSwaggerApiJson';
12
+ import buildFieldsToCompJson from '$src/utils/buildFieldsToCompJson';
13
13
 
14
14
  import MiddleItem from './middle-item';
15
15
 
@@ -1,4 +1,4 @@
1
- import JSONWatch from '@src/utils/JSONWatch';
1
+ import JSONWatch from '$src/utils/JSONWatch';
2
2
  import AjaxSchema from '../base-schema/AjaxSchema';
3
3
 
4
4
  const Default_AjaxSchema = {
@@ -1,17 +1,20 @@
1
1
  /* eslint-disable indent */
2
- import JSONWatch from '@src/utils/JSONWatch';
2
+ import JSONWatch from '$src/utils/JSONWatch';
3
3
  import AjaxSchema from '../base-schema/AjaxSchema';
4
4
 
5
5
  export default class TableSchema extends JSONWatch {
6
6
  constructor(props) {
7
7
  const {
8
8
  columns = [],
9
+ rowDoubleClick = [],
9
10
  actionColumns = [],
10
11
  bulkActions = [],
11
12
  primaryKey = 'id',
12
13
  tree = false, // 开启树形
14
+ treeLinkageCheck = false, // 树形 是否父子级联勾选
13
15
  showIndex = false, // 是否显示序号
14
- hideCommonToolbar = false, // 是否影藏通用顶部操作区
16
+ hideCommonToolbar = false, // 是否隐藏通用顶部操作区
17
+ actionMaxCharNum, // 操作列按钮最长字符数,可能会对一码多端效果造成影响,慎用
15
18
  actionWidth, // 操作列宽度
16
19
  showSelect = false, // 是否显示勾选操作
17
20
  remoteSort = false, // 是否开启远程排序
@@ -33,6 +36,7 @@ export default class TableSchema extends JSONWatch {
33
36
 
34
37
  super({
35
38
  columns,
39
+ rowDoubleClick,
36
40
  actionColumns,
37
41
  bulkActions,
38
42
  primaryKey,
@@ -40,12 +44,14 @@ export default class TableSchema extends JSONWatch {
40
44
  tree,
41
45
  showIndex,
42
46
  hideCommonToolbar,
47
+ actionMaxCharNum,
43
48
  actionWidth,
44
49
  showSelect,
45
50
  rowDetailModule,
46
51
  remoteSort,
47
52
  useVirtual,
48
53
  columnsAutoWidth,
54
+ treeLinkageCheck,
49
55
  ...more,
50
56
  });
51
57
  this.initAjaxSchemaData(loadChildrenDataApi);
@@ -92,7 +98,7 @@ export default class TableSchema extends JSONWatch {
92
98
  * {array} actionColumns 操作列
93
99
  * {object} pagination 分页
94
100
  */
95
- if (['columns', 'actionColumns', 'bulkActions'].includes(key)) {
101
+ if (['columns', 'actionColumns', 'bulkActions', 'rowDoubleClick'].includes(key)) {
96
102
  this.data[key].splice(index, 1, data);
97
103
  } else {
98
104
  this.data[key] = data;
@@ -5,9 +5,9 @@ import FormilyFormSchema from './formily-form';
5
5
  import FormilyFormV2Schema from './formily-form-v2';
6
6
  import DetailSchema from './detail';
7
7
  import EditTableSchema from './edit-table';
8
- import { EVENT_KEY, MDD_SCHEMA_LS_KEY } from '@src/common/const';
9
- import storage from '@src/utils/persistentStorage';
10
- import { IS_VSCODE, emitSave } from '@src/utils/vscode';
8
+ import { EVENT_KEY, MDD_SCHEMA_LS_KEY } from '$src/common/const';
9
+ import storage from '$src/utils/persistentStorage';
10
+ import { IS_VSCODE, emitSave } from '$src/utils/vscode';
11
11
 
12
12
  /**
13
13
  * 构建schema对象
@@ -1,6 +1,6 @@
1
1
  // import { request } from 'ice';
2
2
  import axios from 'axios';
3
- import jsonSchemaRefParser from '@src/utils/jsonSchemaRefParser';
3
+ import jsonSchemaRefParser from '$src/utils/jsonSchemaRefParser';
4
4
  // import $RefParser from '@apidevtools/json-schema-ref-parser';
5
5
 
6
6
  function transferOpenAPI3ToSwagger2(data) {
@@ -0,0 +1,62 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Input, Switch, Icon, NumberPicker } from '@cainiaofe/cn-ui';
3
+ import MddTableForm from '$src/components/mdd-table-form';
4
+ import { columnsTypeOptionsWithEditCnTable } from '../const';
5
+
6
+ export default function EditTablePanel({ schema }) {
7
+ const columnMddFormRef = React.useRef();
8
+ const [_, forceUpdate] = useState({});
9
+ useEffect(() => {
10
+ schema.on('$updated', (changeData, ignoreUpdate) => {
11
+ !ignoreUpdate && forceUpdate({});
12
+ });
13
+ }, []);
14
+
15
+ const columns = schema.get('columns');
16
+
17
+ const onAddHandle = (key) => {
18
+ switch (key) {
19
+ case 'columns':
20
+ schema.add(
21
+ {
22
+ type: 'text',
23
+ label: '展示项',
24
+ name: '',
25
+ },
26
+ 'columns',
27
+ true,
28
+ );
29
+ columnMddFormRef.current?.updateData(schema.get('columns'));
30
+ break;
31
+ default:
32
+ break;
33
+ }
34
+ };
35
+ const onRemoveHandle = (index, key) => {
36
+ schema.remove(index, key, true);
37
+ columnMddFormRef.current?.updateData(schema.get('columns'));
38
+ };
39
+
40
+ const onChangeHandle = ({ index, record }, key) => {
41
+ schema.update(index, record, key, true);
42
+ };
43
+
44
+ return (
45
+ <div>
46
+ <MddTableForm
47
+ ref={columnMddFormRef}
48
+ data={columns}
49
+ title="配置可编辑表格列"
50
+ componentOptions={columnsTypeOptionsWithEditCnTable.filter(
51
+ (col) => !['blocks-edit-table', 'blocks-table'].includes(col.value),
52
+ )}
53
+ onAdd={() => onAddHandle('columns')}
54
+ onRemove={(index) => onRemoveHandle(index, 'columns')}
55
+ onChange={({ index, record }) => onChangeHandle({ index, record }, 'columns')}
56
+ onSort={(newList) => {
57
+ schema.setItemAll(newList, 'columns', true);
58
+ }}
59
+ />
60
+ </div>
61
+ );
62
+ }
@@ -0,0 +1,137 @@
1
+ import React from 'react';
2
+ import { Form, NumberPicker, Select, Input, Switch } from '@cainiaofe/cn-ui';
3
+ import MddTableForm, { PenetrateTypes } from '$src/components/mdd-table-form';
4
+ import MddForm from '$src/components/mdd-form';
5
+ import { componentOptions } from '../const';
6
+
7
+ import { propFields } from '$src/common/comp-schema/fields/propFields';
8
+
9
+
10
+ const Default_Add_Schema = {
11
+ type: 'input',
12
+ label: '输入框',
13
+ name: '',
14
+ input: propFields.input,
15
+ };
16
+
17
+ // 缓存保存逻辑下拉数据源
18
+ const Save_Selected_Options = [
19
+ {
20
+ label: '不开启',
21
+ value: '',
22
+ },
23
+ {
24
+ label: '开启客户端缓存',
25
+ value: 'local',
26
+ },
27
+ {
28
+ label: '开启服务端缓存',
29
+ value: 'server',
30
+ },
31
+ ];
32
+
33
+ const FormColOpts = [
34
+ {
35
+ label: '自适应',
36
+ value: 0,
37
+ },
38
+ {
39
+ label: '1',
40
+ value: 1,
41
+ },
42
+ {
43
+ label: '2',
44
+ value: 2,
45
+ },
46
+ {
47
+ label: '3',
48
+ value: 3,
49
+ },
50
+ {
51
+ label: '4',
52
+ value: 4,
53
+ },
54
+ {
55
+ label: '5',
56
+ value: 5,
57
+ },
58
+ {
59
+ label: '6',
60
+ value: 6,
61
+ },
62
+ {
63
+ label: '7',
64
+ value: 7,
65
+ },
66
+ {
67
+ label: '8',
68
+ value: 8,
69
+ },
70
+ ];
71
+
72
+ export default function FilterPanel({ schema, swaggerFields = [] }) {
73
+ const mddFormRef = React.useRef();
74
+ const [_, forceUpdate] = React.useState({});
75
+ React.useEffect(() => {
76
+ schema.on('$updated', (changeData, ignoreUpdate) => {
77
+ !ignoreUpdate && forceUpdate({});
78
+ });
79
+ }, []);
80
+
81
+ const fields = schema.get('fields');
82
+
83
+ const refreshMddTableForm = () => {
84
+ mddFormRef.current?.updateData(schema.get('fields'));
85
+ };
86
+
87
+ const onAddHandle = () => {
88
+ schema.add(Default_Add_Schema, 'fields', true);
89
+ refreshMddTableForm();
90
+ };
91
+ const onRemoveHandle = (index) => {
92
+ schema.remove(index, 'fields', true);
93
+ refreshMddTableForm();
94
+ };
95
+
96
+ const onChangeHandle = ({ index, record }) => {
97
+ // 移除多余propsField
98
+ for (const k in propFields) {
99
+ if (record.type !== k) {
100
+ !['name'].includes(k) && delete record[k];
101
+ }
102
+ }
103
+
104
+ schema.update(index, record, 'fields', true);
105
+ };
106
+
107
+ return (
108
+ <div>
109
+ {/* MddTableForm 组件已经内置了状态,在需要update的时候再刷新,不要每次schema变化就刷新 */}
110
+ <MddTableForm
111
+ ref={mddFormRef}
112
+ data={fields}
113
+ penetrateType={PenetrateTypes.FILTER}
114
+ componentOptions={componentOptions}
115
+ title="配置查询条件"
116
+ onAdd={onAddHandle}
117
+ onRemove={onRemoveHandle}
118
+ onChange={onChangeHandle}
119
+ swaggerFieldDataSource={swaggerFields}
120
+ onSort={(newList) => {
121
+ schema.setFieldsAll(newList, true);
122
+ }}
123
+ />
124
+ </div>
125
+ );
126
+ }
127
+
128
+ /**
129
+ * 兼容老的格式,老格式是boolean 类型现在改成string类型
130
+ * https://alidocs.dingtalk.com/i/nodes/Obva6QBXJwxNZoMOC34Bmylx8n4qY5Pr
131
+ */
132
+ function adaptorSaveSelected(enableSaveSelected) {
133
+ if (typeof enableSaveSelected === 'boolean') {
134
+ return enableSaveSelected === true ? Save_Selected_Options[1].value : Save_Selected_Options[0].value;
135
+ }
136
+ return enableSaveSelected;
137
+ }