index.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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: getApp().globalData.Language.getMapText('按业务员'),
  25. value: 0
  26. }, {
  27. name: getApp().globalData.Language.getMapText('按客户'),
  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. pointsL: this.data.points.map(v => getApp().globalData.Language.getMapText(v))
  63. })
  64. this.getList()
  65. getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
  66. this.setSumWidth()
  67. },
  68. setSumWidth() {
  69. this.setData({
  70. sumWidth: this.data.table.reduce((prev, cur) => {
  71. return prev.width ? prev.width + cur.width : prev + cur.width
  72. })
  73. })
  74. },
  75. getList(init = false) {
  76. if (init.detail != undefined) init = init.detail;
  77. let content = this.data.content;
  78. if (init) content.pageNumber = 1;
  79. if (content.pageNumber > content.pageTotal) return;
  80. _Http.basic({
  81. "id": 20240320111604,
  82. content
  83. }).then(res => {
  84. if (res.code != '1') return wx.showToast({
  85. title: res.msg,
  86. icon: "none"
  87. })
  88. this.setListHeight()
  89. this.selectComponent('#ListBox').RefreshToComplete();
  90. console.log("逾期账款列表", res)
  91. let showList = [],
  92. obj = {
  93. "sumallaoverduemount": '总逾期',
  94. "sumonemonthamount": '逾期1月',
  95. "sumthreemonthamount": '逾期1-3月',
  96. "sumupthreemonthamount": '逾期三月以上'
  97. }
  98. if (res.data.length) {
  99. for (const key in obj) {
  100. showList.push({
  101. name: getApp().globalData.Language.getMapText(obj[key] + '(元)'),
  102. value: res.data[0][key] >= 10000 ? (CNY(wx.getStorageSync('languagecode')=='ZH' ? res.data[0][key] / 10000 : res.data[0][key] / 1000) + getApp().globalData.Language.getMapText( '万')) : res.data[0][key]
  103. })
  104. }
  105. } else {
  106. for (const key in obj) {
  107. showList.push({
  108. name: getApp().globalData.Language.getMapText(obj[key] + '(元)'),
  109. value: CNY(0)
  110. })
  111. }
  112. }
  113. this.setData({
  114. showList
  115. })
  116. let list = res.data.map(v => {
  117. v.allaoverduemount = CNY(v.allaoverduemount)
  118. v.onemonthamount = CNY(v.onemonthamount)
  119. v.threemonthamount = CNY(v.threemonthamount)
  120. v.upthreemonthamount = CNY(v.upthreemonthamount)
  121. return v
  122. })
  123. this.setData({
  124. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  125. "content.pageNumber": res.pageNumber + 1,
  126. "content.pageTotal": res.pageTotal,
  127. "content.total": res.total,
  128. })
  129. })
  130. },
  131. toDetail(e) {
  132. let {
  133. item
  134. } = e.currentTarget.dataset;
  135. let content = JSON.parse(JSON.stringify(this.data.content));
  136. content.dataid = item.userid || item.sa_customersid;
  137. wx.navigateTo({
  138. url: '/packageA/receivables/detail?content=' + JSON.stringify(content),
  139. })
  140. },
  141. querytypeChange(e) {
  142. this.setData({
  143. "content.querytype": e.detail.value
  144. });
  145. if (e.detail.value == 0) {
  146. this.data.table[0] = {
  147. title: '部门',
  148. width: 230,
  149. key: 'depname',
  150. fun: 'toDetail'
  151. }
  152. } else {
  153. this.data.table[0] = {
  154. title: '客户名称',
  155. width: 330,
  156. key: 'enterprisename',
  157. fun: 'toDetail'
  158. }
  159. }
  160. this.setData({
  161. table: this.data.table
  162. })
  163. this.getList(true)
  164. },
  165. pointChange(e) {
  166. this.data.content.point = this.data.points[e.detail.value]
  167. this.getList(true)
  168. },
  169. onReady() {
  170. this.setListHeight()
  171. this.selectComponent("#organization").initDepAndUser();
  172. },
  173. /* 设置页面高度 */
  174. setListHeight() {
  175. this.selectComponent("#ListBox").setHeight(".roof", this);
  176. },
  177. openFiltrate() {
  178. this.setData({
  179. showFiltrate: true
  180. })
  181. },
  182. handleFilter({
  183. detail
  184. }) {
  185. if (detail.name == 'reset') {
  186. this.selectComponent("#organization").initDepAndUser()
  187. this.setData({
  188. 'content.dataid': wx.getStorageSync('userMsg').userid,
  189. 'content.type': 0,
  190. })
  191. } else {
  192. let active = this.selectComponent("#organization").data.result;
  193. let type = active.userid ? 0 : 1,
  194. dataid = type == 0 ? active.userid : active.departmentid
  195. this.setData({
  196. 'content.dataid': dataid,
  197. 'content.type': type
  198. })
  199. }
  200. this.getList(true)
  201. },
  202. startSearch({
  203. detail
  204. }) {
  205. this.data.content.where.condition = detail;
  206. this.getList(true)
  207. },
  208. onClear() {
  209. this.data.content.where.condition = '';
  210. this.getList(true)
  211. },
  212. showSearch() {
  213. this.setData({
  214. startUsing: !this.data.startUsing
  215. })
  216. setTimeout(() => {
  217. this.setListHeight()
  218. }, 400)
  219. },
  220. })