index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = sum => currency(sum, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Page({
  8. data: {
  9. list: [],
  10. filtrate: false,
  11. colors: {
  12. '新建': '#3874f6',
  13. '提交': '#67C23A',
  14. '审核': '#e6a23c'
  15. },
  16. "content": {
  17. "nocache": true,
  18. "pageNumber": 1,
  19. "pageSize": 20,
  20. "pageTotal": 1,
  21. "where": {
  22. "condition": ""
  23. }
  24. }
  25. },
  26. onLoad(options) {
  27. this.getList(true);
  28. try {
  29. let privacyFieldC = wx.getStorageSync('auth').writeOff.forms.list.formcols.map(v => v.title);
  30. this.setData({
  31. privacyFieldC
  32. })
  33. console.log("privacyFieldC", privacyFieldC)
  34. } catch (error) {
  35. console.error(error)
  36. }
  37. },
  38. getList(init = false) {
  39. if (init.detail != undefined) init = init.detail;
  40. let content = this.data.content;
  41. if (init) content.pageNumber = 1;
  42. if (content.pageNumber > content.pageTotal) return;
  43. _Http.basic({
  44. id: 2025081811145503,
  45. content: content
  46. }).then(res => {
  47. console.log("配件核销申请", res)
  48. this.selectComponent('#ListBox').RefreshToComplete();
  49. if (res.msg != '成功') return wx.showToast({
  50. title: res.msg,
  51. icon: "none"
  52. })
  53. res.data = res.data.map(v => {
  54. v.totalamount = CNY(v.totalamount)
  55. v.offamount = CNY(v.offamount)
  56. return v
  57. })
  58. this.setData({
  59. total: res.total,
  60. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  61. 'content.pageNumber': res.pageNumber + 1,
  62. 'content.pageTotal': res.pageTotal
  63. })
  64. })
  65. },
  66. /* 更新列表 */
  67. updateList() {
  68. let params = JSON.parse(JSON.stringify(this.data.content));
  69. params.pageSize = (params.pageNumber - 1) * params.pageSize;
  70. params.pageNumber = 1;
  71. _Http.basic({
  72. "id": 2025081811145503,
  73. content: params
  74. }).then(res => {
  75. console.log("配件核销申请", res)
  76. if (res.msg != '成功') return;
  77. res.data = res.data.map(v => {
  78. v.totalamount = CNY(v.totalamount)
  79. v.offamount = CNY(v.offamount)
  80. return v
  81. })
  82. this.setData({
  83. list: res.data,
  84. total: res.total,
  85. })
  86. })
  87. },
  88. startSearch({
  89. detail
  90. }) {
  91. if (detail == this.data.content.where.condition) return;
  92. this.data.content.where.condition = detail;
  93. this.getList(true);
  94. },
  95. createOrder(e) {
  96. _Http.basic({
  97. "id": 2025081811143103,
  98. "content": {
  99. "sa_tpartreimbursementid": 0,
  100. "remarks": '',
  101. "billdate": e.detail.value,
  102. },
  103. }).then(res => {
  104. console.log("创建", res)
  105. wx.showToast({
  106. title: res.code == 1 ? '创建成功' : res.msg,
  107. icon: "none"
  108. })
  109. if (res.code == 1) wx.navigateTo({
  110. url: '/packageA/writeOff/detail?id=' + res.data.sa_tpartreimbursementid,
  111. })
  112. })
  113. },
  114. /* 取消搜索 */
  115. onClear() {
  116. this.data.content.where.condition = "";
  117. this.getList(true);
  118. },
  119. openFiltrate() {
  120. this.setData({
  121. filtrate: true
  122. })
  123. },
  124. /* 处理筛选 */
  125. handleFilter(e) {
  126. e.detail.condition = this.data.content.where.condition;
  127. e.detail.begindate = e.detail.startdate
  128. this.setData({
  129. "content.where": e.detail
  130. })
  131. console.log("this.data.content", this.data.content)
  132. this.getList(true)
  133. },
  134. })