Commit 9f9a1a476d36a78326d7d1072cc7a3891f5ca3a8
1 parent
09c035a7
1.增加手机端单据,主表搜索的全部逻辑
Showing
5 changed files
with
108 additions
and
21 deletions
src/components/Common/commonBusiness.js
| ... | ... | @@ -1094,7 +1094,7 @@ export function getKeyUpEvent(name, sFieldName, tableConfig, masterData, tableDa |
| 1094 | 1094 | const sAssignField = tableConfig.gdsconfigformslave[iConfigIndex].sOnChangeAssignField; |
| 1095 | 1095 | // eslint-disable-next-line prefer-destructuring |
| 1096 | 1096 | const sButtonParam = tableConfig.gdsconfigformslave[iConfigIndex].sButtonParam; /* 设置多级联动 */ |
| 1097 | - console.log('sAssignField:', sAssignField); | |
| 1097 | + | |
| 1098 | 1098 | /* keyUp联动其他表 */ |
| 1099 | 1099 | if (commonUtils.isNotEmptyObject(sAssignField) && (sAssignField.includes('@@@:') || sAssignField.includes(';,'))) { |
| 1100 | 1100 | const sAssignFieldObj = sAssignField.split(';,'); | ... | ... |
src/mobile/common/CommobileComponent.js
| ... | ... | @@ -387,9 +387,9 @@ export default class CommonComponent extends Component { |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /* 主表过滤从表 */ |
| 390 | - handleMobileFilterTable = () => { | |
| 390 | + handleMobileFilterTable = (e, bClear) => { | |
| 391 | 391 | console.log('主表过滤从表', this.props.record); |
| 392 | - this.props.onMobileFilterTable(this.props.showConfig, this.props.name, this.props.record); | |
| 392 | + this.props.onMobileFilterTable(this.props.showConfig, this.props.name, this.props.record, '', bClear); | |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** 渲染 */ |
| ... | ... | @@ -478,13 +478,62 @@ export default class CommonComponent extends Component { |
| 478 | 478 | } else if (is_Scan) { |
| 479 | 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>; |
| 480 | 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 { | |
| 481 | + // 封装回车处理函数,复用点击搜索的逻辑 | |
| 482 | + const handleSearchEnter = e => { | |
| 483 | + if (e.key === "Enter") { | |
| 484 | + e.preventDefault(); | |
| 485 | + // 和右侧放大镜点击执行同一个搜索方法 | |
| 486 | + this.handleMobileFilterTable(e); | |
| 487 | + } | |
| 488 | + }; | |
| 489 | + | |
| 490 | + // 自定义清空方法 | |
| 491 | + const handleClear = (e) => { | |
| 492 | + // 构造空值事件,同步更新受控value newValue | |
| 493 | + const emptyEvent = { target: { value: '' } }; | |
| 494 | + this.handleSelectOptionEvent(); | |
| 495 | + // 清空后执行搜索刷新列表 | |
| 496 | + this.handleMobileFilterTable(e, true); | |
| 497 | + }; | |
| 498 | + // 输入框清空回调 | |
| 499 | + const handleClearInput = () => { | |
| 500 | + // 清空后同样执行搜索,刷新列表 | |
| 501 | + console.log("清空", 111); | |
| 502 | + this.handleMobileFilterTable(); | |
| 503 | + }; | |
| 504 | + input = ( | |
| 505 | + <div style={{ position: "relative", width: "95%" }}> | |
| 506 | + <InputItem | |
| 507 | + // clear | |
| 508 | + {...outFormItemProps} | |
| 509 | + onKeyDown={handleSearchEnter} | |
| 510 | + // 关键:绑定清空事件 | |
| 511 | + onClear={handleClearInput} | |
| 512 | + > | |
| 513 | + {sTitle} | |
| 514 | + </InputItem> | |
| 515 | + {/* 自定义清空 × 按钮:有输入内容才显示 */} | |
| 516 | + {newValue && ( | |
| 517 | + <span | |
| 518 | + className={styles.clearStyle} | |
| 519 | + onClick={(e) =>handleClear(e)} | |
| 520 | + style={{ right: 45 }} // 定位在放大镜左边,错开位置 | |
| 521 | + > | |
| 522 | + <span style={{ fontSize: 30, color: '#ccc' }}>×</span> | |
| 523 | + </span> | |
| 524 | + )} | |
| 525 | + <span className={styles.searchStyle} onClick={e => this.handleMobileFilterTable(e)}> | |
| 526 | + <img className={styles.scanStyle} src={search} style={!this.state.enabled ? { opacity: 0.8 } : { opacity: 1 }} alt="scan" /> | |
| 527 | + </span> | |
| 528 | + | |
| 529 | + </div> | |
| 530 | + ); | |
| 531 | + } else { | |
| 483 | 532 | input = (<InputItem id={this.props.showConfig.sName} clear {...outFormItemProps} >{sTitle}</InputItem>); |
| 484 | 533 | } |
| 485 | 534 | } |
| 486 | - } else if (this.firstDataIndex === 'd') { | |
| 487 | - outFormItemProps.moneyKeyboardAlign = 'left'; | |
| 535 | + } else if (this.firstDataIndex === "d") { | |
| 536 | + outFormItemProps.moneyKeyboardAlign = "left"; | |
| 488 | 537 | outFormItemProps.moneyKeyboardWrapProps = moneyKeyboardWrapProps; |
| 489 | 538 | input = (<InputItem clear {...outFormItemProps} type="digit" >{sTitle}</InputItem>); |
| 490 | 539 | } else if (this.firstDataIndex === 't') { | ... | ... |
src/mobile/common/CommobileSubBill.js
| ... | ... | @@ -2256,14 +2256,32 @@ const CommobileBillComponent = createForm()(CommobileBill); |
| 2256 | 2256 | |
| 2257 | 2257 | const TabComponentSlave = (props) => { |
| 2258 | 2258 | |
| 2259 | - const { masterConfig, masterData, slaveData: slaveDataOld, slaveConfig, sModelsId, enabled, app, sUseInfo, searchSlaveData:searchSlaveDataOld = [] } = props; | |
| 2259 | + const { masterConfig, masterData, slaveData: slaveDataOld, slaveConfig, sModelsId, enabled, app, sUseInfo, searchSlaveData:searchSlaveDataOld = [], bSearchModel } = props; | |
| 2260 | 2260 | |
| 2261 | - const slaveDataOld2 = slaveDataOld === undefined ? [] : slaveDataOld; | |
| 2262 | - let slaveData = dataSource.cloneWithRows(slaveDataOld2); | |
| 2263 | - if(commonUtils.isNotEmptyArr(searchSlaveDataOld)){ | |
| 2264 | - slaveData = dataSource.cloneWithRows(searchSlaveDataOld); | |
| 2261 | + | |
| 2262 | + const slaveDataOld2 = slaveDataOld || []; | |
| 2263 | + let showList = slaveDataOld2; | |
| 2264 | + | |
| 2265 | + if (commonUtils.isNotEmptyArr(searchSlaveDataOld)) { | |
| 2266 | + const sIdSet = new Set(); | |
| 2267 | + for (const item of searchSlaveDataOld) { | |
| 2268 | + if (item?.sId != null) sIdSet.add(item.sId); | |
| 2269 | + } | |
| 2270 | + | |
| 2271 | + showList = []; | |
| 2272 | + for (const row of slaveDataOld2) { | |
| 2273 | + if (sIdSet.has(row.sId)) { | |
| 2274 | + showList.push(row); | |
| 2275 | + } | |
| 2276 | + } | |
| 2277 | + }else if (searchSlaveDataOld === null){ | |
| 2278 | + showList = []; | |
| 2265 | 2279 | } |
| 2266 | 2280 | |
| 2281 | + | |
| 2282 | + const slaveData = dataSource.cloneWithRows(showList); | |
| 2283 | + | |
| 2284 | + | |
| 2267 | 2285 | const style = { |
| 2268 | 2286 | display: 'flex', |
| 2269 | 2287 | justifyContent: 'center', |
| ... | ... | @@ -2290,7 +2308,7 @@ const TabComponentSlave = (props) => { |
| 2290 | 2308 | justifyContent: 'space-between', |
| 2291 | 2309 | background: ' #f0f0f0', |
| 2292 | 2310 | }; |
| 2293 | - console.log('aaa', props); | |
| 2311 | + | |
| 2294 | 2312 | |
| 2295 | 2313 | const row = (rowData, sectionID, rowID) => { |
| 2296 | 2314 | return ( | ... | ... |
src/mobile/common/CommobileSubBillEvent.js
| ... | ... | @@ -1983,19 +1983,27 @@ export default (ChildComponent) => { |
| 1983 | 1983 | return cellVal.includes(targetVal); |
| 1984 | 1984 | }); |
| 1985 | 1985 | }); |
| 1986 | - | |
| 1987 | - return filterList; | |
| 1986 | + console.log('过滤逻辑', filterList) | |
| 1987 | + return filterList.length > 0 ? filterList : null; | |
| 1988 | 1988 | } |
| 1989 | 1989 | |
| 1990 | - handleMobileFilterTable = (fieldConfig, tbName, record) => { | |
| 1991 | - const{ slaveData = []}= this.props; | |
| 1990 | + handleMobileFilterTable = (fieldConfig, tbName, record, newValue, bClear) => { | |
| 1991 | + const { slaveData = [] } = this.props; | |
| 1992 | 1992 | const fieldName = fieldConfig?.sName; |
| 1993 | 1993 | const inputVal = record?.[fieldName]; |
| 1994 | - // 原始子表数据 | |
| 1995 | - // 执行过滤 | |
| 1994 | + | |
| 1995 | + console.log('inputVal', inputVal, bClear); | |
| 1996 | + | |
| 1997 | + if (bClear || !inputVal || !inputVal.trim()) { | |
| 1998 | + this.props.onSaveState({ searchSlaveData: [] }); | |
| 1999 | + return; | |
| 2000 | + } | |
| 2001 | + | |
| 2002 | + // 始终基于原始 slaveData 过滤(保证修改后的数据也能被搜到) | |
| 2003 | + // 由于对象引用特性:searchSlaveData 中的对象和 slaveData 是同一个引用 | |
| 2004 | + // 所以修改 searchSlaveData 中的数据,slaveData 也会同步变化 | |
| 1996 | 2005 | const filterResult = this.handleFilterData(fieldConfig, slaveData, inputVal); |
| 1997 | - console.log('过滤后列表', filterResult); | |
| 1998 | - // 更新视图 | |
| 2006 | + console.log('过滤结果', filterResult); | |
| 1999 | 2007 | this.props.onSaveState({ searchSlaveData: filterResult }); |
| 2000 | 2008 | |
| 2001 | 2009 | } | ... | ... |
src/mobile/mobile.less
| ... | ... | @@ -257,6 +257,18 @@ |
| 257 | 257 | top: 3%; |
| 258 | 258 | right: 12%; |
| 259 | 259 | } |
| 260 | +.searchStyle{ | |
| 261 | + position: absolute; | |
| 262 | + top: 16%; | |
| 263 | + right: -3%; | |
| 264 | + | |
| 265 | +} | |
| 266 | +.clearStyle{ | |
| 267 | + position: absolute; | |
| 268 | + top: -26%; | |
| 269 | + right: 5%; | |
| 270 | + | |
| 271 | +} | |
| 260 | 272 | .requireStyle{ |
| 261 | 273 | position: absolute; |
| 262 | 274 | height: 4px; | ... | ... |