detail.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. tabsActive: 0, //tabs 选中项
  5. sa_projectid: "",
  6. tabsList: [{
  7. label: "详细信息",
  8. num: 132
  9. }, {
  10. label: "阶段任务",
  11. num: 132
  12. }, {
  13. label: "跟进动态",
  14. num: 132
  15. }, {
  16. label: "关联客户",
  17. num: 132
  18. }, {
  19. label: "联系人",
  20. num: 132
  21. }],
  22. tabbarList: [{
  23. icon: "icon-genjin",
  24. label: "报备"
  25. }, {
  26. icon: "icon-genjin",
  27. label: "跟进"
  28. }, {
  29. icon: "icon-bianji",
  30. label: "编辑"
  31. }, {
  32. icon: "icon-zhuanyi",
  33. label: "更换负责人"
  34. }, {
  35. icon: "icon-shanchu",
  36. label: "作废"
  37. }],
  38. },
  39. onLoad(options) {
  40. this.setData({
  41. sa_projectid: options.sa_projectid
  42. });
  43. this.getDetail()
  44. },
  45. getDetail() {
  46. _Http.basic({
  47. "id": 20221021103902,
  48. "content": {
  49. "sa_projectid": this.data.sa_projectid
  50. },
  51. }).then(res => {
  52. console.log("项目商机详情", res)
  53. if (res.msg != '成功') return wx.showToast({
  54. title: res.data,
  55. icon: "none"
  56. });
  57. this.setData({
  58. detail: res.data,
  59. briefs: [{
  60. label: "项目编号",
  61. value: res.data.projectnum
  62. }, {
  63. label: "项目地址",
  64. value: res.data.province + res.data.city + res.data.county + res.data.address
  65. }, {
  66. label: "项目类型",
  67. value: res.data.projecttype
  68. }, {
  69. label: "负责人",
  70. value: res.data.name
  71. }, {
  72. label: "当前项目阶段",
  73. value: res.data.stagename
  74. }, {
  75. label: "赢率",
  76. value: res.data.winrate
  77. }, {
  78. label: "最近跟进时间",
  79. value: res.data.followdate
  80. }],
  81. list1: [{
  82. label: "项目名称",
  83. value: res.data.projectname
  84. }, {
  85. label: "项目编号",
  86. value: res.data.projectnum
  87. }, {
  88. label: "项目类型",
  89. value: res.data.projecttype
  90. }, {
  91. label: "省市县",
  92. value: res.data.province ? res.data.province + res.data.city + res.data.county : ''
  93. }, {
  94. label: "详细地址",
  95. value: res.data.address
  96. }, {
  97. label: "项目等级",
  98. value: res.data.grade
  99. }, {
  100. label: "当前阶段",
  101. value: res.data.stagename
  102. }, {
  103. label: "项目报备时间",
  104. value: res.data.createdate
  105. }, {
  106. label: "项目规模",
  107. value: res.data.scale
  108. }, {
  109. label: "项目状态",
  110. value: res.data.status
  111. }, {
  112. label: "项目预算",
  113. value: res.data.budgetary
  114. }, {
  115. label: "预计签约金额",
  116. value: res.data.signamount_due
  117. }, {
  118. label: "预计签约月份",
  119. value: res.data.signdate_due
  120. }, {
  121. label: "赢率",
  122. value: res.data.winrate
  123. }, {
  124. label: "负责人",
  125. value: res.data.name
  126. }],
  127. list2: [{
  128. label: "创建人",
  129. value: res.data.createby
  130. }, {
  131. label: "创建时间",
  132. value: res.data.createdate
  133. }, {
  134. label: "最近编辑人",
  135. value: res.data.changeby
  136. }, {
  137. label: "最近编辑时间",
  138. value: res.data.changedate
  139. }, {
  140. label: "最近跟进人",
  141. value: res.data.followby
  142. }, {
  143. label: "最近跟进时间",
  144. value: res.data.followdate
  145. }, {
  146. label: "转手次数",
  147. value: res.data.changecount
  148. }, {
  149. label: "报备人",
  150. value: res.data.reportby
  151. }, {
  152. label: "报备时间",
  153. value: res.data.reportdate
  154. }, {
  155. label: "报备审核通过时间",
  156. value: res.data.reportcheckdate
  157. }]
  158. })
  159. //更新列表赢率
  160. getCurrentPages().forEach(v => {
  161. if (v.__route__ == 'packageA/project/index') {
  162. let i = v.data.list.findIndex(e => e.sa_projectid == this.data.sa_projectid);
  163. if (i != -1) v.setData({
  164. [`list[${i}].winrate`]: parseFloat(res.data.winrate.substring(0, res.data.winrate.length - 1))
  165. })
  166. }
  167. })
  168. this.getTags();
  169. this.getGroup();
  170. this.partialRenewal();
  171. })
  172. },
  173. //tabs 切换
  174. tabsChange({
  175. detail
  176. }) {
  177. this.setData({
  178. tabsActive: detail
  179. });
  180. this.partialRenewal();
  181. },
  182. //更新标签
  183. getTags() {
  184. this.selectComponent("#Tags").getTags();
  185. },
  186. //更新团队成员
  187. getGroup() {
  188. this.selectComponent("#Group").getList();
  189. },
  190. //局部数据更新 tabs
  191. partialRenewal(init = false) {
  192. const id = this.data.detail.sa_projectid;
  193. let model = '';
  194. let name = this.data.tabsList[this.data.tabsActive].label;
  195. switch (name) {
  196. case "跟进动态":
  197. model = "#Trace"
  198. break;
  199. case "阶段任务":
  200. model = '#Task'
  201. break;
  202. case "关联客户":
  203. model = "#Treaty"
  204. break;
  205. case "联系人":
  206. model = "#Contacts"
  207. break;
  208. };
  209. if (model) {
  210. // 确定好模块ID total = null 是第一次加载 加载数据
  211. // init是新增或修改需要清数据
  212. let Component = this.selectComponent(model);
  213. const {
  214. total,
  215. pageNumber,
  216. pageTotal
  217. } = Component.data.content;
  218. if (total == null || init) {
  219. Component.getList(id, init);
  220. } else if (pageNumber <= pageTotal) {
  221. Component.getList(id, false);
  222. } else {
  223. //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据
  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/setclient/modules/trace/add/index?ownertable=sa_project&ownerid=${data.sa_projectid}`,
  239. })
  240. break;
  241. case "编辑":
  242. wx.navigateTo({
  243. url: `/packageA/project/addAndEdit?data=${JSON.stringify(data)}`,
  244. })
  245. break;
  246. case "作废":
  247. wx.navigateTo({
  248. url: `/packageA/project/delete?id=${this.data.detail.sa_projectid}`,
  249. })
  250. break;
  251. case "更换负责人":
  252. wx.navigateTo({
  253. url: `/packageA/group/select?data=${JSON.stringify({
  254. ownertable:"sa_project",
  255. ownerid:data.sa_projectid,
  256. })}&radio=true&principal=true`,
  257. })
  258. break;
  259. case "报备":
  260. console.log(detail)
  261. _Http.basic({
  262. "id": 20221114163402,
  263. "content": {
  264. "sa_projectid": data.sa_projectid,
  265. "tag": "报备中"
  266. }
  267. }).then(res => {
  268. if (res.msg != '成功') return wx.showToast({
  269. title: res.data,
  270. icon: "none"
  271. });
  272. this.getTags();
  273. setTimeout(() => {
  274. wx.showToast({
  275. title: '已提交报备!',
  276. icon: "none"
  277. })
  278. }, 200)
  279. })
  280. break;
  281. default:
  282. console.log(detail)
  283. break;
  284. }
  285. },
  286. /* 更换负责人 */
  287. handelSubmit(arr) {
  288. const that = this;
  289. wx.showModal({
  290. title: '提示',
  291. content: '是否确认更换负责人',
  292. complete: ({
  293. confirm
  294. }) => {
  295. if (confirm) _Http.basic({
  296. "id": 20220930103701,
  297. "content": {
  298. ownertable: "sa_project",
  299. ownerid: that.data.detail.sa_projectid,
  300. userid: arr[0]
  301. }
  302. }).then(res => {
  303. console.log("更换负责人", res)
  304. if (res.msg != '成功') return wx.showToast({
  305. title: res.data,
  306. icon: "none"
  307. });
  308. wx.showToast({
  309. title: '更换成功!',
  310. icon: "none"
  311. });
  312. setTimeout(() => {
  313. that.getDetail();
  314. getCurrentPages().forEach(v => {
  315. if (['packageA/project/index'].includes(v.__route__)) v.getList(true)
  316. })
  317. wx.navigateBack();
  318. }, 300)
  319. })
  320. }
  321. })
  322. },
  323. onShareAppMessage() {
  324. }
  325. })