ztxkui 2.4.2 → 2.4.5

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.
@@ -17,6 +17,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
17
17
  import React, { useEffect, useState, useCallback, useRef } from 'react';
18
18
  import Table from 'components/Table';
19
19
  import EnhanceSelect from 'components/EnhanceSelect';
20
+ import TestCom from './TestCom';
20
21
  import { DatePicker } from 'index';
21
22
  import dayjs from 'dayjs';
22
23
  import update from 'immutability-helper';
@@ -108,6 +109,173 @@ export var getTableLayoutFullData = function (columns, tableLayout) {
108
109
  }
109
110
  return columns;
110
111
  };
112
+ var list1 = [
113
+ {
114
+ id: '010101',
115
+ name: '重轨',
116
+ aboutField: {
117
+ // 品名
118
+ brand: {
119
+ isRequired: 1,
120
+ addonBefore: null,
121
+ addonAfter: null,
122
+ unit: null,
123
+ connector: ' ', // 连接符
124
+ },
125
+ // 材质
126
+ texture: {
127
+ isRequired: 1,
128
+ addonBefore: null,
129
+ addonAfter: null,
130
+ unit: null,
131
+ connector: ' ', // 连接符
132
+ },
133
+ // 规格,一个产品层次可能对应多个规格
134
+ specifications: [
135
+ {
136
+ title: '单位重量',
137
+ isRequired: 1,
138
+ addonBefore: null,
139
+ addonAfter: null,
140
+ unit: 'kg/m',
141
+ connector: '*', // 连接符
142
+ },
143
+ {
144
+ title: '长度',
145
+ isRequired: 1,
146
+ addonBefore: null,
147
+ addonAfter: null,
148
+ unit: 'm',
149
+ connector: null, // 连接符
150
+ },
151
+ ],
152
+ // 产地
153
+ placesteel: {
154
+ isRequired: 1,
155
+ addonBefore: null,
156
+ addonAfter: null,
157
+ unit: null,
158
+ connector: null, // 连接符
159
+ },
160
+ // 型号
161
+ model: null,
162
+ },
163
+ },
164
+ {
165
+ id: '010102',
166
+ name: '轻轨',
167
+ aboutField: {
168
+ // 品名
169
+ brand: {
170
+ isRequired: 1,
171
+ addonBefore: null,
172
+ addonAfter: null,
173
+ unit: null,
174
+ connector: ' ', // 连接符
175
+ },
176
+ // 材质
177
+ texture: null,
178
+ // 规格,一个产品层次可能对应多个规格
179
+ specifications: [
180
+ {
181
+ title: '单位重量',
182
+ isRequired: 1,
183
+ addonBefore: null,
184
+ addonAfter: null,
185
+ unit: 'kg/m',
186
+ connector: '*', // 连接符
187
+ },
188
+ {
189
+ title: '长度',
190
+ isRequired: 1,
191
+ addonBefore: null,
192
+ addonAfter: null,
193
+ unit: 'm',
194
+ connector: null, // 连接符
195
+ },
196
+ ],
197
+ // 产地
198
+ placesteel: {
199
+ isRequired: 1,
200
+ addonBefore: null,
201
+ addonAfter: null,
202
+ unit: null,
203
+ connector: null, // 连接符
204
+ },
205
+ // 型号
206
+ model: null,
207
+ },
208
+ },
209
+ {
210
+ id: '010203',
211
+ name: '角钢',
212
+ aboutField: {
213
+ // 品名
214
+ brand: {
215
+ isRequired: 1,
216
+ addonBefore: null,
217
+ addonAfter: null,
218
+ unit: null,
219
+ connector: ' ', // 连接符
220
+ },
221
+ // 材质
222
+ texture: {
223
+ isRequired: 1,
224
+ addonBefore: null,
225
+ addonAfter: null,
226
+ unit: null,
227
+ connector: null, // 连接符
228
+ },
229
+ // 规格,一个产品层次可能对应多个规格
230
+ specifications: [
231
+ {
232
+ title: '边宽度1',
233
+ isRequired: 1,
234
+ addonBefore: null,
235
+ addonAfter: null,
236
+ unit: null,
237
+ connector: '*',
238
+ valueType: 'select',
239
+ source: '/api/test/111',
240
+ },
241
+ {
242
+ title: '边宽度2',
243
+ isRequired: 1,
244
+ addonBefore: null,
245
+ addonAfter: null,
246
+ unit: null,
247
+ connector: '*', // 连接符
248
+ },
249
+ {
250
+ title: '边厚度',
251
+ isRequired: 1,
252
+ addonBefore: null,
253
+ addonAfter: null,
254
+ unit: 'mm',
255
+ connector: ' ', // 连接符
256
+ },
257
+ {
258
+ title: '长度',
259
+ isRequired: 1,
260
+ addonBefore: null,
261
+ addonAfter: null,
262
+ unit: 'm',
263
+ connector: '', // 连接符
264
+ },
265
+ ],
266
+ // 产地
267
+ placesteel: {
268
+ isRequired: 1,
269
+ addonBefore: null,
270
+ addonAfter: null,
271
+ unit: null,
272
+ connector: ' ', // 连接符
273
+ },
274
+ // 型号
275
+ model: null,
276
+ },
277
+ },
278
+ ];
111
279
  var TableDemo = function () {
112
280
  var _a = useGetTableRecords(), records = _a.records, setRecords = _a.setRecords;
113
281
  var _b = useGetSelectList(), list = _b.list, loading = _b.loading, setLoading = _b.setLoading;
@@ -136,6 +304,61 @@ var TableDemo = function () {
136
304
  key: 'index',
137
305
  render: function (_text, _record, index) { return "" + (index + 1); },
138
306
  },
307
+ {
308
+ title: '产品层次',
309
+ width: 100,
310
+ dataIndex: 'key2',
311
+ key: 'key2',
312
+ shouldCellUpdate: function (record, preRecord) {
313
+ console.log('key2render');
314
+ if (lengthChange) {
315
+ setLengthChange(false);
316
+ return true;
317
+ }
318
+ if (moveChange) {
319
+ setMoveChange(false);
320
+ return true;
321
+ }
322
+ return record.key2 !== preRecord.key2;
323
+ },
324
+ render: function (text, record, index) {
325
+ return (React.createElement(EnhanceSelect, { value: text, list: list1, dataKey: "id", titleKey: "name", onChange: function (value, option, fullData) {
326
+ var newRecord = {
327
+ key2: value,
328
+ key2Name: fullData === null || fullData === void 0 ? void 0 : fullData.name,
329
+ aboutField: fullData === null || fullData === void 0 ? void 0 : fullData.aboutField,
330
+ };
331
+ onEditableSaveHandle(newRecord, index);
332
+ } }));
333
+ },
334
+ },
335
+ {
336
+ title: '物料选择相关',
337
+ width: 700,
338
+ dataIndex: 'key1',
339
+ key: 'key1',
340
+ shouldCellUpdate: function (record, preRecord) {
341
+ if (lengthChange) {
342
+ setLengthChange(false);
343
+ return true;
344
+ }
345
+ if (moveChange) {
346
+ setMoveChange(false);
347
+ return true;
348
+ }
349
+ return record.key1 !== preRecord.key1 || record.key2 !== preRecord.key2;
350
+ },
351
+ render: function (text, record, index) {
352
+ var aboutField;
353
+ try {
354
+ aboutField = JSON.stringify(record === null || record === void 0 ? void 0 : record.aboutField);
355
+ }
356
+ catch (err) {
357
+ console.log(err);
358
+ }
359
+ return React.createElement(TestCom, { aboutField: aboutField, controleType: "hide" });
360
+ },
361
+ },
139
362
  {
140
363
  title: '测试字段1',
141
364
  width: 120,
@@ -381,7 +604,7 @@ var TableDemo = function () {
381
604
  // 新增删除行
382
605
  onAddAndDelHandle: onAddAndDelHandle,
383
606
  // 表格行拖拽
384
- onMoveRow: onMoveRowHandle, rowClassName: function () { return Table.DiffClassName; } }),
607
+ onMoveRow: onMoveRowHandle }),
385
608
  React.createElement("div", null,
386
609
  React.createElement("button", { onClick: function () { return console.log(records); } }, "\u83B7\u53D6\u6570\u636E"))));
