Commit ea4c3d0df881615450e2ff92a547b64024c574fe

Authored by 乔启韬
1 parent 202d7248

fix BUG2207190037关联记录表格分页

@@ -76,8 +76,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r @@ -76,8 +76,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
76 /* eslint-disable jsx-a11y/anchor-is-valid */ 76 /* eslint-disable jsx-a11y/anchor-is-valid */
77 import React, { useEffect, useMemo, useRef, useState } from 'react'; 77 import React, { useEffect, useMemo, useRef, useState } from 'react';
78 import Core from '../../index'; 78 import Core from '../../index';
79 -var confirm = _Modal.confirm;  
80 -import { useVT } from 'virtualizedtableforantd4'; 79 +var confirm = _Modal.confirm; // import {useVT} from 'virtualizedtableforantd4';
  80 +
81 var BUTTON_ICONS_MAP = { 81 var BUTTON_ICONS_MAP = {
82 ExportOutlined: /*#__PURE__*/React.createElement(_ExportOutlined, null), 82 ExportOutlined: /*#__PURE__*/React.createElement(_ExportOutlined, null),
83 ImportOutlined: /*#__PURE__*/React.createElement(_ImportOutlined, null), 83 ImportOutlined: /*#__PURE__*/React.createElement(_ImportOutlined, null),
@@ -124,11 +124,10 @@ var VirtualList = function VirtualList(_ref) { @@ -124,11 +124,10 @@ var VirtualList = function VirtualList(_ref) {
124 fieldName = schema.fieldName, 124 fieldName = schema.fieldName,
125 _schema$qxProps = schema.qxProps, 125 _schema$qxProps = schema.qxProps,
126 qxProps = _schema$qxProps === void 0 ? {} : _schema$qxProps, 126 qxProps = _schema$qxProps === void 0 ? {} : _schema$qxProps,
127 - subformMode = schema.subformMode,  
128 - pageType = schema.pageType; 127 + subformMode = schema.subformMode;
129 128
130 var _props$scrollY = props.scrollY, 129 var _props$scrollY = props.scrollY,
131 - scrollY = _props$scrollY === void 0 ? 400 : _props$scrollY, 130 + scrollY = _props$scrollY === void 0 ? 300 : _props$scrollY,
132 _summary = props.summary, 131 _summary = props.summary,
133 batchKey = props.batchKey, 132 batchKey = props.batchKey,
134 type = props.type, 133 type = props.type,
@@ -139,18 +138,8 @@ var VirtualList = function VirtualList(_ref) { @@ -139,18 +138,8 @@ var VirtualList = function VirtualList(_ref) {
139 searchKey = props.searchKey, 138 searchKey = props.searchKey,
140 rowSelection = props.rowSelection, 139 rowSelection = props.rowSelection,
141 size = props.size, 140 size = props.size,
142 - rest = _objectWithoutProperties(props, _excluded); 141 + rest = _objectWithoutProperties(props, _excluded); // const [vt, set_components] = useVT(() => ({scroll: {y: scrollY}}), []);
143 142
144 - var _useVT = useVT(function () {  
145 - return {  
146 - scroll: {  
147 - y: scrollY  
148 - }  
149 - };  
150 - }, []),  
151 - _useVT2 = _slicedToArray(_useVT, 2),  
152 - vt = _useVT2[0],  
153 - set_components = _useVT2[1];  
154 143
155 var _useState = useState(''), 144 var _useState = useState(''),
156 _useState2 = _slicedToArray(_useState, 2), 145 _useState2 = _slicedToArray(_useState, 2),
@@ -190,6 +179,8 @@ var VirtualList = function VirtualList(_ref) { @@ -190,6 +179,8 @@ var VirtualList = function VirtualList(_ref) {
190 var newRowSelection = useMemo(function () { 179 var newRowSelection = useMemo(function () {
191 var _bar$buttons; 180 var _bar$buttons;
192 181
  182 + if (schema.isReadOnly) return null;
  183 +
193 var _rowSelection = _.cloneDeep(rowSelection); // 根据是否含有批量操作按钮,渲染表格是否可选择 184 var _rowSelection = _.cloneDeep(rowSelection); // 根据是否含有批量操作按钮,渲染表格是否可选择
194 185
195 186
@@ -210,7 +201,7 @@ var VirtualList = function VirtualList(_ref) { @@ -210,7 +201,7 @@ var VirtualList = function VirtualList(_ref) {
210 } 201 }
211 202
212 return _rowSelection; 203 return _rowSelection;
213 - }, [rowSelection, selectedRowKeys, bar]); 204 + }, [rowSelection, selectedRowKeys, bar, rowSelection]);
214 useEffect(function () { 205 useEffect(function () {
215 displayList.forEach(function (item, index) { 206 displayList.forEach(function (item, index) {
216 if (_typeof(item) === 'object') { 207 if (_typeof(item) === 'object') {
@@ -287,14 +278,14 @@ var VirtualList = function VirtualList(_ref) { @@ -287,14 +278,14 @@ var VirtualList = function VirtualList(_ref) {
287 return { 278 return {
288 total: dataSource.length, 279 total: dataSource.length,
289 position: ['bottomRight'], 280 position: ['bottomRight'],
290 - pageSize: 10, 281 + pageSize: props.limit || 10,
291 showTotal: function showTotal(total) { 282 showTotal: function showTotal(total) {
292 return handleTotal(total); 283 return handleTotal(total);
293 }, 284 },
294 defaultCurrent: 1, 285 defaultCurrent: 1,
295 size: 'default' 286 size: 'default'
296 }; 287 };
297 - }, [dataSource]); 288 + }, [dataSource, props.limit]);
298 var barButtons = useMemo(function () { 289 var barButtons = useMemo(function () {
299 var _barButtons = _.cloneDeep(bar.buttons || []); // 关联表的导入,先隐藏 TODO 290 var _barButtons = _.cloneDeep(bar.buttons || []); // 关联表的导入,先隐藏 TODO
300 291
@@ -331,7 +322,7 @@ var VirtualList = function VirtualList(_ref) { @@ -331,7 +322,7 @@ var VirtualList = function VirtualList(_ref) {
331 }); 322 });
332 } 323 }
333 324
334 - if (props.originWidget === 'relSelector' && subformMode && type !== 'view') { 325 + if (props.originWidget === 'relSelector' && subformMode && type === 'edit') {
335 _barButtons.unshift({ 326 _barButtons.unshift({
336 code: 'subformEdit', 327 code: 'subformEdit',
337 icon: 'EditOutlined', 328 icon: 'EditOutlined',
@@ -419,12 +410,12 @@ var VirtualList = function VirtualList(_ref) { @@ -419,12 +410,12 @@ var VirtualList = function VirtualList(_ref) {
419 var column = ((_schema$props2 = schema.props) === null || _schema$props2 === void 0 ? void 0 : _schema$props2.column) || {}; 410 var column = ((_schema$props2 = schema.props) === null || _schema$props2 === void 0 ? void 0 : _schema$props2.column) || {};
420 return { 411 return {
421 dataIndex: child, 412 dataIndex: child,
422 - width: column.width ? parseInt(column.width) : FIELD_LENGTH, 413 + width: (column.width ? parseInt(column.width) : FIELD_LENGTH) + padding,
423 align: column.align || 'left', 414 align: column.align || 'left',
424 fixed: column.fixed || props.fixed && index < props.fixed, 415 fixed: column.fixed || props.fixed && index < props.fixed,
425 title: /*#__PURE__*/React.createElement("div", { 416 title: /*#__PURE__*/React.createElement("div", {
426 style: { 417 style: {
427 - width: (column.width ? parseInt(column.width) : FIELD_LENGTH - padding) + "px" 418 + width: (column.width ? parseInt(column.width) : FIELD_LENGTH) + "px"
428 } 419 }
429 }, schema.required ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { 420 }, schema.required ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
430 className: "fr-label-required" 421 className: "fr-label-required"
@@ -958,15 +949,13 @@ var VirtualList = function VirtualList(_ref) { @@ -958,15 +949,13 @@ var VirtualList = function VirtualList(_ref) {
958 scroll: { 949 scroll: {
959 y: scrollY, 950 y: scrollY,
960 x: '100%' 951 x: '100%'
961 - },  
962 - components: vt, 952 + } // components={vt}
  953 + ,
963 size: size || 'small', 954 size: size || 'small',
964 columns: columns, 955 columns: columns,
965 dataSource: dataSource, 956 dataSource: dataSource,
966 - pagination: pagination,  
967 - style: {  
968 - marginBottom: 25  
969 - }, 957 + pagination: pagination // style={{marginBottom: 25}}
  958 + ,
970 rowSelection: newRowSelection, 959 rowSelection: newRowSelection,
971 summary: function summary() { 960 summary: function summary() {
972 if (!_summary || Array.isArray(_summary) && !_summary.length) { 961 if (!_summary || Array.isArray(_summary) && !_summary.length) {
@@ -175,6 +175,10 @@ var RenderList = function RenderList(_ref) { @@ -175,6 +175,10 @@ var RenderList = function RenderList(_ref) {
175 getFieldsProps: getFieldsProps 175 getFieldsProps: getFieldsProps
176 }; 176 };
177 177
  178 + if (renderWidget === 'listForMobile') {
  179 + return /*#__PURE__*/React.createElement(ListForMobile, displayProps);
  180 + }
  181 +
178 switch (renderWidget) { 182 switch (renderWidget) {
179 case 'list0': 183 case 'list0':
180 case 'cardList': 184 case 'cardList':
@@ -195,9 +199,8 @@ var RenderList = function RenderList(_ref) { @@ -195,9 +199,8 @@ var RenderList = function RenderList(_ref) {
195 case 'list4': 199 case 'list4':
196 case 'virtualList': 200 case 'virtualList':
197 return /*#__PURE__*/React.createElement(VirtualList, displayProps); 201 return /*#__PURE__*/React.createElement(VirtualList, displayProps);
198 -  
199 - case 'listForMobile':  
200 - return /*#__PURE__*/React.createElement(ListForMobile, displayProps); 202 + // case 'listForMobile':
  203 + // return <ListForMobile {...displayProps} />
201 204
202 default: 205 default:
203 return /*#__PURE__*/React.createElement(CardList, displayProps); 206 return /*#__PURE__*/React.createElement(CardList, displayProps);
@@ -49,9 +49,6 @@ @@ -49,9 +49,6 @@
49 .rowReverse { 49 .rowReverse {
50 flex-direction: row-reverse; 50 flex-direction: row-reverse;
51 } 51 }
52 -.ant-modal-body .qx-virtualList {  
53 - margin-bottom: 0 !important;  
54 -}  
55 .qx-card-mobile .adm-list-item-content-main { 52 .qx-card-mobile .adm-list-item-content-main {
56 font-size: 14px; 53 font-size: 14px;
57 } 54 }
@@ -79,8 +79,6 @@ var _react = _interopRequireWildcard(require("react")); @@ -79,8 +79,6 @@ var _react = _interopRequireWildcard(require("react"));
79 79
80 var _index2 = _interopRequireDefault(require("../../index")); 80 var _index2 = _interopRequireDefault(require("../../index"));
81 81
82 -var _virtualizedtableforantd = require("virtualizedtableforantd4");  
83 -  
84 var _excluded = ["scrollY", "summary", "batchKey", "type", "bar", "line", "searchKey", "rowSelection", "size"]; 82 var _excluded = ["scrollY", "summary", "batchKey", "type", "bar", "line", "searchKey", "rowSelection", "size"];
85 83
86 function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } 84 function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -127,7 +125,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return @@ -127,7 +125,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
127 125
128 function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } 126 function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
129 127
130 -var confirm = _modal.default.confirm; 128 +var confirm = _modal.default.confirm; // import {useVT} from 'virtualizedtableforantd4';
  129 +
131 var BUTTON_ICONS_MAP = { 130 var BUTTON_ICONS_MAP = {
132 ExportOutlined: /*#__PURE__*/_react.default.createElement(_ExportOutlined2.default, null), 131 ExportOutlined: /*#__PURE__*/_react.default.createElement(_ExportOutlined2.default, null),
133 ImportOutlined: /*#__PURE__*/_react.default.createElement(_ImportOutlined2.default, null), 132 ImportOutlined: /*#__PURE__*/_react.default.createElement(_ImportOutlined2.default, null),
@@ -174,11 +173,10 @@ var VirtualList = function VirtualList(_ref) { @@ -174,11 +173,10 @@ var VirtualList = function VirtualList(_ref) {
174 fieldName = schema.fieldName, 173 fieldName = schema.fieldName,
175 _schema$qxProps = schema.qxProps, 174 _schema$qxProps = schema.qxProps,
176 qxProps = _schema$qxProps === void 0 ? {} : _schema$qxProps, 175 qxProps = _schema$qxProps === void 0 ? {} : _schema$qxProps,
177 - subformMode = schema.subformMode,  
178 - pageType = schema.pageType; 176 + subformMode = schema.subformMode;
179 177
180 var _props$scrollY = props.scrollY, 178 var _props$scrollY = props.scrollY,
181 - scrollY = _props$scrollY === void 0 ? 400 : _props$scrollY, 179 + scrollY = _props$scrollY === void 0 ? 300 : _props$scrollY,
182 _summary = props.summary, 180 _summary = props.summary,
183 batchKey = props.batchKey, 181 batchKey = props.batchKey,
184 type = props.type, 182 type = props.type,
@@ -189,18 +187,8 @@ var VirtualList = function VirtualList(_ref) { @@ -189,18 +187,8 @@ var VirtualList = function VirtualList(_ref) {
189 searchKey = props.searchKey, 187 searchKey = props.searchKey,
190 rowSelection = props.rowSelection, 188 rowSelection = props.rowSelection,
191 size = props.size, 189 size = props.size,
192 - rest = _objectWithoutProperties(props, _excluded); 190 + rest = _objectWithoutProperties(props, _excluded); // const [vt, set_components] = useVT(() => ({scroll: {y: scrollY}}), []);
193 191
194 - var _useVT = (0, _virtualizedtableforantd.useVT)(function () {  
195 - return {  
196 - scroll: {  
197 - y: scrollY  
198 - }  
199 - };  
200 - }, []),  
201 - _useVT2 = _slicedToArray(_useVT, 2),  
202 - vt = _useVT2[0],  
203 - set_components = _useVT2[1];  
204 192
205 var _useState = (0, _react.useState)(''), 193 var _useState = (0, _react.useState)(''),
206 _useState2 = _slicedToArray(_useState, 2), 194 _useState2 = _slicedToArray(_useState, 2),
@@ -240,6 +228,8 @@ var VirtualList = function VirtualList(_ref) { @@ -240,6 +228,8 @@ var VirtualList = function VirtualList(_ref) {
240 var newRowSelection = (0, _react.useMemo)(function () { 228 var newRowSelection = (0, _react.useMemo)(function () {
241 var _bar$buttons; 229 var _bar$buttons;
242 230
  231 + if (schema.isReadOnly) return null;
  232 +
243 var _rowSelection = _.cloneDeep(rowSelection); // 根据是否含有批量操作按钮,渲染表格是否可选择 233 var _rowSelection = _.cloneDeep(rowSelection); // 根据是否含有批量操作按钮,渲染表格是否可选择
244 234
245 235
@@ -260,7 +250,7 @@ var VirtualList = function VirtualList(_ref) { @@ -260,7 +250,7 @@ var VirtualList = function VirtualList(_ref) {
260 } 250 }
261 251
262 return _rowSelection; 252 return _rowSelection;
263 - }, [rowSelection, selectedRowKeys, bar]); 253 + }, [rowSelection, selectedRowKeys, bar, rowSelection]);
264 (0, _react.useEffect)(function () { 254 (0, _react.useEffect)(function () {
265 displayList.forEach(function (item, index) { 255 displayList.forEach(function (item, index) {
266 if (_typeof(item) === 'object') { 256 if (_typeof(item) === 'object') {
@@ -337,14 +327,14 @@ var VirtualList = function VirtualList(_ref) { @@ -337,14 +327,14 @@ var VirtualList = function VirtualList(_ref) {
337 return { 327 return {
338 total: dataSource.length, 328 total: dataSource.length,
339 position: ['bottomRight'], 329 position: ['bottomRight'],
340 - pageSize: 10, 330 + pageSize: props.limit || 10,
341 showTotal: function showTotal(total) { 331 showTotal: function showTotal(total) {
342 return handleTotal(total); 332 return handleTotal(total);
343 }, 333 },
344 defaultCurrent: 1, 334 defaultCurrent: 1,
345 size: 'default' 335 size: 'default'
346 }; 336 };
347 - }, [dataSource]); 337 + }, [dataSource, props.limit]);
348 var barButtons = (0, _react.useMemo)(function () { 338 var barButtons = (0, _react.useMemo)(function () {
349 var _barButtons = _.cloneDeep(bar.buttons || []); // 关联表的导入,先隐藏 TODO 339 var _barButtons = _.cloneDeep(bar.buttons || []); // 关联表的导入,先隐藏 TODO
350 340
@@ -381,7 +371,7 @@ var VirtualList = function VirtualList(_ref) { @@ -381,7 +371,7 @@ var VirtualList = function VirtualList(_ref) {
381 }); 371 });
382 } 372 }
383 373
384 - if (props.originWidget === 'relSelector' && subformMode && type !== 'view') { 374 + if (props.originWidget === 'relSelector' && subformMode && type === 'edit') {
385 _barButtons.unshift({ 375 _barButtons.unshift({
386 code: 'subformEdit', 376 code: 'subformEdit',
387 icon: 'EditOutlined', 377 icon: 'EditOutlined',
@@ -471,12 +461,12 @@ var VirtualList = function VirtualList(_ref) { @@ -471,12 +461,12 @@ var VirtualList = function VirtualList(_ref) {
471 var column = ((_schema$props2 = schema.props) === null || _schema$props2 === void 0 ? void 0 : _schema$props2.column) || {}; 461 var column = ((_schema$props2 = schema.props) === null || _schema$props2 === void 0 ? void 0 : _schema$props2.column) || {};
472 return { 462 return {
473 dataIndex: child, 463 dataIndex: child,
474 - width: column.width ? parseInt(column.width) : FIELD_LENGTH, 464 + width: (column.width ? parseInt(column.width) : FIELD_LENGTH) + padding,
475 align: column.align || 'left', 465 align: column.align || 'left',
476 fixed: column.fixed || props.fixed && index < props.fixed, 466 fixed: column.fixed || props.fixed && index < props.fixed,
477 title: /*#__PURE__*/_react.default.createElement("div", { 467 title: /*#__PURE__*/_react.default.createElement("div", {
478 style: { 468 style: {
479 - width: (column.width ? parseInt(column.width) : FIELD_LENGTH - padding) + "px" 469 + width: (column.width ? parseInt(column.width) : FIELD_LENGTH) + "px"
480 } 470 }
481 }, schema.required ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", { 471 }, schema.required ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
482 className: "fr-label-required" 472 className: "fr-label-required"
@@ -1010,15 +1000,13 @@ var VirtualList = function VirtualList(_ref) { @@ -1010,15 +1000,13 @@ var VirtualList = function VirtualList(_ref) {
1010 scroll: { 1000 scroll: {
1011 y: scrollY, 1001 y: scrollY,
1012 x: '100%' 1002 x: '100%'
1013 - },  
1014 - components: vt, 1003 + } // components={vt}
  1004 + ,
1015 size: size || 'small', 1005 size: size || 'small',
1016 columns: columns, 1006 columns: columns,
1017 dataSource: dataSource, 1007 dataSource: dataSource,
1018 - pagination: pagination,  
1019 - style: {  
1020 - marginBottom: 25  
1021 - }, 1008 + pagination: pagination // style={{marginBottom: 25}}
  1009 + ,
1022 rowSelection: newRowSelection, 1010 rowSelection: newRowSelection,
1023 summary: function summary() { 1011 summary: function summary() {
1024 if (!_summary || Array.isArray(_summary) && !_summary.length) { 1012 if (!_summary || Array.isArray(_summary) && !_summary.length) {
@@ -192,6 +192,10 @@ var RenderList = function RenderList(_ref) { @@ -192,6 +192,10 @@ var RenderList = function RenderList(_ref) {
192 getFieldsProps: getFieldsProps 192 getFieldsProps: getFieldsProps
193 }; 193 };
194 194
  195 + if (renderWidget === 'listForMobile') {
  196 + return /*#__PURE__*/_react.default.createElement(_ListForMobile.default, displayProps);
  197 + }
  198 +
195 switch (renderWidget) { 199 switch (renderWidget) {
196 case 'list0': 200 case 'list0':
197 case 'cardList': 201 case 'cardList':
@@ -212,9 +216,8 @@ var RenderList = function RenderList(_ref) { @@ -212,9 +216,8 @@ var RenderList = function RenderList(_ref) {
212 case 'list4': 216 case 'list4':
213 case 'virtualList': 217 case 'virtualList':
214 return /*#__PURE__*/_react.default.createElement(_VirtualList.default, displayProps); 218 return /*#__PURE__*/_react.default.createElement(_VirtualList.default, displayProps);
215 -  
216 - case 'listForMobile':  
217 - return /*#__PURE__*/_react.default.createElement(_ListForMobile.default, displayProps); 219 + // case 'listForMobile':
  220 + // return <ListForMobile {...displayProps} />
218 221
219 default: 222 default:
220 return /*#__PURE__*/_react.default.createElement(_CardList.default, displayProps); 223 return /*#__PURE__*/_react.default.createElement(_CardList.default, displayProps);
@@ -49,9 +49,6 @@ @@ -49,9 +49,6 @@
49 .rowReverse { 49 .rowReverse {
50 flex-direction: row-reverse; 50 flex-direction: row-reverse;
51 } 51 }
52 -.ant-modal-body .qx-virtualList {  
53 - margin-bottom: 0 !important;  
54 -}  
55 .qx-card-mobile .adm-list-item-content-main { 52 .qx-card-mobile .adm-list-item-content-main {
56 font-size: 14px; 53 font-size: 14px;
57 } 54 }
1 { 1 {
2 "name": "@qx/form-render", 2 "name": "@qx/form-render",
3 - "version": "0.0.31-fix", 3 + "version": "0.0.32-fix",
4 "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成", 4 "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5 "repository": { 5 "repository": {
6 "type": "git", 6 "type": "git",