Commit d3540216 by peii

耗材子类过滤

parent 163cd886
......@@ -715,46 +715,44 @@ class ChooseProductPage extends Component {
/**
* @description: 搜索过滤
* @param {*}
* @param {array} list 要过滤的数组
* @param {boolean} isChildFilter 子组件调用(三级调用)
* @return {*}
*/
rightNameFilter(list = []) {
rightNameFilter(list = [], isChildFilter = false) {
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') {
const curSupplier = topProcOptionList[topActiveIndex]
const auth = R.find(R.propEq('supplier_code', curSupplier.supplier_code))(authorizations)
if (isNotBlank(auth) && isNotBlank(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)
} 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 {
list = []
}
}
const includes = item => {
if (isBlank(searchValue)) return list
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)
// 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 {
// 返回右侧二级数据
renderContItem() {
let { leftActiveIndex, defaultThridShow, topProcOptionList, topActiveIndex} = this.state
let { leftActiveIndex, defaultThridShow, topProcOptionList, topActiveIndex, searchValue } = this.state
let curRigSecoOption = []
let curSuperLeftOption = []
let topItem = topProcOptionList[topActiveIndex]
......@@ -876,6 +874,8 @@ class ChooseProductPage extends Component {
superCallBack={(count, coutFieName) => this.handleChangeCount(count, coutFieName)}
superReduceBack={() => this.handleSubSelected()}
superLeftData={curSuperLeftOption}
rightNameFilter={this.rightNameFilter.bind(this)}
inputSearchValue={this.inputSearchValue.bind(this)}
/>
</View>
)
......
......@@ -3,7 +3,7 @@ import { View, Text, StyleSheet, TouchableOpacity, Image, ScrollView, FlatList,
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 PicTitDetaiCalcu from '../../common/listDataComponent/PicTitDetaiCalcu';
import { cloneObject } from '../../../utils/Utils';
import { cloneObject, isBlank, isNotBlank} from '../../../utils/Utils';
import { PicListNoData } from '../../common/CellTextStyle';
import _ from "lodash";
import { connect } from 'react-redux';
......@@ -157,11 +157,10 @@ class ProductRightStyle extends Component {
// 修改当前小类是否展示
changeThrShow(show, superItem, superIndex) {
let { curThridObj, rowSingleData } = this.state
let { curThridObj, rowSingleData, lastInputText } = this.state
let that = this
if (show && superItem) {
// 大类点击标题
let curRowData = R.clone(superItem['details'])
curThridObj = {
superItem: superItem,
superIndex: superIndex,
......@@ -170,7 +169,7 @@ class ProductRightStyle extends Component {
that.setState({
thridIsVisible: show,
curThridObj: curThridObj,
rowSingleData: curRowData
rowSingleData: R.clone(superItem['details'])
})
this.props.changeThrShow(show)
} else {
......@@ -178,7 +177,7 @@ class ProductRightStyle extends Component {
if (curThridObj.superItem) {
let curDa = curThridObj.superItem
let curInd = curThridObj.superIndex
curDa.details = cloneObject(rowSingleData)
curDa.details = R.clone(rowSingleData)
curDa[LocalVariable.QUANTITY_FIELD] = 0
curDa.details.forEach(itVal => {
if (itVal[LocalVariable.QUANTITY_FIELD] > 0) {
......@@ -187,7 +186,8 @@ class ProductRightStyle extends Component {
})
that.handleCalCallBack(curDa, curInd, 'rightSecondData', LocalVariable.QUANTITY_FIELD)
that.setState({
thridIsVisible: show
thridIsVisible: show,
lastInputText: ''
})
this.props.changeThrShow(show)
}
......@@ -335,13 +335,16 @@ class ProductRightStyle extends Component {
// 耗材 -- 小类每一列
renderThridItem(item, index) {
let { rowSingleData } = this.state
const idx = R.findIndex(R.propEq('item_code', item.item_code))(rowSingleData)
return (
<SafeAreaView style={styles.thr_container} key={'item_code' + index}>
<PicTitDetaiCalcu
listItem={item}
listIndex={index}
listIndex={idx}
calField={LocalVariable.QUANTITY_FIELD}
subCalCallBack={(item, index) => this.handleCalCallBack(item, index, 'rowSingleData')}
subCalCallBack={(item, idx) => this.handleCalCallBack(item, idx, 'rowSingleData')}
titText={'manufacturer_product_code'}
tipTextStr={'item_name'}
tipTextOne={'general_name'}
......@@ -359,12 +362,14 @@ class ProductRightStyle extends Component {
// 耗材 -- 小类
renderThridStyle() {
let { rowSingleData } = this.state
let data = this.props.rightNameFilter(rowSingleData, true)
return (
<View style={styles.stencil_cont}>
<FlatList
style={styles.cont_thr_list}
keyExtractor={item => item.id}
data={rowSingleData}
data={data}
extraData={this.state}
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