detail.js 12 KB

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