Commit 4e38828f by wong.peiyi

org

parent f1f30bd8
...@@ -29,10 +29,12 @@ hToR($color, opacity = 1) ...@@ -29,10 +29,12 @@ hToR($color, opacity = 1)
@keyframes slide-up @keyframes slide-up
from from
-webkit-transform translate3d(0, 100%, 0) // -webkit-transform translate3d(0, 100%, 0)
transform translate3d(0, 100%, 0) // transform translate3d(0, 100%, 0)
translateY 100%
visibility visible visibility visible
to to
-webkit-transform translate3d(0, 0, 0) // -webkit-transform translate3d(0, 0, 0)
transform translate3d(0, 0, 0) // transform translate3d(0, 0, 0)
translateY 0
...@@ -11,12 +11,10 @@ ...@@ -11,12 +11,10 @@
width 100% width 100%
height 100% height 100%
background-color rgba(0, 0, 0, 0.5) background-color rgba(0, 0, 0, 0.5)
@extend .animated
animation-name slide-up
&-content &-content
position absolute position absolute
width 100% width 100%
height 400px max-height 400px
background-color foundation_color background-color foundation_color
bottom 0 bottom 0
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
* @Revision: * @Revision:
* *
*/ */
import React from 'react' import React, { useEffect, useRef, useState } from 'react'
import { View, Text, TouchableOpacity, ScrollView } from 'react-native' import { View, Text, TouchableOpacity, ScrollView, Animated } from 'react-native'
import { IOption } from 'bonehouse' import { IOption } from 'bonehouse'
import * as R from 'ramda' import * as R from 'ramda'
import { isBlank } from '../../utils/utils' import { isBlank } from '../../utils/utils'
...@@ -32,25 +32,67 @@ type IModalProps = { ...@@ -32,25 +32,67 @@ type IModalProps = {
onClose: Function onClose: Function
} }
/**
* @description: 动画函数
* @param {*} bottomAnim
* @param {*} bottom
* @param {*} opacityAnim
* @param {*} opacity
* @param {*} cb
* @return {*}
*/
function animated(bottomAnim, bottom, opacityAnim, opacity, cb) {
Animated.parallel([
Animated.timing(bottomAnim, {
toValue: bottom,
duration: 150,
}),
Animated.timing(opacityAnim, {
toValue: opacity,
duration: 150,
}),
]).start(() => {
cb && cb()
})
}
/**
* @description: 选择器弹窗
* @param {IModalProps} props
* @return {*}
*/
export function SelectModal(props: IModalProps) { export function SelectModal(props: IModalProps) {
const { data = [], value, mask, onChange, visible, title, onClose } = props const { data = [], value, mask, onChange, visible, title, onClose } = props
const { width, height } = Resolution.get()
const [modalHeight, setModalHeight] = useState(height - store.headerHeight)
const [contentHeight, setContentHeight] = useState(400)
const bottom = useRef(new Animated.Value(-contentHeight)).current
const opacity = useRef(new Animated.Value(0)).current
useEffect(() => {
if (visible) {
animated(bottom, 0, opacity, 1)
}
}, [visible])
if (!visible) return <></> if (!visible) return <></>
const { width, height } = Resolution.get() console.log(data)
return ( return (
<View style={[g(styles, 'modal'), { width, height: height - store.headerHeight }]}> <Animated.View style={[g(styles, 'modal'), { width, height: modalHeight, opacity: opacity }]}>
{!!mask && ( {!!mask && (
<TouchableOpacity <TouchableOpacity
style={g(styles, 'modal-mask')} style={g(styles, 'modal-mask')}
activeOpacity={1} activeOpacity={1}
onPress={() => { onPress={() => {
onClose() animated(bottom, -contentHeight, opacity, 0, onClose)
}} }}
></TouchableOpacity> ></TouchableOpacity>
)} )}
<View style={g(styles, 'modal-content')}> <Animated.View style={[g(styles, 'modal-content'), { bottom, height: contentHeight }]}>
{!!title && ( {!!title && (
<View style={g(styles, 'modal-hd')}> <View style={g(styles, 'modal-hd')}>
<Text style={g(styles, 'modal-header__text')}>{title}</Text> <Text style={g(styles, 'modal-header__text')}>{title}</Text>
...@@ -69,13 +111,13 @@ export function SelectModal(props: IModalProps) { ...@@ -69,13 +111,13 @@ export function SelectModal(props: IModalProps) {
onChange && onChange(option) onChange && onChange(option)
}} }}
> >
<Text>{option.label}</Text> <Text>{option.label}123123</Text>
</TouchableOpacity> </TouchableOpacity>
) )
})} })}
</View> </View>
</ScrollView> </ScrollView>
</View> </Animated.View>
</View> </Animated.View>
) )
} }
...@@ -61,6 +61,7 @@ export default class Select extends Component<IProps> { ...@@ -61,6 +61,7 @@ export default class Select extends Component<IProps> {
const required = isRequired(item) const required = isRequired(item)
const val = getText(item, value) const val = getText(item, value)
console.log(item)
return ( return (
<> <>
<TouchableOpacity <TouchableOpacity
......
...@@ -25,26 +25,24 @@ export default class BModal extends Component<IProps> { ...@@ -25,26 +25,24 @@ export default class BModal extends Component<IProps> {
render() { render() {
let { title, visible, footerButtons, maskClosable = false } = this.props let { title, visible, footerButtons, maskClosable = false } = this.props
if (visible) { if (!visible) return <></>
return (
<Provider> return (
<Modal <Provider>
title={title} <Modal
transparent={true} title={title}
onClose={() => { transparent={true}
this.onClose() onClose={() => {
}} this.onClose()
maskClosable={maskClosable} }}
visible={visible} maskClosable={maskClosable}
footer={footerButtons} visible={visible}
style={styles.base} footer={footerButtons}
> style={styles.base}
{this.props.children} >
</Modal> {this.props.children}
</Provider> </Modal>
) </Provider>
} else { )
return <></>
}
} }
} }
/*
* @FilePath: /BoneHouse_Business_APP/src/inversify/index.ts
* @Author: peii
* @Date: 2021-04-29 16:38:54
* @Vision: 1.0
* @Description: DI
*
* @Revision:
*
*/
import 'reflect-metadata' import 'reflect-metadata'
import { Container } from 'inversify' import { Container } from 'inversify'
import { TYPES } from './types' import { TYPES } from './types'
...@@ -5,6 +15,7 @@ import Service from '../services/service' ...@@ -5,6 +15,7 @@ import Service from '../services/service'
import Store from '../stores/store' import Store from '../stores/store'
import System from '../stores/system' import System from '../stores/system'
import User from '../stores/user' import User from '../stores/user'
import Organization from '../stores/organization'
const container = new Container({ defaultScope: 'Singleton' }) const container = new Container({ defaultScope: 'Singleton' })
...@@ -12,5 +23,6 @@ container.bind<Service>(TYPES.Service).to(Service) ...@@ -12,5 +23,6 @@ container.bind<Service>(TYPES.Service).to(Service)
container.bind<Store>(TYPES.Store).to(Store) container.bind<Store>(TYPES.Store).to(Store)
container.bind<System>(TYPES.SysStore).to(System) container.bind<System>(TYPES.SysStore).to(System)
container.bind<User>(TYPES.UserStore).to(User) container.bind<User>(TYPES.UserStore).to(User)
container.bind<Organization>(TYPES.OrgStore).to(Organization)
export default container export default container
/*
* @FilePath: /BoneHouse_Business_APP/src/inversify/types.ts
* @Author: peii
* @Date: 2021-04-29 16:38:54
* @Vision: 1.0
* @Description: DI 类型
*
* @Revision:
*
*/
export const TYPES = { export const TYPES = {
Service: Symbol.for('service'), Service: Symbol.for('service'),
Store: Symbol.for('store'), Store: Symbol.for('store'),
SysStore: Symbol.for('system'), SysStore: Symbol.for('system'),
UserStore: Symbol.for('user'), UserStore: Symbol.for('user'),
OrgStore: Symbol.for('organization'),
} }
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { View, Text, ScrollView } from 'react-native' import { View, Text, ScrollView } from 'react-native'
import { inject, observer } from 'mobx-react' import { inject, observer } from 'mobx-react'
import { IOrganization } from 'bonehouse'
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'
...@@ -24,6 +25,10 @@ type IProps = { ...@@ -24,6 +25,10 @@ type IProps = {
personName: string personName: string
} }
sysStore: {} sysStore: {}
orgStore: {
organizations: IOrganization[]
orgs: Function
}
} }
class Consume extends Component<IProps> { class Consume extends Component<IProps> {
...@@ -54,7 +59,7 @@ class Consume extends Component<IProps> { ...@@ -54,7 +59,7 @@ class Consume extends Component<IProps> {
field: 'orgId', field: 'orgId',
label: '组织', label: '组织',
type: FieldType.SELECT, type: FieldType.SELECT,
options: [], options: this.props.orgStore.orgs(),
placeholder: '请选择', placeholder: '请选择',
rules: [{ required: true, message: '请选择组织' }], rules: [{ required: true, message: '请选择组织' }],
}, },
...@@ -89,4 +94,4 @@ class Consume extends Component<IProps> { ...@@ -89,4 +94,4 @@ class Consume extends Component<IProps> {
} }
} }
export default inject('sysStore', 'userStore')(observer(Consume)) export default inject('sysStore', 'userStore', 'orgStore')(observer(Consume))
...@@ -29,6 +29,9 @@ type IProps = { ...@@ -29,6 +29,9 @@ type IProps = {
sysStore: { sysStore: {
getSysProfile: Function getSysProfile: Function
} }
orgStore: {
getOrganizations: Function
}
} }
class Index extends Component<IProps> { class Index extends Component<IProps> {
...@@ -47,10 +50,11 @@ class Index extends Component<IProps> { ...@@ -47,10 +50,11 @@ class Index extends Component<IProps> {
this.props.store.setNavigation(this.props.navigation) this.props.store.setNavigation(this.props.navigation)
setTimeout(() => { setTimeout(() => {
const { navigation, store } = this.props const { navigation, store, orgStore } = this.props
!store.token && navigation.navigate('Signin') !store.token && navigation.navigate('Signin')
this.getSysProfile() this.getSysProfile()
orgStore.getOrganizations()
}, 0) }, 0)
} }
...@@ -118,4 +122,4 @@ class Index extends Component<IProps> { ...@@ -118,4 +122,4 @@ class Index extends Component<IProps> {
} }
} }
export default inject('store', 'sysStore')(observer(Index)) export default inject('store', 'sysStore', 'orgStore')(observer(Index))
...@@ -26,6 +26,11 @@ interface RequestConfig { ...@@ -26,6 +26,11 @@ interface RequestConfig {
let requestQueue = [] let requestQueue = []
/**
* @description: 总请求
* @param {Partial} args
* @return {*}
*/
export const request = (args: Partial<RequestConfig>) => { export const request = (args: Partial<RequestConfig>) => {
const store = container.get<Store>(TYPES.Store) const store = container.get<Store>(TYPES.Store)
let cancel = null let cancel = null
...@@ -44,13 +49,14 @@ export const request = (args: Partial<RequestConfig>) => { ...@@ -44,13 +49,14 @@ export const request = (args: Partial<RequestConfig>) => {
method: R.propOr('get', 'method', args), method: R.propOr('get', 'method', args),
reTries: R.propOr(3, 'reTries', args), reTries: R.propOr(3, 'reTries', args),
needToken: R.propOr(true, 'needToken', args), needToken: R.propOr(true, 'needToken', args),
data: R.propOr({}, 'data', args),
...args, ...args,
} }
if (options.needToken) { if (options.needToken) {
options.data.accessToken = store.token options.data.accessToken = store.token
} }
args.data = transformObject(args.data, 'toLine') args.data = transformObject(options.data, 'toLine')
options = R.cond([ options = R.cond([
[ [
......
...@@ -34,4 +34,12 @@ export default class Service { ...@@ -34,4 +34,12 @@ export default class Service {
method: 'POST', method: 'POST',
}) })
} }
/**
* 获取组织
* @returns
*/
getOrganizations() {
return request({ url: `${ctx}/authorized_inventory/search` })
}
} }
/*
* @FilePath: /BoneHouse_Business_APP/src/stores/index.ts
* @Author: peii
* @Date: 2021-04-29 16:38:54
* @Vision: 1.0
* @Description: 总仓库
*
* @Revision:
*
*/
import container from '../inversify' import container from '../inversify'
import { TYPES } from '../inversify/types' import { TYPES } from '../inversify/types'
import { AsyncStorage } from 'react-native' import { AsyncStorage } from 'react-native'
...@@ -6,6 +16,7 @@ import { create } from 'mobx-persist' ...@@ -6,6 +16,7 @@ import { create } from 'mobx-persist'
const store = container.get<any>(TYPES.Store) const store = container.get<any>(TYPES.Store)
const sysStore = container.get<any>(TYPES.SysStore) const sysStore = container.get<any>(TYPES.SysStore)
const userStore = container.get<any>(TYPES.UserStore) const userStore = container.get<any>(TYPES.UserStore)
const orgStore = container.get<any>(TYPES.OrgStore)
const hydrate = create({ const hydrate = create({
storage: AsyncStorage, storage: AsyncStorage,
...@@ -16,5 +27,6 @@ const hydrate = create({ ...@@ -16,5 +27,6 @@ const hydrate = create({
hydrate('store', store) hydrate('store', store)
hydrate('sysStore', sysStore) hydrate('sysStore', sysStore)
hydrate('userStore', userStore) hydrate('userStore', userStore)
hydrate('orgStore', orgStore)
export default { store, sysStore, userStore } export default { store, sysStore, userStore, orgStore }
/*
* @FilePath: /BoneHouse_Business_APP/src/stores/organization.ts
* @Author: peii
* @Date: 2021-04-29 19:30:03
* @Vision: 1.0
* @Description: 组织结构store
*
* @Revision:
*
*/
import { observable, action, runInAction, toJS, flow } from 'mobx'
import { persist } from 'mobx-persist'
import { injectable, inject } from 'inversify'
import Service from '../services/service'
import { IOrganization } from 'bonehouse'
import * as R from 'ramda'
import { isBlank } from '../utils/utils'
import { TYPES } from '../inversify/types'
@injectable()
export default class Organization {
@inject(TYPES.Service) service!: Service
@persist @observable organizations: IOrganization[] = []
@persist @observable inventories = []
orgs(): IOrganization[] {
return R.map(
R.applySpec({
label: R.prop('orgName'),
value: R.prop('orgCode'),
}) as any,
)(this.organizations as any) as any
}
/**
* @description: 获取组织
* @return {*}
*/
getOrganizations = flow(function* (this: Organization) {
const res = yield this.service.getOrganizations()
this.organizations = res.data.organizations
this.inventories = res.data.inventories
})
}
...@@ -53,4 +53,9 @@ declare module 'bonehouse' { ...@@ -53,4 +53,9 @@ declare module 'bonehouse' {
rules?: IRule[] rules?: IRule[]
disabled?: boolean disabled?: boolean
} }
export type IOrganization = {
orgName: string
orgCode: string
}
} }
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