detail.js 14 KB

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