detail.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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 isCreateby = res.data.createuserid == wx.getStorageSync('userMsg').userid,
  73. tabbarList = [{
  74. icon: "icon-genjin",
  75. label: "跟进"
  76. }, {
  77. icon: "icon-dibu-chengjiao",
  78. label: "完成"
  79. }];
  80. if (isCreateby) tabbarList.splice(1, 0, {
  81. icon: "icon-guanlian-bianji",
  82. label: "编辑"
  83. })
  84. this.setData({
  85. tabbarList,
  86. detail: res.data,
  87. briefs: [{
  88. label: "任务要求",
  89. value: res.data.remarks
  90. }, {
  91. label: "开始时间",
  92. value: res.data.starttime
  93. }, {
  94. label: "截止时间",
  95. value: res.data.endtime
  96. },
  97. {
  98. label: '关联页数数据',
  99. value: res.data.allocationstatus
  100. },
  101. {
  102. label: '状态',
  103. value: res.data.status
  104. }
  105. ],
  106. list1: [{
  107. label: "任务要求",
  108. value: res.data.remarks
  109. },
  110. {
  111. label: "开始时间",
  112. value: res.data.starttime
  113. },
  114. {
  115. label: "截止时间",
  116. value: res.data.endtime
  117. },
  118. {
  119. label: '关联页数数据',
  120. value: res.data.allocationstatus
  121. },
  122. {
  123. label: '状态',
  124. value: res.data.status
  125. }
  126. ],
  127. list2: [{
  128. label: "创建人",
  129. value: res.data.createby
  130. }, {
  131. label: "创建时间",
  132. value: res.data.createdate
  133. }, {
  134. label: "最近编辑人",
  135. value: res.data.changeby
  136. }, {
  137. label: "最近编辑时间",
  138. value: res.data.changedate
  139. }, {
  140. label: "转手次数",
  141. value: res.data.leader[0].leadernum
  142. }]
  143. });
  144. /* 更新列表中状态 */
  145. let page = getCurrentPages().find(v => v.__route__ == 'packageA/saleClue/index');
  146. if (page) {
  147. let index = page.data.list.findIndex(v => v.sys_taskid == res.data.sys_taskid);
  148. if (index != -1) page.setData({
  149. [`list[${index}].status`]: res.data.status,
  150. [`list[${index}].title`]: res.data.title,
  151. [`list[${index}].remarks`]: res.data.remarks
  152. })
  153. } else {
  154. let pages = getCurrentPages(),
  155. p = pages[pages.length - 2].selectComponent("#Work");
  156. if (p) {
  157. let index = p.data.list.findIndex(v => v.sys_taskid == res.data.sys_taskid);
  158. if (index != -1) p.setData({
  159. [`list[${index}].status`]: res.data.status,
  160. [`list[${index}].title`]: res.data.title,
  161. [`list[${index}].remarks`]: res.data.remarks
  162. })
  163. }
  164. }
  165. this.getTags();
  166. this.getGroup();
  167. this.partialRenewal();
  168. })
  169. },
  170. //tabs 切换
  171. tabsChange({
  172. detail
  173. }) {
  174. this.setData({
  175. tabsActive: detail
  176. });
  177. this.partialRenewal();
  178. },
  179. //更新标签
  180. getTags() {
  181. this.selectComponent("#Tags").getTags();
  182. },
  183. //更新团队成员
  184. getGroup() {
  185. this.selectComponent("#Group").getList();
  186. },
  187. onClose() {
  188. this.setData({
  189. show: false
  190. });
  191. },
  192. //局部数据更新 tabs
  193. partialRenewal(init = false) {
  194. let id = this.data.detail.sys_taskid;
  195. let model = '';
  196. let name = this.data.tabsList[this.data.tabsActive].label;
  197. switch (name) {
  198. case "操作":
  199. model = "#Record"
  200. break;
  201. case "跟进动态":
  202. model = "#Trace"
  203. break;
  204. case "附件":
  205. model = "#Files"
  206. break;
  207. };
  208. if (model) {
  209. // 确定好模块ID total = null 是第一次加载 加载数据
  210. // init是新增或修改需要清数据
  211. let Component = this.selectComponent(model);
  212. const {
  213. total,
  214. pageNumber,
  215. pageTotal
  216. } = Component.data.content;
  217. if (total == null || init) {
  218. Component.getList(id, init);
  219. } else if (pageNumber <= pageTotal) {
  220. Component.getList(id, false);
  221. } else {
  222. //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据
  223. }
  224. }
  225. },
  226. onReachBottom() {
  227. this.partialRenewal();
  228. },
  229. //详情按钮回调
  230. tabbarOnClick({
  231. detail
  232. }) {
  233. switch (detail.label) {
  234. case "编辑":
  235. let group = this.selectComponent("#Group").query();
  236. wx.navigateTo({
  237. url: `/packageA/work/add?data=${JSON.stringify(this.data.detail)}&group=${JSON.stringify(group)}`,
  238. })
  239. break;
  240. case "完成":
  241. this.setData({
  242. confirmShow: true
  243. })
  244. break;
  245. case "跟进":
  246. wx.navigateTo({
  247. url: `/packageA/setclient/modules/trace/add/index?ownertable=sys_task&ownerid=${this.data.sys_taskid}`,
  248. })
  249. break;
  250. }
  251. },
  252. onShareAppMessage() {}
  253. })