project.js 4.9 KB

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