Commit b7c69c78 by wong.peiyi

借货订单筛选增加部门及其他销售员搜索

parent d05845e5
...@@ -37,6 +37,10 @@ export const requestHistorSurgeryType = async (global_domain_config, params) => ...@@ -37,6 +37,10 @@ export const requestHistorSurgeryType = async (global_domain_config, params) =>
return await GetRequest(global_domain_config, getUrlParams('/system/value_set/search', params)) return await GetRequest(global_domain_config, getUrlParams('/system/value_set/search', params))
} }
export const reqOrgDepartments = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/sale/sale_relationship/search', params))
}
// 借货订单查询 params: {access_token: '', ...} // 借货订单查询 params: {access_token: '', ...}
export function requestGetAllBorrow(params) { export function requestGetAllBorrow(params) {
return (dispatch, getState) => { return (dispatch, getState) => {
......
...@@ -26,14 +26,15 @@ import { ...@@ -26,14 +26,15 @@ import {
pxSize, pxSize,
third_text_color, third_text_color,
Height, Height,
font_family_medium font_family_medium,
btn_sub_color
} from '../../../base/BaseStyle'; } from '../../../base/BaseStyle';
import DateModel from '../../common/DateModel'; import DateModel from '../../common/DateModel';
import DialogModel from '../../common/DialogModel'; import DialogModel from '../../common/DialogModel';
import StatusBarView from '../../common/StatusBarView'; import StatusBarView from '../../common/StatusBarView';
import HeadBackItem from '../../common/HeadBackItem'; import HeadBackItem from '../../common/HeadBackItem';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { exitLoginStatus } from '../../../action/LoginAction'; import { exitLoginStatus, requestSysProfile} from '../../../action/LoginAction';
import { import {
LOGIN_NO LOGIN_NO
} from '../../../base/ActionTypes'; } from '../../../base/ActionTypes';
...@@ -42,11 +43,13 @@ import { ...@@ -42,11 +43,13 @@ import {
requestHistorSurgeryHospital, requestHistorSurgeryHospital,
requestHistorOrderType, requestHistorOrderType,
requestHistorTarOrSourOrd, requestHistorTarOrSourOrd,
requestHistorSurgeryType requestHistorSurgeryType,
reqOrgDepartments
} from '../../../action/HistorAction'; } from '../../../action/HistorAction';
import { show, dedupQuoteArray, cloneObject } from '../../../utils/Utils'; import { show, dedupQuoteArray, cloneObject, isBlank, isNotBlank } from '../../../utils/Utils';
import moment from 'moment'; import moment from 'moment';
import ErrorTipModel from '../../common/ErrorTipModel'; import ErrorTipModel from '../../common/ErrorTipModel';
import * as R from 'ramda';
const REQUEST_NUMBER_BAR_CODE = 'REQUEST_NUMBER_BAR_CODE' const REQUEST_NUMBER_BAR_CODE = 'REQUEST_NUMBER_BAR_CODE'
...@@ -86,7 +89,8 @@ class FilterModel extends Component { ...@@ -86,7 +89,8 @@ class FilterModel extends Component {
// surgery_type_code: '', // 手术类型 -- 不用此参数 // surgery_type_code: '', // 手术类型 -- 不用此参数
surgery_date_from: '', // 手术时间开始 surgery_date_from: '', // 手术时间开始
surgery_date_to: '', // 手术时间结束 surgery_date_to: '', // 手术时间结束
order_type_code: '' // 订单类型 order_type_code: '', // 订单类型
department_code: '' // 部门
}, },
consumeSearchOption: { // [消耗]筛选条件 consumeSearchOption: { // [消耗]筛选条件
consumed_flag: '', // 状态筛选 'Y'/'N' consumed_flag: '', // 状态筛选 'Y'/'N'
...@@ -175,6 +179,11 @@ class FilterModel extends Component { ...@@ -175,6 +179,11 @@ class FilterModel extends Component {
title: '订单类型', title: '订单类型',
name: '请选择', name: '请选择',
value: '' value: ''
}, {
"id": "11",
title: '部门',
name: '请选择',
value: ''
}], }],
consumeListOptionData: [{ // [消耗]筛选-对应字段 consumeListOptionData: [{ // [消耗]筛选-对应字段
"id": "0", "id": "0",
...@@ -311,13 +320,19 @@ class FilterModel extends Component { ...@@ -311,13 +320,19 @@ class FilterModel extends Component {
], ],
errorPopType: false, // 错误提示弹窗 errorPopType: false, // 错误提示弹窗
errorTit: '', // 错误提示文字 errorTit: '', // 错误提示文字
isRightExit: true isRightExit: true,
sysValues: {
OBS_MOBILE_COLL_DEPARTMENT: 'N'
},
departments: {},
sellers: []
} }
} }
componentDidMount() { componentDidMount() {
this.getSellerName() this.getSellerName()
this.initSelectPickerData() this.initSelectPickerData()
this.getSysConfigValue()
} }
// 赋值销售员 初始化数据 // 赋值销售员 初始化数据
...@@ -402,6 +417,31 @@ class FilterModel extends Component { ...@@ -402,6 +417,31 @@ class FilterModel extends Component {
} }
} }
/**
* 获取系统配置
*/
getSysConfigValue() {
const { global_domain_config, token} = this.props
const {sysValues} = this.state
const getSysProfile = async code => {
const params = {
access_token: token,
profile_code: code
}
let res = await requestSysProfile(global_domain_config, params)
console.log('sysRes:==', res)
if(res && res.error_code === 0) {
const value = res.data.profile_value
sysValues[code] = isNaN(value) ? value : Number(value)
this.setState({ sysValues })
}
}
R.compose(R.map(getSysProfile), R.keys)(sysValues)
}
// 修改选择器为属性 name 和 value // 修改选择器为属性 name 和 value
changeNameAndValue(data, nameType, valueType) { changeNameAndValue(data, nameType, valueType) {
let result = [] let result = []
...@@ -415,13 +455,14 @@ class FilterModel extends Component { ...@@ -415,13 +455,14 @@ class FilterModel extends Component {
} }
// 清空当前项以下的值 // 清空当前项以下的值
clearInitNameAndValue(curIndex) { clearInitNameAndValue(curIndex, endIndex) {
let { topActiveIndex, borrowListOptionData, consumeListOptionData, localOtherObj} = this.state let { topActiveIndex, borrowListOptionData, consumeListOptionData, localOtherObj} = this.state
switch(topActiveIndex) { switch(topActiveIndex) {
case 0: case 0:
borrowListOptionData = borrowListOptionData.map((item, index) => { borrowListOptionData = borrowListOptionData.map((item, index) => {
if(index > curIndex && index < 7 ) { !endIndex && (endIndex = 7)
if(index > curIndex && index < endIndex ) {
item.name = localOtherObj.name item.name = localOtherObj.name
item.value = localOtherObj.value item.value = localOtherObj.value
if(item.title == '主治医生') { if(item.title == '主治医生') {
...@@ -434,7 +475,8 @@ class FilterModel extends Component { ...@@ -434,7 +475,8 @@ class FilterModel extends Component {
break; break;
case 1: case 1:
consumeListOptionData = consumeListOptionData.map((item, index) => { consumeListOptionData = consumeListOptionData.map((item, index) => {
if(index > curIndex && index < 4 ) { !endIndex && (endIndex = 4)
if(index > curIndex && index < endIndex ) {
item.name = localOtherObj.name item.name = localOtherObj.name
item.value = localOtherObj.value item.value = localOtherObj.value
} }
...@@ -456,6 +498,7 @@ class FilterModel extends Component { ...@@ -456,6 +498,7 @@ class FilterModel extends Component {
// 选择器弹窗回调函数 // 选择器弹窗回调函数
handleCallBack(item, itemTitle) { handleCallBack(item, itemTitle) {
let { topActiveIndex, borrowListOptionData, consumeListOptionData, transferListOptionData} = this.state let { topActiveIndex, borrowListOptionData, consumeListOptionData, transferListOptionData} = this.state
const {userInfo} = this.props
let self = this let self = this
this.setState({ this.setState({
currentItem: item currentItem: item
...@@ -468,6 +511,16 @@ class FilterModel extends Component { ...@@ -468,6 +511,16 @@ class FilterModel extends Component {
chItem.value = item.value chItem.value = item.value
if(itemTitle === '组织') { if(itemTitle === '组织') {
self.clearInitNameAndValue(2) self.clearInitNameAndValue(2)
self.clearInitNameAndValue(10, 12)
self.getDepartmentsByOrg(item.value)
self.setSellerList()
}
if (itemTitle === '部门') {
borrowListOptionData[1].value = userInfo.user_name
borrowListOptionData[1].name = userInfo.person_name
this.setState({ borrowListOptionData, sellers: [] }, () => {
this.setSellerList()
})
} }
if(itemTitle === '客户名称') { if(itemTitle === '客户名称') {
self.clearInitNameAndValue(3) self.clearInitNameAndValue(3)
...@@ -523,6 +576,8 @@ class FilterModel extends Component { ...@@ -523,6 +576,8 @@ class FilterModel extends Component {
}) })
} }
// 修改当前选择器值 -- 可隐藏 // 修改当前选择器值 -- 可隐藏
changeCurrentObj(item, itemTitle, optArray) { changeCurrentObj(item, itemTitle, optArray) {
let result = [] let result = []
...@@ -667,6 +722,73 @@ class FilterModel extends Component { ...@@ -667,6 +722,73 @@ class FilterModel extends Component {
return [obj, org_code]; return [obj, org_code];
} }
/**
* 获取部门信息
* @param {*} org_code
*/
async getDepartmentsByOrg(org_code) {
const {token, global_domain_config, userInfo} = this.props
const params = {
access_token: token,
org_code,
seller_code: userInfo.user_name,
scope_flag: 'Y'
}
try {
const res = await reqOrgDepartments(global_domain_config, params)
console.log('depRes', res)
let departments = res.data.relationships
this.setState({ departments })
const {borrowListOptionData} = this.state
const noop = () => {}
// 部门只有一个时直接设置
R.cond([
[R.equals(0), () => show('当前组织没有部门信息')],
[R.equals(1), () => {
const dep = R.head(departments)
borrowListOptionData[11].name = dep.department_name
borrowListOptionData[11].value = dep.department_code
this.setState({ borrowListOptionData }, () => {
this.setSellerList()
})
}],
[R.T, noop]
])(R.length(departments))
} catch (error) {
console.log(error)
}
}
/**
* 根据部门信息设置销售员
*/
setSellerList() {
const {userInfo} = this.props
const {departments, borrowListOptionData} = this.state
let sellers = []
const department = R.find(R.propEq('department_code', borrowListOptionData[11].value))(departments)
if (isNotBlank(department)) {
sellers = R.compose(
R.map(R.applySpec({
name: R.prop('seller_name'),
value: R.prop('seller_code'),
})),
R.propOr([], 'seller_list')
)(department)
R.ifElse(R.compose(R.includes(userInfo.user_name), R.pluck('value')), () => { }, () => {
sellers = R.concat([{
name: userInfo.person_name,
value: userInfo.user_name
}], sellers)
})(sellers)
}
this.setState({ sellers })
}
// 组织 - 筛选 // 组织 - 筛选
handleOrganizationCheck() { handleOrganizationCheck() {
let {props} = this let {props} = this
...@@ -710,6 +832,57 @@ class FilterModel extends Component { ...@@ -710,6 +832,57 @@ class FilterModel extends Component {
}) })
} }
/**
* 部门
*/
handleDepartmentCheck() {
if(!this.judgeOrgIsNull()) return
const curItem = this.getCurrentOption(11)
const {departments} = this.state
const options = R.compose(
R.map(
R.applySpec({
name: R.prop('department_name'),
value: R.prop('department_code'),
})
)
)(departments)
this.setState({
currentTitle: '部门',
currentItem: curItem[0],
showTypePop: true,
listCurrentOption: options
})
}
/**
* 设置销售员
*/
setCollectSeller(seller) {
const {sellers, borrowListOptionData} = this.state
let sellerCodes = R.compose(R.split(','), R.pathOr('', [1, 'value']))(borrowListOptionData)
R.ifElse(R.contains(R.__, sellerCodes), () => {
// 已在其中,减掉
if (R.length(sellerCodes) === 1) {
return show('最少要有一个销售员')
}
const idx = R.findIndex(R.equals(seller.value))(sellerCodes)
borrowListOptionData[1].value = R.compose(R.join(','), R.remove(idx, 1))(sellerCodes)
let sellerNames = R.compose(R.split(','), R.pathOr('', [1, 'name']))(borrowListOptionData)
borrowListOptionData[1].name = R.compose(R.join(','), R.remove(idx, 1))(sellerNames)
}, () => {
borrowListOptionData[1].value += `,${seller.value}`
borrowListOptionData[1].name += `,${seller.name}`
})(seller.value)
this.setState({ borrowListOptionData })
}
// 客户名称 - 筛选 // 客户名称 - 筛选
handleCustomerCheck() { handleCustomerCheck() {
if(!this.judgeOrgIsNull()) { if(!this.judgeOrgIsNull()) {
...@@ -1279,7 +1452,8 @@ class FilterModel extends Component { ...@@ -1279,7 +1452,8 @@ class FilterModel extends Component {
case 0: case 0:
borrowListOptionData = cloneObject(subBorrowInitListOption) borrowListOptionData = cloneObject(subBorrowInitListOption)
this.setState({ this.setState({
borrowListOptionData borrowListOptionData,
sellers: []
}) })
break; break;
case 1: case 1:
...@@ -1350,6 +1524,7 @@ class FilterModel extends Component { ...@@ -1350,6 +1524,7 @@ class FilterModel extends Component {
tempSubOption.surgery_date_from = borrowListOptionData[8].value tempSubOption.surgery_date_from = borrowListOptionData[8].value
tempSubOption.surgery_date_to = borrowListOptionData[9].value tempSubOption.surgery_date_to = borrowListOptionData[9].value
tempSubOption.order_type_code = borrowListOptionData[10].value tempSubOption.order_type_code = borrowListOptionData[10].value
tempSubOption.department_code = borrowListOptionData[11].value
params = Object.assign({}, params, tempSubOption) params = Object.assign({}, params, tempSubOption)
props.callSupSubmit(params) props.callSupSubmit(params)
that.changeSeaColorAct() // 改变筛选颜色 that.changeSeaColorAct() // 改变筛选颜色
...@@ -1600,7 +1775,7 @@ class FilterModel extends Component { ...@@ -1600,7 +1775,7 @@ class FilterModel extends Component {
// 返回筛选 // 返回筛选
renderTopSelectItem() { renderTopSelectItem() {
let {topActiveIndex, borrowListOptionData, consumeListOptionData, transferListOptionData} = this.state let {topActiveIndex, borrowListOptionData, consumeListOptionData, transferListOptionData, sysValues, sellers} = this.state
return ( return (
<View style={styles.sea_container}> <View style={styles.sea_container}>
<View style={styles.sea_scr_box}> <View style={styles.sea_scr_box}>
...@@ -1639,6 +1814,88 @@ class FilterModel extends Component { ...@@ -1639,6 +1814,88 @@ class FilterModel extends Component {
<View style={styles.sea_qui_select}> <View style={styles.sea_qui_select}>
<Text style={styles.sea_qui_tit}>快捷筛选</Text> <Text style={styles.sea_qui_tit}>快捷筛选</Text>
<View style={styles.sea_qui_box}> <View style={styles.sea_qui_box}>
{
// 兼容旧版本的
sysValues.OBS_MOBILE_COLL_DEPARTMENT === 'Y' && (
<>
<View style={styles.qui_cell}>
<Text style={styles.qui_cell_tit}>组织</Text>
<TouchableOpacity
activeOpacity={.8}
style={styles.qui_cell_rig}
onPress={() => this.handleOrganizationCheck() }
>
<Text style={styles.cell_rig_sel}>{borrowListOptionData[2].name}</Text>
<View style={styles.arr_icon_box}>
<Image source={require('../../../images/arr_rig.png')} style={icon_style} />
</View>
</TouchableOpacity>
</View>
<View style={styles.qui_cell}>
<Text style={styles.qui_cell_tit}>部门</Text>
<TouchableOpacity
activeOpacity={.8}
style={styles.qui_cell_rig}
onPress={() => this.handleDepartmentCheck() }
>
<Text style={styles.cell_rig_sel}>{borrowListOptionData[11].name}</Text>
<View style={styles.arr_icon_box}>
<Image source={require('../../../images/arr_rig.png')} style={icon_style} />
</View>
</TouchableOpacity>
</View>
<View style={styles.qui_cell}>
<Text style={styles.qui_cell_tit}>销售员</Text>
<TouchableOpacity
activeOpacity={1}
style={styles.qui_cell_rig}
>
<Text style={styles.cell_rig_sel}>{borrowListOptionData[1].name}</Text>
<View style={styles.arr_icon_box}>
</View>
</TouchableOpacity>
</View>
{
sellers && sellers.length > 0 &&
<View style={[styles.qui_cell, styles.qui_cell_select]}>
{
sellers.map(seller => {
const isSelected = R.compose(R.includes(seller.value), R.pathOr('', [1, 'value']))(borrowListOptionData)
return (
<TouchableOpacity style={isSelected
? [styles.qui_cell_select_box, styles.qui_cell_select_box_selected]
: styles.qui_cell_select_box}
key={seller.value}
activeOpacity={0.5}
onPress={() => this.setCollectSeller(seller)}
>
<Text style={
borrowListOptionData[1].value === seller.value
? styles.qui_cell_select_text_selected
: styles.qui_cell_select_text
}
>
{seller.name}
</Text>
{
isSelected &&
<View style={styles.btn_act_icon}>
<Image source={require('../../../images/his_ord_sel.png')} style={icon_style} />
</View>
}
</TouchableOpacity>
)
})
}
</View>
}
</>
)
}
{
// 兼容旧版本的
sysValues.OBS_MOBILE_COLL_DEPARTMENT === 'N' && (
<>
<View style={styles.qui_cell}> <View style={styles.qui_cell}>
<Text style={styles.qui_cell_tit}>销售员</Text> <Text style={styles.qui_cell_tit}>销售员</Text>
<TouchableOpacity <TouchableOpacity
...@@ -1663,6 +1920,9 @@ class FilterModel extends Component { ...@@ -1663,6 +1920,9 @@ class FilterModel extends Component {
</View> </View>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</>
)
}
<View style={styles.qui_cell}> <View style={styles.qui_cell}>
<Text style={styles.qui_cell_tit}>客户名称</Text> <Text style={styles.qui_cell_tit}>客户名称</Text>
<TouchableOpacity <TouchableOpacity
...@@ -2419,13 +2679,38 @@ const styles = StyleSheet.create({ ...@@ -2419,13 +2679,38 @@ const styles = StyleSheet.create({
qui_cell: { qui_cell: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
marginTop: 12 marginTop: pxSize(12)
}, },
qui_cell_tit: { qui_cell_tit: {
color: first_text_color, color: first_text_color,
fontSize: 14, fontSize: 14,
fontFamily: font_family_regular, fontFamily: font_family_regular,
width: 80 width: pxSize(80)
},
qui_cell_select: {
paddingLeft: pxSize(80),
justifyContent: 'space-between',
flexWrap: 'wrap',
},
qui_cell_select_box: {
width: "30%",
padding: pxSize(5),
borderWidth: pxSize(1),
borderColor: "#eee",
backgroundColor: "#FFF",
marginBottom: pxSize(5)
},
qui_cell_select_box_selected: {
backgroundColor: "#E7F1FD",
},
qui_cell_select_text: {
width: "100%",
textAlign: 'center'
},
qui_cell_select_text_selected: {
width: "100%",
textAlign: 'center',
color: '#007EFF'
}, },
qui_cell_rig: { qui_cell_rig: {
height: 40, height: 40,
......
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