Commit 09c035a726672d084710d352666a3156adc79ebf
1 parent
3f4f05b2
1.手机端增加主表根据配置过滤从表数据功能
Showing
5 changed files
with
69 additions
and
50 deletions
src/assets/mobile/search.svg
0 → 100644
| 1 | +<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1781587856458" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4456" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M802.133333 770.438095l-121.904762-121.904762c42.666667-47.542857 68.266667-109.714286 68.266667-177.980952 0-147.504762-120.685714-268.190476-268.190476-268.190476s-268.190476 120.685714-268.190476 268.190476 120.685714 268.190476 268.190476 268.190476c57.295238 0 110.933333-18.285714 154.819048-48.761905l124.342857 124.342858 42.666666-43.885715zM273.066667 470.552381c0-114.590476 92.647619-207.238095 207.238095-207.238095s207.238095 92.647619 207.238095 207.238095-92.647619 207.238095-207.238095 207.238095-207.238095-92.647619-207.238095-207.238095z" fill="#8a8a8a" p-id="4457"></path></svg> | |
| 0 | 2 | \ No newline at end of file | ... | ... |
src/mobile/common/CommobileComponent.js
| ... | ... | @@ -9,7 +9,7 @@ import * as commonUtils from '../../utils/utils'; |
| 9 | 9 | import styles from '../mobile.less'; |
| 10 | 10 | import iconSetting from '../../assets/mobile/setting.png'; |
| 11 | 11 | import scan from '../../assets/mobile/scanning.svg'; |
| 12 | - | |
| 12 | +import search from '../../assets/mobile/search.svg'; | |
| 13 | 13 | |
| 14 | 14 | // eslint-disable-next-line prefer-destructuring |
| 15 | 15 | const CheckboxItem = Checkbox.CheckboxItem; |
| ... | ... | @@ -386,6 +386,12 @@ export default class CommonComponent extends Component { |
| 386 | 386 | this.props.onMobileScan(this.props.showConfig, this.props.name, this.props.record); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | + /* 主表过滤从表 */ | |
| 390 | + handleMobileFilterTable = () => { | |
| 391 | + console.log('主表过滤从表', this.props.record); | |
| 392 | + this.props.onMobileFilterTable(this.props.showConfig, this.props.name, this.props.record); | |
| 393 | + } | |
| 394 | + | |
| 389 | 395 | /** 渲染 */ |
| 390 | 396 | render() { |
| 391 | 397 | const { sDateFormat: sDateFormatOld, sFieldValidation, bNotEmpty, bOpenKeyboard } = this.props.showConfig; |
| ... | ... | @@ -435,7 +441,7 @@ export default class CommonComponent extends Component { |
| 435 | 441 | // </List.Item> |
| 436 | 442 | // </Picker> |
| 437 | 443 | // ); |
| 438 | - | |
| 444 | + | |
| 439 | 445 | input = ( |
| 440 | 446 | <SearchablePicker |
| 441 | 447 | data={this.getSelectOption()} |
| ... | ... | @@ -465,11 +471,15 @@ export default class CommonComponent extends Component { |
| 465 | 471 | const is_Pda = this.props.showConfig.sControlName && this.props.showConfig.sControlName.includes('_pda'); |
| 466 | 472 | const pdaInput = <InputItem id={this.props.showConfig.sName} {...pdaPro} ref={(el) => { this.inputRef = el; }} clear onChange={debounce(this.handleFieldScan, 1000)} >{sTitle}</InputItem>; |
| 467 | 473 | const is_Scan = this.props.showConfig.sControlName && this.props.showConfig.sControlName.includes('_scan'); |
| 474 | + const is_Search = this.props.showConfig.sControlName && this.props.showConfig.sControlName.toLowerCase().includes('_search'); | |
| 475 | + | |
| 468 | 476 | if (is_Pda) { |
| 469 | 477 | input = pdaInput; |
| 470 | 478 | } else if (is_Scan) { |
| 471 | 479 | 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>; |
| 472 | - } else { | |
| 480 | + } else if (is_Search) { | |
| 481 | + input = <div style={{ position: 'relative' }}><InputItem clear {...outFormItemProps} >{sTitle}</InputItem><span className={styles.spanStyle} onClick={(e) => this.handleMobileFilterTable(e)}><img className={styles.scanStyle} src={search} style={!this.state.enabled ? { opacity: 0.8 } : { opacity: 1 }} alt="scan" /></span></div>; | |
| 482 | + } else { | |
| 473 | 483 | input = (<InputItem id={this.props.showConfig.sName} clear {...outFormItemProps} >{sTitle}</InputItem>); |
| 474 | 484 | } |
| 475 | 485 | } | ... | ... |
src/mobile/common/CommobileSubBill.js
| ... | ... | @@ -2256,10 +2256,13 @@ const CommobileBillComponent = createForm()(CommobileBill); |
| 2256 | 2256 | |
| 2257 | 2257 | const TabComponentSlave = (props) => { |
| 2258 | 2258 | |
| 2259 | - const { masterConfig, masterData, slaveData: slaveDataOld, slaveConfig, sModelsId, enabled, app, sUseInfo } = props; | |
| 2259 | + const { masterConfig, masterData, slaveData: slaveDataOld, slaveConfig, sModelsId, enabled, app, sUseInfo, searchSlaveData:searchSlaveDataOld = [] } = props; | |
| 2260 | 2260 | |
| 2261 | 2261 | const slaveDataOld2 = slaveDataOld === undefined ? [] : slaveDataOld; |
| 2262 | - const slaveData = dataSource.cloneWithRows(slaveDataOld2); | |
| 2262 | + let slaveData = dataSource.cloneWithRows(slaveDataOld2); | |
| 2263 | + if(commonUtils.isNotEmptyArr(searchSlaveDataOld)){ | |
| 2264 | + slaveData = dataSource.cloneWithRows(searchSlaveDataOld); | |
| 2265 | + } | |
| 2263 | 2266 | |
| 2264 | 2267 | const style = { |
| 2265 | 2268 | display: 'flex', |
| ... | ... | @@ -2287,6 +2290,7 @@ const TabComponentSlave = (props) => { |
| 2287 | 2290 | justifyContent: 'space-between', |
| 2288 | 2291 | background: ' #f0f0f0', |
| 2289 | 2292 | }; |
| 2293 | + console.log('aaa', props); | |
| 2290 | 2294 | |
| 2291 | 2295 | const row = (rowData, sectionID, rowID) => { |
| 2292 | 2296 | return ( |
| ... | ... | @@ -2578,53 +2582,9 @@ const TabComponentSlaveChild = (props) => { |
| 2578 | 2582 | const f8 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[7]; |
| 2579 | 2583 | const f9 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[8]; |
| 2580 | 2584 | const f10 = commonUtils.isEmptyObject(masterConfig) ? {} : masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.iTag === 1)[9]; |
| 2581 | - | |
| 2585 | + console.log('77777222', props); | |
| 2582 | 2586 | return ( |
| 2583 | 2587 | <div className="commobileBillContainer"> |
| 2584 | - {/*<div style={{ padding: '5px 0' }} className={styles.onlyWordBg}>*/} | |
| 2585 | - {/*<Flex style={{ padding: '0 15px 5px 15px' }}>*/} | |
| 2586 | - {/* {*/} | |
| 2587 | - {/* f1 ? <Flex.Item className={styles.wordsFlow} style={{ color: '#fff', fontWeight: 'bold', fontSize: '17px' }}>{f1.showName} : {_this.getViewValue(f1, masterData)}</Flex.Item> : ''*/} | |
| 2588 | - {/* }*/} | |
| 2589 | - {/* {*/} | |
| 2590 | - {/* f2 ? <Flex.Item className={`${styles.wordsFlow} ${styles.fr}`} style={{ fontSize: '17px' }}>{f2.showName} : {_this.getViewValue(f2, masterData)}</Flex.Item> : ''*/} | |
| 2591 | - {/* }*/} | |
| 2592 | - {/*</Flex>*/} | |
| 2593 | - {/*<Flex style={{ padding: '0 15px 5px 15px' }}>*/} | |
| 2594 | - {/* {*/} | |
| 2595 | - {/* f3 ? <Flex.Item className={styles.wordsFlow} style={{ fontSize: '17px' }}>{f3.showName} : {_this.getViewValue(f3, masterData)}</Flex.Item> : ''*/} | |
| 2596 | - {/* }*/} | |
| 2597 | - {/*</Flex>*/} | |
| 2598 | - {/*<Flex style={{ padding: '0 15px 5px 15px', fontSize: '17px' }} wrap={'wrap'} align='start'>*/} | |
| 2599 | - {/* {*/} | |
| 2600 | - {/* f4 ? <><div>{f4.showName} : </div><Flex.Item style={{ fontSize: '17px' }}> {_this.getViewValue(f4, masterData)}</Flex.Item></> : ''*/} | |
| 2601 | - {/* }*/} | |
| 2602 | - {/*</Flex>*/} | |
| 2603 | - {/*<Flex style={{ padding: '0 15px 5px 15px' }}>*/} | |
| 2604 | - {/* {*/} | |
| 2605 | - {/* f5 ? <Flex.Item className={styles.wordsFlow} style={{ fontSize: '17px' }}>{f5.showName} : {_this.getViewValue(f5, masterData)}</Flex.Item> : ''*/} | |
| 2606 | - {/* }*/} | |
| 2607 | - {/* {*/} | |
| 2608 | - {/* f6 ? <Flex.Item className={`${styles.wordsFlow} ${styles.fr}`} style={{ fontSize: '17px' }}>{f6.showName} : {_this.getViewValue(f6, masterData)}</Flex.Item> : ''*/} | |
| 2609 | - {/* }*/} | |
| 2610 | - {/*</Flex>*/} | |
| 2611 | - {/*<Flex style={{ padding: '0 15px 5px 15px' }}>*/} | |
| 2612 | - {/* {*/} | |
| 2613 | - {/* f7 ? <Flex.Item className={styles.wordsFlow} style={{ fontSize: '17px' }}>{f7.showName} : {_this.getViewValue(f7, masterData)}</Flex.Item> : ''*/} | |
| 2614 | - {/* }*/} | |
| 2615 | - {/* {*/} | |
| 2616 | - {/* f8 ? <Flex.Item className={`${styles.wordsFlow} ${styles.fr}`} style={{ fontSize: '17px' }}>{f8.showName} : {_this.getViewValue(f8, masterData)}</Flex.Item> : ''*/} | |
| 2617 | - {/* }*/} | |
| 2618 | - {/*</Flex>*/} | |
| 2619 | - {/*<Flex style={{ padding: '0 15px 0px 15px' }}>*/} | |
| 2620 | - {/* {*/} | |
| 2621 | - {/* f9 ? <Flex.Item className={styles.wordsFlow} style={{ fontSize: '17px' }}>{f9.showName} : {_this.getViewValue(f9, masterData)}</Flex.Item> : ''*/} | |
| 2622 | - {/* }*/} | |
| 2623 | - {/* {*/} | |
| 2624 | - {/* f10 ? <Flex.Item className={`${styles.wordsFlow} ${styles.fr}`} style={{ fontSize: '17px' }}>{f10.showName} : {_this.getViewValue(f10, masterData)}</Flex.Item> : ''*/} | |
| 2625 | - {/* }*/} | |
| 2626 | - {/*</Flex>*/} | |
| 2627 | - {/*</div>*/} | |
| 2628 | 2588 | <form style={{ paddingBottom: '47px' }} { ...props.formProps || {} } > |
| 2629 | 2589 | <div className="flex-container" style={{ color: 'white' }}> |
| 2630 | 2590 | <CommobileViewMaster {...props} iTag={1} /> | ... | ... |
src/mobile/common/CommobileSubBillEvent.js
| ... | ... | @@ -1957,6 +1957,49 @@ export default (ChildComponent) => { |
| 1957 | 1957 | } |
| 1958 | 1958 | } |
| 1959 | 1959 | |
| 1960 | + /** | |
| 1961 | + * 子表多字段模糊过滤 | |
| 1962 | + * @param {Object} fieldConfig 列配置对象(包含sActiveKey) | |
| 1963 | + * @param {Array} searchSlaveData 原始列表数据源 | |
| 1964 | + * @param {String} searchVal 输入框搜索值(如222) | |
| 1965 | + * @returns {Array} 过滤后的新数组 | |
| 1966 | + */ | |
| 1967 | + handleFilterData = (fieldConfig, searchSlaveData, searchVal)=> { | |
| 1968 | + // 1. 判空兜底 | |
| 1969 | + if (!fieldConfig?.sActiveKey || !searchSlaveData?.length || !searchVal?.trim()) { | |
| 1970 | + return searchSlaveData || []; | |
| 1971 | + } | |
| 1972 | + | |
| 1973 | + // 2. 分割多搜索字段 sActiveKey:"sProductName,sDefineNo" | |
| 1974 | + const searchKeys = fieldConfig.sActiveKey.split(',').map(key => key.trim()); | |
| 1975 | + const targetVal = searchVal.trim(); | |
| 1976 | + | |
| 1977 | + // 3. 过滤逻辑:任意字段包含搜索值即匹配(模糊查询) | |
| 1978 | + const filterList = searchSlaveData.filter(item => { | |
| 1979 | + return searchKeys.some(key => { | |
| 1980 | + // 当前行该字段的值,转字符串防止数字/空报错 | |
| 1981 | + const cellVal = String(item[key] ?? ''); | |
| 1982 | + // 模糊匹配:包含搜索文本;需要精确匹配改为 cellVal === targetVal | |
| 1983 | + return cellVal.includes(targetVal); | |
| 1984 | + }); | |
| 1985 | + }); | |
| 1986 | + | |
| 1987 | + return filterList; | |
| 1988 | + } | |
| 1989 | + | |
| 1990 | + handleMobileFilterTable = (fieldConfig, tbName, record) => { | |
| 1991 | + const{ slaveData = []}= this.props; | |
| 1992 | + const fieldName = fieldConfig?.sName; | |
| 1993 | + const inputVal = record?.[fieldName]; | |
| 1994 | + // 原始子表数据 | |
| 1995 | + // 执行过滤 | |
| 1996 | + const filterResult = this.handleFilterData(fieldConfig, slaveData, inputVal); | |
| 1997 | + console.log('过滤后列表', filterResult); | |
| 1998 | + // 更新视图 | |
| 1999 | + this.props.onSaveState({ searchSlaveData: filterResult }); | |
| 2000 | + | |
| 2001 | + } | |
| 2002 | + | |
| 1960 | 2003 | handleButtonClick = async (name ) => { |
| 1961 | 2004 | if(name === 'BtnRefresh') { |
| 1962 | 2005 | const { sModelsType, slaveConfig, masterConfig, employeeConfig, slave0Config, slaveChildConfig}= this.props; |
| ... | ... | @@ -1994,6 +2037,7 @@ export default (ChildComponent) => { |
| 1994 | 2037 | onEdit={this.handleEdit} |
| 1995 | 2038 | isOutsourcedProcesses={this.isOutsourcedProcesses} |
| 1996 | 2039 | onMobileScan={this.handleMobileScan} |
| 2040 | + onMobileFilterTable={this.handleMobileFilterTable} | |
| 1997 | 2041 | handleNameToIndex={this.handleNameToIndex} |
| 1998 | 2042 | onButtonClick = {this.handleButtonClick} |
| 1999 | 2043 | /> | ... | ... |
src/mobile/common/CommobileViewMaster.js
| ... | ... | @@ -15,6 +15,9 @@ export default class CommobileViewMaster extends Component { |
| 15 | 15 | handleMobileScan = (fieldConfig, tbName, record, newValue, cancelValue) => { |
| 16 | 16 | this.props.onMobileScan(fieldConfig, tbName, record, newValue, cancelValue); |
| 17 | 17 | } |
| 18 | + handleMobileFilterTable = (fieldConfig, tbName, record, newValue, cancelValue) => { | |
| 19 | + this.props.onMobileFilterTable(fieldConfig, tbName, record, newValue, cancelValue); | |
| 20 | + } | |
| 18 | 21 | handleFocus = (fieldConfig) => { |
| 19 | 22 | this.props.onFocus(fieldConfig); |
| 20 | 23 | } |
| ... | ... | @@ -76,6 +79,7 @@ export default class CommobileViewMaster extends Component { |
| 76 | 79 | onSaveState: this.props.onSaveState, |
| 77 | 80 | onFieldScan: this.handleMasterFieldScan, |
| 78 | 81 | onMobileScan: this.handleMobileScan, |
| 82 | + onMobileFilterTable:this.handleMobileFilterTable, /* 主表筛选从表 */ | |
| 79 | 83 | bOpenKeyboard, |
| 80 | 84 | }; |
| 81 | 85 | if (child.iTag === 1) { | ... | ... |