detail.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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. 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. icon: "icon-shanchu",
  122. label: "作废"
  123. }])
  124. tabbarList.push(data.status == '已失败' ? {
  125. icon: "icon-dibu-chehui",
  126. label: "恢复"
  127. } : {
  128. icon: "icon-dibu-jieshu",
  129. label: "结束"
  130. })
  131. }
  132. data.signamount_due = CNY(data.signamount_due);
  133. this.setData({
  134. isLeader,
  135. tabbarList,
  136. detail: data,
  137. briefs: [{
  138. label: "项目编号",
  139. value: data.projectnum
  140. }, {
  141. label: "项目等级",
  142. value: data.grade
  143. }, {
  144. label: "项目类型",
  145. value: data.projecttype
  146. }, {
  147. label: "项目阶段",
  148. value: data.stagename
  149. }, {
  150. label: "赢率",
  151. value: data.winrate ? data.winrate + "%" : data.winrate
  152. }],
  153. list1: [{
  154. label: "项目编号",
  155. value: data.projectnum
  156. }, {
  157. label: "项目名称",
  158. value: data.projectname
  159. }, {
  160. label: "项目类型",
  161. value: data.projecttype
  162. }, {
  163. label: "项目阶段",
  164. value: data.stagename
  165. }, {
  166. label: "项目等级",
  167. value: data.grade
  168. }, {
  169. label: "省市县",
  170. value: data.province ? data.province + data.city + data.county : ''
  171. }, {
  172. label: "地址",
  173. value: data.address
  174. }, {
  175. label: "项目规模",
  176. value: data.scale
  177. }, {
  178. label: "项目预算(万元)",
  179. value: CNY(data.budgetary)
  180. },
  181. {
  182. label: "总投资额(万元)",
  183. value: CNY(data.totalinvestment)
  184. },
  185. {
  186. label: "造价(万元)",
  187. value: CNY(data.costofconstruction)
  188. },
  189. {
  190. label: "预计开工时间",
  191. value: data.begdate_due
  192. },
  193. {
  194. label: "预计完工时间",
  195. value: data.enddate_due
  196. }, {
  197. label: "预计签约时间",
  198. value: data.signdate_due
  199. }, {
  200. label: "预计签约金额(元)",
  201. value: data.signamount_due
  202. }, {
  203. label: "领域",
  204. value: data.tradefields
  205. }, {
  206. label: "品牌",
  207. value: data.brandname
  208. }, {
  209. label: "赢率",
  210. value: data.winrate
  211. }, {
  212. label: "项目状态",
  213. value: data.status
  214. }, {
  215. label: "负责人",
  216. value: data.name
  217. }
  218. ],
  219. list2: [{
  220. label: "创建人",
  221. value: data.createby
  222. }, {
  223. label: "创建时间",
  224. value: data.createdate
  225. }, {
  226. label: "最近编辑人",
  227. value: data.changeby
  228. }, {
  229. label: "最近编辑时间",
  230. value: data.changedate
  231. }, {
  232. label: "提交报备人",
  233. value: data.reportby
  234. }, {
  235. label: "提交报备时间",
  236. value: data.reportdate
  237. }, {
  238. label: "报备审核人",
  239. value: data.reportcheckby
  240. }, {
  241. label: "报备审核时间",
  242. value: data.reportcheckdate
  243. }, {
  244. label: "作废原因",
  245. value: data.deletereason
  246. }, {
  247. label: "转手次数",
  248. value: data.changecount
  249. }]
  250. })
  251. },
  252. //详情按钮回调
  253. tabbarOnClick({
  254. detail
  255. }) {
  256. let data = this.data.detail,
  257. that = this;
  258. switch (detail.label) {
  259. case "结束":
  260. if (data.status != '跟进中') return wx.showToast({
  261. title: '当前状态不可结束',
  262. icon: "none"
  263. });
  264. wx.showModal({
  265. title: '提示',
  266. content: '是否确认结束项目',
  267. complete: ({
  268. confirm
  269. }) => {
  270. if (confirm) _Http.basic({
  271. "id": 20221215163702,
  272. "content": {
  273. "sa_projectid": data.sa_projectid
  274. }
  275. }).then(res => {
  276. console.log('结束', res)
  277. wx.showToast({
  278. title: res.msg == '成功' ? '已结束' : res.msg,
  279. icon: "none"
  280. });
  281. if (res.msg == '成功') setTimeout(this.getDetail, 300);
  282. })
  283. }
  284. })
  285. break;
  286. case "恢复":
  287. if (data.status != '已失败') return wx.showToast({
  288. title: '失败项目才可恢复!',
  289. icon: "none"
  290. });
  291. wx.showModal({
  292. title: '提示',
  293. content: '是否确认恢复项目',
  294. complete: ({
  295. confirm
  296. }) => {
  297. if (confirm) _Http.basic({
  298. "id": 20221215164002,
  299. "content": {
  300. "sa_projectid": data.sa_projectid
  301. }
  302. }).then(res => {
  303. console.log('恢复', res)
  304. wx.showToast({
  305. title: res.msg == '成功' ? '已恢复' : res.msg,
  306. icon: "none"
  307. });
  308. if (res.msg == '成功') setTimeout(this.getDetail, 300);
  309. })
  310. }
  311. })
  312. break;
  313. case "提交报备":
  314. wx.showModal({
  315. title: '提示',
  316. content: '是否确认提交项目审核',
  317. complete: ({
  318. confirm
  319. }) => {
  320. if (confirm) that.handleReport(1)
  321. }
  322. })
  323. break;
  324. case "报备审核":
  325. wx.showModal({
  326. title: '提示',
  327. content: '是否确认审核项目',
  328. complete: ({
  329. confirm
  330. }) => {
  331. if (confirm) that.handleReport(2)
  332. }
  333. })
  334. break;
  335. case "报备驳回(退回)":
  336. wx.showModal({
  337. title: '提示',
  338. content: '是否确认报备驳回(退回)项目',
  339. complete: ({
  340. confirm
  341. }) => {
  342. if (confirm) that.handleReport(3)
  343. }
  344. })
  345. break;
  346. case "跟进":
  347. wx.navigateTo({
  348. url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_project&ownerid=${data.sa_projectid}`,
  349. })
  350. break;
  351. case "编辑":
  352. let tags = that.selectComponent("#Tags").data.systemtag;
  353. wx.navigateTo({
  354. url: `/packageA/project/addAndEdit?data=${JSON.stringify(data)}&disabled=${tags.includes("报备中")||tags.includes("已报备")}`,
  355. })
  356. break;
  357. case "作废":
  358. wx.navigateTo({
  359. url: `/packageA/project/delete?id=${this.data.detail.sa_projectid}`,
  360. })
  361. break;
  362. case "更换负责人":
  363. wx.navigateTo({
  364. url: `/pages/group/select?data=${JSON.stringify({
  365. ownertable:"sa_project",
  366. ownerid:data.sa_projectid,
  367. })}&radio=true&principal=true`,
  368. })
  369. break;
  370. default:
  371. console.log(detail)
  372. break;
  373. }
  374. },
  375. /* 1提交报备,2报备审核,3报备驳回(退回) */
  376. handleReport(type) {
  377. _Http.basic({
  378. "id": 20221114163402,
  379. "content": {
  380. "sa_projectid": this.data.sa_projectid,
  381. type
  382. }
  383. }).then(res => {
  384. console.log("报备", type, res)
  385. wx.showToast({
  386. title: res.data == '失败' ? res.msg : "操作成功",
  387. icon: "none",
  388. mask: true
  389. })
  390. if (res.data != '失败') this.getDetail();
  391. })
  392. },
  393. //局部数据更新 tabs
  394. partialRenewal(init = false) {
  395. let model = this.data.tabsList[this.data.tabsActive].model;
  396. if (model) {
  397. let Component = this.selectComponent(model),
  398. {
  399. total,
  400. pageNumber,
  401. pageTotal
  402. } = Component.data.content,
  403. id = this.data.sa_projectid;
  404. if (total == null || init) {
  405. Component.getList(id, init);
  406. } else if (pageNumber < pageTotal) {
  407. Component.getList(id, false);
  408. }
  409. }
  410. },
  411. onReachBottom() {
  412. this.partialRenewal();
  413. },
  414. /* 项目评估切换 */
  415. taskTabsChange({
  416. detail
  417. }) {
  418. if (detail.change) {
  419. this.setData({
  420. tabsActive: this.data.tabsList.findIndex(v => v.label == '项目评估')
  421. });
  422. this.selectComponent("#Task").getList(this.data.sa_projectid, true)
  423. }
  424. },
  425. //tabs 切换
  426. tabsChange({
  427. detail
  428. }) {
  429. this.setData({
  430. tabsActive: detail
  431. });
  432. this.partialRenewal();
  433. },
  434. /* 更换负责人 */
  435. handelSubmit(arr) {
  436. const that = this;
  437. wx.showModal({
  438. title: '提示',
  439. content: '是否确认更换负责人',
  440. complete: ({
  441. confirm
  442. }) => {
  443. if (confirm) _Http.basic({
  444. "id": 20220930103701,
  445. "content": {
  446. ownertable: "sa_project",
  447. ownerid: that.data.detail.sa_projectid,
  448. userid: arr[0]
  449. }
  450. }).then(res => {
  451. wx.showToast({
  452. title: res.msg != '成功' ? res.data : '更换成功',
  453. icon: "none",
  454. mask: true
  455. });
  456. if (res.msg == '成功') setTimeout(() => {
  457. that.getDetail(true);
  458. wx.navigateBack();
  459. }, 300)
  460. })
  461. }
  462. })
  463. },
  464. //更新标签
  465. getTags() {
  466. this.selectComponent("#Tags").getTags();
  467. },
  468. //更新团队成员
  469. getGroup() {
  470. this.selectComponent("#Group").getList();
  471. },
  472. onUnload() {
  473. const page = getCurrentPages().find(v => v.__route__ == 'packageA/project/index');
  474. if (!page) return;
  475. let content = JSON.parse(JSON.stringify(page.data.content));
  476. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  477. content.pageNumber = 1;
  478. _Http.basic({
  479. id: 20221020143502,
  480. content
  481. }).then(res => {
  482. console.log("更新项目商机列表", res);
  483. if (res.msg == '成功') {
  484. page.data.list = res.data;
  485. page.data.content.total = res.total;
  486. page.setListHeight();
  487. page.getTags();
  488. }
  489. })
  490. }
  491. })