detail.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. isLeader: false, //是否为负责人
  6. tabsActive: 1, //tabs 选中项
  7. sat_campaignid: 0
  8. },
  9. onLoad(options) {
  10. const appAuth = wx.getStorageSync('auth').wmarketing_activity;
  11. this.setData({
  12. sat_campaignid: options.id,
  13. appAuth
  14. })
  15. this.getDetail();
  16. },
  17. /* 获取详情 */
  18. getDetail() {
  19. _Http.basic({
  20. "classname": "webmanage.saletool.orderclue.ordercluecampaign",
  21. "method": "queryCampaignMain",
  22. "content": {
  23. sat_campaignid: this.data.sat_campaignid
  24. }
  25. }).then(res => {
  26. console.log("详情", res)
  27. if (res.code != '1') return wx.showToast({
  28. title: res.data,
  29. icon: "none"
  30. })
  31. this.setPreview(res);
  32. this.setData({
  33. loading: false,
  34. detail: res.data,
  35. })
  36. //获取标签
  37. if (this.data.appAuth.isdatatag) this.getTags();
  38. if (this.data.appAuth.isdatateam) this.getGroup()
  39. this.setTabbar();
  40. this.partialRenewal();
  41. });
  42. },
  43. setPreview(res) {
  44. /* 摘要信息 */
  45. let briefs = [{
  46. label: "活动类型",
  47. value: res.data.type
  48. }, {
  49. label: "承办医院",
  50. value: res.data.hospitalname
  51. }, {
  52. label: "科室",
  53. value: res.data.hospitaldepname
  54. }, {
  55. label: "申请金额",
  56. value: _Http.formatMoney(res.data.amount),
  57. style: `color:#FF3B30`
  58. }, {
  59. label: "实际发生金额",
  60. value: _Http.formatMoney(res.data.actualAmount),
  61. style: `color:#FF3B30`
  62. }, {
  63. label: "活动地址",
  64. value: res.data.province + res.data.city + res.data.county + res.data.address
  65. }, {
  66. label: "创建人",
  67. value: res.data.createby
  68. }];
  69. /* 基本信息 */
  70. let list1 = [{
  71. label: "活动名称",
  72. value: res.data.name
  73. }, {
  74. label: "承办医院",
  75. value: res.data.hospitalname
  76. }, {
  77. label: "科室",
  78. value: res.data.hospitaldepname
  79. }, {
  80. label: "活动类型",
  81. value: res.data.type
  82. }, {
  83. label: "活动性质",
  84. value: res.data.activitytype
  85. }, {
  86. label: "活动地址",
  87. value: res.data.province + res.data.city + res.data.county + res.data.address
  88. }, {
  89. label: "开始日期",
  90. value: res.data.begdate
  91. }, {
  92. label: "结束日期",
  93. value: res.data.enddate
  94. }, {
  95. label: "申请金额",
  96. value: _Http.formatMoney(res.data.amount)
  97. }, {
  98. label: "实际发生金额",
  99. value: _Http.formatMoney(res.data.actualAmount)
  100. }, {
  101. label: "产品总培训费",
  102. value: _Http.formatMoney(res.data.doctorAmount)
  103. }, {
  104. label: "负责人",
  105. value: res.data.leader ? res.data.leader[0].name : '--'
  106. }];
  107. /* 系统信息 */
  108. let list2 = [{
  109. label: "创建人",
  110. value: res.data.createby
  111. }, {
  112. label: "创建时间",
  113. value: res.data.createdate
  114. }, {
  115. label: "最近编辑人",
  116. value: res.data.changeby
  117. }, {
  118. label: "最近编辑时间",
  119. value: res.data.changedate
  120. }, {
  121. label: "转手次数",
  122. value: res.data.leader ? res.data.leader[0].leadernum : 0
  123. }];
  124. this.setData({
  125. briefs,
  126. list1,
  127. list2
  128. });
  129. },
  130. //详情按钮回调
  131. tabbarOnClick({
  132. detail
  133. }) {
  134. let data = this.data.detail,
  135. that = this;
  136. switch (detail.label) {
  137. case "编辑":
  138. wx.navigateTo({
  139. url: `/prsx/activity/insert?data=${JSON.stringify(data)}`,
  140. })
  141. break;
  142. case "跟进":
  143. that.selectComponent("#Trace").toAdd()
  144. break;
  145. default:
  146. console.log(detail)
  147. break;
  148. }
  149. },
  150. /* 底部功能 */
  151. async setTabbar() {
  152. let detail = this.data.detail,
  153. isAdmin = this.data.isAdmin,
  154. isLeader = detail.leader.some(some => some.userid == wx.getStorageSync('userMsg').userid),
  155. editdataleader = isLeader ? 1 : 0,
  156. tabbarList = [],
  157. appAuth = this.data.appAuth,
  158. tabsList = [{
  159. label: "详细信息",
  160. icon: "icon-tabxiangxixinxi1"
  161. }, {
  162. label: "参与医生",
  163. icon: "icon-yisheng",
  164. model: "#Doctors"
  165. }];
  166. if (!isLeader) {
  167. let res = await getApp().agentOrNot("sat_campaign", this.data.sat_campaignid),
  168. data = res.code == '1' ? res.data : {
  169. editable: 0,
  170. editdataleader: 0
  171. }
  172. if (appAuth.isdatateam) isLeader = this.selectComponent("#Group").data.editable == 1;
  173. if (!isLeader) isLeader = data.editable == 1;
  174. editdataleader = data.editdataleader;
  175. }
  176. if (appAuth.isdatafollowup) {
  177. tabsList.push({
  178. label: "跟进动态",
  179. icon: "icon-tabgenjinjilu",
  180. model: "#Trace"
  181. })
  182. if (detail.status != '已终止') tabbarList.push({
  183. icon: "color-genjin",
  184. label: "跟进"
  185. });
  186. }
  187. tabsList = tabsList.concat([{
  188. label: "附件",
  189. icon: "icon-tabfujian1",
  190. model: "#Files"
  191. }, {
  192. label: "操作",
  193. icon: "icon-tabcaozuojilu1",
  194. model: "#Record"
  195. }])
  196. if (isLeader || isAdmin) {
  197. tabbarList.push({
  198. icon: "color-bianji",
  199. label: "编辑"
  200. })
  201. }
  202. this.setData({
  203. tabbarList,
  204. isLeader,
  205. tabsList
  206. })
  207. },
  208. //tabs 切换
  209. tabsChange({
  210. detail
  211. }) {
  212. this.setData({
  213. tabsActive: detail
  214. });
  215. this.partialRenewal();
  216. },
  217. //局部数据更新 tabs
  218. partialRenewal(init = false) {
  219. try {
  220. let model = this.data.tabsList[this.data.tabsActive].model;
  221. if (model) {
  222. let Component = this.selectComponent(model),
  223. {
  224. total,
  225. pageNumber,
  226. pageTotal
  227. } = Component.data.content,
  228. id = this.data.detail.sat_campaignid;
  229. if (model == "#Files") init = true;
  230. if (total == null || init) {
  231. Component.getList(id, init);
  232. } else if (pageNumber <= pageTotal) {
  233. Component.getList(id, false);
  234. }
  235. }
  236. } catch (error) {
  237. }
  238. },
  239. //更新标签
  240. getTags() {
  241. this.selectComponent("#Tags").getTags()
  242. },
  243. //更新团队成员
  244. getGroup() {
  245. this.selectComponent("#Group").getList().then(this.setTabbarList)
  246. },
  247. onReachBottom() {
  248. this.partialRenewal();
  249. },
  250. onUnload() {
  251. const page = getCurrentPages().find(v => v.__route__ == 'prsx/activity/index');
  252. if (!page) return;
  253. let content = JSON.parse(JSON.stringify(page.data.content));
  254. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  255. content.pageNumber = 1;
  256. _Http.basic({
  257. id: '20221101095102',
  258. content
  259. }).then(res => {
  260. console.log("更新列表", res);
  261. if (res.code == '1') {
  262. res.data = res.data.map(v => {
  263. v.amount = _Http.formatMoney(v.amount)
  264. v.actualAmount = _Http.formatMoney(v.actualAmount)
  265. return v
  266. })
  267. page.setData({
  268. list: res.data,
  269. "content.total": res.total
  270. })
  271. }
  272. })
  273. }
  274. })