387
610
  };
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import './style.scss';
3
+ export interface IAboutField {
4
+ isRequired: any;
5
+ addonBefore: any;
6
+ addonAfter: any;
7
+ unit: any;
8
+ connector: any;
9
+ title?: string;
10
+ }
11
+ interface IProps {
12
+ value?: any;
13
+ onChange?: any;
14
+ aboutField?: any;
15
+ controleType?: 'disabled' | 'hide';
16
+ }
17
+ declare const MaterialComp: React.FC<IProps>;
18
+ export default MaterialComp;
@@ -0,0 +1,178 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import React, { useMemo, useEffect, useState } from 'react';
13
+ import Form from '../components/Form';
14
+ import SearchContainer from '../components/business/SearchContainer';
15
+ import Input from '../components/Input';
16
+ import Modal from '../components/Modal';
17
+ import EnhanceSelect from 'components/EnhanceSelect';
18
+ import './style.scss';
19
+ import Button from 'components/Button';
20
+ var SearchItem = SearchContainer.SearchItem, SearchLeft = SearchContainer.SearchLeft;
21
+ /**
22
+ * 品名:brand
23
+ * 材质:texture
24
+ * 规格:specifications
25
+ * 产地:placesteel
26
+ * 型号:model
27
+ */
28
+ var width = '120px';
29
+ var initConfigInfo = {
30
+ brand: {
31
+ isChangeable: 0,
32
+ isDisplay: 1,
33
+ },
34
+ texture: {
35
+ isChangeable: 0,
36
+ isDisplay: 1,
37
+ },
38
+ specifications: {
39
+ isChangeable: 0,
40
+ isDisplay: 1,
41
+ },
42
+ placesteel: {
43
+ isChangeable: 0,
44
+ isDisplay: 1,
45
+ },
46
+ model: {
47
+ isChangeable: 0,
48
+ isDisplay: 1,
49
+ },
50
+ };
51
+ var list = [
52
+ {
53
+ id: '1',
54
+ name: '&11kg*8',
55
+ },
56
+ {
57
+ id: '2',
58
+ name: '33m*44mm',
59
+ },
60
+ {
61
+ id: '3',
62
+ name: '@17$22*22 22&',
63
+ },
64
+ ];
65
+ var MaterialComp = function (_a) {
66
+ var value = _a.value, onChange = _a.onChange, aboutField = _a.aboutField, controleType = _a.controleType;
67
+ var form = Form.useForm()[0];
68
+ var _b = useState(initConfigInfo), configInfo = _b[0], setConfigInfo = _b[1];
69
+ console.log('test render');
70
+ var controlConfigInfo = useMemo(function () {
71
+ return controleType === 'hide'
72
+ ? {
73
+ isDisplay: 0,
74
+ isChangeable: 1,
75
+ }
76
+ : {
77
+ isDisplay: 1,
78
+ isChangeable: 0,
79
+ };
80
+ }, [controleType]);
81
+ var aboutFieldObj = useMemo(function () {
82
+ if (!aboutField) {
83
+ return {};
84
+ }
85
+ var _aboutFieldObj;
86
+ try {
87
+ _aboutFieldObj = JSON.parse(aboutField);
88
+ return _aboutFieldObj;
89
+ }
90
+ catch (err) {
91
+ console.log(err);
92
+ return {};
93
+ }
94
+ }, [aboutField]);
95
+ /**
96
+ * 根据外部参数变更内部内容
97
+ */
98
+ useEffect(function () {
99
+ var _configInfo = {};
100
+ Object.keys(aboutFieldObj).forEach(function (key) {
101
+ var _a;
102
+ if (key === 'specifications') {
103
+ // 规格需要做不同的处理
104
+ if (!aboutFieldObj[key]) {
105
+ _configInfo[key] = __assign({}, controlConfigInfo);
106
+ }
107
+ else {
108
+ var isRequired = (_a = aboutFieldObj[key]) === null || _a === void 0 ? void 0 : _a.some(function (item) {
109
+ return item.isRequired ? true : false;
110
+ });
111
+ _configInfo[key] = {
112
+ isDisplay: 1,
113
+ isChangeable: 1,
114
+ isRequired: isRequired ? 1 : 0,
115
+ };
116
+ }
117
+ }
118
+ else {
119
+ var isRequired = (aboutFieldObj[key] || {}).isRequired;
120
+ if (!aboutFieldObj[key]) {
121
+ _configInfo[key] = __assign({}, controlConfigInfo);
122
+ }
123
+ else {
124
+ _configInfo[key] = {
125
+ isDisplay: 1,
126
+ isChangeable: 1,
127
+ isRequired: isRequired ? 1 : 0,
128
+ };
129
+ }
130
+ }
131
+ });
132
+ if (Object.keys(_configInfo).length !== 0) {
133
+ setConfigInfo(_configInfo);
134
+ }
135
+ else {
136
+ setConfigInfo(initConfigInfo);
137
+ }
138
+ }, [controlConfigInfo, aboutFieldObj]);
139
+ return (React.createElement(Form, { name: "test-list", form: form, className: "table-form" },
140
+ React.createElement(SearchContainer, null,
141
+ React.createElement(SearchLeft, { configInfo: configInfo },
142
+ React.createElement(SearchItem, { style: { width: width }, label: "\u54C1\u540D", name: "brand" },
143
+ React.createElement(Input, null)),
144
+ React.createElement(SearchItem, { style: { width: width }, label: "\u6750\u8D28", name: "texture" },
145
+ React.createElement(Input, null)),
146
+ React.createElement(SearchItem, { style: { width: '162px' }, label: "\u89C4\u683C", name: "specifications" },
147
+ React.createElement(SpecificationsComp, { config: aboutFieldObj === null || aboutFieldObj === void 0 ? void 0 : aboutFieldObj.specifications })),
148
+ React.createElement(SearchItem, { style: { width: width }, label: "\u4EA7\u5730", name: "placesteel" },
149
+ React.createElement(Input, null)),
150
+ React.createElement(SearchItem, { style: { width: width }, label: "\u578B\u53F7", name: "model" },
151
+ React.createElement(Input, null))))));
152
+ };
153
+ var SpecificationsComp = function (_a) {
154
+ var value = _a.value, onChange = _a.onChange, config = _a.config, disabled = _a.disabled;
155
+ var _b = useState(false), visible = _b[0], setVisible = _b[1];
156
+ /**
157
+ * @description 模态框设置
158
+ */
159
+ var dataConfig = function () {
160
+ console.log(config);
161
+ };
162
+ /**
163
+ * @description 模态框关闭隐藏
164
+ */
165
+ var openModal = function () {
166
+ dataConfig();
167
+ setVisible(true);
168
+ };
169
+ var closeModal = function () {
170
+ setVisible(false);
171
+ };
172
+ return (React.createElement(React.Fragment, null,
173
+ React.createElement(EnhanceSelect, { defaultList: list, disabled: disabled, value: value, onChange: onChange, dropdownMatchSelectWidth: 130 }),
174
+ React.createElement(Button, { type: "primary", size: "small", disabled: disabled, onClick: openModal }, "\u65B0\u5EFA"),
175
+ React.createElement(Modal, { visible: visible, loading: false, onCancel: closeModal, maskClosable: false, title: "\u9009\u62E9\u89C4\u683C", width: "60%" },
176
+ React.createElement("div", null, "\u9009\u62E9\u89C4\u683C"))));
177
+ };
178
+ export default MaterialComp;
@@ -150,7 +150,7 @@ function Table(props) {
150
150
  // }
151
151
  }, [onMoveRow]);
