index.js 5.9 KB

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