detail.js 14 KB

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