152
152
  return (React.createElement("div", { style: { position: 'relative', overflow: 'hidden' } },
153
- React.createElement(DndProvider, { backend: HTML5Backend },
153
+ React.createElement(DndProvider, { backend: HTML5Backend, context: window },
154
154
  React.createElement(AntTable, __assign({ className: classes, bordered: bordered, pagination: pagination, scroll: scroll ? scroll : _scroll, columns: newColumns, dataSource: dataSource, components: onMoveRow || onEditableSave ? components : undefined, onRow: onMoveRow
155
155
  ? function (record, index) {
156
156
  return ({
@@ -20,15 +20,15 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import React from 'react';
23
+ import React, { forwardRef } from 'react';
24
24
  import { Spin } from 'antd';
25
25
  import classNames from 'classnames';
26
- var Container = function (_a) {
26
+ var Container = forwardRef(function (_a, ref) {
27
27
  var loading = _a.loading, children = _a.children, className = _a.className, restProps = __rest(_a, ["loading", "children", "className"]);
28
28
  var classes = classNames('zt-container', className);
29
- return (React.createElement("div", __assign({ className: classes }, restProps),
29
+ return (React.createElement("div", __assign({ className: classes }, restProps, { ref: ref }),
30
30
  loading && (React.createElement("div", { className: "zt-container__loading" },
31
31
  React.createElement(Spin, { size: "large", spinning: loading }))),
32
32
  children));
33
- };
33
+ });
34
34
  export default Container;
@@ -58,7 +58,7 @@ var SearchDrawer = function (_a) {
58
58
  React.createElement(Button, { type: "default", onClick: onReset }, "\u91CD\u7F6E"),
59
59
  React.createElement(Button, { type: "primary", onClick: onSureHandle }, "\u786E\u5B9A"))); };
60
60
  return (React.createElement(Drawer, { className: "search-drawer", title: "\u67E5\u8BE2\u6761\u4EF6\u5207\u6362", placement: "right", visible: visible, closable: false, maskClosable: false, footer: renderFooter() },
61
- React.createElement(DndProvider, { backend: HTML5Backend },
61
+ React.createElement(DndProvider, { backend: HTML5Backend, context: window },
62
62
  React.createElement(Checkbox.Group, { value: checkedValues, onChange: onCheckboxChange }, dynamicList.map(function (item, index) { return (React.createElement(Sortable, { key: item.name, type: "search-drawer", index: index, onMoveItem: onMoveItem },
63
63
  React.createElement(Checkbox, { value: item.name }, item.label || item.name))); })))));
64
64
  };
@@ -45,9 +45,7 @@ var SearchItem = function (_a) {
45
45
  'zt-search__left__item--noborder': noBorder,
46
46
  'zt-search__left__item--nolabel': noLabel,
47
47
  });
48
- return (React.createElement("div", { className: classes, style: {
49
- width: getWidthStr(width),
50
- } },
48
+ return (React.createElement("div", { className: classes, style: __assign({ width: getWidthStr(width) }, style) },
51
49
  React.createElement(Item, __assign({}, restProps), children)));
52
50
  };
53
51
  export default SearchItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "2.4.2",
3
+ "version": "2.4.5",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",