sales.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = (value, symbol = "¥", precision = 2) => currency(value, {
  4. symbol,
  5. precision
  6. }).format();
  7. Component({
  8. options: {
  9. addGlobalClass: true
  10. },
  11. lifetimes: {
  12. attached: function () {
  13. getApp().globalData.Language.getLanguagePackage(this)
  14. }
  15. },
  16. properties: {
  17. },
  18. data: {
  19. followSize: 0,
  20. dateType: "本年",
  21. showList: false,
  22. list: [],
  23. "type": 1,
  24. "content": {
  25. "nocache": true,
  26. "pageNumber": 1,
  27. "pageTotal": 1,
  28. "total": null,
  29. "where": {
  30. begdate: "",
  31. enddate: "",
  32. }
  33. }
  34. },
  35. methods: {
  36. getList(id, init) {
  37. let content = this.data.content;
  38. content.hrid = id;
  39. content.type = this.data.type;
  40. if (init) {
  41. content.pageNumber = 1;
  42. content.total = null;
  43. }
  44. if (!this.data.showList && content.total != null) return;
  45. if (content.pageNumber > content.pageTotal) return;
  46. _Http.basic({
  47. "id": 20230717101004,
  48. content
  49. }).then(res => {
  50. console.log("业务员关联项目", res)
  51. if (res.code != '1') return wx.showToast({
  52. title: res.data,
  53. icon: "none"
  54. })
  55. content.pageNumber = res.pageNumber + 1;
  56. content.pageSize = res.pageSize;
  57. content.pageTotal = res.pageTotal;
  58. content.total = res.total;
  59. res.data = res.data.map(v => {
  60. try {
  61. v.signamount_due = CNY(v.signamount_due);
  62. } catch (error) {
  63. }
  64. return v
  65. })
  66. this.setData({
  67. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  68. content,
  69. id: id,
  70. });
  71. this.selectComponent("#TimeRange").onCancel()
  72. })
  73. _Http.basic({
  74. "id": 20230717101104,
  75. "content": {
  76. ...content,
  77. pageSize: 0
  78. }
  79. }).then(res => {
  80. try {
  81. this.setData({
  82. followSize: res.data[0].followSize
  83. })
  84. } catch (error) {
  85. }
  86. })
  87. },
  88. changeDate({
  89. detail
  90. }) {
  91. let type = 99;
  92. switch (detail.dateType) {
  93. case '全部':
  94. type = 0;
  95. break;
  96. case '本年':
  97. type = 1;
  98. break;
  99. case '本季':
  100. type = 2;
  101. break;
  102. case '本月':
  103. type = 3;
  104. break;
  105. }
  106. this.setData({
  107. dateType: detail.dateType,
  108. type,
  109. "content.where.begdate": detail.begdate || "",
  110. "content.where.enddate": detail.enddate || ""
  111. })
  112. this.getList(this.data.id, true)
  113. },
  114. shrinkChange({
  115. detail
  116. }) {
  117. this.setData({
  118. showList: detail
  119. })
  120. },
  121. upDateList() {
  122. let content = JSON.parse(JSON.stringify(this.data.content));
  123. try {
  124. content.hrid = this.data.id;
  125. content.type = this.data.type;
  126. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  127. content.pageNumber = 1;
  128. } catch (error) {
  129. console.log("error", error)
  130. }
  131. _Http.basic({
  132. id: '20230717101004',
  133. content
  134. }).then(res => {
  135. console.log("更新业务员关联项目", res);
  136. if (res.code == '1') {
  137. res.data = res.data.map(v => {
  138. try {
  139. v.signamount_due = CNY(v.signamount_due);
  140. } catch (error) {
  141. }
  142. return v
  143. })
  144. this.setData({
  145. list: res.data,
  146. "content.total": res.total
  147. })
  148. }
  149. })
  150. _Http.basic({
  151. "id": 20230717101104,
  152. "content": {
  153. ...content,
  154. pageSize: 0
  155. }
  156. }).then(res => {
  157. try {
  158. this.setData({
  159. followSize: res.data[0].followSize
  160. })
  161. } catch (error) {
  162. }
  163. })
  164. }
  165. }
  166. })