invoice_head_information.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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 {RoundingData} from '../../source/inspect/inspect';
  15. import {List, SwipeAction} from '@ant-design/react-native';
  16. import {RequestNetwork} from '../../data/encryption';
  17. import {RetrieveData, StorageData} from '../../data/storage';
  18. import invoice_head_css from './invoice_head_css';
  19. import public_css from '../../source/css/public_css';
  20. import { ToastShow } from "../../components/toast/toast";
  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.bottomStatus]}>
  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. let entInformation = JSON.parse(ent);
  161. const url = '/sys/invoice_info/save';
  162. let response = await RequestNetwork(
  163. url,
  164. token,
  165. {
  166. interactType: 1,
  167. interactTypeDetail: this.state.customerEmail,
  168. invoiceWay: 1,
  169. invoiceCategory: 1,
  170. cmdParam: {
  171. REQUEST_COMMON_FPKJ: {
  172. KPLX: 0, //开票类型 0-蓝字发票;1-红字发票
  173. FPZL: 1, //发票种类 1.增值税普通电子发票 2.增值税电子专用发票 3.增值税普通纸质发票 4 增值税专用纸质发票
  174. TTLX: 2, //收票客户抬头类型 1:个人 2:企业
  175. KPF_NSRSBH: entInformation.entTaxId, //开票方纳税人识别号
  176. KPF_MC: entInformation.entName, //开票方名称
  177. KPF_DZ: entInformation.entAddress, //开票方地址
  178. KPF_DH: entInformation.entAddress, //开票方电话
  179. KPF_YHZH: '', //开票方银行账号
  180. KPF_KHHMC: '', //开票方开户行名称
  181. SPF_NSRSBH: this.state.customerEntTaxId, //收票方纳税人识别号
  182. SPF_MC: this.state.customerName, //收票方名称
  183. SPF_DH: this.state.contactPhone.toString(), //收票方电话
  184. SPF_DZ: this.state.address.toString(), //收票方地址
  185. SPF_YHZH: this.state.bankAccountNo, //收票方银行账号
  186. SPF_KHHMC: '', //收票方开户行名称
  187. KPR: account, //开票人
  188. SKR: this.state.payees, //收款人
  189. FHR: this.state.reviewers, //复核人
  190. YFP_DM: '', //原发票代码
  191. YFP_HM: '', //原发票号码
  192. JSHJ: RoundingData(parseFloat(this.state.amount_total)), //价税合计
  193. HJJE: RoundingData(
  194. this.state.amount_total - this.state.tax_rate_total,
  195. ), //合计金额
  196. HJSE: RoundingData(this.state.tax_rate_total), //合计税额
  197. BZ: this.state.remark, //备注
  198. HYLX: 0, //发票行性质 0 正常行、1 折扣行、2 被折扣行
  199. TSPZ: '00', //特殊票种标识 “00”不是 “01”农产品销售“02”农产品收购“06”抵扣通行费“07”其它通行费“08”成品油销售说明:如果非特殊票种此节点可以没有。
  200. // FPQQLSH: '',
  201. // KPLX: '0',
  202. // BMB_BBH: '',
  203. // ZSFS: '0',
  204. // XSF_NSRSBH: entInformation.entTaxId,
  205. // XSF_MC: entInformation.entName,
  206. // XSF_DZDH: entInformation.entAddress,
  207. // XSF_YHZH: '',
  208. // GMF_NSRSBH: this.state.customerEntTaxId,
  209. // GMF_MC: this.state.customerName,
  210. // GMF_DZDH:
  211. // this.state.address.toString() +
  212. // this.state.contactPhone.toString(),
  213. // GMF_YHZH: this.state.bankAccountNo,
  214. // GMF_SJH: '',
  215. // GMF_DZYX: this.state.customerEmail,
  216. // FPT_ZH: '',
  217. // WX_OPENID: '',
  218. // KPR: account,
  219. // SKR: '',
  220. // FHR: '',
  221. // YFP_DM: '',
  222. // YFP_HM: '',
  223. // JSHJ: RoundingData(parseFloat(this.state.amount_total)),
  224. // HJJE: RoundingData(
  225. // this.state.amount_total - this.state.tax_rate_total,
  226. // ),
  227. // HJSE: RoundingData(this.state.tax_rate_total),
  228. // KCE: '',
  229. // BZ: this.state.remark,
  230. // HYLX: '0',
  231. // BY1: '',
  232. // BY2: '',
  233. // BY3: '',
  234. // BY4: '',
  235. // BY5: '',
  236. // BY6: '',
  237. // BY7: '',
  238. // BY8: '',
  239. // BY9: '',
  240. // BY10: '',
  241. // WX_ORDER_ID: '',
  242. // WX_APP_ID: '',
  243. // ZFB_UID: '',
  244. // // TSPZ: '',
  245. // QJ_ORDER_ID: '',
  246. // WX_GROUP_ID: '',
  247. COMMON_FPKJ_XMXXS: {
  248. COMMON_FPKJ_XMXX: this.state.listData,
  249. }, // 产品列表
  250. },
  251. },
  252. mobile: account,
  253. reqChannel: 3,
  254. },
  255. false,
  256. 1,
  257. );
  258. if (response) {
  259. if (response.code == 0) {
  260. ToastShow(1, '开票成功!');
  261. this.props.navigation.popToTop();
  262. }
  263. } else {
  264. ToastShow(1, '服务器故障!');
  265. }
  266. }
  267. };
  268. //产品列表
  269. renderItem = data => (
  270. <SwipeAction autoClose style={{backgroundColor: 'transparent'}}>
  271. <List.Item>
  272. <View style={{flexDirection: 'row', justifyContent: 'space-around'}}>
  273. <Text>{data.item.XMMC} </Text>
  274. <Text>{data.item.XMSL} </Text>
  275. <Text>{data.item.GGXH}</Text>
  276. <Text>{data.item.XMDJ}</Text>
  277. <Text>{data.item.SL * 100}</Text>
  278. </View>
  279. </List.Item>
  280. </SwipeAction>
  281. );
  282. //初始化数据
  283. initData = () => {
  284. this.setState({
  285. customer_name: '',
  286. ent_tax_id: '',
  287. contact_phone: '',
  288. address: '',
  289. bank_account: '',
  290. });
  291. };
  292. }