Commit d05845e5 by wong.peiyi

转单申请添加部门信息

parent f4c56687
......@@ -48,6 +48,10 @@ export const reqTransOrganizations = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/authorized_inventory/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:'', org_code:'', seller_code:''}
export function requestTransSurgeryHospital(params) {
return (dispatch, getState) => {
......
......@@ -1610,9 +1610,7 @@ class EquipConsuPage extends Component {
if(res && res.error_code === 0){
const value = res.data.profile_value
sysValues[code] = isNaN(value) ? value : Number(value)
this.setState({ sysValues }, () => {
console.log(sysValues)
})
this.setState({ sysValues })
}
}
......
......@@ -50,7 +50,8 @@ import {
reqTransSurgeryHospital,
requestSubSourBorOrdNum,
requestListDataSuccess,
reqTransOrganizations
reqTransOrganizations,
reqOrgDepartments
} from '../../action/TransAction';
import { show, dedupQuoteArray, cloneObject } from '../../utils/Utils';
import {
......@@ -66,6 +67,7 @@ import ImagePicker from 'react-native-image-picker';
import { exitLoginStatus, requestSysProfile } from '../../action/LoginAction';
import moment from 'moment';
import PageListArrow from '../common/listDataComponent/PageListArrow';
import * as R from 'ramda';
class TransOrderPage extends Component {
constructor(props) {
......@@ -131,6 +133,12 @@ class TransOrderPage extends Component {
value: '',
isAddImage: true, // 添加图片
uploadImgArr: [] // 上传后的路径
},
{
"id": "9",
title: '部门',
name: '请选择',
value: ''
}
],
subInitListOption: [], // 提交成功后,初始化当前数据
......@@ -140,7 +148,8 @@ class TransOrderPage extends Component {
remark: '', // 备注信息
voice_url: '', // 录音地址
sur_order_transfer_line: '',
img_url: '' // 图片地址
img_url: '', // 图片地址
department_code: '',
// seller_code: '', // 用户名username
// org_code: '', // 组织
......@@ -172,8 +181,11 @@ class TransOrderPage extends Component {
],
isShowImage: false,
currShowImgIndex: 0,
bor_ware_required: 0, // APP目标仓库显示及必填权限
sysValues: {
OBS_MOBILE_BOR_WARE_REQUIRED: 0, // APP目标仓库显示及必填权限
OBS_MOBILE_TRANS_DEPARTMENT_DISPLAY: 0
},
departments: []
}
}
......@@ -489,12 +501,12 @@ class TransOrderPage extends Component {
}
// 清空当前项以下的值
clearInitNameAndValue(curIndex) {
clearInitNameAndValue(startIndex, endIndex = 5) {
let { listOptionData, localOtherObj } = this.state
let that = this
this.setState({
listOptionData: listOptionData.map((item, index) => {
if(index > curIndex && index < 5 ) {
if(index > startIndex && index < endIndex) {
item.name = localOtherObj.name
item.value = localOtherObj.value
if(listOptionData[1].value && item.title == '客户名称') {
......@@ -511,11 +523,11 @@ class TransOrderPage extends Component {
// 判断是否都有值,修改提交按钮的颜色
changeCanSub(isSubCheck) {
let { listOptionData, bor_ware_required } = this.state
let { listOptionData, sysValues } = this.state
let tempStatus = false
let tempTit = ''
let maxIndex = 4
if(bor_ware_required === 3){
if(sysValues.OBS_MOBILE_BOR_WARE_REQUIRED === 3){
maxIndex = 5
}
for(let chIndex in listOptionData) {
......@@ -529,6 +541,10 @@ class TransOrderPage extends Component {
tempTit = `“${listOptionData[chIndex].title}”未添加`
tempStatus = true
break
} else if (chIndex == 9 && !listOptionData[chIndex].value) {
tempTit = `“${listOptionData[chIndex].title}”未选择`
tempStatus = true
break
}
}
this.setState({
......@@ -553,6 +569,8 @@ class TransOrderPage extends Component {
chItem.value = item.value
if(itemTitle === '组织') {
that.clearInitNameAndValue(1)
that.clearInitNameAndValue(8, 10)
that.getDepartmentsByOrg(item.value)
}
if(itemTitle === '客户名称') {
that.clearInitNameAndValue(2)
......@@ -695,6 +713,70 @@ class TransOrderPage extends Component {
// }
}
/**
* 根据组织获取部门等信息, 其他信息在部门下面
* @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('departments: ', res)
let departments = res.data.relationships
this.setState({ departments })
const {listOptionData, sysValues} = this.state
const noop = () => {}
// 部门只有一个时直接设置
R.cond([
[R.equals(0), () => setTimeout(() => show('当前组织没有部门信息'), 4000)],
[R.equals(1), () => {
const dep = R.head(departments)
listOptionData[9].name = dep.department_name
listOptionData[9].value = dep.department_code
this.setState({ listOptionData })
}],
[R.T, noop]
])(R.length(departments))
} catch (error) {
console.log(error)
}
}
/**
* 部门点击
*/
handleDepCheck(curData) {
if (!this.judgeOrgIsNull()) return
const {departments} = this.state
const listOptions = R.map(
R.applySpec({
name: R.prop('department_name'),
value: R.prop('department_code')
})
)(departments)
this.setState({
currentTitle: curData.title,
currentItem: {
name: curData.name,
value: curData.value
},
showTypePop: true,
listCurrentOption: listOptions
})
}
// 客户名称 点击
handleCustomerCheck(curData) {
let { state, props } = this
......@@ -1098,6 +1180,8 @@ class TransOrderPage extends Component {
tempSubOption.voice_url = state.listOptionData[6].value
tempSubOption.sur_order_transfer_line = state.listOptionData[7].subOption
tempSubOption.img_url = state.listOptionData[8].uploadImgArr.join(',')
tempSubOption.department_code = state.listOptionData[9].value
let params = {
access_token: props.token,
data: { ...tempSubOption }
......@@ -1174,20 +1258,25 @@ class TransOrderPage extends Component {
}
// 获取配置值
async getSysConfigValue() {
let { global_domain_config, token } = this.props
let { global_domain_config, token} = this.props
const {sysValues} = this.state
const log = R.bind(console.log, console)
const getSysProfile = async code => {
const params = {
access_token: token,
profile_code: 'OBS_MOBILE_BOR_WARE_REQUIRED'
profile_code: code,
}
let res = await requestSysProfile(global_domain_config, params)
console.log('sysRes:==', res)
if(res.error_code === 0){
const value = res.data.profile_value
sysValues[code] = isNaN(value) ? value : Number(value)
this.setState({ sysValues })
}
let sysRes = await requestSysProfile(global_domain_config, params)
console.log('sysRes:==', sysRes)
if(sysRes.error_code === 0){
this.setState({
bor_ware_required: Number(sysRes.data.profile_value) || 0
})
// }else {
// this.showWarnError(sysRes)
}
R.compose(R.map(getSysProfile), R.keys)(sysValues)
}
showWarnError(res){
if(res.error_code == 41006) {
......@@ -1201,7 +1290,7 @@ class TransOrderPage extends Component {
// 返回备注以上的元素
renderListItem() {
let { listOptionData, bor_ware_required } = this.state
let { listOptionData, sysValues } = this.state
return(
<View style={styles.list_cont}>
<PageListArrow
......@@ -1221,6 +1310,19 @@ class TransOrderPage extends Component {
listCallBack={() => this.handleOrganizationCheck(listOptionData[1])}
listHasArrow={true}
/>
{
sysValues.OBS_MOBILE_TRANS_DEPARTMENT_DISPLAY > 1 && (
<PageListArrow
listActOpa={.8}
listHasAster={sysValues.OBS_MOBILE_TRANS_DEPARTMENT_DISPLAY === 3}
listItem={listOptionData[9]}
listName={'name'}
listTitle={'title'}
listCallBack={() => this.handleDepCheck(listOptionData[9])}
listHasArrow={true}
/>
)
}
<PageListArrow
listActOpa={.8}
listHasAster={true}
......@@ -1241,10 +1343,10 @@ class TransOrderPage extends Component {
listMaxLines={3}
/>
{
bor_ware_required > 1 &&
sysValues.OBS_MOBILE_BOR_WARE_REQUIRED > 1 &&
<PageListArrow
listActOpa={.8}
listHasAster={bor_ware_required === 3}
listHasAster={sysValues.OBS_MOBILE_BOR_WARE_REQUIRED === 3}
listItem={listOptionData[4]}
listName={'name'}
listTitle={'title'}
......
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