index.jsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import React, { Component } from "react";
  2. import Taro, { getCurrentInstance } from "@tarojs/taro";
  3. import { View, Text, Button, Image } from "@tarojs/components";
  4. import { getDrbitNote } from "../../utils/servers/servers";
  5. import { commonAdd } from "../../utils/tools"
  6. import "taro-ui/dist/style/components/search-bar.scss";
  7. import "taro-ui/dist/style/components/button.scss";
  8. import "taro-ui/dist/style/components/icon.scss";
  9. import "taro-ui/dist/style/components/list.scss";
  10. import "taro-ui/dist/style/components/icon.scss";
  11. import noData from '../../image/noData.png';
  12. import './index.less';
  13. class DebitNote extends Component {
  14. $instance = getCurrentInstance();
  15. constructor(props) {
  16. super(props);
  17. this.state = {
  18. list: [],
  19. listVisible: false,
  20. };
  21. this.getList = this.getList.bind(this);
  22. }
  23. componentDidMount() {
  24. this.getList()
  25. }
  26. getList() {
  27. getDrbitNote({
  28. depId: this.$instance.router.params.depId,
  29. id: this.$instance.router.params.id
  30. }).then((msg) => {
  31. if (msg.error.length === 0) {
  32. this.setState({
  33. list: msg.data,
  34. });
  35. } else {
  36. Taro.showToast({ title: msg.error[0].message, icon: "none" });
  37. }
  38. }).catch(() => {
  39. });
  40. }
  41. render() {
  42. const { list } = this.state
  43. return (
  44. <View className="debitnote">
  45. {list.length == 0 ?
  46. <View className='noData'>
  47. <Image src={noData} className='noDataImg' />
  48. <View className='noDataTitle'>您暂时没有能使用的借支单</View>
  49. </View> :
  50. <View className="dlist">
  51. {
  52. list?.map((v, k) => (
  53. <View className="dlitem" key={k}>
  54. <View className="txt">
  55. <View className="num">{commonAdd(v.totalAmount, -v.settlementAmount)}元</View>
  56. <View className="info">
  57. 总金额:{v.totalAmount}元,
  58. 已使用:{v.settlementAmount}元
  59. </View>
  60. </View>
  61. <Button
  62. className="bt"
  63. type='primary'
  64. size="mini"
  65. disabled={v.liquidationStatus == 2}
  66. onClick={() => {
  67. let pages = Taro.getCurrentPages();
  68. let prevPage = pages[pages.length - 2];
  69. prevPage.setData({
  70. debitId: v.id,
  71. totalAmount: commonAdd(v.totalAmount, -v.settlementAmount),
  72. });
  73. Taro.navigateBack({
  74. delta: 1
  75. })
  76. }}
  77. >{(v.liquidationStatus == 2) ? "已抵消" : "选择"}</Button>
  78. </View>
  79. ))
  80. }
  81. </View>}
  82. </View>
  83. );
  84. }
  85. }
  86. export default DebitNote;