add.js 3.8 KB

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