invoice_qrcode_product_number.js 7.4 KB

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