invoice_product_number.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. Text,
  5. TextInput,
  6. TouchableOpacity,
  7. DeviceEventEmitter,
  8. Image,
  9. ScrollView,
  10. KeyboardAvoidingView,
  11. } from 'react-native';
  12. import login_css from '../login/login_css';
  13. import public_css from '../../source/css/public_css';
  14. import {RoundingData, GetNum} from '../../source/inspect/inspect';
  15. import {ShowToast} from '../../components/rootToast/root_toast';
  16. export default class invoice_product_number extends Component {
  17. constructor(props) {
  18. super(props);
  19. this.props.navigation.dangerouslyGetParent().setOptions({
  20. tabBarVisible: false,
  21. });
  22. this.state = {
  23. key: this.props.route.params.key,
  24. product_name: this.props.route.params.XMMC,
  25. specsModel: this.props.route.params.GGXH,
  26. price: this.props.route.params.XMDJ,
  27. taxRate: this.props.route.params.SL,
  28. product_number: '',
  29. };
  30. }
  31. render() {
  32. return (
  33. <View style={public_css.body}>
  34. <ScrollView>
  35. <View style={login_css.inputView}>
  36. <View style={[public_css.view, public_css.lineTopBottom]}>
  37. <Text style={public_css.text}>*产品名称:</Text>
  38. <TextInput
  39. style={public_css.textInputStyle}
  40. placeholder="请输入产品名称"
  41. clearButtonMode="while-editing"
  42. secureTextEntry={false}
  43. value={this.state.product_name}
  44. onChangeText={text => {
  45. this.setState({
  46. product_name: text,
  47. });
  48. }}
  49. />
  50. </View>
  51. <View style={[public_css.view, public_css.lineTopBottom]}>
  52. <Text style={public_css.text}>*规格型号:</Text>
  53. <TextInput
  54. style={public_css.textInputStyle}
  55. placeholder="请输入规格型号"
  56. clearButtonMode="while-editing"
  57. secureTextEntry={false}
  58. value={this.state.specsModel}
  59. onChangeText={text => {
  60. this.setState({
  61. specsModel: text,
  62. });
  63. }}
  64. />
  65. </View>
  66. <View style={[public_css.view, public_css.lineTopBottom]}>
  67. <Text style={public_css.text}>*单价:</Text>
  68. <TextInput
  69. style={public_css.textInputStyle}
  70. placeholder="请输入单价"
  71. clearButtonMode="while-editing"
  72. secureTextEntry={false}
  73. keyboardType={'numeric'}
  74. value={this.state.price.toString()}
  75. onChangeText={text => {
  76. this.setState({
  77. price: text,
  78. });
  79. }}
  80. />
  81. </View>
  82. <View style={[public_css.view, public_css.lineTopBottom]}>
  83. <Text style={public_css.text}>*税率(%):</Text>
  84. <TextInput
  85. style={public_css.textInputStyle}
  86. placeholder="请输入税率"
  87. clearButtonMode="while-editing"
  88. secureTextEntry={false}
  89. keyboardType={'numeric'}
  90. value={this.state.taxRate.toString()}
  91. onChangeText={text => {
  92. this.setState({
  93. taxRate: text,
  94. });
  95. }}
  96. />
  97. </View>
  98. <View style={[public_css.view, public_css.lineTopBottom]}>
  99. <Text style={public_css.text}>*产品数量:</Text>
  100. <TextInput
  101. style={public_css.textInputStyle}
  102. placeholder="请输入产品数量"
  103. clearButtonMode="while-editing"
  104. secureTextEntry={false}
  105. keyboardType={'numeric'}
  106. value={this.state.product_number.toString()}
  107. onChangeText={text => {
  108. this.setState({
  109. product_number: text,
  110. });
  111. }}
  112. />
  113. </View>
  114. <View style={[public_css.view, public_css.lineTopBottom]}>
  115. <Text style={public_css.text}> 合计:</Text>
  116. <TextInput
  117. style={public_css.textInputStyle}
  118. clearButtonMode="while-editing"
  119. secureTextEntry={false}
  120. editable={false}
  121. value={RoundingData(
  122. this.state.product_number * parseFloat(this.state.price),
  123. ).toString().replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")}
  124. />
  125. </View>
  126. </View>
  127. </ScrollView>
  128. <View style={public_css.bottomStaus}>
  129. <TouchableOpacity
  130. style={[public_css.statusBtn, public_css.statusRBtn]}
  131. onPress={() => this.submitData()}>
  132. <Image
  133. source={require('../../source/img/productImg/confirm.png')}
  134. style={{width: 32, height: 32}}
  135. />
  136. <Text style={{color: '#fff'}}>确定添加</Text>
  137. </TouchableOpacity>
  138. </View>
  139. </View>
  140. );
  141. }
  142. //提交数据添加到产品列表中
  143. submitData = () => {
  144. if (this.state.product_name == '') {
  145. ShowToast('产品名称不能为空!');
  146. return;
  147. }
  148. if (this.state.specsModel == '') {
  149. ShowToast('规格型号不能为空!');
  150. return;
  151. }
  152. if (this.state.price == '') {
  153. ShowToast('单价不能为空!');
  154. return;
  155. }
  156. if (this.state.taxRate == '') {
  157. ShowToast('税率不能为空!');
  158. return;
  159. }
  160. if (this.state.product_number == '') {
  161. ShowToast('产品数量不能为空!');
  162. return;
  163. }
  164. if (this.state.product_number == 0) {
  165. ShowToast('产品数量不能为空!');
  166. return;
  167. }
  168. let data = {
  169. FPHXZ: this.props.route.params.FPHXZ, //发票行性质 0正常行 1折扣行 2被折扣行 必填
  170. SPBM: this.props.route.params.SPBM, //商品编码
  171. ZXBM: this.props.route.params.ZXBM, //自行编码
  172. YHZCBS: this.props.route.params.YHZCBS, //优惠政策标识 0不使用 1使用
  173. LSLBS: this.props.route.params.LSLBS, //零税率标识
  174. ZZSTSGL: this.props.route.params.ZZSTSGL, //增值税特殊管理
  175. XMMC: this.state.product_name, //项目名称 必填
  176. DW: this.props.route.params.DW, //计量单位
  177. GGXH: this.state.specsModel, //规格型号
  178. XMSL: this.state.product_number, //项目数量
  179. XMDJ: GetNum(this.state.price / (1 + this.state.taxRate / 100)), //项目单价
  180. XMJE: RoundingData(
  181. this.state.product_number * this.state.price -
  182. ((this.state.product_number * this.state.price) /
  183. (1 + this.state.taxRate / 100)) *
  184. (this.state.taxRate / 100),
  185. ), //项目金额 不含税
  186. SL: this.state.taxRate / 100, //税率 必填
  187. SE: RoundingData(
  188. ((this.state.product_number * this.state.price) /
  189. (1 + this.state.taxRate / 100)) *
  190. (this.state.taxRate / 100),
  191. ), //税额 必填
  192. // SE: RoundingData((this.state.product_number * this.state.price) * this.state.taxRate), //税额 必填
  193. };
  194. DeviceEventEmitter.emit('产品监听', data);
  195. this.props.navigation.navigate('invoice_product_list');
  196. };
  197. }