detail.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. isLeader: false, //是否为负责人
  5. tabsActive: 0, //tabs 选中项
  6. sat_orderclueid: "",
  7. detail: '',
  8. tabsList: [{
  9. label: "详细信息",
  10. icon: "icon-tabxiangxixinxi1"
  11. }, {
  12. label: "跟进记录",
  13. icon: "icon-tabgenjinjilu"
  14. }, {
  15. label: "操作",
  16. icon: "icon-tabcaozuojilu1"
  17. }, {
  18. label: "跟进动态",
  19. icon: "icon-tabgenjinjilu"
  20. }, {
  21. label: "任务",
  22. icon: "icon-tabrenwu"
  23. }, {
  24. label: "附件",
  25. icon: "icon-tabfujian1"
  26. }],
  27. tabbarList: [{
  28. icon: "icon-bianji",
  29. label: "编辑"
  30. }, {
  31. icon: "icon-zhuanyi",
  32. label: "分配"
  33. }, {
  34. icon: "icon-dibu-jieshu",
  35. label: "删除"
  36. }],
  37. },
  38. onLoad(options) {
  39. this.setData({
  40. sat_orderclueid: options.sat_orderclueid,
  41. isAdmin: wx.getStorageSync('auth').wCustomer.options.some(v => v == "admin"), //是否具有管理权限
  42. });
  43. this.getDetail();
  44. },
  45. getDetail() {
  46. _Http.basic({
  47. "classname": "webmanage.saletool.orderclue.publicclue.PublicClue",
  48. "method": "selectDetail",
  49. "version": 1,
  50. "content": {
  51. "nocache": true,
  52. "sat_orderclueid": this.data.sat_orderclueid
  53. },
  54. }).then(res => {
  55. console.log("线索详情", res)
  56. if (res.msg != '成功') return wx.showToast({
  57. title: res.msg,
  58. icon: "none"
  59. });
  60. this.setData({
  61. isLeader: res.data.createuserid == wx.getStorageSync('userMsg').userid,
  62. detail: res.data,
  63. briefs: [{
  64. label: "联系人",
  65. value: res.data.name
  66. }, {
  67. label: "手机号",
  68. value: res.data.phonenumber
  69. }, {
  70. label: "市场活动",
  71. value: res.data.campaign_name
  72. }, {
  73. label: "领域",
  74. value: res.data.tradefield
  75. }, {
  76. label: '负责人',
  77. value: res.data.leader && res.data.leader.length > 0 ? res.data.leader[0].name : ''
  78. },
  79. {
  80. label: '分配状态',
  81. value: res.data.allocationstatus
  82. },
  83. {
  84. label: '跟进状态',
  85. value: res.data.status
  86. },
  87. {
  88. label: '跟进次数',
  89. value: res.data.followcount || '0'
  90. },
  91. ],
  92. list1: [{
  93. label: "客户(企业)",
  94. value: res.data.enterprisename_customer
  95. }, {
  96. label: "联系人",
  97. value: res.data.name
  98. }, {
  99. label: "手机号码",
  100. value: res.data.phonenumber
  101. }, {
  102. label: "省市县",
  103. value: res.data.province ? res.data.province + res.data.city + res.data.county : ''
  104. }, {
  105. label: "地址",
  106. value: res.data.address
  107. }, {
  108. label: "项目名称",
  109. value: res.data.projectname
  110. }, {
  111. label: "项目规模",
  112. value: res.data.scale
  113. }, {
  114. label: "总投资额(万元)",
  115. value: res.data.totalinvestment
  116. }, {
  117. label: "造价(万元)",
  118. value: res.data.costofconstruction
  119. }, {
  120. label: "预计开工时间",
  121. value: res.data.begdate_due
  122. }, {
  123. label: "预计完工时间",
  124. value: res.data.enddate_due
  125. }, {
  126. label: "市场活动",
  127. value: res.data.campaign_name
  128. }, {
  129. label: "领域",
  130. value: res.data.tradefield
  131. }, {
  132. label: "来源",
  133. value: res.data.cluesource
  134. }, {
  135. label: "线索概括",
  136. value: res.data.notes
  137. }, {
  138. label: '所属业务员',
  139. value: res.data.salename
  140. }, {
  141. label: '负责人',
  142. value: res.data.leader && res.data.leader.length > 0 ? res.data.leader[0].name : ''
  143. }, {
  144. label: '分配状态',
  145. value: res.data.allocationstatus
  146. }, {
  147. label: '跟进状态',
  148. value: res.data.status
  149. }],
  150. list2: [{
  151. label: "创建人",
  152. value: res.data.createBy
  153. }, {
  154. label: "创建时间",
  155. value: res.data.createDate
  156. }, {
  157. label: "分配人",
  158. value: res.data.assignedBy
  159. }, {
  160. label: "分配时间",
  161. value: res.data.assignedDate
  162. }, {
  163. label: "分配人",
  164. value: res.data.assignedBy
  165. }, {
  166. label: "分配时间",
  167. value: res.data.assignedDate
  168. }, {
  169. label: "最近跟进人",
  170. value: res.data.followBy
  171. }, {
  172. label: "最近跟进时间",
  173. value: res.data.followDate
  174. }, {
  175. label: "最近编辑人",
  176. value: res.data.editBy
  177. }, {
  178. label: "最近编辑时间",
  179. value: res.data.editDate
  180. }, {
  181. label: "无效原因",
  182. value: res.data.invalidreason
  183. }, {
  184. label: "作废原因",
  185. value: res.data.deletereason
  186. }, {
  187. label: "跟进次数",
  188. value: res.data.followcount
  189. }],
  190. tabsList: this.data.tabsList,
  191. });
  192. /* {
  193. label: "转移人",
  194. value: res.data.changeBy
  195. }, {
  196. label: "最近转移时间",
  197. value: res.data.changeDate
  198. } */
  199. var arr = this.data.tabbarList
  200. if (res.data.status != '待跟进') {
  201. arr = arr.filter(item => {
  202. return item.label != '编辑' && item.label != '撤回'
  203. })
  204. }
  205. /* 更新列表中状态 */
  206. let page = getCurrentPages().find(v => v.__route__ == 'packageA/publicClue/index');
  207. if (page) {
  208. let index = page.data.list.findIndex(v => v.sat_orderclueid == res.data.sat_orderclueid);
  209. if (index != -1) page.setData({
  210. [`list[${index}].status`]: res.data.status
  211. })
  212. }
  213. this.setData({
  214. tabbarList: arr
  215. })
  216. this.getTags();
  217. this.partialRenewal();
  218. })
  219. },
  220. //tabs 切换
  221. tabsChange({
  222. detail
  223. }) {
  224. this.setData({
  225. tabsActive: detail
  226. });
  227. this.partialRenewal();
  228. },
  229. //更新标签
  230. getTags() {
  231. this.selectComponent("#Tags").getTags();
  232. },
  233. //局部数据更新 tabs
  234. partialRenewal(init = false) {
  235. let id = this.data.detail.sat_orderclueid;
  236. let model = '';
  237. let name = this.data.tabsList[this.data.tabsActive].label;
  238. switch (name) {
  239. case "任务":
  240. model = "#Work"
  241. break;
  242. case "跟进记录":
  243. model = "#follow"
  244. break;
  245. case "操作":
  246. model = "#Record"
  247. break;
  248. case "跟进动态":
  249. model = "#Trace"
  250. break;
  251. case "附件":
  252. model = "#Files"
  253. break;
  254. };
  255. if (model) {
  256. // 确定好模块ID total = null 是第一次加载 加载数据
  257. // init是新增或修改需要清数据
  258. let Component = this.selectComponent(model);
  259. const {
  260. total,
  261. pageNumber,
  262. pageTotal
  263. } = Component.data.content;
  264. if (total == null || init) {
  265. Component.getList(id, init);
  266. } else if (pageNumber <= pageTotal) {
  267. Component.getList(id, false);
  268. } else {
  269. //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据
  270. }
  271. }
  272. },
  273. onReachBottom() {
  274. this.partialRenewal();
  275. },
  276. //详情按钮回调
  277. tabbarOnClick({
  278. detail
  279. }) {
  280. let data = this.data.detail,
  281. that = this;
  282. switch (detail.label) {
  283. case "编辑":
  284. wx.navigateTo({
  285. url: `/packageA/publicClue/addClue?rowData=${JSON.stringify(this.data.detail)}`,
  286. })
  287. break;
  288. case "分配":
  289. wx.navigateTo({
  290. url: `/packageA/publicClue/distribution?data=${JSON.stringify(this.data.detail)}`,
  291. })
  292. break;
  293. case "删除":
  294. wx.showModal({
  295. title: '提示',
  296. content: `是否确认删除该线索?`,
  297. complete: ({
  298. confirm
  299. }) => {
  300. if (confirm) _Http.basic({
  301. "id": 20221101100502,
  302. "content": {
  303. "sat_orderclueids": [this.data.detail.sat_orderclueid]
  304. }
  305. }).then(res => {
  306. wx.showToast({
  307. title: res.msg == '成功' ? `操作成功` : res.msg,
  308. icon: "none"
  309. });
  310. setTimeout(() => {
  311. wx.navigateBack()
  312. getCurrentPages().forEach(v => {
  313. if (v.__route__ == "packageA/publicClue/index") {
  314. v.getList(true)
  315. }
  316. })
  317. }, 300)
  318. })
  319. }
  320. })
  321. break;
  322. case "撤回":
  323. wx.showModal({
  324. title: '提示',
  325. content: `是否确认撤回该线索?`,
  326. complete: ({
  327. confirm
  328. }) => {
  329. if (confirm) _Http.basic({
  330. classname: "webmanage.saletool.orderclue.publicclue.PublicClue",
  331. method: "revoke",
  332. "content": {
  333. "sat_orderclueid": this.data.detail.sat_orderclueid
  334. }
  335. }).then(res => {
  336. setTimeout(() => {
  337. wx.showToast({
  338. title: res.msg == '成功' ? `操作成功` : res.msg,
  339. icon: "none"
  340. });
  341. }, 1000)
  342. if (res.msg == '成功') this.getDetail()
  343. })
  344. }
  345. })
  346. break;
  347. case "更换负责人":
  348. wx.navigateTo({
  349. url: `/pages/group/select?data=${JSON.stringify({
  350. ownertable:"sat_orderclue",
  351. ownerid:data.sat_orderclueid,
  352. })}&radio=true&principal=true`,
  353. })
  354. break;
  355. }
  356. },
  357. /* 更换负责人 */
  358. handelSubmit(arr) {
  359. const that = this;
  360. wx.showModal({
  361. title: '提示',
  362. content: '是否确认更换负责人',
  363. complete: ({
  364. confirm
  365. }) => {
  366. if (confirm) _Http.basic({
  367. "id": 20220930103701,
  368. "content": {
  369. ownertable: "sat_orderclue",
  370. ownerid: that.data.detail.sat_orderclueid,
  371. userid: arr[0]
  372. }
  373. }).then(res => {
  374. console.log("更换负责人", res)
  375. if (res.msg != '成功') return wx.showToast({
  376. title: res.data,
  377. icon: "none"
  378. });
  379. wx.showToast({
  380. title: '更换成功!',
  381. icon: "none"
  382. });
  383. setTimeout(() => {
  384. that.getDetail();
  385. wx.navigateBack();
  386. /* getCurrentPages().forEach(v => {
  387. if (['packageA/project/index'].includes(v.__route__)) v.getList(true)
  388. }) */
  389. }, 300)
  390. })
  391. }
  392. })
  393. },
  394. onShareAppMessage() {}
  395. })