Commit dfa0cadd by wong.peiyi

增加F1打开开发者工具

parent d7704f9d
package com.bonehouse_business_app; package com.bonehouse_business_app;
import com.facebook.react.ReactApplication;
import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.uimanager.IllegalViewOperationException; import com.facebook.react.uimanager.IllegalViewOperationException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.view.KeyEvent;
import com.imagepicker.FileProvider; import com.imagepicker.FileProvider;
import java.io.File; import java.io.File;
public class RNToolsManager extends ReactContextBaseJavaModule { public class RNToolsManager extends ReactContextBaseJavaModule implements LifecycleEventListener {
public RNToolsManager(ReactApplicationContext reactContext) { public RNToolsManager(ReactApplicationContext reactContext) {
super(reactContext); super(reactContext);
reactContext.addLifecycleEventListener(this);
} }
// 重写getName方法声明Module类名称,在RN调用时用到 // 重写getName方法声明Module类名称,在RN调用时用到
...@@ -82,4 +89,38 @@ public class RNToolsManager extends ReactContextBaseJavaModule { ...@@ -82,4 +89,38 @@ public class RNToolsManager extends ReactContextBaseJavaModule {
String STRING_API_ENV = getReactApplicationContext().getResources().getString(R.string.baseUrl); // 需要在 android/app/build.gradle 添加'productFlavors' String STRING_API_ENV = getReactApplicationContext().getResources().getString(R.string.baseUrl); // 需要在 android/app/build.gradle 添加'productFlavors'
promise.resolve(STRING_API_ENV); promise.resolve(STRING_API_ENV);
} }
/**
* 用于开发时打开开发者工具
*/
private BroadcastReceiver keyReceive = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int keyCode = intent.getIntExtra("keyCode", 0);
if (BuildConfig.DEBUG && keyCode == KeyEvent.KEYCODE_F1) {
ReactApplication application = (ReactApplication)getReactApplicationContext()
.getCurrentActivity()
.getApplication();
application.getReactNativeHost().getReactInstanceManager().showDevOptionsDialog();
}
}
};
@Override
public void onHostResume() {
IntentFilter filter = new IntentFilter();
filter.addAction("android.rfid.FUN_KEY");
getCurrentActivity().registerReceiver(keyReceive, filter);
}
@Override
public void onHostPause() {
getCurrentActivity().unregisterReceiver(keyReceive);
}
@Override
public void onHostDestroy() {
}
} }
\ No newline at end of file
...@@ -48,7 +48,9 @@ class Index extends Component<IProps> { ...@@ -48,7 +48,9 @@ class Index extends Component<IProps> {
setTimeout(() => { setTimeout(() => {
const { navigation, store, orgStore } = this.props const { navigation, store, orgStore } = this.props
!store.token && navigation.navigate('Signin') if (!store.token) {
return navigation.navigate('Signin')
}
orgStore.getOrganizations() orgStore.getOrganizations()
}, 0) }, 0)
......
...@@ -17,7 +17,7 @@ import * as R from 'ramda' ...@@ -17,7 +17,7 @@ import * as R from 'ramda'
import Form from '../../components/form' import Form from '../../components/form'
import { FieldType } from '../../enums' import { FieldType } from '../../enums'
import Header from '../../components/header/header' import Header from '../../components/header/header'
import { g, getFormItem, isBlank, isNotBlank, show } from '../../utils/utils' import { g, getFormItem, isBlank, isNotBlank, show, translateSysprofile } from '../../utils/utils'
import styles from './quick.styl' import styles from './quick.styl'
type IProps = { type IProps = {
...@@ -185,6 +185,42 @@ class QuickOrder extends Component<IProps> { ...@@ -185,6 +185,42 @@ class QuickOrder extends Component<IProps> {
*/ */
setOptionsFormItems() { setOptionsFormItems() {
const { sysProfiles } = this.props.sysStore const { sysProfiles } = this.props.sysStore
let { formItems } = this.state
// 部门(00)第一位显示、第二位必需
let dep = translateSysprofile(sysProfiles.OBS_MOBILE_DEPARTMENT_DISPLAY)
if (dep.show) {
formItems = R.insert(
2,
{
field: 'departmentCode',
label: '部门',
type: FieldType.SELECT,
placeholder: '请选择',
options: [],
rules: [{ required: dep.required, message: '请选择客户' }],
refrence: ['orgCode'],
},
formItems,
)
}
// 业务经理(00)第一位显示、第二位必需
let businessManager = translateSysprofile(sysProfiles.OBS_MOBILE_DEPARTMENT_DISPLAY)
if (businessManager.show) {
}
// 跟台员(00)第一位显示、第二位必需
let follower = translateSysprofile(sysProfiles.OBS_MOBILE_SUR_FOLLOWER_DISPLAY)
if (follower.show) {
}
// 送货员(00)第一位显示、第二位必需
let deliver = translateSysprofile(sysProfiles.OBS_MOBILE_DELIVERYMAN_DISPLAY)
if (deliver.show) {
}
this.setState({ formItems })
} }
/** /**
......
...@@ -189,3 +189,17 @@ export const debounce = (fn: Function, wait = 300): Function => { ...@@ -189,3 +189,17 @@ export const debounce = (fn: Function, wait = 300): Function => {
*/ */
export const getFormItem = (items: IFormField[], fieldName: string) => export const getFormItem = (items: IFormField[], fieldName: string) =>
R.find(R.propEq('field', fieldName), items) R.find(R.propEq('field', fieldName), items)
/**
* @description: 解释配置性的表单项的显示及必填
* @param {string} profile
* @return {*}
*/
export const translateSysprofile = (profile: string) => {
if (isBlank(profile)) {
return { show: false, required: false }
}
const show = R.ifElse(R.pathEq([0], '1'), R.T, R.F)(profile)
const required = R.ifElse(R.pathEq([1], '1'), R.T, R.F)(profile)
return { show, required }
}
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