From 72419e2f826031a158173f46d723a672064e37cd Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 31 八月 2021 22:42:51 +0800 Subject: [PATCH] 2021-08-31 --- src/tabviews/custom/components/card/table-card/index.jsx | 55 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index 1ce92a1..bf19684 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -27,11 +27,11 @@ config: null, // 鍥捐〃閰嶇疆淇℃伅 loading: false, // 鏁版嵁鍔犺浇鐘舵�� search: null, // 鎼滅储鏉′欢 - preIndex: 0, // 寮�濮嬬储寮� pageIndex: 1, // 椤电爜 total: 0, // 鎬绘暟 sync: false, // 鏄惁缁熶竴璇锋眰鏁版嵁 data: null, // 鏁版嵁 + BData: null } /** @@ -59,6 +59,7 @@ item.key = index item.$$uuid = item[_config.setting.primaryKey] || '' item.$$BID = BID || '' + item.$Index = index + 1 + '' return item }) } @@ -104,7 +105,7 @@ componentDidMount () { MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) - MKEmitter.addListener('getexceloutparam', this.getexceloutparam) + MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) } @@ -118,7 +119,7 @@ } MKEmitter.removeListener('reloadData', this.reloadData) MKEmitter.removeListener('resetSelectLine', this.resetParentParam) - MKEmitter.removeListener('getexceloutparam', this.getexceloutparam) + MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) } @@ -138,16 +139,15 @@ item.key = index item.$$uuid = item[config.setting.primaryKey] || '' item.$$BID = BID || '' + item.$Index = index + 1 + '' return item }) this.setState({sync: false, data: _data}) - } else if (nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { - if (config.setting.syncRefresh === 'true') { - this.setState({}, () => { - this.loadData() - }) - } + } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { + this.setState({}, () => { + this.loadData() + }) } } @@ -176,12 +176,12 @@ } } - resetParentParam = (MenuID, id) => { + resetParentParam = (MenuID, id, data) => { const { config } = this.state if (!config.setting.supModule || config.setting.supModule !== MenuID) return if (id !== this.state.BID) { - this.setState({ BID: id }, () => { + this.setState({ BID: id, BData: data, pageIndex: 1 }, () => { this.loadData() }) } @@ -198,14 +198,14 @@ /** * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁� */ - getexceloutparam = (menuId, btnId) => { + queryModuleParam = (menuId, btnId) => { const { mainSearch } = this.props const { arr_field, config, search } = this.state if (config.uuid !== menuId) return let searches = search ? fromJS(search).toJS() : [] - if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 + if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 let keys = searches.map(item => item.key.toLowerCase()) mainSearch.forEach(item => { if (!keys.includes(item.key.toLowerCase())) { @@ -214,7 +214,7 @@ }) } - MKEmitter.emit('execExcelout', config.uuid, btnId, { + MKEmitter.emit('returnModuleParam', config.uuid, btnId, { arr_field: arr_field, orderBy: config.setting.order || '', search: searches, @@ -224,25 +224,29 @@ async loadData () { const { mainSearch, menuType } = this.props - const { config, arr_field, pageIndex, search, BID } = this.state + const { config, arr_field, pageIndex, search, BID, BData } = this.state if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ data: [], - total: 0, - preIndex: 0 + total: 0 }) return } let searches = search ? fromJS(search).toJS() : [] - if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 + if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 let keys = searches.map(item => item.key) mainSearch.forEach(item => { if (!keys.includes(item.key)) { searches.push(item) } }) + } + + let requireFields = searches.filter(item => item.required && item.value === '') + if (requireFields.length > 0) { + return } this.setState({ @@ -254,9 +258,9 @@ let result = await Api.genericInterface(param) if (result.status) { - let _preIndex = 0 + let start = 1 if (config.setting.laypage) { - _preIndex = config.setting.pageSize * (pageIndex - 1) + start = config.setting.pageSize * (pageIndex - 1) + 1 } this.setState({ @@ -264,10 +268,11 @@ item.key = index item.$$uuid = item[config.setting.primaryKey] || '' item.$$BID = BID || '' + item.$$BData = BData || '' + item.$Index = index + start + '' return item }), total: result.total, - preIndex: _preIndex, loading: false }) } else { @@ -290,7 +295,7 @@ }) } - getLines = (data, seq) => { + getLines = (data) => { const { config } = this.state let line = [] @@ -321,7 +326,7 @@ line.push( <Col key={index} span={24}> <div className="card-item-box" style={item.style}> - <CardCellComponent seq={seq} data={data} cards={config} cardCell={item} elements={item.elements}/> + <CardCellComponent data={data} cards={config} cardCell={item} elements={item.elements}/> </div> </Col> ) @@ -340,7 +345,7 @@ } render() { - const { config, loading, data, BID, pageIndex, preIndex, total } = this.state + const { config, loading, data, BID, pageIndex, total } = this.state return ( <div className="custom-table-card-box" style={{...config.style}}> @@ -352,7 +357,7 @@ } <NormalHeader config={config} BID={BID} menuType={this.props.menuType} refresh={this.refreshSearch} /> {data && data.length > 0 ? <Row className="card-row-list" style={{height: config.wrap.contentHeight}}> - {data.map((item, index) => this.getLines(item, preIndex + index + 1))} + {data.map(item => this.getLines(item))} </Row> : null} {data && data.length === 0 ? <div className="card-row-list" style={{height: config.wrap.contentHeight}}> <Empty description={false}/> -- Gitblit v1.8.0