detail.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. isLeader: false, //是否为负责人
  6. tabsActive: 1, //tabs 选中项
  7. },
  8. onLoad(options) {
  9. getApp().globalData.Language.getLanguagePackage(this, '活动详情');
  10. getApp().globalData.handleClue = null;
  11. const appAuth = wx.getStorageSync('auth').wmarketing_activity;
  12. let tabsList = [{
  13. label: "详细信息",
  14. icon: "icon-tabxiangxixinxi1"
  15. }, {
  16. label: "活动线索",
  17. icon: "icon-tabxiansuo",
  18. model: "#Clue"
  19. }, {
  20. label: "操作",
  21. icon: "icon-tabcaozuojilu1",
  22. model: "#Record"
  23. }]
  24. if (appAuth.isdatafollowup) tabsList.push({
  25. label: "跟进动态",
  26. icon: "icon-tabgenjinjilu",
  27. model: "#Trace"
  28. })
  29. if (appAuth.istask) tabsList.push({
  30. label: "任务",
  31. icon: "icon-tabrenwu",
  32. model: "#Work"
  33. })
  34. this.setData({
  35. sat_campaignid: options.id,
  36. isAdmin: appAuth.options.some(v => v == "admin"), //是否具有管理权限
  37. options: appAuth.options, //权限列表
  38. tabsList,
  39. appAuth
  40. });
  41. this.getDetail();
  42. },
  43. getDetail() {
  44. _Http.basic({
  45. "classname": "webmanage.saletool.orderclue.ordercluecampaign",
  46. "method": "queryCampaignMain",
  47. "version": 1,
  48. "content": {
  49. "nocache": true,
  50. "sat_campaignid": this.data.sat_campaignid
  51. },
  52. }).then(res => {
  53. console.log("市场活动详情", res)
  54. if (res.code != '1') return wx.showToast({
  55. title: res.msg,
  56. icon: "none"
  57. });
  58. this.setData({
  59. loading: false,
  60. detail: res.data,
  61. briefs: [{
  62. label: "活动类型",
  63. value: res.data.type
  64. }, {
  65. label: "线索数",
  66. value: res.data.ordercluecount || '0'
  67. }, {
  68. label: "活动负责人",
  69. value: res.data.director
  70. }, {
  71. label: "状态",
  72. value: getApp().globalData.Language.getMapText(res.data.status),
  73. style:`color:${this.data.sColors[res.data.status]}`
  74. }],
  75. list1: [{
  76. label: "市场活动名称",
  77. value: res.data.name
  78. }, {
  79. label: "活动类型",
  80. value: res.data.type
  81. }, {
  82. label: "线索数",
  83. value: res.data.ordercluecount || '0'
  84. }, {
  85. label: "活动地点",
  86. value: res.data.address
  87. }, {
  88. label: "状态",
  89. value: getApp().globalData.Language.getMapText(res.data.status),
  90. style:`color:${this.data.sColors[res.data.status]}`
  91. }, {
  92. label: "开始时间",
  93. value: res.data.begdate
  94. }, {
  95. label: "结束时间",
  96. value: res.data.enddate
  97. }, {
  98. label: "活动负责人",
  99. value: res.data.director
  100. }, {
  101. label: "负责人",
  102. value: res.data.leader[0].name
  103. }],
  104. list2: [{
  105. label: "创建人",
  106. value: res.data.createby
  107. }, {
  108. label: "创建时间",
  109. value: res.data.createdate
  110. }, {
  111. label: "最近编辑人",
  112. value: res.data.changeby
  113. }, {
  114. label: "最近编辑时间",
  115. value: res.data.changedate
  116. }, {
  117. label: "发布人",
  118. value: res.data.changeby
  119. }, {
  120. label: "发布时间",
  121. value: res.data.followdate
  122. }, {
  123. label: "结束人",
  124. value: res.data.followdate
  125. }, {
  126. label: "转手次数",
  127. value: res.data.leader[0].leadernum
  128. }]
  129. });
  130. let appAuth = this.data.appAuth;
  131. if (appAuth.isdatatag) this.getTags();
  132. if (appAuth.isdatateam) this.getGroup();
  133. this.partialRenewal(true);
  134. this.setTabbarList()
  135. })
  136. },
  137. async setTabbarList() {
  138. let tabbarList = [],
  139. detail = this.data.detail,
  140. isLeader = detail.leader.length ? detail.leader.some(v => v.userid == wx.getStorageSync('userMsg').userid) : false,
  141. status = this.data.detail.status,
  142. editdataleader = isLeader ? 1 : 0;
  143. if (!isLeader) {
  144. let res = await getApp().agentOrNot("sat_campaign", this.data.sat_campaignid),
  145. data = res.code == '1' ? res.data : {
  146. editable: 0,
  147. editdataleader: 0
  148. }
  149. if (this.data.appAuth.isdatateam) isLeader = this.selectComponent("#Group").data.editable == 1;
  150. if (!isLeader) isLeader = data.editable == 1;
  151. editdataleader = data.editdataleader;
  152. }
  153. if (isLeader || this.data.isAdmin) {
  154. if (status == '新建') {
  155. tabbarList = [{
  156. icon: "icon-bianji",
  157. label: "编辑"
  158. }, {
  159. icon: "icon-dibu-chengjiao",
  160. label: "发布"
  161. }]
  162. } else if (status == '发布') {
  163. tabbarList = [{
  164. icon: "icon-dibu-chengjiao",
  165. label: "取消发布"
  166. }, {
  167. icon: "icon-dibu-jieshu",
  168. label: "结束"
  169. }]
  170. };
  171. getApp().globalData.handleClue = this.isDelete.bind(this);
  172. }
  173. this.setData({
  174. tabbarList,
  175. isLeader
  176. })
  177. },
  178. /**
  179. * 是否可以删除活动
  180. * @param {number} total 数据数量
  181. */
  182. isDelete(total) {
  183. if (this.data.detail.status == '新建' && this.data.isLeader && total == 0) this.setData({
  184. tabbarList: this.data.tabbarList.concat([{
  185. icon: "icon-guanlian-shanchu",
  186. label: "删除"
  187. }])
  188. })
  189. },
  190. //tabs 切换
  191. tabsChange({
  192. detail
  193. }) {
  194. this.setData({
  195. tabsActive: detail
  196. });
  197. this.partialRenewal();
  198. },
  199. //更新标签
  200. getTags() {
  201. if (this.data.appAuth.isdatatag) this.selectComponent("#Tags").getTags();
  202. },
  203. //更新团队成员
  204. getGroup() {
  205. this.selectComponent("#Group").getList().then(this.setTabbarList)
  206. },
  207. //局部数据更新 tabs
  208. partialRenewal(init = false) {
  209. let model = this.data.tabsList[this.data.tabsActive].model;
  210. if (model) {
  211. let Component = this.selectComponent(model),
  212. {
  213. total,
  214. pageNumber,
  215. pageTotal
  216. } = Component.data.content,
  217. id = this.data.detail.sat_campaignid;
  218. if (total == null || init) {
  219. Component.getList(id, init);
  220. } else if (pageNumber <= pageTotal) {
  221. Component.getList(id, false);
  222. }
  223. }
  224. },
  225. onReachBottom() {
  226. this.partialRenewal();
  227. },
  228. //详情按钮回调
  229. tabbarOnClick({
  230. detail
  231. }) {
  232. let data = this.data.detail;
  233. switch (detail.label) {
  234. case "编辑":
  235. wx.navigateTo({
  236. url: `/packageA/activity/addActivity?rowData=${JSON.stringify(this.data.detail)}`,
  237. })
  238. break;
  239. case "发布":
  240. wx.showModal({
  241. title: getApp().globalData.Language.getMapText('提示'),
  242. content: getApp().globalData.Language.getMapText('是否确认发布该市场活动?'),
  243. cancelText: getApp().globalData.Language.getMapText('取消'),
  244. confirmText: getApp().globalData.Language.getMapText('确定'),
  245. complete: ({
  246. confirm
  247. }) => {
  248. if (confirm) _Http.basic({
  249. "classname": "webmanage.saletool.orderclue.ordercluecampaign",
  250. method: 'release',
  251. "content": {
  252. "sat_campaignids": [this.data.detail.sat_campaignid]
  253. }
  254. }).then(res => {
  255. wx.showToast({
  256. title: res.code == '1' ? getApp().globalData.Language.getMapText('活动发布成功') : res.msg,
  257. icon: "none"
  258. });
  259. if (res.code == '1') this.getDetail()
  260. })
  261. }
  262. })
  263. break;
  264. case "结束":
  265. wx.showModal({
  266. title: getApp().globalData.Language.getMapText('提示'),
  267. content: getApp().globalData.Language.getMapText('是否确认结束该市场活动?'),
  268. cancelText: getApp().globalData.Language.getMapText('取消'),
  269. confirmText: getApp().globalData.Language.getMapText('确定'),
  270. complete: ({
  271. confirm
  272. }) => {
  273. if (confirm) _Http.basic({
  274. "classname": "webmanage.saletool.orderclue.ordercluecampaign",
  275. method: 'endcampaign',
  276. "content": {
  277. "sat_campaignids": [this.data.detail.sat_campaignid]
  278. }
  279. }).then(res => {
  280. wx.showToast({
  281. title: res.code == '1' ? getApp().globalData.Language.getMapText('已结束该活动') : res.msg,
  282. icon: "none"
  283. });
  284. if (res.code == '1') this.getDetail()
  285. })
  286. }
  287. })
  288. break;
  289. case "取消发布":
  290. wx.showModal({
  291. title: getApp().globalData.Language.getMapText('提示'),
  292. content: getApp().globalData.Language.getMapText('是否确认取消发布该市场活动') + `?`,
  293. cancelText: getApp().globalData.Language.getMapText('取消'),
  294. confirmText: getApp().globalData.Language.getMapText('确定'),
  295. complete: ({
  296. confirm
  297. }) => {
  298. if (confirm) _Http.basic({
  299. "classname": "webmanage.saletool.orderclue.ordercluecampaign",
  300. method: "undercarriage",
  301. "content": {
  302. "sat_campaignids": [this.data.detail.sat_campaignid]
  303. }
  304. }).then(res => {
  305. wx.showToast({
  306. title: res.code == '1' ? getApp().globalData.Language.getMapText('已取消该活动') : res.msg,
  307. icon: "none"
  308. });
  309. if (res.code == '1') this.getDetail()
  310. })
  311. }
  312. })
  313. break;
  314. case "删除":
  315. wx.showModal({
  316. title: getApp().globalData.Language.getMapText('提示'),
  317. content: getApp().globalData.Language.getMapText('是否确认删除该市场活动') + `?`,
  318. cancelText: getApp().globalData.Language.getMapText('取消'),
  319. confirmText: getApp().globalData.Language.getMapText('确定'),
  320. complete: ({
  321. confirm
  322. }) => {
  323. if (confirm) _Http.basic({
  324. id: "20230329163504",
  325. "content": {
  326. "sat_campaignid": this.data.detail.sat_campaignid
  327. }
  328. }).then(res => {
  329. wx.showToast({
  330. title: res.code == '1' ? getApp().globalData.Language.getMapText('删除成功') : res.msg,
  331. icon: "none"
  332. });
  333. if (res.code == '1') setTimeout(() => {
  334. wx.navigateBack()
  335. }, 300)
  336. })
  337. }
  338. })
  339. break;
  340. }
  341. },
  342. onUnload() {
  343. const page = getCurrentPages().find(v => v.__route__ == 'packageA/activity/index');
  344. if (!page) return;
  345. let content = JSON.parse(JSON.stringify(page.data.content));
  346. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  347. content.pageNumber = 1;
  348. _Http.basic({
  349. id: '20221101095102',
  350. content
  351. }).then(res => {
  352. console.log("更新市场活动列表", res);
  353. if (res.code == '1') page.setData({
  354. list: res.data,
  355. "content.total": res.total
  356. })
  357. })
  358. }
  359. })