invoice_head_information.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. Text,
  5. TextInput,
  6. TouchableOpacity,
  7. StyleSheet,
  8. Dimensions,
  9. PixelRatio,
  10. Modal,
  11. FlatList,
  12. Image,
  13. } from 'react-native';
  14. import {ShowToast} from '../../components/rootToast/root_toast';
  15. import {RoundingData} from '../../source/inspect/inspect';
  16. import {List, SwipeAction} from '@ant-design/react-native';
  17. import {GetDataPost} from '../../data/encryption';
  18. import {RetrieveData, StorageData} from '../../data/storage';
  19. import invoice_head_css from './invoice_head_css';
  20. import public_css from '../../source/css/public_css';
  21. export default class invoice_head_information extends Component {
  22. constructor(props) {
  23. super(props);
  24. this.props.navigation.dangerouslyGetParent().setOptions({
  25. tabBarVisible: false,
  26. });
  27. this.state = {
  28. listData: this.props.route.params.listData,
  29. customerName: this.props.route.params.customerName,
  30. customerEntTaxId: this.props.route.params.customerEntTaxId,
  31. address: this.props.route.params.address,
  32. contactPhone: this.props.route.params.contactPhone,
  33. bankName: this.props.route.params.bankName,
  34. bankAccountNo: this.props.route.params.bankAccountNo,
  35. customerEmail: this.props.route.params.customerEmail,
  36. customerMobile: this.props.route.params.customerMobile,
  37. remark: this.props.route.params.remark,
  38. belongEntTaxId: this.props.route.params.belongEntTaxId,
  39. entName: this.props.route.params.entName,
  40. product_number_total: this.props.route.params.product_number_total,
  41. amount_total: this.props.route.params.amount_total,
  42. tax_rate_total: this.props.route.params.tax_rate_total,
  43. };
  44. }
  45. render() {
  46. return (
  47. <View style={public_css.body}>
  48. <View style={{marginLeft: 10}}>
  49. <View style={invoice_head_css.itemView}>
  50. <Text style={invoice_head_css.itemViewName}>
  51. 客户姓名:
  52. </Text>
  53. <Text>{this.state.customerName}</Text>
  54. </View>
  55. <View style={invoice_head_css.itemView}>
  56. <Text style={invoice_head_css.itemViewName}>
  57. 客户企业税号:
  58. </Text>
  59. <Text>{this.state.customerEntTaxId}</Text>
  60. </View>
  61. <View style={invoice_head_css.itemView}>
  62. <Text style={invoice_head_css.itemViewName}>
  63. 联系电话:
  64. </Text>
  65. <Text>{this.state.contactPhone}</Text>
  66. </View>
  67. <View style={invoice_head_css.itemView}>
  68. <Text style={invoice_head_css.itemViewName}>
  69. 地址:
  70. </Text>
  71. <Text>{this.state.address}</Text>
  72. </View>
  73. <View style={invoice_head_css.itemView}>
  74. <Text style={invoice_head_css.itemViewName}>
  75. 开户银行:
  76. </Text>
  77. <Text>{this.state.bankName}</Text>
  78. </View>
  79. <View style={invoice_head_css.itemView}>
  80. <Text style={invoice_head_css.itemViewName}>
  81. 银行账号:
  82. </Text>
  83. <Text>{this.state.bankAccountNo}</Text>
  84. </View>
  85. <View style={invoice_head_css.itemView}>
  86. <Text style={invoice_head_css.itemViewName}>
  87. 客户邮箱:
  88. </Text>
  89. <Text>{this.state.customerEmail}</Text>
  90. </View>
  91. <View style={invoice_head_css.itemView}>
  92. <Text style={invoice_head_css.itemViewName}>
  93. 客户手机号:
  94. </Text>
  95. <Text>{this.state.customerMobile}</Text>
  96. </View>
  97. <View style={invoice_head_css.itemView}>
  98. <Text style={invoice_head_css.itemViewName}>
  99. 备注:
  100. </Text>
  101. <Text>{this.state.remark}</Text>
  102. </View>
  103. </View>
  104. <View style={invoice_head_css.list_view}>
  105. <Text style={invoice_head_css.list_title_text}>产品名称</Text>
  106. <Text sstyle={invoice_head_css.list_title_text}>产品数量</Text>
  107. <Text sstyle={invoice_head_css.list_title_text}>规格型号</Text>
  108. <Text style={invoice_head_css.list_title_text}>单价</Text>
  109. <Text style={invoice_head_css.list_title_text}>税率(%)</Text>
  110. </View>
  111. <View
  112. style={{
  113. flex: 1,
  114. }}>
  115. <FlatList
  116. data={this.state.listData}
  117. renderItem={item => this.renderItem(item)}
  118. />
  119. </View>
  120. <View
  121. style={{
  122. flexDirection: 'row',
  123. justifyContent: 'space-around',
  124. alignItems: 'center',
  125. width: Dimensions.get('window').width,
  126. height: 50,
  127. }}>
  128. <Text>共{this.state.product_number_total}个产品</Text>
  129. <Text>
  130. 开票金额:
  131. {RoundingData(parseFloat(this.state.amount_total)).replace(
  132. /(\d)(?=(\d{3})+(?:\.\d+)?$)/g,
  133. '$1,',
  134. )}
  135. </Text>
  136. <Text>
  137. 税额:{RoundingData(parseFloat(this.state.tax_rate_total))}
  138. </Text>
  139. </View>
  140. <View style={[public_css.bottomStaus]}>
  141. <TouchableOpacity
  142. style={[public_css.statusBtn, public_css.statusRBtn]}
  143. onPress={() => this.submitData()}>
  144. <Image
  145. source={require('../../source/img/productImg/confirm.png')}
  146. style={{width: 32, height: 32}}
  147. />
  148. <Text style={{color: '#fff'}}>提交</Text>
  149. </TouchableOpacity>
  150. </View>
  151. </View>
  152. );
  153. }
  154. //提交开票信息
  155. submitData = async () => {
  156. let account = await RetrieveData('account');
  157. let token = await RetrieveData('token');
  158. let ent = await RetrieveData('defaultEnt');
  159. if (token && account && ent) {
  160. account = account.substring(1, account.length - 1);
  161. token = token.substring(1, token.length - 1);
  162. let entInformation = JSON.parse(ent);
  163. const url = '/sys/invoiceInfo/save';
  164. let response = await GetDataPost(
  165. url,
  166. token,
  167. {
  168. interactType: 1,
  169. interactTypeDetail: this.state.customerEmail,
  170. invoiceWay: 1,
  171. invoiceCategory: 1,
  172. cmdParam: {
  173. REQUEST_COMMON_FPKJ: {
  174. KPLX: 0, //开票类型 0-蓝字发票;1-红字发票
  175. FPZL: 1, //发票种类 1.增值税普通电子发票 2.增值税电子专用发票 3.增值税普通纸质发票 4 增值税专用纸质发票
  176. TTLX: 2, //收票客户抬头类型 1:个人 2:企业
  177. KPF_NSRSBH: entInformation.entTaxId, //开票方纳税人识别号
  178. KPF_MC: entInformation.entName, //开票方名称
  179. KPF_DZ: entInformation.entAddress, //开票方地址
  180. KPF_DH: entInformation.entAddress, //开票方电话
  181. KPF_YHZH: '', //开票方银行账号
  182. KPF_KHHMC: '', //开票方开户行名称
  183. SPF_NSRSBH: this.state.customerEntTaxId, //收票方纳税人识别号
  184. SPF_MC: this.state.customerName, //收票方名称
  185. SPF_DH: this.state.contactPhone.toString(), //收票方电话
  186. SPF_DZ: this.state.address.toString(), //收票方地址
  187. SPF_YHZH: this.state.bankAccountNo, //收票方银行账号
  188. SPF_KHHMC: '', //收票方开户行名称
  189. KPR: account, //开票人
  190. SKR: this.state.payees, //收款人
  191. FHR: this.state.reviewers, //复核人
  192. YFP_DM: '', //原发票代码
  193. YFP_HM: '', //原发票号码
  194. JSHJ: RoundingData(parseFloat(this.state.amount_total)), //价税合计
  195. HJJE: RoundingData(
  196. this.state.amount_total - this.state.tax_rate_total,
  197. ), //合计金额
  198. HJSE: RoundingData(this.state.tax_rate_total), //合计税额
  199. BZ: this.state.remark, //备注
  200. HYLX: 0, //发票行性质 0 正常行、1 折扣行、2 被折扣行
  201. TSPZ: '00', //特殊票种标识 “00”不是 “01”农产品销售“02”农产品收购“06”抵扣通行费“07”其它通行费“08”成品油销售说明:如果非特殊票种此节点可以没有。
  202. // FPQQLSH: '',
  203. // KPLX: '0',
  204. // BMB_BBH: '',
  205. // ZSFS: '0',
  206. // XSF_NSRSBH: entInformation.entTaxId,
  207. // XSF_MC: entInformation.entName,
  208. // XSF_DZDH: entInformation.entAddress,
  209. // XSF_YHZH: '',
  210. // GMF_NSRSBH: this.state.customerEntTaxId,
  211. // GMF_MC: this.state.customerName,
  212. // GMF_DZDH:
  213. // this.state.address.toString() +
  214. // this.state.contactPhone.toString(),
  215. // GMF_YHZH: this.state.bankAccountNo,
  216. // GMF_SJH: '',
  217. // GMF_DZYX: this.state.customerEmail,
  218. // FPT_ZH: '',
  219. // WX_OPENID: '',
  220. // KPR: account,
  221. // SKR: '',
  222. // FHR: '',
  223. // YFP_DM: '',
  224. // YFP_HM: '',
  225. // JSHJ: RoundingData(parseFloat(this.state.amount_total)),
  226. // HJJE: RoundingData(
  227. // this.state.amount_total - this.state.tax_rate_total,
  228. // ),
  229. // HJSE: RoundingData(this.state.tax_rate_total),
  230. // KCE: '',
  231. // BZ: this.state.remark,
  232. // HYLX: '0',
  233. // BY1: '',
  234. // BY2: '',
  235. // BY3: '',
  236. // BY4: '',
  237. // BY5: '',
  238. // BY6: '',
  239. // BY7: '',
  240. // BY8: '',
  241. // BY9: '',
  242. // BY10: '',
  243. // WX_ORDER_ID: '',
  244. // WX_APP_ID: '',
  245. // ZFB_UID: '',
  246. // // TSPZ: '',
  247. // QJ_ORDER_ID: '',
  248. // WX_GROUP_ID: '',
  249. COMMON_FPKJ_XMXXS: {
  250. COMMON_FPKJ_XMXX: this.state.listData,
  251. }, // 产品列表
  252. },
  253. },
  254. mobile: account,
  255. reqChannel: 3,
  256. },
  257. false,
  258. 1,
  259. );
  260. if (response) {
  261. if (response.code == 0) {
  262. ShowToast('开票成功!');
  263. this.props.navigation.popToTop();
  264. }
  265. } else {
  266. ShowToast('服务器故障!');
  267. }
  268. }
  269. };
  270. //产品列表
  271. renderItem = data => (
  272. <SwipeAction autoClose style={{backgroundColor: 'transparent'}}>
  273. <List.Item>
  274. <View style={{flexDirection: 'row', justifyContent: 'space-around'}}>
  275. <Text>{data.item.XMMC} </Text>
  276. <Text>{data.item.XMSL} </Text>
  277. <Text>{data.item.GGXH}</Text>
  278. <Text>{data.item.XMDJ}</Text>
  279. <Text>{data.item.SL * 100}</Text>
  280. </View>
  281. </List.Item>
  282. </SwipeAction>
  283. );
  284. //初始化数据
  285. initData = () => {
  286. this.setState({
  287. customer_name: '',
  288. ent_tax_id: '',
  289. contact_phone: '',
  290. address: '',
  291. bank_account: '',
  292. });
  293. };
  294. }