index.js 5.9 KB

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