Commit c5fab05db9691ad6ee16d7bef7f7ac925b922130

Authored by Min
1 parent d9ea02ad

1.处理移动端PDA 大数据量情况下,输入卡顿情况

src/mobile/common/CommobileComponent.js
... ... @@ -398,9 +398,8 @@ export default class CommonComponent extends Component {
398 398 }
399 399  
400 400 /* 主表过滤从表 */
401   - handleMobileFilterTable = (e, bClear) => {
402   - console.log('主表过滤从表', this.props.record);
403   - this.props.onMobileFilterTable(this.props.showConfig, this.props.name, this.props.record, '', bClear);
  401 + handleMobileFilterTable = (e, bClear, searchValue) => {
  402 + this.props.onMobileFilterTable(this.props.showConfig, this.props.name, this.props.record, searchValue || '', bClear);
404 403 }
405 404  
406 405 /** 渲染 */
... ... @@ -492,19 +491,34 @@ export default class CommonComponent extends Component {
492 491 } else if (is_Scan) {
493 492 input = <div style={{ position: 'relative' }}><InputItem clear {...outFormItemProps} >{sTitle}</InputItem><span className={styles.spanStyle} onClick={this.handleMobileScan}><img className={styles.scanStyle} src={scan} style={!this.state.enabled ? { opacity: 0.8 } : { opacity: 1 }} alt="scan" /></span></div>;
494 493 } else if (is_Search) {
  494 + // 获取输入值的辅助函数(InputItem 的 ref 结构: ref.state.value)
  495 + const getSearchValue = () => {
  496 + if (this.searchInputRef && this.searchInputRef.state) {
  497 + return this.searchInputRef.state.value || '';
  498 + }
  499 + return '';
  500 + };
  501 +
  502 + // 清空输入框的辅助函数
  503 + const clearSearchInput = () => {
  504 + if (this.searchInputRef && this.searchInputRef.state) {
  505 + this.searchInputRef.state.value = '';
  506 + }
  507 + };
  508 +
495 509 // 封装回车处理函数,复用点击搜索的逻辑
496 510 const handleSearchEnter = e => {
497 511 if (e.key === "Enter") {
498 512 e.preventDefault();
499   - // 和右侧放大镜点击执行同一个搜索方法
500   - this.handleMobileFilterTable(e);
  513 + const searchValue = getSearchValue();
  514 + console.log('搜索框回车', searchValue);
  515 + this.handleMobileFilterTable(e, false, searchValue);
501 516 }
502 517 };
503 518  
504 519 // 自定义清空方法
505 520 const handleClear = (e) => {
506   - // 构造空值事件,同步更新受控value newValue
507   - const emptyEvent = { target: { value: '' } };
  521 + clearSearchInput();
508 522 this.handleSelectOptionEvent();
509 523 // 清空后执行搜索刷新列表
510 524 this.handleMobileFilterTable(e, true);
... ... @@ -518,8 +532,11 @@ export default class CommonComponent extends Component {
518 532 input = (
519 533 <div style={{ position: "relative", width: "95%" }}>
520 534 <InputItem
521   - // clear
522   - {...outFormItemProps}
  535 + id={this.props.showConfig.sName}
  536 + placeholder={this.props.showConfig.placeholder || '请输入'}
  537 + disabled={!this.state.enabled}
  538 + ref={(el) => { this.searchInputRef = el; }}
  539 + clear
523 540 onKeyDown={handleSearchEnter}
524 541 // 关键:绑定清空事件
525 542 onClear={handleClearInput}
... ... @@ -536,7 +553,11 @@ export default class CommonComponent extends Component {
536 553 <span style={{ fontSize: 30, color: '#ccc' }}>×</span>
537 554 </span>
538 555 )}
539   - <span className={styles.searchStyle} onClick={e => this.handleMobileFilterTable(e)}>
  556 + <span className={styles.searchStyle} onClick={e => {
  557 + const searchValue = getSearchValue();
  558 + console.log('搜索框点击搜索', searchValue);
  559 + this.handleMobileFilterTable(e, false, searchValue);
  560 + }}>
540 561 <img className={styles.scanStyle} src={search} style={!this.state.enabled ? { opacity: 0.8 } : { opacity: 1 }} alt="scan" />
541 562 </span>
542 563  
... ...
src/mobile/common/CommobileSubBill.js
... ... @@ -2076,7 +2076,7 @@ class CommobileBill extends React.Component {
2076 2076  
2077 2077  
2078 2078 const dWidth = document.documentElement.clientWidth || document.body.clientWidth; /* 获取手机视窗宽度 */
2079   - const dHeight = document.documentElement.clientHeight || document.body.clientHeight; /* 获取手机视窗宽1度 */
  2079 + const dHeight = document.documentElement.clientHeight || document.body.clientHeight; /* 获取手机视窗宽度 */
2080 2080 const formItemLayout = { labelCol: { span: 2 }, wrapperCol: { span: 18 } };
2081 2081 const style = {
2082 2082 display: 'flex',
... ... @@ -2094,7 +2094,7 @@ class CommobileBill extends React.Component {
2094 2094 const rowSum = (rowData, sectionID, rowID) => {
2095 2095 return (
2096 2096 <div style={{ backgroundColor: '#f0f0f0', marginBottom: '8px', borderBottom:'6px solid rgb(236, 236, 237)' }} key={rowID}>
2097   - 2323232 {commonUtils.isEmptyObject(slaveConfig) ? '' : slaveConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '').map((child) => {
  2097 + {commonUtils.isEmptyObject(slaveConfig) ? '' : slaveConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '').map((child) => {
2098 2098 const sMemo = child.sName.toLowerCase().endsWith('memo');
2099 2099 // sUseInfo是指被其他单据调用,或者被审核
2100 2100 let enabledNew = (enabled && !child.bReadonly && !child.specialControl && commonUtils.isEmpty(sUseInfo));
... ... @@ -2472,13 +2472,13 @@ const TabComponentSlave = (props) =&gt; {
2472 2472 const TabComponentSlaveChild = (props) => {
2473 2473  
2474 2474 const { masterConfig, masterData, slaveData: slaveDataOld, slaveChildData: slaveChildDataOld, slaveChildConfig, slaveConfig, sModelsId, enabled, app, sUseInfo } = props;
2475   -
  2475 +
2476 2476 // 需要优化性能的模块ID列表(PDA慢的界面)
2477 2477 const performanceOptimizedModels = [
2478 2478 '12710101117220510358930',
2479 2479 ];
2480 2480 const isPerformanceOptimized = performanceOptimizedModels.includes(sModelsId);
2481   -
  2481 +
2482 2482 const slaveDataOld2 = slaveDataOld === undefined ? [] : slaveDataOld;
2483 2483 const slaveData = dataSource.cloneWithRows(slaveDataOld2);
2484 2484  
... ...
src/mobile/common/CommobileSubBillEvent.js
... ... @@ -1990,10 +1990,13 @@ export default (ChildComponent) =&gt; {
1990 1990 handleMobileFilterTable = (fieldConfig, tbName, record, newValue, bClear) => {
1991 1991 const { slaveData = [] } = this.props;
1992 1992 const fieldName = fieldConfig?.sName;
1993   - const inputVal = record?.[fieldName];
1994 1993  
1995   - console.log('inputVal', inputVal, bClear);
  1994 + // 优先使用传入的 newValue(搜索框传出的值),否则从 record 获取
  1995 + const inputVal = newValue !== undefined && newValue !== '' ? newValue : record?.[fieldName];
1996 1996  
  1997 + console.log('搜索值:', inputVal, 'bClear:', bClear, 'newValue:', newValue);
  1998 +
  1999 + // 清空搜索:bClear=true 或 inputVal 为空
1997 2000 if (bClear || !inputVal || !inputVal.trim()) {
1998 2001 this.props.onSaveState({ searchSlaveData: [] });
1999 2002 return;
... ...