invoice_head_product_number.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. Text,
  5. TextInput,
  6. TouchableOpacity,
  7. DeviceEventEmitter,
  8. ScrollView,
  9. Image,
  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_head_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. )
  123. .toString()
  124. .replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, '$1,')}
  125. />
  126. </View>
  127. </View>
  128. </ScrollView>
  129. <View style={public_css.bottomStaus}>
  130. <TouchableOpacity
  131. style={[public_css.statusBtn, public_css.statusRBtn]}
  132. onPress={() => this.submitData()}>
  133. <Image
  134. source={require('../../source/img/productImg/confirm.png')}
  135. style={{width: 32, height: 32}}
  136. />
  137. <Text style={{color: '#fff'}}>确定添加</Text>
  138. </TouchableOpacity>
  139. </View>
  140. </View>
  141. );
  142. }
  143. //提交数据添加到产品列表中
  144. submitData = () => {
  145. if (this.state.product_name == '') {
  146. ShowToast('产品名称不能为空!');
  147. return;
  148. }
  149. if (this.state.specsModel == '') {
  150. ShowToast('规格型号不能为空!');
  151. return;
  152. }
  153. if (this.state.price == '') {
  154. ShowToast('单价不能为空!');
  155. return;
  156. }
  157. if (this.state.taxRate == '') {
  158. ShowToast('税率不能为空!');
  159. return;
  160. }
  161. if (this.state.product_number == '') {
  162. ShowToast('产品数量不能为空!');
  163. return;
  164. }
  165. if (this.state.product_number == 0) {
  166. ShowToast('产品数量不能为空!');
  167. return;
  168. }
  169. let data = {
  170. FPHXZ: this.props.route.params.FPHXZ, //发票行性质 0正常行 1折扣行 2被折扣行 必填
  171. SPBM: this.props.route.params.SPBM, //商品编码
  172. ZXBM: this.props.route.params.ZXBM, //自行编码
  173. YHZCBS: this.props.route.params.YHZCBS, //优惠政策标识 0不使用 1使用
  174. LSLBS: this.props.route.params.LSLBS, //零税率标识
  175. ZZSTSGL: this.props.route.params.ZZSTSGL, //增值税特殊管理
  176. XMMC: this.state.product_name, //项目名称 必填
  177. DW: this.props.route.params.DW, //计量单位
  178. GGXH: this.state.specsModel, //规格型号
  179. XMSL: this.state.product_number, //项目数量
  180. XMDJ: GetNum(this.state.price / (1 + this.state.taxRate / 100)), //项目单价
  181. XMJE: RoundingData(
  182. this.state.product_number * this.state.price -
  183. ((this.state.product_number * this.state.price) /
  184. (1 + this.state.taxRate / 100)) *
  185. (this.state.taxRate / 100),
  186. ), //项目金额 不含税
  187. SL: this.state.taxRate / 100, //税率 必填
  188. SE: RoundingData(
  189. ((this.state.product_number * this.state.price) /
  190. (1 + this.state.taxRate / 100)) *
  191. (this.state.taxRate / 100),
  192. ), //税额 必填
  193. // SE: RoundingData((this.state.product_number * this.state.price) * this.state.taxRate), //税额 必填
  194. BY1: this.props.route.params.BY1, //备用字段1
  195. BY2: this.props.route.params.BY2, //备用字段2
  196. BY3: this.props.route.params.BY3, //备用字段3
  197. BY4: this.props.route.params.BY4, //备用字段4
  198. BY5: this.props.route.params.BY5, //备用字段5
  199. };
  200. DeviceEventEmitter.emit('待开抬头产品列表', data);
  201. this.props.navigation.navigate('invoice_head_product_list');
  202. };
  203. }