detail.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Page({
  8. data: {
  9. isLeader: false, //是否为负责人
  10. tabsActive: 0, //tabs 选中项
  11. sa_projectid: "",
  12. tabsList: [{
  13. label: "详细信息",
  14. icon: "icon-tabxiangxixinxi1"
  15. }, {
  16. label: "关联客户",
  17. icon: "icon-tabkehu",
  18. model: "#Treaty"
  19. }, {
  20. label: "联系人",
  21. icon: "icon-tablianxiren",
  22. model: "#Contacts"
  23. }, {
  24. label: "产品配置单",
  25. icon: "icon-tabchanpin",
  26. model: "#Product"
  27. }, {
  28. label: "报价单",
  29. icon: "icon-tabbaojiadan",
  30. model: "#Offers"
  31. }, {
  32. label: "竞争对手",
  33. icon: "icon-tabjingzhengduishou",
  34. model: "#Opponent"
  35. }, {
  36. label: "合同",
  37. icon: "icon-tabhetong",
  38. model: "#Contract"
  39. }, {
  40. label: "关联线索",
  41. icon: "icon-tabxiansuo",
  42. model: "#Clue"
  43. }, {
  44. label: "项目评估",
  45. icon: "icon-tabxiangmupinggu",
  46. model: "#Task"
  47. }, {
  48. label: "任务",
  49. icon: "icon-tabrenwu",
  50. model: "#Work"
  51. }, {
  52. label: "附件",
  53. icon: "icon-tabfujian1",
  54. model: "#Files"
  55. }, {
  56. label: "操作记录",
  57. icon: "icon-tabcaozuojilu1",
  58. model: "#Record"
  59. }, {
  60. label: "跟进动态",
  61. icon: "icon-tabgenjinjilu",
  62. model: "#Trace"
  63. }],
  64. tabbarList: [],
  65. },
  66. onLoad(options) {
  67. this.setData({
  68. sa_projectid: options.id,
  69. isAdmin: wx.getStorageSync('auth').wproject.options.some(v => v == "admin"), //是否具有管理权限
  70. options: wx.getStorageSync('auth').wproject.options, //权限列表
  71. });
  72. this.getDetail(true)
  73. },
  74. getDetail(init = false) {
  75. _Http.basic({
  76. "id": 20221021103902,
  77. "content": {
  78. nocache: true,
  79. "sa_projectid": this.data.sa_projectid
  80. },
  81. }).then(res => {
  82. console.log("项目商机详情", res)
  83. if (res.msg != '成功') return wx.showToast({
  84. title: res.data,
  85. icon: "none"
  86. });
  87. this.setPreview(res.data);
  88. if (init) {
  89. this.getTags();
  90. this.getGroup();
  91. this.selectComponent("#TaskTabs").getList();
  92. }
  93. this.partialRenewal(init);
  94. })
  95. },
  96. /* 设置显示信息 */
  97. setPreview(data) {
  98. let isLeader = data.leader.some(some => some.userid == wx.getStorageSync('userMsg').userid),
  99. tabbarList = [{
  100. icon: "icon-genjin",
  101. label: "跟进"
  102. }];
  103. if (this.data.isAdmin) tabbarList = [{
  104. icon: "icon-genjin",
  105. label: "报备审核"
  106. }, {
  107. icon: "icon-genjin",
  108. label: "报备驳回(退回)"
  109. }].concat(tabbarList);
  110. if (isLeader || this.data.isAdmin) {
  111. if (data.status != '已失败') tabbarList = tabbarList.concat([{
  112. icon: "icon-bianji",
  113. label: "编辑"
  114. }, {
  115. icon: "icon-genjin",
  116. label: "提交报备"
  117. }, {
  118. icon: "icon-zhuanyi",
  119. label: "更换负责人"
  120. }])
  121. tabbarList.push({
  122. icon: "icon-shanchu",
  123. label: "作废"
  124. })
  125. tabbarList.push(data.status == '已失败' ? {
  126. icon: "icon-dibu-chehui",
  127. label: "恢复"
  128. } : {
  129. icon: "icon-dibu-jieshu",
  130. label: "结束"
  131. })
  132. }
  133. data.signamount_due = CNY(data.signamount_due);
  134. this.setData({
  135. isLeader,
  136. tabbarList,
  137. detail: data,
  138. briefs: [{
  139. label: "项目编号",
  140. value: data.projectnum
  141. }, {
  142. label: "项目等级",
  143. value: data.grade
  144. }, {
  145. label: "项目类型",
  146. value: data.projecttype
  147. }, {
  148. label: "项目阶段",
  149. value: data.stagename
  150. }, {
  151. label: "赢率",
  152. value: data.winrate ? data.winrate + "%" : data.winrate
  153. }],
  154. list1: [{
  155. label: "项目编号",
  156. value: data.projectnum
  157. }, {
  158. label: "项目名称",
  159. value: data.projectname
  160. }, {
  161. label: "项目类型",
  162. value: data.projecttype
  163. }, {
  164. label: "项目阶段",
  165. value: data.stagename
  166. }, {
  167. label: "项目等级",
  168. value: data.grade
  169. }, {
  170. label: "省市县",
  171. value: data.province ? data.province + data.city + data.county : ''
  172. }, {
  173. label: "地址",
  174. value: data.address
  175. }, {
  176. label: "项目规模",
  177. value: data.scale
  178. }, {
  179. label: "项目预算(万元)",
  180. value: CNY(data.budgetary)
  181. },
  182. {
  183. label: "总投资额(万元)",
  184. value: CNY(data.totalinvestment)
  185. },
  186. {
  187. label: "造价(万元)",
  188. value: CNY(data.costofconstruction)
  189. },
  190. {
  191. label: "预计开工时间",
  192. value: data.begdate_due
  193. },
  194. {
  195. label: "预计完工时间",
  196. value: data.enddate_due
  197. }, {
  198. label: "预计签约时间",
  199. value: data.signdate_due
  200. }, {
  201. label: "预计签约金额(元)",
  202. value: data.signamount_due
  203. }, {
  204. label: "领域",
  205. value: data.tradefields
  206. }, {
  207. label: "品牌",
  208. value: data.brandname
  209. }, {
  210. label: "赢率",
  211. value: data.winrate
  212. }, {
  213. label: "项目状态",
  214. value: data.status
  215. }, {
  216. label: "负责人",
  217. value: data.name
  218. }
  219. ],
  220. list2: [{
  221. label: "创建人",
  222. value: data.createby
  223. }, {
  224. label: "创建时间",
  225. value: data.createdate
  226. }, {
  227. label: "最近编辑人",
  228. value: data.changeby
  229. }, {
  230. label: "最近编辑时间",
  231. value: data.changedate
  232. }, {
  233. label: "提交报备人",
  234. value: data.reportby
  235. }, {
  236. label: "提交报备时间",
  237. value: data.reportdate
  238. }, {
  239. label: "报备审核人",
  240. value: data.reportcheckby
  241. }, {
  242. label: "报备审核时间",
  243. value: data.reportcheckdate
  244. }, {
  245. label: "作废原因",
  246. value: data.deletereason
  247. }, {
  248. label: "转手次数",
  249. value: data.changecount
  250. }]
  251. })
  252. },
  253. //详情按钮回调
  254. tabbarOnClick({
  255. detail
  256. }) {
  257. let data = this.data.detail,
  258. that = this;
  259. switch (detail.label) {
  260. case "结束":
  261. if (data.status != '跟进中') return wx.showToast({
  262. title: '当前状态不可结束',
  263. icon: "none"
  264. });
  265. wx.showModal({
  266. title: '提示',
  267. content: '是否确认结束项目',
  268. complete: ({
  269. confirm
  270. }) => {
  271. if (confirm) _Http.basic({
  272. "id": 20221215163702,
  273. "content": {
  274. "sa_projectid": data.sa_projectid
  275. }
  276. }).then(res => {
  277. console.log('结束', res)
  278. wx.showToast({
  279. title: res.msg == '成功' ? '已结束' : res.msg,
  280. icon: "none"
  281. });
  282. if (res.msg == '成功') setTimeout(this.getDetail, 300);
  283. })
  284. }
  285. })
  286. break;
  287. case "恢复":
  288. if (data.status != '已失败') return wx.showToast({
  289. title: '失败项目才可恢复!',
  290. icon: "none"
  291. });
  292. wx.showModal({
  293. title: '提示',
  294. content: '是否确认恢复项目',
  295. complete: ({
  296. confirm
  297. }) => {
  298. if (confirm) _Http.basic({
  299. "id": 20221215164002,
  300. "content": {
  301. "sa_projectid": data.sa_projectid
  302. }
  303. }).then(res => {
  304. console.log('恢复', res)
  305. wx.showToast({
  306. title: res.msg == '成功' ? '已恢复' : res.msg,
  307. icon: "none"
  308. });
  309. if (res.msg == '成功') setTimeout(this.getDetail, 300);
  310. })
  311. }
  312. })
  313. break;
  314. case "提交报备":
  315. wx.showModal({
  316. title: '提示',
  317. content: '是否确认提交项目审核',
  318. complete: ({
  319. confirm
  320. }) => {
  321. if (confirm) that.handleReport(1)
  322. }
  323. })
  324. break;
  325. case "报备审核":
  326. wx.showModal({
  327. title: '提示',
  328. content: '是否确认审核项目',
  329. complete: ({
  330. confirm
  331. }) => {
  332. if (confirm) that.handleReport(2)
  333. }
  334. })
  335. break;
  336. case "报备驳回(退回)":
  337. wx.showModal({
  338. title: '提示',
  339. content: '是否确认报备驳回(退回)项目',
  340. complete: ({
  341. confirm
  342. }) => {
  343. if (confirm) that.handleReport(3)
  344. }
  345. })
  346. break;
  347. case "跟进":
  348. wx.navigateTo({
  349. url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_project&ownerid=${data.sa_projectid}`,
  350. })
  351. break;
  352. case "编辑":
  353. let tags = that.selectComponent("#Tags").data.systemtag;
  354. wx.navigateTo({
  355. url: `/packageA/project/addAndEdit?data=${JSON.stringify(data)}&disabled=${tags.includes("报备中")||tags.includes("已报备")}`,
  356. })
  357. break;
  358. case "作废":
  359. wx.navigateTo({
  360. url: `/packageA/project/delete?id=${this.data.detail.sa_projectid}`,
  361. })
  362. break;
  363. case "更换负责人":
  364. wx.navigateTo({
  365. url: `/pages/group/select?data=${JSON.stringify({
  366. ownertable:"sa_project",
  367. ownerid:data.sa_projectid,
  368. })}&radio=true&principal=true`,
  369. })
  370. break;
  371. default:
  372. console.log(detail)
  373. break;
  374. }
  375. },
  376. /* 1提交报备,2报备审核,3报备驳回(退回) */
  377. handleReport(type) {
  378. _Http.basic({
  379. "id": 20221114163402,
  380. "content": {
  381. "sa_projectid": this.data.sa_projectid,
  382. type
  383. }
  384. }).then(res => {
  385. console.log("报备", type, res)
  386. wx.showToast({
  387. title: res.data == '失败' ? res.msg : "操作成功",
  388. icon: "none",
  389. mask: true
  390. })
  391. if (res.data != '失败') {
  392. if (type != 1) {
  393. this.getDetail();
  394. } else {
  395. this.getTags();
  396. }
  397. }
  398. })
  399. },
  400. //局部数据更新 tabs
  401. partialRenewal(init = false) {
  402. let model = this.data.tabsList[this.data.tabsActive].model;
  403. if (model) {
  404. let Component = this.selectComponent(model),
  405. {
  406. total,
  407. pageNumber,
  408. pageTotal
  409. } = Component.data.content,
  410. id = this.data.sa_projectid;
  411. if (total == null || init) {
  412. Component.getList(id, init);
  413. } else if (pageNumber < pageTotal) {
  414. Component.getList(id, false);
  415. }
  416. }
  417. },
  418. onReachBottom() {
  419. this.partialRenewal();
  420. },
  421. /* 项目评估切换 */
  422. taskTabsChange({
  423. detail
  424. }) {
  425. if (detail.change) {
  426. this.setData({
  427. tabsActive: this.data.tabsList.findIndex(v => v.label == '项目评估')
  428. });
  429. this.selectComponent("#Task").getList(this.data.sa_projectid, true)
  430. }
  431. },
  432. //tabs 切换
  433. tabsChange({
  434. detail
  435. }) {
  436. this.setData({
  437. tabsActive: detail
  438. });
  439. this.partialRenewal();
  440. },
  441. /* 更换负责人 */
  442. handelSubmit(arr) {
  443. const that = this;
  444. wx.showModal({
  445. title: '提示',
  446. content: '是否确认更换负责人',
  447. complete: ({
  448. confirm
  449. }) => {
  450. if (confirm) _Http.basic({
  451. "id": 20220930103701,
  452. "content": {
  453. ownertable: "sa_project",
  454. ownerid: that.data.detail.sa_projectid,
  455. userid: arr[0]
  456. }
  457. }).then(res => {
  458. wx.showToast({
  459. title: res.msg != '成功' ? res.data : '更换成功',
  460. icon: "none",
  461. mask: true
  462. });
  463. if (res.msg == '成功') setTimeout(() => {
  464. that.getDetail(true);
  465. wx.navigateBack();
  466. }, 300)
  467. })
  468. }
  469. })
  470. },
  471. //更新标签
  472. getTags() {
  473. this.selectComponent("#Tags").getTags();
  474. },
  475. //更新团队成员
  476. getGroup() {
  477. this.selectComponent("#Group").getList();
  478. },
  479. /* tag更新列表 */
  480. onGetList(e) {
  481. if (e.detail.data.systemtag.includes('报备中')) this.setData({
  482. tabbarList: this.data.tabbarList.filter(v => v.label != '提交报备')
  483. })
  484. },
  485. onUnload() {
  486. const page = getCurrentPages().find(v => v.__route__ == 'packageA/project/index');
  487. if (!page) return;
  488. let content = JSON.parse(JSON.stringify(page.data.content));
  489. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  490. content.pageNumber = 1;
  491. _Http.basic({
  492. id: 20221020143502,
  493. content
  494. }).then(res => {
  495. console.log("更新项目商机列表", res);
  496. if (res.msg == '成功') {
  497. page.data.list = res.data;
  498. page.data.content.total = res.total;
  499. page.setListHeight();
  500. page.getTags();
  501. }
  502. })
  503. }
  504. })