index.jsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. }).then((msg) => {
  30. if (msg.error.length === 0) {
  31. this.setState({
  32. list: msg.data,
  33. });
  34. } else {
  35. Taro.showToast({ title: msg.error[0].message, icon: "none" });
  36. }
  37. }).catch(() => {
  38. });
  39. }
  40. render() {
  41. const { list } = this.state
  42. return (
  43. <View className="debitnote">
  44. {list.length == 0 ?
  45. <View className='noData'>
  46. <Image src={noData} className='noDataImg' />
  47. <View className='noDataTitle'>您暂时没有能使用的借支单</View>
  48. </View> :
  49. <View className="dlist">
  50. {
  51. list?.map((v, k) => (
  52. <View className="dlitem" key={k}>
  53. <View className="txt">
  54. <View className="num">{commonAdd(v.totalAmount, -v.settlementAmount)}元</View>
  55. <View className="info">
  56. 总金额:{v.totalAmount}元,
  57. 已使用:{v.settlementAmount}元
  58. </View>
  59. </View>
  60. <Button
  61. className="bt"
  62. type='primary'
  63. size="mini"
  64. disabled={v.liquidationStatus == 2 || v.liquidationStatus == 3}
  65. onClick={() => {
  66. let pages = Taro.getCurrentPages();
  67. let prevPage = pages[pages.length - 2];
  68. prevPage.setData({
  69. debitId: v.id,
  70. totalAmount: commonAdd(v.totalAmount, -v.settlementAmount),
  71. });
  72. Taro.navigateBack({
  73. delta: 1
  74. })
  75. }}
  76. >{(v.liquidationStatus == 2 || v.liquidationStatus == 3) ? "已抵消" : "选择"}</Button>
  77. </View>
  78. ))
  79. }
  80. </View>}
  81. </View>
  82. );
  83. }
  84. }
  85. export default DebitNote;