project.js 5.1 KB

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