index.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. "content": {
  12. "pageNumber": 1,
  13. "pageSize": 40,
  14. "type": "0", //1按部门 0按人员
  15. "dataid": wx.getStorageSync('userMsg').userid, //部门人员id
  16. "querytype": "1", //0按业务员 1按客户
  17. "point": "开票", // 入账节点
  18. "where": {
  19. "condition": ""
  20. }
  21. },
  22. querytypes: [{
  23. name: getApp().globalData.Language.getMapText('按业务员'),
  24. value: 0
  25. }, {
  26. name: getApp().globalData.Language.getMapText('按客户'),
  27. value: 1
  28. }],
  29. points: ['开票', '出货'],
  30. filtratelist: [],
  31. table: [{
  32. title: '客户名称',
  33. width: 330,
  34. key: 'enterprisename',
  35. fun: 'toDetail'
  36. }, {
  37. title: '业务员',
  38. width: 200,
  39. key: 'name'
  40. }, {
  41. title: '期初余额(2021-12-31)',
  42. width: 330,
  43. key: 'openingbalance'
  44. }, {
  45. title: '开票总金额(2022-01-01至今)',
  46. width: 400,
  47. key: 'receivableamount'
  48. }, {
  49. title: '收入总金额(2022-01-01至今)',
  50. width: 400,
  51. key: 'revenueamount'
  52. }, {
  53. title: '开票总应收',
  54. width: 200,
  55. key: 'totalamount'
  56. }],
  57. sumWidth: 0,
  58. sumtotalamount: "0.00"
  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": 20241217135703,
  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 list = res.data.map(v => {
  92. v.openingbalance = CNY(v.openingbalance)
  93. v.sumreceivableamount = CNY(v.sumreceivableamount)
  94. v.sumrevenueamount = CNY(v.sumrevenueamount)
  95. v.receivableamount = CNY(v.receivableamount)
  96. v.revenueamount = CNY(v.revenueamount)
  97. v.totalamount = CNY(v.totalamount)
  98. return v
  99. })
  100. this.setData({
  101. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  102. "content.pageNumber": res.pageNumber + 1,
  103. "content.pageTotal": res.pageTotal,
  104. "content.total": res.total,
  105. sumtotalamount: list.length ? CNY(list[0].sumtotalamount) : '0.00'
  106. })
  107. })
  108. },
  109. toDetail(e) {
  110. let {
  111. item
  112. } = e.currentTarget.dataset;
  113. let content = {
  114. ...this.data.content
  115. };
  116. content.dataid = item.userid || item.sa_customersid;
  117. console.log(content)
  118. wx.navigateTo({
  119. url: '/packageA/accountReceivable/detail?content=' + JSON.stringify(content),
  120. })
  121. },
  122. querytypeChange(e) {
  123. this.setData({
  124. "content.querytype": e.detail.value
  125. });
  126. if (e.detail.value == 0) {
  127. this.data.table[0] = {
  128. title: '部门',
  129. width: 230,
  130. key: 'depname',
  131. fun: 'toDetail'
  132. }
  133. } else {
  134. this.data.table[0] = {
  135. title: '客户名称',
  136. width: 330,
  137. key: 'enterprisename',
  138. fun: 'toDetail'
  139. }
  140. }
  141. this.setData({
  142. table: this.data.table
  143. })
  144. this.getList(true)
  145. },
  146. pointChange(e) {
  147. this.setData({
  148. 'content.point': this.data.points[e.detail.value],
  149. table: [{
  150. title: '客户名称',
  151. width: 330,
  152. key: 'enterprisename',
  153. fun: 'toDetail'
  154. }, {
  155. title: '业务员',
  156. width: 200,
  157. key: 'name'
  158. }, {
  159. title: '期初余额(2021-12-31)',
  160. width: 330,
  161. key: 'openingbalance'
  162. }, {
  163. title: this.data.points[e.detail.value] + '总金额(2022-01-01至今)',
  164. width: 400,
  165. key: 'receivableamount'
  166. }, {
  167. title: '收入总金额(2022-01-01至今)',
  168. width: 400,
  169. key: 'revenueamount'
  170. }, {
  171. title: this.data.points[e.detail.value] + '总应收',
  172. width: 200,
  173. key: 'totalamount'
  174. }],
  175. })
  176. this.getList(true)
  177. },
  178. onReady() {
  179. this.setListHeight()
  180. this.selectComponent("#organization").initDepAndUser();
  181. },
  182. /* 设置页面高度 */
  183. setListHeight() {
  184. this.selectComponent("#ListBox").setHeight(".roof", this);
  185. },
  186. openFiltrate() {
  187. this.setData({
  188. showFiltrate: true
  189. })
  190. },
  191. handleFilter({
  192. detail
  193. }) {
  194. if (detail.name == 'reset') {
  195. this.selectComponent("#organization").initDepAndUser()
  196. this.setData({
  197. 'content.dataid': wx.getStorageSync('userMsg').userid,
  198. 'content.type': 0,
  199. })
  200. } else {
  201. let active = this.selectComponent("#organization").data.result;
  202. let type = active.userid ? 0 : 1,
  203. dataid = type == 0 ? active.userid : active.departmentid
  204. this.setData({
  205. 'content.dataid': dataid,
  206. 'content.type': type
  207. })
  208. }
  209. this.getList(true)
  210. },
  211. startSearch({
  212. detail
  213. }) {
  214. this.data.content.where.condition = detail;
  215. this.getList(true)
  216. },
  217. onClear() {
  218. this.data.content.where.condition = '';
  219. this.getList(true)
  220. },
  221. showSearch() {
  222. this.setData({
  223. startUsing: !this.data.startUsing
  224. })
  225. setTimeout(() => {
  226. this.setListHeight()
  227. }, 400)
  228. },
  229. })