Showing
7 changed files
with
47 additions
and
70 deletions
| ... | ... | @@ -76,8 +76,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r |
| 76 | 76 | /* eslint-disable jsx-a11y/anchor-is-valid */ |
| 77 | 77 | import React, { useEffect, useMemo, useRef, useState } from 'react'; |
| 78 | 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 | 81 | var BUTTON_ICONS_MAP = { |
| 82 | 82 | ExportOutlined: /*#__PURE__*/React.createElement(_ExportOutlined, null), |
| 83 | 83 | ImportOutlined: /*#__PURE__*/React.createElement(_ImportOutlined, null), |
| ... | ... | @@ -124,11 +124,10 @@ var VirtualList = function VirtualList(_ref) { |
| 124 | 124 | fieldName = schema.fieldName, |
| 125 | 125 | _schema$qxProps = schema.qxProps, |
| 126 | 126 | qxProps = _schema$qxProps === void 0 ? {} : _schema$qxProps, |
| 127 | - subformMode = schema.subformMode, | |
| 128 | - pageType = schema.pageType; | |
| 127 | + subformMode = schema.subformMode; | |
| 129 | 128 | |
| 130 | 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 | 131 | _summary = props.summary, |
| 133 | 132 | batchKey = props.batchKey, |
| 134 | 133 | type = props.type, |
| ... | ... | @@ -139,18 +138,8 @@ var VirtualList = function VirtualList(_ref) { |
| 139 | 138 | searchKey = props.searchKey, |
| 140 | 139 | rowSelection = props.rowSelection, |
| 141 | 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 | 144 | var _useState = useState(''), |
| 156 | 145 | _useState2 = _slicedToArray(_useState, 2), |
| ... | ... | @@ -190,6 +179,8 @@ var VirtualList = function VirtualList(_ref) { |
| 190 | 179 | var newRowSelection = useMemo(function () { |
| 191 | 180 | var _bar$buttons; |
| 192 | 181 | |
| 182 | + if (schema.isReadOnly) return null; | |
| 183 | + | |
| 193 | 184 | var _rowSelection = _.cloneDeep(rowSelection); // 根据是否含有批量操作按钮,渲染表格是否可选择 |
| 194 | 185 | |
| 195 | 186 | |
| ... | ... | @@ -210,7 +201,7 @@ var VirtualList = function VirtualList(_ref) { |
| 210 | 201 | } |
| 211 | 202 | |
| 212 | 203 | return _rowSelection; |
| 213 | - }, [rowSelection, selectedRowKeys, bar]); | |
| 204 | + }, [rowSelection, selectedRowKeys, bar, rowSelection]); | |
| 214 | 205 | useEffect(function () { |
| 215 | 206 | displayList.forEach(function (item, index) { |
| 216 | 207 | if (_typeof(item) === 'object') { |
| ... | ... | @@ -287,14 +278,14 @@ var VirtualList = function VirtualList(_ref) { |
| 287 | 278 | return { |
| 288 | 279 | total: dataSource.length, |
| 289 | 280 | position: ['bottomRight'], |
| 290 | - pageSize: 10, | |
| 281 | + pageSize: props.limit || 10, | |
| 291 | 282 | showTotal: function showTotal(total) { |
| 292 | 283 | return handleTotal(total); |
| 293 | 284 | }, |
| 294 | 285 | defaultCurrent: 1, |
| 295 | 286 | size: 'default' |
| 296 | 287 | }; |
| 297 | - }, [dataSource]); | |
| 288 | + }, [dataSource, props.limit]); | |
| 298 | 289 | var barButtons = useMemo(function () { |
| 299 | 290 | var _barButtons = _.cloneDeep(bar.buttons || []); // 关联表的导入,先隐藏 TODO |
| 300 | 291 | |
| ... | ... | @@ -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 | 326 | _barButtons.unshift({ |
| 336 | 327 | code: 'subformEdit', |
| 337 | 328 | icon: 'EditOutlined', |
| ... | ... | @@ -419,12 +410,12 @@ var VirtualList = function VirtualList(_ref) { |
| 419 | 410 | var column = ((_schema$props2 = schema.props) === null || _schema$props2 === void 0 ? void 0 : _schema$props2.column) || {}; |
| 420 | 411 | return { |
| 421 | 412 | dataIndex: child, |
| 422 | - width: column.width ? parseInt(column.width) : FIELD_LENGTH, | |
| 413 | + width: (column.width ? parseInt(column.width) : FIELD_LENGTH) + padding, | |
| 423 | 414 | align: column.align || 'left', |
| 424 | 415 | fixed: column.fixed || props.fixed && index < props.fixed, |
| 425 | 416 | title: /*#__PURE__*/React.createElement("div", { |
| 426 | 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 | 420 | }, schema.required ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { |
| 430 | 421 | className: "fr-label-required" |
| ... | ... | @@ -958,15 +949,13 @@ var VirtualList = function VirtualList(_ref) { |
| 958 | 949 | scroll: { |
| 959 | 950 | y: scrollY, |
| 960 | 951 | x: '100%' |
| 961 | - }, | |
| 962 | - components: vt, | |
| 952 | + } // components={vt} | |
| 953 | + , | |
| 963 | 954 | size: size || 'small', |
| 964 | 955 | columns: columns, |
| 965 | 956 | dataSource: dataSource, |
| 966 | - pagination: pagination, | |
| 967 | - style: { | |
| 968 | - marginBottom: 25 | |
| 969 | - }, | |
| 957 | + pagination: pagination // style={{marginBottom: 25}} | |
| 958 | + , | |
| 970 | 959 | rowSelection: newRowSelection, |
| 971 | 960 | summary: function summary() { |
| 972 | 961 | if (!_summary || Array.isArray(_summary) && !_summary.length) { | ... | ... |
| ... | ... | @@ -175,6 +175,10 @@ var RenderList = function RenderList(_ref) { |
| 175 | 175 | getFieldsProps: getFieldsProps |
| 176 | 176 | }; |
| 177 | 177 | |
| 178 | + if (renderWidget === 'listForMobile') { | |
| 179 | + return /*#__PURE__*/React.createElement(ListForMobile, displayProps); | |
| 180 | + } | |
| 181 | + | |
| 178 | 182 | switch (renderWidget) { |
| 179 | 183 | case 'list0': |
| 180 | 184 | case 'cardList': |
| ... | ... | @@ -195,9 +199,8 @@ var RenderList = function RenderList(_ref) { |
| 195 | 199 | case 'list4': |
| 196 | 200 | case 'virtualList': |
| 197 | 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 | 205 | default: |
| 203 | 206 | return /*#__PURE__*/React.createElement(CardList, displayProps); | ... | ... |
| ... | ... | @@ -79,8 +79,6 @@ var _react = _interopRequireWildcard(require("react")); |
| 79 | 79 | |
| 80 | 80 | var _index2 = _interopRequireDefault(require("../../index")); |
| 81 | 81 | |
| 82 | -var _virtualizedtableforantd = require("virtualizedtableforantd4"); | |
| 83 | - | |
| 84 | 82 | var _excluded = ["scrollY", "summary", "batchKey", "type", "bar", "line", "searchKey", "rowSelection", "size"]; |
| 85 | 83 | |
| 86 | 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 | 125 | |
| 128 | 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 | 130 | var BUTTON_ICONS_MAP = { |
| 132 | 131 | ExportOutlined: /*#__PURE__*/_react.default.createElement(_ExportOutlined2.default, null), |
| 133 | 132 | ImportOutlined: /*#__PURE__*/_react.default.createElement(_ImportOutlined2.default, null), |
| ... | ... | @@ -174,11 +173,10 @@ var VirtualList = function VirtualList(_ref) { |
| 174 | 173 | fieldName = schema.fieldName, |
| 175 | 174 | _schema$qxProps = schema.qxProps, |
| 176 | 175 | qxProps = _schema$qxProps === void 0 ? {} : _schema$qxProps, |
| 177 | - subformMode = schema.subformMode, | |
| 178 | - pageType = schema.pageType; | |
| 176 | + subformMode = schema.subformMode; | |
| 179 | 177 | |
| 180 | 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 | 180 | _summary = props.summary, |
| 183 | 181 | batchKey = props.batchKey, |
| 184 | 182 | type = props.type, |
| ... | ... | @@ -189,18 +187,8 @@ var VirtualList = function VirtualList(_ref) { |
| 189 | 187 | searchKey = props.searchKey, |
| 190 | 188 | rowSelection = props.rowSelection, |
| 191 | 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 | 193 | var _useState = (0, _react.useState)(''), |
| 206 | 194 | _useState2 = _slicedToArray(_useState, 2), |
| ... | ... | @@ -240,6 +228,8 @@ var VirtualList = function VirtualList(_ref) { |
| 240 | 228 | var newRowSelection = (0, _react.useMemo)(function () { |
| 241 | 229 | var _bar$buttons; |
| 242 | 230 | |
| 231 | + if (schema.isReadOnly) return null; | |
| 232 | + | |
| 243 | 233 | var _rowSelection = _.cloneDeep(rowSelection); // 根据是否含有批量操作按钮,渲染表格是否可选择 |
| 244 | 234 | |
| 245 | 235 | |
| ... | ... | @@ -260,7 +250,7 @@ var VirtualList = function VirtualList(_ref) { |
| 260 | 250 | } |
| 261 | 251 | |
| 262 | 252 | return _rowSelection; |
| 263 | - }, [rowSelection, selectedRowKeys, bar]); | |
| 253 | + }, [rowSelection, selectedRowKeys, bar, rowSelection]); | |
| 264 | 254 | (0, _react.useEffect)(function () { |
| 265 | 255 | displayList.forEach(function (item, index) { |
| 266 | 256 | if (_typeof(item) === 'object') { |
| ... | ... | @@ -337,14 +327,14 @@ var VirtualList = function VirtualList(_ref) { |
| 337 | 327 | return { |
| 338 | 328 | total: dataSource.length, |
| 339 | 329 | position: ['bottomRight'], |
| 340 | - pageSize: 10, | |
| 330 | + pageSize: props.limit || 10, | |
| 341 | 331 | showTotal: function showTotal(total) { |
| 342 | 332 | return handleTotal(total); |
| 343 | 333 | }, |
| 344 | 334 | defaultCurrent: 1, |
| 345 | 335 | size: 'default' |
| 346 | 336 | }; |
| 347 | - }, [dataSource]); | |
| 337 | + }, [dataSource, props.limit]); | |
| 348 | 338 | var barButtons = (0, _react.useMemo)(function () { |
| 349 | 339 | var _barButtons = _.cloneDeep(bar.buttons || []); // 关联表的导入,先隐藏 TODO |
| 350 | 340 | |
| ... | ... | @@ -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 | 375 | _barButtons.unshift({ |
| 386 | 376 | code: 'subformEdit', |
| 387 | 377 | icon: 'EditOutlined', |
| ... | ... | @@ -471,12 +461,12 @@ var VirtualList = function VirtualList(_ref) { |
| 471 | 461 | var column = ((_schema$props2 = schema.props) === null || _schema$props2 === void 0 ? void 0 : _schema$props2.column) || {}; |
| 472 | 462 | return { |
| 473 | 463 | dataIndex: child, |
| 474 | - width: column.width ? parseInt(column.width) : FIELD_LENGTH, | |
| 464 | + width: (column.width ? parseInt(column.width) : FIELD_LENGTH) + padding, | |
| 475 | 465 | align: column.align || 'left', |
| 476 | 466 | fixed: column.fixed || props.fixed && index < props.fixed, |
| 477 | 467 | title: /*#__PURE__*/_react.default.createElement("div", { |
| 478 | 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 | 471 | }, schema.required ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", { |
| 482 | 472 | className: "fr-label-required" |
| ... | ... | @@ -1010,15 +1000,13 @@ var VirtualList = function VirtualList(_ref) { |
| 1010 | 1000 | scroll: { |
| 1011 | 1001 | y: scrollY, |
| 1012 | 1002 | x: '100%' |
| 1013 | - }, | |
| 1014 | - components: vt, | |
| 1003 | + } // components={vt} | |
| 1004 | + , | |
| 1015 | 1005 | size: size || 'small', |
| 1016 | 1006 | columns: columns, |
| 1017 | 1007 | dataSource: dataSource, |
| 1018 | - pagination: pagination, | |
| 1019 | - style: { | |
| 1020 | - marginBottom: 25 | |
| 1021 | - }, | |
| 1008 | + pagination: pagination // style={{marginBottom: 25}} | |
| 1009 | + , | |
| 1022 | 1010 | rowSelection: newRowSelection, |
| 1023 | 1011 | summary: function summary() { |
| 1024 | 1012 | if (!_summary || Array.isArray(_summary) && !_summary.length) { | ... | ... |
| ... | ... | @@ -192,6 +192,10 @@ var RenderList = function RenderList(_ref) { |
| 192 | 192 | getFieldsProps: getFieldsProps |
| 193 | 193 | }; |
| 194 | 194 | |
| 195 | + if (renderWidget === 'listForMobile') { | |
| 196 | + return /*#__PURE__*/_react.default.createElement(_ListForMobile.default, displayProps); | |
| 197 | + } | |
| 198 | + | |
| 195 | 199 | switch (renderWidget) { |
| 196 | 200 | case 'list0': |
| 197 | 201 | case 'cardList': |
| ... | ... | @@ -212,9 +216,8 @@ var RenderList = function RenderList(_ref) { |
| 212 | 216 | case 'list4': |
| 213 | 217 | case 'virtualList': |
| 214 | 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 | 222 | default: |
| 220 | 223 | return /*#__PURE__*/_react.default.createElement(_CardList.default, displayProps); | ... | ... |