Commit d3540216 by peii

耗材子类过滤

parent 163cd886
...@@ -715,46 +715,44 @@ class ChooseProductPage extends Component { ...@@ -715,46 +715,44 @@ class ChooseProductPage extends Component {
/** /**
* @description: 搜索过滤 * @description: 搜索过滤
* @param {*} * @param {array} list 要过滤的数组
* @param {boolean} isChildFilter 子组件调用(三级调用)
* @return {*} * @return {*}
*/ */
rightNameFilter(list = []) { rightNameFilter(list = [], isChildFilter = false) {
if(isBlank(list)) return [] if(isBlank(list)) return []
const {searchValue, authorizations, productAuthorization, topActiveIndex, topProcOptionList, leftActiveIndex} = this.state const {searchValue, authorizations, productAuthorization, topActiveIndex, topProcOptionList, leftActiveIndex, defaultThridShow} = this.state
if (productAuthorization === 'Y') { if (productAuthorization === 'Y') {
const curSupplier = topProcOptionList[topActiveIndex] const curSupplier = topProcOptionList[topActiveIndex]
const auth = R.find(R.propEq('supplier_code', curSupplier.supplier_code))(authorizations) const auth = R.find(R.propEq('supplier_code', curSupplier.supplier_code))(authorizations)
if (isNotBlank(auth) && isNotBlank(auth.product_line_category_list)) { if (isNotBlank(auth) && isNotBlank(auth.product_line_category_list)) {
const typeCodes = R.pluck('product_line_category_code', auth.product_line_category_list) const typeCodes = R.pluck('product_line_category_code', auth.product_line_category_list)
if (R.compose(R.isNil, R.path([0, 'details']))(list)) { if (R.compose(R.isNil, R.path([0, 'details']) || isChildFilter)(list)) {
list = R.filter(R.propSatisfies(R.includes(R.__, typeCodes), 'product_line_category_code'))(list) list = R.filter(R.propSatisfies(R.includes(R.__, typeCodes), 'product_line_category_code'))(list)
} else {
R.map(item => {
if (isBlank(item.details)) return
item.details = R.filter(R.propSatisfies(R.includes(R.__, typeCodes), 'product_line_category_code'))(item.details)
})(list)
} }
} else { } else {
list = [] list = []
} }
} }
const includes = item => {
if (isBlank(searchValue)) return list
const reg = new RegExp(searchValue, 'g') const reg = new RegExp(searchValue, 'g')
return R.test(reg, item.general_name) || R.test(reg, item.item_name) const keys = ['general_name', 'item_name', 'specification', 'manufacturer_product_code', 'initials_pinyin', 'serial_number', 'category_name']
const includes = item => {
const preds = R.compose(
R.map(val => R.test(R.__, val)),
R.filter(isNotBlank),
R.map(key => item[key])
)(keys)
return R.anyPass(preds)(reg)
} }
return R.filter(includes, list) return R.filter(includes, list)
// if (R.compose(R.isNil, R.path([0, 'details']))(list)) {
// return R.filter(includes, list)
// } else {
// R.map(item => {
// if (isBlank(item.details)) return
// item.display_details = R.filter(includes, item.details)
// })(list)
// return list
// }
} }
// 返回搜索元素 // 返回搜索元素
...@@ -846,7 +844,7 @@ class ChooseProductPage extends Component { ...@@ -846,7 +844,7 @@ class ChooseProductPage extends Component {
// 返回右侧二级数据 // 返回右侧二级数据
renderContItem() { renderContItem() {
let { leftActiveIndex, defaultThridShow, topProcOptionList, topActiveIndex} = this.state let { leftActiveIndex, defaultThridShow, topProcOptionList, topActiveIndex, searchValue } = this.state
let curRigSecoOption = [] let curRigSecoOption = []
let curSuperLeftOption = [] let curSuperLeftOption = []
let topItem = topProcOptionList[topActiveIndex] let topItem = topProcOptionList[topActiveIndex]
...@@ -876,6 +874,8 @@ class ChooseProductPage extends Component { ...@@ -876,6 +874,8 @@ class ChooseProductPage extends Component {
superCallBack={(count, coutFieName) => this.handleChangeCount(count, coutFieName)} superCallBack={(count, coutFieName) => this.handleChangeCount(count, coutFieName)}
superReduceBack={() => this.handleSubSelected()} superReduceBack={() => this.handleSubSelected()}
superLeftData={curSuperLeftOption} superLeftData={curSuperLeftOption}
rightNameFilter={this.rightNameFilter.bind(this)}
inputSearchValue={this.inputSearchValue.bind(this)}
/> />
</View> </View>
) )
......
...@@ -3,7 +3,7 @@ import { View, Text, StyleSheet, TouchableOpacity, Image, ScrollView, FlatList, ...@@ -3,7 +3,7 @@ import { View, Text, StyleSheet, TouchableOpacity, Image, ScrollView, FlatList,
import * as R from "ramda"; import * as R from "ramda";
import { third_text_color, foundation_color, second_text_size, Width, pxSize, font_family_regular, icon_style } from '../../../base/BaseStyle'; import { third_text_color, foundation_color, second_text_size, Width, pxSize, font_family_regular, icon_style } from '../../../base/BaseStyle';
import PicTitDetaiCalcu from '../../common/listDataComponent/PicTitDetaiCalcu'; import PicTitDetaiCalcu from '../../common/listDataComponent/PicTitDetaiCalcu';
import { cloneObject } from '../../../utils/Utils'; import { cloneObject, isBlank, isNotBlank} from '../../../utils/Utils';
import { PicListNoData } from '../../common/CellTextStyle'; import { PicListNoData } from '../../common/CellTextStyle';
import _ from "lodash"; import _ from "lodash";
import { connect } from 'react-redux'; import { connect } from 'react-redux';
...@@ -157,11 +157,10 @@ class ProductRightStyle extends Component { ...@@ -157,11 +157,10 @@ class ProductRightStyle extends Component {
// 修改当前小类是否展示 // 修改当前小类是否展示
changeThrShow(show, superItem, superIndex) { changeThrShow(show, superItem, superIndex) {
let { curThridObj, rowSingleData } = this.state let { curThridObj, rowSingleData, lastInputText } = this.state
let that = this let that = this
if (show && superItem) { if (show && superItem) {
// 大类点击标题 // 大类点击标题
let curRowData = R.clone(superItem['details'])
curThridObj = { curThridObj = {
superItem: superItem, superItem: superItem,
superIndex: superIndex, superIndex: superIndex,
...@@ -170,7 +169,7 @@ class ProductRightStyle extends Component { ...@@ -170,7 +169,7 @@ class ProductRightStyle extends Component {
that.setState({ that.setState({
thridIsVisible: show, thridIsVisible: show,
curThridObj: curThridObj, curThridObj: curThridObj,
rowSingleData: curRowData rowSingleData: R.clone(superItem['details'])
}) })
this.props.changeThrShow(show) this.props.changeThrShow(show)
} else { } else {
...@@ -178,7 +177,7 @@ class ProductRightStyle extends Component { ...@@ -178,7 +177,7 @@ class ProductRightStyle extends Component {
if (curThridObj.superItem) { if (curThridObj.superItem) {
let curDa = curThridObj.superItem let curDa = curThridObj.superItem
let curInd = curThridObj.superIndex let curInd = curThridObj.superIndex
curDa.details = cloneObject(rowSingleData) curDa.details = R.clone(rowSingleData)
curDa[LocalVariable.QUANTITY_FIELD] = 0 curDa[LocalVariable.QUANTITY_FIELD] = 0
curDa.details.forEach(itVal => { curDa.details.forEach(itVal => {
if (itVal[LocalVariable.QUANTITY_FIELD] > 0) { if (itVal[LocalVariable.QUANTITY_FIELD] > 0) {
...@@ -187,7 +186,8 @@ class ProductRightStyle extends Component { ...@@ -187,7 +186,8 @@ class ProductRightStyle extends Component {
}) })
that.handleCalCallBack(curDa, curInd, 'rightSecondData', LocalVariable.QUANTITY_FIELD) that.handleCalCallBack(curDa, curInd, 'rightSecondData', LocalVariable.QUANTITY_FIELD)
that.setState({ that.setState({
thridIsVisible: show thridIsVisible: show,
lastInputText: ''
}) })
this.props.changeThrShow(show) this.props.changeThrShow(show)
} }
...@@ -335,13 +335,16 @@ class ProductRightStyle extends Component { ...@@ -335,13 +335,16 @@ class ProductRightStyle extends Component {
// 耗材 -- 小类每一列 // 耗材 -- 小类每一列
renderThridItem(item, index) { renderThridItem(item, index) {
let { rowSingleData } = this.state
const idx = R.findIndex(R.propEq('item_code', item.item_code))(rowSingleData)
return ( return (
<SafeAreaView style={styles.thr_container} key={'item_code' + index}> <SafeAreaView style={styles.thr_container} key={'item_code' + index}>
<PicTitDetaiCalcu <PicTitDetaiCalcu
listItem={item} listItem={item}
listIndex={index} listIndex={idx}
calField={LocalVariable.QUANTITY_FIELD} calField={LocalVariable.QUANTITY_FIELD}
subCalCallBack={(item, index) => this.handleCalCallBack(item, index, 'rowSingleData')} subCalCallBack={(item, idx) => this.handleCalCallBack(item, idx, 'rowSingleData')}
titText={'manufacturer_product_code'} titText={'manufacturer_product_code'}
tipTextStr={'item_name'} tipTextStr={'item_name'}
tipTextOne={'general_name'} tipTextOne={'general_name'}
...@@ -359,12 +362,14 @@ class ProductRightStyle extends Component { ...@@ -359,12 +362,14 @@ class ProductRightStyle extends Component {
// 耗材 -- 小类 // 耗材 -- 小类
renderThridStyle() { renderThridStyle() {
let { rowSingleData } = this.state let { rowSingleData } = this.state
let data = this.props.rightNameFilter(rowSingleData, true)
return ( return (
<View style={styles.stencil_cont}> <View style={styles.stencil_cont}>
<FlatList <FlatList
style={styles.cont_thr_list} style={styles.cont_thr_list}
keyExtractor={item => item.id} keyExtractor={item => item.id}
data={rowSingleData} data={data}
extraData={this.state} extraData={this.state}
renderItem={({ item, index }) => this.renderThridItem(item, index)} renderItem={({ item, index }) => this.renderThridItem(item, index)}
/> />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment