invoice_monitor.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. TouchableOpacity,
  5. Text,
  6. SafeAreaView,
  7. FlatList,
  8. ActivityIndicator,
  9. Alert,
  10. RefreshControl,
  11. ScrollView,
  12. } from 'react-native';
  13. import {
  14. Drawer,
  15. List,
  16. Provider,
  17. SwipeAction,
  18. Picker, WingBlank, WhiteSpace,
  19. } from "@ant-design/react-native";
  20. import public_css from '../../../source/css/public_css';
  21. import {RetrieveData} from '../../../data/storage';
  22. import {RequestNetwork} from '../../../data/encryption';
  23. import {ToastShow} from '../../../components/toast/toast';
  24. import {InvoiceType, Distribute} from '../../../utils/config';
  25. import {CleanAll} from '../../../components/abnormalMessage/abnormal_message';
  26. import Spinner from 'react-native-loading-spinner-overlay';
  27. import loading_css from '../../../source/css/loading_css';
  28. const Item = List.Item;
  29. export default class invoice_monitor extends Component {
  30. constructor(props) {
  31. super(props);
  32. this.props.navigation.dangerouslyGetParent().setOptions({
  33. tabBarVisible: false,
  34. });
  35. this.state = {
  36. spinner: false,
  37. type: '',
  38. companyName: '',
  39. entTaxId: '',
  40. deviceId: '',
  41. invoiceType: '',
  42. dateBeginDate: '',
  43. dataEndDate: '',
  44. invoiceEndDate: '',
  45. oneInvoiceAmount: '',
  46. numberInvoiceAmount: '',
  47. negativeInfo: '',
  48. newDate: '',
  49. upEndDate: '',
  50. offDate: '',
  51. offAmount: '',
  52. offNegativeAmount: '',
  53. device: {
  54. entTaxId: '',
  55. deviceType: '',
  56. taxDiscId: '',
  57. deviceLabel: '',
  58. deviceKey: '',
  59. },
  60. };
  61. }
  62. render() {
  63. return (
  64. <SafeAreaView style={public_css.body}>
  65. <ScrollView>
  66. <Spinner
  67. visible={this.state.spinner}
  68. textContent={'Loading...'}
  69. textStyle={loading_css.spinnerTextStyle}
  70. />
  71. <View style={{backgroundColor: '#F7F7F7', height: 70, justifyContent: 'center'}}>
  72. <Text style={{color: '#000000', fontSize: 17, fontWeight: 'bold', marginLeft: 10}}>{this.state.companyName}</Text>
  73. <Text style={{color: '#333333', fontSize: 15, marginLeft: 10}}>{this.state.entTaxId}</Text>
  74. </View>
  75. <List style={{Opacity: 0.6, color: 'red'}}>
  76. <Item extra={<Text style={{color: '#2A67FE', fontSize: 16}}>{this.state.deviceId}</Text>} arrow="horizontal" onPress={() => {this.getDevice()}}>
  77. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>税控设备编号:</Text>
  78. </Item>
  79. <Item extra={<Text style={{color: '#313131', fontSize: 16, fontWeight: 'bold'}}>{this.state.invoiceType}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  80. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>发票种类:</Text>
  81. </Item>
  82. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.dateBeginDate}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  83. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>数据报起始日期:</Text>
  84. </Item>
  85. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.dataEndDate}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  86. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>数据报终止日期:</Text>
  87. </Item>
  88. <View style={{height: 36, backgroundColor: '#F7F7F7', justifyContent: 'center', marginLeft: 14}}>
  89. <Text style={{color: '#888888', fontSize: 16}}>发票/报税信息</Text>
  90. </View>
  91. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.invoiceEndDate}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  92. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>开票截止日期:</Text>
  93. </Item>
  94. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.oneInvoiceAmount}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  95. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>单张发票开票金额(元):</Text>
  96. </Item>
  97. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.numberInvoiceAmount}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  98. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>正数发票累计金额限额(元):</Text>
  99. </Item>
  100. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.negativeInfo}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  101. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>负数发票标识:</Text>
  102. </Item>
  103. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.newDate}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  104. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>最新报税日期:</Text>
  105. </Item>
  106. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.upEndDate}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  107. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>上传截止日期:</Text>
  108. </Item>
  109. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.offDate}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  110. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>离线开票时长(小时):</Text>
  111. </Item>
  112. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.offAmount}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  113. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>离线正数金额(元):</Text>
  114. </Item>
  115. <Item extra={<Text style={{color: '#000000', fontSize: 16}}>{this.state.offNegativeAmount}</Text>} arrow="empty" onPress={() => {this.getDevice()}}>
  116. <Text style={{color: 'rgba(0, 0, 0, 0.6)', fontSize: 16}}>离线负数金额(元):</Text>
  117. </Item>
  118. </List>
  119. </ScrollView>
  120. <WingBlank>
  121. <View style={[public_css.bottomStatus]}>
  122. <TouchableOpacity
  123. style={[public_css.statusBtn, public_css.statusRBtn]}
  124. onPress={() => this.refresh()}>
  125. <Text style={{color: '#fff'}}>刷新</Text>
  126. </TouchableOpacity>
  127. </View>
  128. </WingBlank>
  129. <WhiteSpace />
  130. </SafeAreaView>
  131. );
  132. }
  133. // render加载完后调用
  134. async componentDidMount() {
  135. let company = await RetrieveData('company');
  136. if (company) {
  137. company = JSON.parse(company);
  138. }
  139. let type = this.props.route.params.type;
  140. this.setState({
  141. type: type,
  142. device: {
  143. entTaxId: company.entTaxId,
  144. deviceKey: company.defaultDeviceInfo.deviceKey,
  145. deviceType: company.defaultDeviceInfo.deviceType,
  146. taxDiscId: company.defaultDeviceInfo.taxDiscId,
  147. deviceLabel: company.defaultDeviceInfo.deviceLabel,
  148. },
  149. companyName: company.entName,
  150. entTaxId: company.entTaxId,
  151. });
  152. this.setLoadingStatus(true);
  153. await this.getMonitorInfo();
  154. }
  155. // 获取设备信息
  156. getDevice = async () => {
  157. this.props.navigation.navigate('device', {
  158. deviceKey: this.state.device.deviceKey,
  159. getDeviceInfo: (data) => {
  160. this.getDeviceInfo(data);
  161. },
  162. });
  163. };
  164. // 获取切换设备信息
  165. getDeviceInfo = async (data) => {
  166. console.log(data);
  167. this.setState({
  168. device: {
  169. entTaxId: data.entTaxId,
  170. deviceType: data.deviceType,
  171. taxDiscId: data.taxDiscId,
  172. deviceLabel: data.deviceLabel,
  173. deviceKey: data.deviceKey,
  174. },
  175. entTaxId: data.entTaxId,
  176. deviceId: data.deviceLabel,
  177. });
  178. await this.initData();
  179. };
  180. // 获取发票监控信息
  181. getMonitorInfo = async () => {
  182. console.log(this.state.device.entTaxId);
  183. const token = await RetrieveData('token');
  184. if (token) {
  185. const url = '/sys/entDevice/monitorInfo';
  186. let response = await RequestNetwork(
  187. url,
  188. token,
  189. {
  190. entTaxId: this.state.device.entTaxId,
  191. deviceType: this.state.device.deviceType,
  192. taxDiscId: this.state.device.taxDiscId,
  193. },
  194. false,
  195. 2,
  196. );
  197. if (response) {
  198. if (response.code === 0) {
  199. this.setLoadingStatus(false);
  200. this.setList(response.data);
  201. } else {
  202. this.setLoadingStatus(false);
  203. await this.abnormalMessage(response);
  204. }
  205. }
  206. }
  207. };
  208. //设置设备信息
  209. setList = (data) => {
  210. let invoiceType = '';
  211. if (this.state.type === 1) {
  212. invoiceType = '增值税普通电子发票';
  213. }
  214. if (this.state.type === 2) {
  215. invoiceType = '增值税电子专用发票';
  216. }
  217. if (this.state.type === 3) {
  218. invoiceType = '增值税普通纸质发票';
  219. }
  220. if (this.state.type === 4) {
  221. invoiceType = '增值税专用纸质发票';
  222. }
  223. let num = 0;
  224. data.map((_, i) => {
  225. if (data[i].invoiceCategory === this.state.type) {
  226. num++;
  227. this.setState({
  228. deviceId: this.state.device.deviceLabel,
  229. invoiceType: invoiceType,
  230. dateBeginDate: data[i].startDateSubmit,
  231. dataEndDate: data[i].endDateSubmit,
  232. invoiceEndDate: data[i].invoiceClosingTime,
  233. oneInvoiceAmount: data[i].singleInvoiceMoneyLimit,
  234. numberInvoiceAmount: data[i].cumulativeInvoiceMoneyLimit,
  235. negativeInfo: data[i].negativeInvoiceFlag,
  236. newDate: data[i].latestTaxDate,
  237. upEndDate: data[i].uploadDeadline,
  238. offDate: data[i].offlineInvoiceLength,
  239. offAmount: data[i].offlineCumulativeMoney,
  240. offNegativeAmount: data[i].negativeOfflineCumulativeMoney,
  241. });
  242. }
  243. });
  244. if (num === 0) {
  245. Alert.alert(
  246. '提示',
  247. '当前票种信息不存在!',
  248. [
  249. {
  250. text: '确定',
  251. onPress: () => {
  252. this.props.navigation.goBack();
  253. },
  254. },
  255. ],
  256. {cancelable: false},
  257. );
  258. }
  259. };
  260. // 刷新
  261. refresh = async () => {
  262. await this.initData();
  263. };
  264. // 刷新数据
  265. initData = async () => {
  266. this.setState({
  267. invoiceType: '',
  268. dateBeginDate: '',
  269. dataEndDate: '',
  270. invoiceEndDate: '',
  271. oneInvoiceAmount: '',
  272. numberInvoiceAmount: '',
  273. negativeInfo: '',
  274. newDate: '',
  275. upEndDate: '',
  276. offDate: '',
  277. offAmount: '',
  278. offNegativeAmount: '',
  279. });
  280. this.setLoadingStatus(true);
  281. await this.getMonitorInfo();
  282. };
  283. //显示loading层
  284. setLoadingStatus(isLoading) {
  285. this.setState({
  286. spinner: isLoading,
  287. });
  288. }
  289. // 处理网络请求数据
  290. abnormalMessage = async (jason) => {
  291. if (jason.code === 401) {
  292. await Alert.alert(
  293. '登录失效',
  294. '登录状态已失效,请重新登录!',
  295. [
  296. {
  297. text: '确定',
  298. onPress: () => {
  299. CleanAll();
  300. this.props.navigation.popToTop();
  301. },
  302. },
  303. ],
  304. {cancelable: false},
  305. );
  306. }
  307. if (jason.code === 403) {
  308. Alert.alert(
  309. '权限',
  310. '暂无权限操作此模块!',
  311. [
  312. {
  313. text: '确定',
  314. onPress: () => {
  315. this.props.navigation.goBack();
  316. },
  317. },
  318. ],
  319. {cancelable: false},
  320. );
  321. }
  322. if (jason.code !== 401 && jason.code !== 403) {
  323. ToastShow(1, jason.msg);
  324. }
  325. };
  326. }