Commit 273c8399 by peii

通过配置文件控制组织显示和隐藏

parent 8ac15a0d
import * as R from 'ramda';
import {
LOGIN_DOING,
LOGIN_SUCCESS,
......@@ -7,7 +8,8 @@ import {
AUTO_LOGIN_FAILURE,
SET_DOMAIN_CONFIGURATE,
SET_VERSION_APK,
SET_DOMAIN_FROM_ORIGIN
SET_DOMAIN_FROM_ORIGIN,
SET_SYSPROFILE
} from '../base/ActionTypes';
import { GetRequest, PostRequest } from '../network/RequestUtils';
import { getUrlParams, show, showWarnErrorMessage, showErrorMessage } from '../utils/Utils';
......@@ -22,6 +24,7 @@ export function requestLogin(params) {
if(res.functions && res.functions.length) {
show('登录成功');
dispatch(loginSuccess(res, params.data.user_name, params.data.user_password));
dispatch(getSysProfiles())
} else {
show(`当前用户没有菜单权限,\n请联系管理员配置!`)
dispatch(loginFailure())
......@@ -156,3 +159,44 @@ export function setVersionApk(versionApk) {
local_version_apk: versionApk
}
}
/**
* @description: 获取系统配置
* @param {*} access_token
* @return {*}
*/
export function getSysProfiles() {
return (dispatch, getState) => {
let {global_domain_config, token, originSysProfiles} = getState().login
function getSysProfile(profile_code) {
const params = {
access_token: token,
profile_code
}
requestSysProfile(global_domain_config, params).then(res => {
console.log(res)
if (res.error_code === 0) {
const value = R.pathOr(originSysProfiles[profile_code], ['data', 'profile_value'])(res)
dispatch(setSysProfiles(profile_code, value))
}
})
}
R.compose(R.map(getSysProfile), R.keys)(originSysProfiles)
}
}
/**
* @description: 设置系统配置
* @param {*} code
* @param {*} value
* @return {*}
*/
export function setSysProfiles(code, value) {
return {
type: SET_SYSPROFILE,
code,
value
}
}
\ No newline at end of file
......@@ -9,6 +9,8 @@ export const AUTO_LOGIN_FAILURE = "AUTO_LOGIN_FAILURE"
export const SET_DOMAIN_CONFIGURATE="SET_DOMAIN_CONFIGURATE"
export const SET_DOMAIN_FROM_ORIGIN = 'SET_DOMAIN_FROM_ORIGIN'
export const SET_VERSION_APK="SET_VERSION_APK"
export const GET_SYSPROFILE = "GET_SYSPROFILE"
export const SET_SYSPROFILE = "SET_SYSPROFILE"
//-----------self order---------------------
export const SELF_ORDER_LIST_NO = "SELF_ORDER_LIST_NO"
export const SELF_ORDER_LIST_DOING = "SELF_ORDER_LIST_DOING"
......
......@@ -638,7 +638,7 @@ class EquipConsuPage extends Component {
let orgResult = await reqEquipOrganizations(global_domain_config, params);
if (orgResult.error_code == 0) {
let { data: { organizations } } = orgResult
let { listOptionData } = state
let { listOptionData, sysValues } = state
// props.requestListDataSuccess(organizations)
let filterOpt = dedupQuoteArray(organizations, 'org_code')
if (filterOpt.length === 0) {
......@@ -652,9 +652,19 @@ class EquipConsuPage extends Component {
listOptionData
}, () => {
that.organizationGetCustomerData()
setTimeout(() => {
if (sysValues.OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY > 0) {
that.getDepartmentsByOrg(listOptionData[1].value)
}
}, 1000)
})
}
// 贵州需要不显示组织, 所以只能每个用户只能授权1个组织
const isShowOrg = R.compose(R.equals('Y'), R.prop('OBS_SHOW_ORG_FLAG'))(this.props.sysProfiles)
if (!isShowOrg && filterOpt.length > 1) {
show(`请先选择组织`)
}
} else if (orgResult.error_code == 41006) {
show('登录过期,请重新登录');
props.exitLoginStatus();
......@@ -1479,6 +1489,8 @@ class EquipConsuPage extends Component {
// 返回备注以上的元素
renderListItem() {
let { listOptionData, dateModelPop, sysValues } = this.state
const isShowOrg = R.compose(R.equals('Y'), R.prop('OBS_SHOW_ORG_FLAG'))(this.props.sysProfiles)
return(
<View style={styles.list_cont}>
<PageListArrow
......@@ -1489,6 +1501,8 @@ class EquipConsuPage extends Component {
listDefaValue={'name'}
listTitle={'title'}
/>
{
isShowOrg && (
<PageListArrow
listActOpa={.8}
listHasAster={true}
......@@ -1498,6 +1512,8 @@ class EquipConsuPage extends Component {
listCallBack={() => this.handleOrganizationCheck(listOptionData[1])}
listHasArrow={true}
/>
)
}
{
sysValues.OBS_MOBILE_CONSU_DEPARTMENT_DISPLAY > 0 && (
<PageListArrow
......@@ -2055,6 +2071,7 @@ const mapStateToProps = (state) => {
equipOrderOption: state.equip.equipOrderOption,
subDetOption: state.equip.subDetOption,
charDetailOption: state.equip.charDetailOption,
sysProfiles: state.login.sysProfiles,
global_domain_config: state.login.global_domain_config
}
}
......
......@@ -333,6 +333,7 @@ class FilterModel extends Component {
this.getSellerName()
this.initSelectPickerData()
this.getSysConfigValue()
this.getOrganizations()
}
// 赋值销售员 初始化数据
......@@ -442,6 +443,35 @@ class FilterModel extends Component {
R.compose(R.map(getSysProfile), R.keys)(sysValues)
}
/**
* @description: 不显示组织的话一开始就请求
* @param {*}
* @return {*}
*/
async getOrganizations() {
const {global_domain_config, token, sysProfiles} = this.props
const params = {
access_token: token
}
const isShowOrg = R.compose(R.equals('Y'), R.prop('OBS_SHOW_ORG_FLAG'))(sysProfiles)
if (isShowOrg) return
let res = await requestHistorOrganizations(global_domain_config, params)
if (res.error_code !== 0) return
const organizations = R.pathOr([], ['data', 'organizations'])(res)
if (R.length(organizations) !== 1) return
const orgCode = R.path([0, 'org_code'])(organizations)
const {borrowListOptionData, consumeListOptionData, transferListOptionData} = this.state
borrowListOptionData[2].value = orgCode
consumeListOptionData[2].value = orgCode
transferListOptionData[2].value = orgCode
this.setState({borrowListOptionData, consumeListOptionData, transferListOptionData})
}
// 修改选择器为属性 name 和 value
changeNameAndValue(data, nameType, valueType) {
let result = []
......@@ -907,7 +937,7 @@ class FilterModel extends Component {
// 修改当前选择器数据
let { data: { customers } } = orgResult
if(customers.length === 0) {
// show(`当前客户名称为空`)
// (`当前客户名称为空`)
that.showErrorModel(`当前客户名称为空`)
return
}
......@@ -1776,6 +1806,8 @@ class FilterModel extends Component {
// 返回筛选
renderTopSelectItem() {
let {topActiveIndex, borrowListOptionData, consumeListOptionData, transferListOptionData, sysValues, sellers} = this.state
const isShowOrg = R.compose(R.equals('Y'), R.prop('OBS_SHOW_ORG_FLAG'))(this.props.sysProfiles)
return (
<View style={styles.sea_container}>
<View style={styles.sea_scr_box}>
......@@ -1818,6 +1850,7 @@ class FilterModel extends Component {
// 兼容旧版本的
sysValues.OBS_MOBILE_COLL_DEPARTMENT === 'Y' && (
<>
{isShowOrg && (
<View style={styles.qui_cell}>
<Text style={styles.qui_cell_tit}>组织</Text>
<TouchableOpacity
......@@ -1831,6 +1864,7 @@ class FilterModel extends Component {
</View>
</TouchableOpacity>
</View>
)}
<View style={styles.qui_cell}>
<Text style={styles.qui_cell_tit}>部门</Text>
<TouchableOpacity
......@@ -1907,6 +1941,8 @@ class FilterModel extends Component {
</View>
</TouchableOpacity>
</View>
{
isShowOrg && (
<View style={styles.qui_cell}>
<Text style={styles.qui_cell_tit}>组织</Text>
<TouchableOpacity
......@@ -1920,6 +1956,8 @@ class FilterModel extends Component {
</View>
</TouchableOpacity>
</View>
)
}
</>
)
}
......@@ -2843,7 +2881,8 @@ const mapStateToProps = (state) => {
userInfo: state.login.userInfo,
token: state.login.token,
loginState: state.login.loginState,
global_domain_config: state.login.global_domain_config
global_domain_config: state.login.global_domain_config,
sysProfiles: state.login.sysProfiles,
}
}
......
......@@ -911,7 +911,7 @@ class EquipConsuPage extends Component {
let orgResult = await reqQuickOrganizations(global_domain_config, params);
if (orgResult.error_code == 0) {
let { data: { organizations } } = orgResult
let { listOptionData } = state
let { listOptionData, sysValues } = state
// props.requestListDataSuccess(organizations)
let filterOpt = dedupQuoteArray(organizations, 'org_code')
if (filterOpt.length === 0) {
......@@ -925,9 +925,19 @@ class EquipConsuPage extends Component {
listOptionData
}, () => {
that.organizationGetCustomerData()
setTimeout(() => {
if (sysValues.OBS_MOBILE_DEPARTMENT_DISPLAY > 0) {
that.getDepartmentsByOrg(listOptionData[1].value)
}
}, 1000);
})
}
// 贵州需要不显示组织, 所以只能每个用户只能授权1个组织
const isShowOrg = R.compose(R.equals('Y'), R.prop('OBS_SHOW_ORG_FLAG'))(this.props.sysProfiles)
if (!isShowOrg && filterOpt.length > 1) {
show(`请先选择组织`)
}
}else {
this.showWarnError(orgResult)
}
......@@ -1648,6 +1658,8 @@ class EquipConsuPage extends Component {
// 返回备注以上的元素
renderListItem() {
let { listOptionData, dateModelPop, sysValues } = this.state
const isShowOrg = R.compose(R.equals('Y'), R.prop('OBS_SHOW_ORG_FLAG'))(this.props.sysProfiles)
return(
<View style={styles.list_cont}>
<PageListArrow
......@@ -1658,6 +1670,8 @@ class EquipConsuPage extends Component {
listDefaValue={'name'}
listTitle={'title'}
/>
{
isShowOrg && (
<PageListArrow
listActOpa={.8}
listHasAster={true}
......@@ -1667,6 +1681,8 @@ class EquipConsuPage extends Component {
listCallBack={() => this.handleOrganizationCheck(listOptionData[1])}
listHasArrow={true}
/>
)
}
{
sysValues.OBS_MOBILE_DEPARTMENT_DISPLAY > 1 && (
......@@ -2021,7 +2037,8 @@ const mapStateToProps = (state) => {
quick_list_status: state.quick.quick_list_status,
submit_quick_order_status: state.quick.submit_quick_order_status,
quickOrderOption: state.quick.quickOrderOption,
global_domain_config: state.login.global_domain_config
global_domain_config: state.login.global_domain_config,
sysProfiles: state.login.sysProfiles,
}
}
......
......@@ -805,7 +805,7 @@ class SelfOrderPage extends Component {
let orgResult = await reqSelfOrganizations(global_domain_config, params);
if (orgResult.error_code == 0) {
let { data: { organizations } } = orgResult
let { listOptionData } = state
let { listOptionData, sysValues } = state
// props.requestListDataSuccess(organizations)
let filterOpt = dedupQuoteArray(organizations, 'org_code')
if (filterOpt.length === 0) {
......@@ -819,9 +819,19 @@ class SelfOrderPage extends Component {
listOptionData
}, () => {
that.organizationGetCustomerData()
setTimeout(() => {
if (sysValues.OBS_MOBILE_DEPARTMENT_DISPLAY > 0) {
that.getDepartmentsByOrg(listOptionData[1].value)
}
}, 1000);
})
}
// 贵州需要不显示组织, 所以只能每个用户只能授权1个组织
const isShowOrg = R.compose(R.equals('Y'), R.prop('OBS_SHOW_ORG_FLAG'))(this.props.sysProfiles)
if (!isShowOrg && filterOpt.length > 1) {
show(`请先选择组织`)
}
} else if (orgResult.error_code == 41006) {
show('登录过期,请重新登录');
props.exitLoginStatus();
......@@ -1860,6 +1870,8 @@ class SelfOrderPage extends Component {
// 返回备注以上的元素
renderListItem() {
let { listOptionData, dateModelPop, sysValues } = this.state
const isShowOrg = R.compose(R.equals('Y'), R.prop('OBS_SHOW_ORG_FLAG'))(this.props.sysProfiles)
return (
<View style={styles.list_cont}>
<PageListArrow
......@@ -1870,6 +1882,8 @@ class SelfOrderPage extends Component {
listDefaValue={'name'}
listTitle={'title'}
/>
{
isShowOrg && (
<PageListArrow
listActOpa={.8}
listHasAster={true}
......@@ -1879,6 +1893,8 @@ class SelfOrderPage extends Component {
listCallBack={() => this.handleOrganizationCheck(listOptionData[1])}
listHasArrow={true}
/>
)
}
{
sysValues.OBS_MOBILE_DEPARTMENT_DISPLAY > 1 && (
<PageListArrow
......@@ -2372,7 +2388,8 @@ const mapStateToProps = (state) => {
submit_self_order_status: state.selfOrder.submit_self_order_status,
selfOrderOption: state.selfOrder.selfOrderOption,
global_domain_config: state.login.global_domain_config,
local_sele_pro_options: state.selfOrder.local_sele_pro_options
local_sele_pro_options: state.selfOrder.local_sele_pro_options,
sysProfiles: state.login.sysProfiles
}
}
......
......@@ -502,7 +502,7 @@ class TransOrderPage extends Component {
// 清空当前项以下的值
clearInitNameAndValue(startIndex, endIndex = 5) {
let { listOptionData, localOtherObj } = this.state
let { listOptionData, localOtherObj, sysValues } = this.state
let that = this
this.setState({
listOptionData: listOptionData.map(async (item, index) => {
......@@ -510,7 +510,9 @@ class TransOrderPage extends Component {
item.name = localOtherObj.name
item.value = localOtherObj.value
if(listOptionData[1].value && item.title == '客户名称') {
await that.getDepartmentsByOrg(listOptionData[1].value)
if (sysValues.OBS_MOBILE_TRANS_DEPARTMENT_DISPLAY > 0) {
that.getDepartmentsByOrg(listOptionData[1].value)
}
setTimeout(() => {
that.organizationGetCustomerData()
}, 0);
......@@ -687,7 +689,7 @@ class TransOrderPage extends Component {
let orgResult = await reqTransOrganizations(global_domain_config, params);
if (orgResult.error_code == 0) {
let { data: { organizations } } = orgResult
let { listOptionData } = state
let { listOptionData, sysValues } = state
// props.requestListDataSuccess(organizations)
let filterOpt = dedupQuoteArray(organizations, 'org_code')
if (filterOpt.length === 0) {
......@@ -700,12 +702,20 @@ class TransOrderPage extends Component {
that.setState({
listOptionData
}, async () => {
await that.getDepartmentsByOrg(listOptionData[1].value)
setTimeout(() => {
that.organizationGetCustomerData()
}, 0);
if (sysValues.OBS_MOBILE_TRANS_DEPARTMENT_DISPLAY > 0) {
that.getDepartmentsByOrg(listOptionData[1].value)
}
}, 1000)
})
}
// 贵州需要不显示组织, 所以只能每个用户只能授权1个组织
const isShowOrg = R.compose(R.equals('Y'), R.prop('OBS_SHOW_ORG_FLAG'))(this.props.sysProfiles)
if (!isShowOrg && filterOpt.length > 1) {
show(`请先选择组织`)
}
}else {
this.showWarnError(orgResult)
}
......@@ -1311,6 +1321,8 @@ class TransOrderPage extends Component {
// 返回备注以上的元素
renderListItem() {
let { listOptionData, sysValues } = this.state
const isShowOrg = R.compose(R.equals('Y'), R.prop('OBS_SHOW_ORG_FLAG'))(this.props.sysProfiles)
return(
<View style={styles.list_cont}>
<PageListArrow
......@@ -1321,6 +1333,8 @@ class TransOrderPage extends Component {
listDefaValue={'name'}
listTitle={'title'}
/>
{
isShowOrg && (
<PageListArrow
listActOpa={.8}
listHasAster={true}
......@@ -1330,6 +1344,8 @@ class TransOrderPage extends Component {
listCallBack={() => this.handleOrganizationCheck(listOptionData[1])}
listHasArrow={true}
/>
)
}
{
sysValues.OBS_MOBILE_TRANS_DEPARTMENT_DISPLAY > 1 && (
<PageListArrow
......@@ -1737,7 +1753,8 @@ const mapStateToProps = (state) => {
submit_trans_order_status: state.trans.submit_trans_order_status,
transOrderOption: state.trans.transOrderOption,
subTransDetOption: state.trans.subTransDetOption,
global_domain_config: state.login.global_domain_config
global_domain_config: state.login.global_domain_config,
sysProfiles: state.login.sysProfiles,
}
}
......
......@@ -8,7 +8,8 @@ import {
AUTO_LOGIN_FAILURE,
SET_DOMAIN_CONFIGURATE,
SET_VERSION_APK,
SET_DOMAIN_FROM_ORIGIN
SET_DOMAIN_FROM_ORIGIN,
SET_SYSPROFILE
} from '../../base/ActionTypes';
// 登录状态
......@@ -21,9 +22,14 @@ const defaultState = {
global_domain_config: 'https://obs.uat.guke.tech',
hasSetDomainFromOrigin: false,
local_version_apk: '',
// 默认【深圳仓】https://obs.uat.guke.tech;【十方uat】https://obs.uat.sfrx.guke.tech;【十方pro】https://obs.sfrx.orth.tech
// 【国药dev】https://obs.dev.guke.tech;【国药pro】https://obs-pro.gyjtsx.com
// 【国药uat】https://obs-dev.gyjtsx.com
originSysProfiles: {
OBS_SHOW_ORG_FLAG: 'Y',
SUR_MOBILE_HISTORY_SALE_PRICE_SHOW_FLAG: 'Y'
},
sysProfiles: {
OBS_SHOW_ORG_FLAG: 'Y',
SUR_MOBILE_HISTORY_SALE_PRICE_SHOW_FLAG: 'Y'
}
}
export default login = (state = defaultState, action) => {
......@@ -73,6 +79,13 @@ export default login = (state = defaultState, action) => {
return Object.assign({}, state, {
local_version_apk: action.local_version_apk
})
case SET_SYSPROFILE:
return Object.assign({}, state, {
sysProfiles: {
...state.sysProfiles,
[action.code]: action.value
}
})
default: // need this for default case
return state
}
......
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