123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- import React, {Component} from 'react';
- import {View, Text, StyleSheet, Dimensions, Alert} from 'react-native';
- import {connect} from 'react-redux'
- import {createAction} from '../../utils/'
- import {Button, List, InputItem, Toast, WhiteSpace, Picker, Provider} from "@ant-design/react-native";
- @connect(home => ({...home}))
- class DeliverAdd extends Component {
- constructor(props) {
- super(props);
- let data = {}
- if (this.props.navigation.state.params.data) {
- data = this.props.navigation.state.params.data
- }
- this.state = {
- no: data.no,
- count: data.count,
- name: data.name,
- cross_code: data.cross_code,
- product_id: data.product_id,
- };
- }
- componentDidMount() {
- //this._fetchSelect();
- if(this.state.no) {
- this._searchNo(this.state.no)
- }
- }
- componentWillUnmount() {
- this.props.dispatch({
- type: 'home/clear'
- });
- }
- onSave = () => {
- if (!this.state.no) {
- Toast.info('请输入防窜货号', 1)
- return
- }
- if (!this.state.product_id) {
- Toast.info('未查询到防窜货号', 1)
- return
- }
- if (this.state.count == '' || this.state.count == null) {
- Toast.info('请填写数量', 1)
- return
- }
- const {goBack, state} = this.props.navigation;
- //在页面返回,卸载时,将上个页面的方法取到,并回传参数,这样回传的参数会重走render方法
- state.params.callback(this.state);
- goBack();
- //this.props.dispatch(createAction('part_new/editParts')(this.state))
- }
- _searchNo = (value) => {
- if (value) {
- this.props.dispatch(createAction('home/fetchProductData')({cross_code: value}))
- this.setState({no: value})
- } else {
- Toast.info("请输入防窜货号!", 1)
- }
- }
- render() {
- const {searchProductData} = this.props.home;
- this.state.name = searchProductData.name
- this.state.cross_code = searchProductData.cross_code
- this.state.product_id = searchProductData.id
- return (
- <Provider>
- <WhiteSpace/>
- <List>
- <InputItem
- clear
- // extra={<Button onPress={this._searchNo}
- // type="primary"
- // size="small"
- // >查询</Button>}
- value={this.state.no}
- onChange={value => this._searchNo(value)}
- ><Text style={styles.redText}>防窜货号</Text></InputItem>
- <InputItem
- clear
- type={"number"}
- value={this.state.count}
- onChange={value => {
- this.setState({
- count: value,
- });
- }}
- ><Text style={styles.redText}>数量</Text></InputItem>
- <List.Item extra={this.state.name} style={styles.text}>产品名称</List.Item>
- <List.Item>
- <Button
- type="primary"
- loading={false}
- onPress={this.onSave}
- >保存</Button>
- </List.Item>
- </List>
- </Provider>
- )
- }
- }
- const styles = StyleSheet.create({
- text: {
- color: '#333'
- },
- redText: {
- color: 'red',
- fontSize: 16,
- },
- })
- export default DeliverAdd
|