project.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. year: new Date().getFullYear(),
  5. content: {
  6. nocache: true,
  7. "year": new Date().getFullYear(),
  8. "hrid": wx.getStorageSync('userMsg').hrid,
  9. "pageNumber": 1,
  10. "pageTotal": 1,
  11. "pageSize": 20,
  12. "where": {
  13. "condition": ""
  14. },
  15. },
  16. projectList: []
  17. },
  18. onLoad(options) {
  19. this.setData({
  20. year: options.year,
  21. 'content.year': options.year,
  22. yearArr: options.yearArr.split(","),
  23. pickerIndex: options.pickerIndex
  24. })
  25. this.getList();
  26. this.getProjectList();
  27. },
  28. /* 添加项目 */
  29. getResult({
  30. detail
  31. }) {
  32. let project = [];
  33. detail.forEach(v => {
  34. let data = this.data.projectList.find(value => value.sa_projectid == v);
  35. project.push({
  36. "target_l": data.signamount_due || "",
  37. "target_h": data.signamount_due || "",
  38. "month": data.signdate_due.split("-")[1] || "",
  39. ...data
  40. })
  41. });
  42. wx.navigateTo({
  43. url: './addProject?data=' + JSON.stringify(project) + '&year=' + this.data.year,
  44. })
  45. },
  46. /* 选择年份
  47. bindDateChange({
  48. detail
  49. }) {
  50. if (this.data.year == detail.value) return;
  51. this.setData({
  52. "year": detail.value,
  53. "content.year": detail.value
  54. });
  55. this.getList(true);
  56. },*/
  57. /* 选择年份 */
  58. bindDateChange({
  59. detail
  60. }) {
  61. let index = detail.value;
  62. if (this.data.pickerIndex == detail.value) return;
  63. this.setData({
  64. "year": this.data.yearArr[detail.value],
  65. "content.year": this.data.yearArr[detail.value],
  66. pickerIndex: index
  67. });
  68. this.getList(true);
  69. },
  70. getList(init = false) {
  71. //init 用于初始化分页
  72. if (init.detail != undefined) init = init.detail;
  73. if (init) this.setData({
  74. ['content.pageNumber']: 1
  75. })
  76. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  77. _Http.basic({
  78. "id": 20220906104002,
  79. "content": this.data.content
  80. }).then(res => {
  81. if (res.msg != '成功') return wx.showToast({
  82. title: res.data,
  83. icon: "none"
  84. })
  85. this.setData({
  86. list: res.data,
  87. 'content.pageNumber': res.pageNumber + 1,
  88. 'content.pageTotal': res.pageTotal,
  89. total: res.total
  90. })
  91. })
  92. },
  93. getProjectList() {
  94. _Http.basic({
  95. "id": 20220905151902,
  96. "content": {
  97. nocache: true,
  98. pageSize: 99999,
  99. "where": {
  100. "condition": ""
  101. }
  102. },
  103. }).then(res => {
  104. if (res.msg != '成功') return wx.showToast({
  105. title: res.data,
  106. icon: "none"
  107. })
  108. this.setData({
  109. projectList: res.data
  110. })
  111. })
  112. },
  113. /* 删除项目 */
  114. deleteItem(e) {
  115. const {
  116. item
  117. } = e.currentTarget.dataset,
  118. that = this;
  119. wx.showModal({
  120. title: '提示',
  121. content: `是否确认删除${item.projectname}`,
  122. success({
  123. confirm
  124. }) {
  125. if (confirm) {
  126. _Http.basic({
  127. "id": 20220905165302,
  128. "content": {
  129. "sa_salestargetid": [
  130. item.sa_salestargetid
  131. ]
  132. },
  133. }).then(res => {
  134. if (res.msg != '成功') return wx.showToast({
  135. title: res.data,
  136. icon: "none"
  137. })
  138. that.setData({
  139. list: that.data.list.filter(v => v.sa_salestargetid != item.sa_salestargetid)
  140. })
  141. wx.showToast({
  142. title: '删除成功',
  143. icon: "none"
  144. })
  145. })
  146. }
  147. }
  148. })
  149. },
  150. /* 开启添加项目 */
  151. addProject() {
  152. this.selectComponent("#Plist").setData({
  153. show: true
  154. })
  155. },
  156. onReachBottom() {
  157. this.getList();
  158. },
  159. onShareAppMessage() {}
  160. })