index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. /* ,
  29. filtratelist: [{
  30. label: "红蓝字",
  31. index: null,
  32. showName: "name", //显示字段
  33. valueKey: "rb", //返回Key
  34. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  35. value: "", //选中值
  36. list: [{
  37. name: "红字",
  38. value: 0
  39. }, {
  40. name: "蓝字",
  41. value: 1
  42. }]
  43. }, {
  44. label: "是否收货",
  45. index: null,
  46. showName: "name", //显示字段
  47. valueKey: "isreceiver", //返回Key
  48. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  49. value: "", //选中值
  50. list: [{
  51. name: "未收货",
  52. value: 0
  53. }, {
  54. name: "已收货",
  55. value: 1
  56. }]
  57. }] */
  58. },
  59. getList(init = false) {
  60. if (init.detail != undefined) init = init.detail;
  61. let content = this.data.content;
  62. if (init) content.pageNumber = 1;
  63. if (content.pageNumber > content.pageTotal) return;
  64. _Http.basic({
  65. id: 2025081811145503,
  66. content: content
  67. }).then(res => {
  68. console.log("配件核销申请", res)
  69. this.selectComponent('#ListBox').RefreshToComplete();
  70. if (res.msg != '成功') return wx.showToast({
  71. title: res.msg,
  72. icon: "none"
  73. })
  74. res.data = res.data.map(v => {
  75. v.totalamount = CNY(v.totalamount)
  76. v.offamount = CNY(v.offamount)
  77. return v
  78. })
  79. this.setData({
  80. total: res.total,
  81. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  82. 'content.pageNumber': res.pageNumber + 1,
  83. 'content.pageTotal': res.pageTotal
  84. })
  85. })
  86. },
  87. /* 更新列表 */
  88. updateList() {
  89. let params = JSON.parse(JSON.stringify(this.data.content));
  90. params.pageSize = (params.pageNumber - 1) * params.pageSize;
  91. params.pageNumber = 1;
  92. _Http.basic({
  93. "id": 2025081811145503,
  94. content: params
  95. }).then(res => {
  96. console.log("配件核销申请", res)
  97. if (res.msg != '成功') return;
  98. res.data = res.data.map(v => {
  99. v.totalamount = CNY(v.totalamount)
  100. v.offamount = CNY(v.offamount)
  101. return v
  102. })
  103. this.setData({
  104. list: res.data,
  105. total: res.total,
  106. })
  107. })
  108. },
  109. startSearch({
  110. detail
  111. }) {
  112. if (detail == this.data.content.where.condition) return;
  113. this.data.content.where.condition = detail;
  114. this.getList(true);
  115. },
  116. createOrder(e) {
  117. _Http.basic({
  118. "id": 2025081811143103,
  119. "content": {
  120. "sa_tpartreimbursementid": 0,
  121. "remarks": '',
  122. "billdate": e.detail.value,
  123. },
  124. }).then(res => {
  125. console.log("创建", res)
  126. wx.showToast({
  127. title: res.code == 1 ? '创建成功' : res.msg,
  128. icon: "none"
  129. })
  130. if (res.code == 1) wx.navigateTo({
  131. url: '/packageA/writeOff/detail?id=' + res.data.sa_tpartreimbursementid,
  132. })
  133. })
  134. },
  135. /* 取消搜索 */
  136. onClear() {
  137. this.data.content.where.condition = "";
  138. this.getList(true);
  139. },
  140. openFiltrate() {
  141. this.setData({
  142. filtrate: true
  143. })
  144. },
  145. /* 处理筛选 */
  146. handleFilter(e) {
  147. e.detail.condition = this.data.content.where.condition;
  148. e.detail.begindate = e.detail.startdate
  149. this.setData({
  150. "content.where": e.detail
  151. })
  152. console.log("this.data.content", this.data.content)
  153. this.getList(true)
  154. },
  155. })