detail.js 12 KB

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