123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- import React, {Component} from 'react';
- import {
- View,
- Text,
- TextInput,
- TouchableOpacity,
- DeviceEventEmitter,
- Image,
- ScrollView,
- } from 'react-native';
- import login_css from '../login/login_css';
- import public_css from '../../source/css/public_css';
- import {RoundingData, GetNum} from '../../source/inspect/inspect';
- import {ShowToast} from '../../components/rootToast/root_toast';
- export default class invoice_product_number extends Component {
- constructor(props) {
- super(props);
- this.props.navigation.dangerouslyGetParent().setOptions({
- tabBarVisible: false,
- });
- this.state = {
- key: this.props.route.params.key,
- product_name: this.props.route.params.XMMC,
- specsModel: this.props.route.params.GGXH,
- price: this.props.route.params.XMDJ,
- taxRate: this.props.route.params.SL,
- product_number: '',
- };
- }
- render() {
- return (
- <View style={public_css.body}>
- <ScrollView>
- <View style={login_css.inputView}>
- <View style={[public_css.view, public_css.lineTopBottom]}>
- <Text style={public_css.text}>*产品名称:</Text>
- <TextInput
- style={public_css.textInputStyle}
- placeholder="请输入产品名称"
- clearButtonMode="while-editing"
- secureTextEntry={false}
- value={this.state.product_name}
- onChangeText={text => {
- this.setState({
- product_name: text,
- });
- }}
- />
- </View>
- <View style={[public_css.view, public_css.lineTopBottom]}>
- <Text style={public_css.text}>*规格型号:</Text>
- <TextInput
- style={public_css.textInputStyle}
- placeholder="请输入规格型号"
- clearButtonMode="while-editing"
- secureTextEntry={false}
- value={this.state.specsModel}
- onChangeText={text => {
- this.setState({
- specsModel: text,
- });
- }}
- />
- </View>
- <View style={[public_css.view, public_css.lineTopBottom]}>
- <Text style={public_css.text}>*单价:</Text>
- <TextInput
- style={public_css.textInputStyle}
- placeholder="请输入单价"
- clearButtonMode="while-editing"
- secureTextEntry={false}
- keyboardType={'numeric'}
- value={this.state.price.toString()}
- onChangeText={text => {
- this.setState({
- price: text,
- });
- }}
- />
- </View>
- <View style={[public_css.view, public_css.lineTopBottom]}>
- <Text style={public_css.text}>*税率(%):</Text>
- <TextInput
- style={public_css.textInputStyle}
- placeholder="请输入税率"
- clearButtonMode="while-editing"
- secureTextEntry={false}
- keyboardType={'numeric'}
- value={this.state.taxRate.toString()}
- onChangeText={text => {
- this.setState({
- taxRate: text,
- });
- }}
- />
- </View>
- <View style={[public_css.view, public_css.lineTopBottom]}>
- <Text style={public_css.text}>*产品数量:</Text>
- <TextInput
- style={public_css.textInputStyle}
- placeholder="请输入产品数量"
- clearButtonMode="while-editing"
- secureTextEntry={false}
- keyboardType={'numeric'}
- value={this.state.product_number.toString()}
- onChangeText={text => {
- this.setState({
- product_number: text,
- });
- }}
- />
- </View>
- <View style={[public_css.view, public_css.lineTopBottom]}>
- <Text style={public_css.text}> 合计:</Text>
- <TextInput
- style={public_css.textInputStyle}
- clearButtonMode="while-editing"
- secureTextEntry={false}
- editable={false}
- value={RoundingData(
- this.state.product_number * parseFloat(this.state.price),
- ).toString()}
- />
- </View>
- </View>
- </ScrollView>
- <View style={public_css.bottomStaus}>
- <TouchableOpacity
- style={[public_css.statusBtn, public_css.statusRBtn]}
- onPress={() => this.submitData()}>
- <Image
- source={require('../../source/img/productImg/confirm.png')}
- style={{width: 32, height: 32}}
- />
- <Text style={{color: '#fff'}}>确定添加</Text>
- </TouchableOpacity>
- </View>
- </View>
- );
- }
- //提交数据添加到产品列表中
- submitData = () => {
- if (this.state.product_name == '') {
- ShowToast('产品名称不能为空!');
- return;
- }
- if (this.state.specsModel == '') {
- ShowToast('规格型号不能为空!');
- return;
- }
- if (this.state.price == '') {
- ShowToast('单价不能为空!');
- return;
- }
- if (this.state.taxRate == '') {
- ShowToast('税率不能为空!');
- return;
- }
- if (this.state.product_number == '') {
- ShowToast('产品数量不能为空!');
- return;
- }
- if (this.state.product_number == 0) {
- ShowToast('产品数量不能为空!');
- return;
- }
- let data = {
- FPHXZ: this.props.route.params.FPHXZ, //发票行性质 0正常行 1折扣行 2被折扣行 必填
- SPBM: this.props.route.params.SPBM, //商品编码
- ZXBM: this.props.route.params.ZXBM, //自行编码
- YHZCBS: this.props.route.params.YHZCBS, //优惠政策标识 0不使用 1使用
- LSLBS: this.props.route.params.LSLBS, //零税率标识
- ZZSTSGL: this.props.route.params.ZZSTSGL, //增值税特殊管理
- XMMC: this.state.product_name, //项目名称 必填
- DW: this.props.route.params.DW, //计量单位
- GGXH: this.state.specsModel, //规格型号
- XMSL: this.state.product_number, //项目数量
- XMDJ: GetNum(this.state.price / (1 + this.state.taxRate / 100)), //项目单价
- XMJE: RoundingData(
- this.state.product_number * this.state.price -
- ((this.state.product_number * this.state.price) /
- (1 + this.state.taxRate / 100)) *
- (this.state.taxRate / 100),
- ), //项目金额 不含税
- SL: this.state.taxRate / 100, //税率 必填
- SE: RoundingData(
- ((this.state.product_number * this.state.price) /
- (1 + this.state.taxRate / 100)) *
- (this.state.taxRate / 100),
- ), //税额 必填
- // SE: RoundingData((this.state.product_number * this.state.price) * this.state.taxRate), //税额 必填
- BY1: this.props.route.params.BY1, //备用字段1
- BY2: this.props.route.params.BY2, //备用字段2
- BY3: this.props.route.params.BY3, //备用字段3
- BY4: this.props.route.params.BY4, //备用字段4
- BY5: this.props.route.params.BY5, //备用字段5
- };
- DeviceEventEmitter.emit('扫码开票', data);
- this.props.navigation.navigate('invoice_qrcode_product_list');
- };
- }
|