index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. const _Http = getApp().globalData.http;
  2. import currency from "../../utils/currency";
  3. let CNY = value => currency(value, {
  4. symbol: "",
  5. precision: 2
  6. }).format();
  7. Page({
  8. data: {
  9. showFiltrate: false,
  10. startUsing: false,
  11. showList: [],
  12. "content": {
  13. "pageNumber": 1,
  14. "pageSize": 40,
  15. "type": "0", //1按部门 0按人员
  16. "dataid": wx.getStorageSync('userMsg').userid, //部门人员id
  17. "querytype": "1", //0按业务员 1按客户
  18. "point": "全部", // 入账节点
  19. "where": {
  20. "condition": ""
  21. }
  22. },
  23. querytypes: [{
  24. name: "按业务员",
  25. value: 0
  26. }, {
  27. name: "按客户",
  28. value: 1
  29. }],
  30. points: ['全部', '订单', '出货', '开票'],
  31. filtratelist: [],
  32. table: [{
  33. title: '客户名称',
  34. width: 330,
  35. key: 'enterprisename',
  36. fun: 'toDetail'
  37. }, {
  38. title: '业务员',
  39. width: 200,
  40. key: 'name'
  41. }, {
  42. title: '总应收',
  43. width: 200,
  44. key: 'allaoverduemount'
  45. }, {
  46. title: '逾期1月',
  47. width: 200,
  48. key: 'onemonthamount'
  49. }, {
  50. title: '逾期1-3月',
  51. width: 200,
  52. key: 'threemonthamount'
  53. }, {
  54. title: '逾期3月及以上',
  55. width: 200,
  56. key: 'upthreemonthamount'
  57. }],
  58. sumWidth: 0,
  59. },
  60. onLoad(options) {
  61. this.setData({
  62. sumWidth: this.data.table.reduce((prev, cur) => {
  63. return prev.width ? prev.width + cur.width : prev + cur.width
  64. })
  65. })
  66. this.getList()
  67. },
  68. getList(init = false) {
  69. if (init.detail != undefined) init = init.detail;
  70. let content = this.data.content;
  71. if (init) content.pageNumber = 1;
  72. if (content.pageNumber > content.pageTotal) return;
  73. _Http.basic({
  74. "id": 20240320111604,
  75. content
  76. }).then(res => {
  77. if (res.msg != '成功') return wx.showToast({
  78. title: res.msg,
  79. icon: "none"
  80. })
  81. this.setListHeight()
  82. this.selectComponent('#ListBox').RefreshToComplete();
  83. console.log("应收账款列表", res)
  84. let showList = [],
  85. obj = {
  86. "sumallaoverduemount": '总应收',
  87. "sumonemonthamount": '逾期1月',
  88. "sumthreemonthamount": '逾期1-3月',
  89. "sumupthreemonthamount": '逾期三月以上'
  90. }
  91. if (res.data.length) {
  92. for (const key in obj) {
  93. showList.push({
  94. name: obj[key] + '(元)',
  95. value: CNY(res.data[0][key])
  96. })
  97. }
  98. } else {
  99. for (const key in obj) {
  100. showList.push({
  101. name: obj[key] + '(元)',
  102. value: CNY(0)
  103. })
  104. }
  105. }
  106. this.setData({
  107. showList
  108. })
  109. let list = res.data.map(v => {
  110. v.allaoverduemount = CNY(v.allaoverduemount)
  111. v.onemonthamount = CNY(v.onemonthamount)
  112. v.threemonthamount = CNY(v.threemonthamount)
  113. v.upthreemonthamount = CNY(v.upthreemonthamount)
  114. return v
  115. })
  116. this.setData({
  117. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  118. "content.pageNumber": res.pageNumber + 1,
  119. "content.pageTotal": res.pageTotal,
  120. "content.total": res.total,
  121. })
  122. })
  123. },
  124. toDetail(e) {
  125. let {
  126. item
  127. } = e.currentTarget.dataset;
  128. let content = JSON.parse(JSON.stringify(this.data.content));
  129. content.dataid = item.userid || item.sa_customersid;
  130. wx.navigateTo({
  131. url: '/packageA/receivables/detail?content=' + JSON.stringify(content),
  132. })
  133. },
  134. querytypeChange(e) {
  135. this.setData({
  136. "content.querytype": e.detail.value
  137. });
  138. if (e.detail.value == 0) {
  139. this.data.table[0] = {
  140. title: '部门',
  141. width: 330,
  142. key: 'depname',
  143. fun: 'toDetail'
  144. }
  145. } else {
  146. this.data.table[0] = {
  147. title: '客户名称',
  148. width: 330,
  149. key: 'enterprisename',
  150. fun: 'toDetail'
  151. }
  152. }
  153. this.setData({
  154. table: this.data.table
  155. })
  156. this.getList(true)
  157. },
  158. pointChange(e) {
  159. this.data.content.point = this.data.points[e.detail.value]
  160. this.getList(true)
  161. },
  162. onReady() {
  163. this.setListHeight()
  164. this.selectComponent("#organization").initDepAndUser();
  165. },
  166. /* 设置页面高度 */
  167. setListHeight() {
  168. this.selectComponent("#ListBox").setHeight(".roof", this);
  169. },
  170. openFiltrate() {
  171. this.setData({
  172. showFiltrate: true
  173. })
  174. },
  175. handleFilter({
  176. detail
  177. }) {
  178. if (detail.name == 'reset') {
  179. this.selectComponent("#organization").initDepAndUser()
  180. this.setData({
  181. 'content.dataid': wx.getStorageSync('userMsg').userid,
  182. 'content.type': 0,
  183. })
  184. } else {
  185. let active = this.selectComponent("#organization").data.result;
  186. let type = active.userid ? 0 : 1,
  187. dataid = type == 0 ? active.userid : active.departmentid
  188. this.setData({
  189. 'content.dataid': dataid,
  190. 'content.type': type
  191. })
  192. }
  193. this.getList(true)
  194. },
  195. startSearch({
  196. detail
  197. }) {
  198. this.data.content.where.condition = detail;
  199. this.getList(true)
  200. },
  201. onClear() {
  202. this.data.content.where.condition = '';
  203. this.getList(true)
  204. },
  205. showSearch() {
  206. this.setData({
  207. startUsing: !this.data.startUsing
  208. })
  209. setTimeout(() => {
  210. this.setListHeight()
  211. }, 400)
  212. },
  213. })