add.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. taskname: ""
  5. },
  6. onLoad(options) {
  7. let content = JSON.parse(options.content);
  8. _Http.basic({
  9. "id": 20221129152304,
  10. "content": {
  11. ...content,
  12. pageSize: 999
  13. }
  14. }).then(res => {
  15. console.log("获取评估项", res)
  16. content.actionnotes = '';
  17. let isUser = res.data[0].option ? true : false;
  18. if (res.data[0].option) {
  19. res.data.map(v => {
  20. v.sa_projtaskmag_optionsid = v.option[0].sa_projtaskmag_optionsid,
  21. v.score = v.option[0].score
  22. })
  23. } else {
  24. res.data = [{
  25. option: {
  26. ...res.data
  27. },
  28. sa_projtaskmag_optionsid: res.data[0].sa_projtaskmag_optionsid,
  29. score: res.data[0].score,
  30. sa_project_partiesid: 0,
  31. }]
  32. }
  33. this.setData({
  34. isUser,
  35. taskname: options.taskname,
  36. content,
  37. list: res.data
  38. })
  39. if (this.data.isUser) this.getTags();
  40. });
  41. },
  42. changeOption(e) {
  43. const {
  44. id,
  45. index,
  46. score
  47. } = e.currentTarget.dataset;
  48. this.setData({
  49. [`list[${index}].sa_projtaskmag_optionsid`]: id,
  50. [`list[${index}].score`]: score,
  51. });
  52. },
  53. /* 获取列表标签 */
  54. getTags() {
  55. let list = this.data.list,
  56. ownerids = list.map(v => v.sa_customersid);
  57. _Http.basic({
  58. "id": 20221018102001,
  59. "content": {
  60. nocache: true,
  61. "ownertable": "sa_customers",
  62. ownerids
  63. }
  64. }).then(res => {
  65. console.log("标签", res)
  66. for (let key in res.data) {
  67. let index = list.findIndex(v => v.sa_customersid == key);
  68. if (index != -1) list[index].tags = res.data[key]
  69. };
  70. console.log(list)
  71. this.setData({
  72. list
  73. })
  74. })
  75. },
  76. onInput(e) {
  77. this.setData({
  78. 'content.actionnotes': e.detail.value
  79. })
  80. },
  81. submit() {
  82. const that = this;
  83. wx.showModal({
  84. title: '提示',
  85. content: '是否确认提交本次评估?',
  86. complete: ({
  87. confirm
  88. }) => {
  89. if (confirm) _Http.basic({
  90. "id": "20221128145004",
  91. "content": {
  92. ...that.data.content,
  93. option: that.data.list.map(v => {
  94. return {
  95. sa_project_partiesid: v.sa_project_partiesid,
  96. sa_projtaskmag_optionsid: v.sa_projtaskmag_optionsid,
  97. score: v.score
  98. }
  99. })
  100. }
  101. }).then(res => {
  102. console.log('提交评估', res)
  103. wx.showToast({
  104. title: res.msg == '成功' ? '提交成功' : res.msg,
  105. icon: "none"
  106. });
  107. if (res.msg == '成功') setTimeout(() => {
  108. let page = getCurrentPages().find(v => v.__route__ == 'packageA/project/detail');
  109. if (page) page.selectComponent("#Task").getList(that.data.content.sa_projectid, true);
  110. wx.navigateBack();
  111. }, 300);
  112. })
  113. }
  114. })
  115. }
  116. })