detail.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. tabsActive: 0, //tabs 选中项
  5. sys_taskid: "",
  6. detail: '',
  7. tabsList: [{
  8. label: "详细信息",
  9. icon: "icon-tabxiangxixinxi1"
  10. }, {
  11. label: "跟进动态",
  12. icon: "icon-tabgenjinjilu"
  13. }, {
  14. label: "操作",
  15. icon: "icon-tabcaozuojilu1"
  16. }, {
  17. label: "附件",
  18. icon: "icon-tabfujian1"
  19. }],
  20. tabbarList: [],
  21. confirmShow: false,
  22. finishnotes: "", //完成说明
  23. },
  24. /* 完成情况说明输入 */
  25. areaInput(e) {
  26. this.setData({
  27. finishnotes: e.detail.value
  28. })
  29. },
  30. onConfirm(e) {
  31. console.log(this.data.finishnotes)
  32. _Http.basic({
  33. "id": 20221211112501,
  34. "content": {
  35. "sys_taskid": this.data.sys_taskid,
  36. "finishnotes": this.data.finishnotes
  37. }
  38. }).then(res => {
  39. console.log("完成情况说明", res)
  40. wx.showToast({
  41. title: res.msg == '成功' ? "提交成功" : res.msg,
  42. icon: "none"
  43. })
  44. if (res.msg == '成功') setTimeout(this.getDetail, 500)
  45. })
  46. },
  47. /* 取消提交说明 */
  48. onCancel(e) {
  49. this.setData({
  50. confirmShow: false
  51. })
  52. },
  53. onLoad(options) {
  54. this.setData({
  55. sys_taskid: options.id
  56. });
  57. this.getDetail();
  58. },
  59. getDetail() {
  60. _Http.basic({
  61. "id": 20221211111901,
  62. "content": {
  63. "nocache": true,
  64. "sys_taskid": this.data.sys_taskid
  65. },
  66. }).then(res => {
  67. console.log("任务详情", res)
  68. if (res.msg != '成功') return wx.showToast({
  69. title: res.msg,
  70. icon: "none"
  71. });
  72. let isLeader = res.data.leader.some(v => v.userid == wx.getStorageSync('userMsg').userid),
  73. isCreateby = res.data.createuserid == wx.getStorageSync('userMsg').userid,
  74. tabbarList = [{
  75. icon: "icon-genjin",
  76. label: "跟进"
  77. }, {
  78. icon: "icon-dibu-chengjiao",
  79. label: "完成"
  80. }];
  81. if (isCreateby) tabbarList.splice(1, 0, {
  82. icon: "icon-guanlian-bianji",
  83. label: "编辑"
  84. })
  85. this.setData({
  86. tabbarList,
  87. detail: res.data,
  88. briefs: [{
  89. label: "任务要求",
  90. value: res.data.remarks
  91. }, {
  92. label: "开始时间",
  93. value: res.data.starttime
  94. }, {
  95. label: "截止时间",
  96. value: res.data.endtime
  97. },
  98. {
  99. label: '关联页数数据',
  100. value: res.data.allocationstatus
  101. },
  102. {
  103. label: '状态',
  104. value: res.data.status
  105. }
  106. ],
  107. list1: [{
  108. label: "任务要求",
  109. value: res.data.remarks
  110. },
  111. {
  112. label: "开始时间",
  113. value: res.data.starttime
  114. },
  115. {
  116. label: "截止时间",
  117. value: res.data.endtime
  118. },
  119. {
  120. label: '关联页数数据',
  121. value: res.data.allocationstatus
  122. },
  123. {
  124. label: '状态',
  125. value: res.data.status
  126. }
  127. ],
  128. list2: [{
  129. label: "创建人",
  130. value: res.data.createby
  131. }, {
  132. label: "创建时间",
  133. value: res.data.createdate
  134. }, {
  135. label: "最近编辑人",
  136. value: res.data.changeby
  137. }, {
  138. label: "最近编辑时间",
  139. value: res.data.changedate
  140. }, {
  141. label: "转手次数",
  142. value: res.data.leader[0].leadernum
  143. }]
  144. });
  145. /* 更新列表中状态 */
  146. let page = getCurrentPages().find(v => v.__route__ == 'packageA/saleClue/index');
  147. if (page) {
  148. let index = page.data.list.findIndex(v => v.sys_taskid == res.data.sys_taskid);
  149. if (index != -1) page.setData({
  150. [`list[${index}].status`]: res.data.status,
  151. [`list[${index}].title`]: res.data.title,
  152. [`list[${index}].remarks`]: res.data.remarks
  153. })
  154. } else {
  155. let pages = getCurrentPages(),
  156. p = pages[pages.length - 2].selectComponent("#Work");
  157. if (p) {
  158. let index = p.data.list.findIndex(v => v.sys_taskid == res.data.sys_taskid);
  159. if (index != -1) p.setData({
  160. [`list[${index}].status`]: res.data.status,
  161. [`list[${index}].title`]: res.data.title,
  162. [`list[${index}].remarks`]: res.data.remarks
  163. })
  164. }
  165. }
  166. this.getTags();
  167. this.getGroup();
  168. this.partialRenewal();
  169. })
  170. },
  171. //tabs 切换
  172. tabsChange({
  173. detail
  174. }) {
  175. this.setData({
  176. tabsActive: detail
  177. });
  178. this.partialRenewal();
  179. },
  180. //更新标签
  181. getTags() {
  182. this.selectComponent("#Tags").getTags();
  183. },
  184. //更新团队成员
  185. getGroup() {
  186. this.selectComponent("#Group").getList();
  187. },
  188. onClose() {
  189. this.setData({
  190. show: false
  191. });
  192. },
  193. //局部数据更新 tabs
  194. partialRenewal(init = false) {
  195. let id = this.data.detail.sys_taskid;
  196. let model = '';
  197. let name = this.data.tabsList[this.data.tabsActive].label;
  198. switch (name) {
  199. case "操作":
  200. model = "#Record"
  201. break;
  202. case "跟进动态":
  203. model = "#Trace"
  204. break;
  205. case "附件":
  206. model = "#Files"
  207. break;
  208. };
  209. if (model) {
  210. // 确定好模块ID total = null 是第一次加载 加载数据
  211. // init是新增或修改需要清数据
  212. let Component = this.selectComponent(model);
  213. const {
  214. total,
  215. pageNumber,
  216. pageTotal
  217. } = Component.data.content;
  218. if (total == null || init) {
  219. Component.getList(id, init);
  220. } else if (pageNumber <= pageTotal) {
  221. Component.getList(id, false);
  222. } else {
  223. //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据
  224. }
  225. }
  226. },
  227. onReachBottom() {
  228. this.partialRenewal();
  229. },
  230. //详情按钮回调
  231. tabbarOnClick({
  232. detail
  233. }) {
  234. switch (detail.label) {
  235. case "编辑":
  236. let group = this.selectComponent("#Group").query();
  237. wx.navigateTo({
  238. url: `/packageA/work/add?data=${JSON.stringify(this.data.detail)}&group=${JSON.stringify(group)}`,
  239. })
  240. break;
  241. case "完成":
  242. this.setData({
  243. confirmShow: true
  244. })
  245. break;
  246. case "跟进":
  247. wx.navigateTo({
  248. url: `/packageA/setclient/modules/trace/add/index?ownertable=sys_task&ownerid=${this.data.sys_taskid}`,
  249. })
  250. break;
  251. }
  252. },
  253. onShareAppMessage() {}
  254. })