index.js 6.3 KB

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