detail.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. let paramvalue = false;
  8. Page({
  9. data: {
  10. loading: true,
  11. isLeader: false, //是否为负责人
  12. isRecover: false, //关闭弹窗是否恢复项目
  13. tabsActive: 0, //tabs 选中项
  14. sa_projectid: "",
  15. tabsList: [{
  16. label: "详细信息",
  17. icon: "icon-tabxiangxixinxi1"
  18. }, {
  19. label: "关联客户",
  20. icon: "icon-tabkehu",
  21. model: "#Treaty"
  22. }, {
  23. label: "联系人",
  24. icon: "icon-tablianxiren",
  25. model: "#Contacts"
  26. }, {
  27. label: "产品配置单",
  28. icon: "icon-tabchanpin",
  29. model: "#Product"
  30. }, {
  31. label: "报价单",
  32. icon: "icon-tabbaojiadan",
  33. model: "#Offers"
  34. }, {
  35. label: "竞争对手",
  36. icon: "icon-tabjingzhengduishou",
  37. model: "#Opponent"
  38. }, {
  39. label: "合同",
  40. icon: "icon-tabhetong",
  41. model: "#Contract"
  42. }, {
  43. label: "关联线索",
  44. icon: "icon-tabxiansuo",
  45. model: "#Clue"
  46. }, {
  47. label: "项目评估",
  48. icon: "icon-tabxiangmupinggu",
  49. model: "#Task"
  50. }, {
  51. label: "任务",
  52. icon: "icon-tabrenwu",
  53. model: "#Work"
  54. }, {
  55. label: "报备进度",
  56. icon: "icon-tabfujian1",
  57. model: "#ReportingProgress"
  58. }, {
  59. label: "附件",
  60. icon: "icon-tabfujian1",
  61. model: "#Files"
  62. }, {
  63. label: "操作记录",
  64. icon: "icon-tabcaozuojilu1",
  65. model: "#Record"
  66. }, {
  67. label: "跟进动态",
  68. icon: "icon-tabgenjinjilu",
  69. model: "#Trace"
  70. }],
  71. tabbarList: [],
  72. },
  73. onLoad(options) {
  74. this.setData({
  75. sa_projectid: options.id,
  76. isAdmin: wx.getStorageSync('auth').wproject.options.some(v => v == "admin"), //是否具有管理权限
  77. options: wx.getStorageSync('auth').wproject.options, //权限列表
  78. });
  79. this.getDetail(true)
  80. },
  81. getDetail(init = false) {
  82. _Http.basic({
  83. "id": 20221021103902,
  84. "content": {
  85. nocache: true,
  86. "sa_projectid": this.data.sa_projectid
  87. },
  88. }).then(res => {
  89. console.log("项目商机详情", res)
  90. if (res.msg != '成功') return wx.showToast({
  91. title: res.data,
  92. icon: "none"
  93. });
  94. this.setPreview(res.data);
  95. this.setTabbar(res.data.status, res.data.leader.some(some => some.userid == wx.getStorageSync('userMsg').userid));
  96. this.setData({
  97. loading: false,
  98. detail: res.data,
  99. })
  100. if (init) {
  101. this.getTags();
  102. this.getGroup();
  103. this.selectComponent("#TaskTabs").getList();
  104. }
  105. this.partialRenewal(init);
  106. })
  107. },
  108. /* 设置显示信息 */
  109. async setPreview(data) {
  110. this.setData({
  111. briefs: [{
  112. label: "项目编号",
  113. value: data.projectnum
  114. }, {
  115. label: "项目等级",
  116. value: data.grade
  117. }, {
  118. label: "项目类型",
  119. value: data.projecttype
  120. }, {
  121. label: "项目阶段",
  122. value: data.stagename
  123. }, {
  124. label: "状态",
  125. value: data.status
  126. }],
  127. list1: [{
  128. label: "项目编号",
  129. value: data.projectnum
  130. }, {
  131. label: "项目名称",
  132. value: data.projectname
  133. }, {
  134. label: "项目类型",
  135. value: data.projecttype
  136. }, {
  137. label: "项目阶段",
  138. value: data.stagename
  139. }, {
  140. label: "项目等级",
  141. value: data.grade
  142. }, {
  143. label: "省市县",
  144. value: data.province ? data.province + data.city + data.county : ''
  145. }, {
  146. label: "地址",
  147. value: data.address
  148. }, {
  149. label: "项目规模",
  150. value: data.scale ? data.scale + data.unitname : ""
  151. }, {
  152. label: "项目预算(万元)",
  153. value: CNY(data.budgetary)
  154. },
  155. {
  156. label: "总投资额(万元)",
  157. value: CNY(data.totalinvestment)
  158. },
  159. {
  160. label: "造价(万元)",
  161. value: CNY(data.costofconstruction)
  162. },
  163. {
  164. label: "预计开工时间",
  165. value: data.begdate_due
  166. },
  167. {
  168. label: "预计完工时间",
  169. value: data.enddate_due
  170. }, {
  171. label: "预计签约时间",
  172. value: data.signdate_due
  173. }, {
  174. label: "预计签约金额(元)",
  175. value: CNY(data.signamount_due)
  176. }, {
  177. label: "项目成交金额",
  178. value: CNY(data.dealamount)
  179. }, {
  180. label: "领域",
  181. value: data.tradefield
  182. }, {
  183. label: "品牌",
  184. value: data.brandname
  185. }, {
  186. label: "赢率",
  187. value: data.winrate
  188. }, {
  189. label: "项目状态",
  190. value: data.status
  191. }, {
  192. label: "负责人",
  193. value: data.name
  194. }
  195. ],
  196. list2: [{
  197. label: "创建人",
  198. value: data.createby
  199. }, {
  200. label: "创建时间",
  201. value: data.createdate
  202. }, {
  203. label: "最近编辑人",
  204. value: data.changeby
  205. }, {
  206. label: "最近编辑时间",
  207. value: data.changedate
  208. }, {
  209. label: "提交报备人",
  210. value: data.reportby
  211. }, {
  212. label: "提交报备时间",
  213. value: data.reportdate
  214. }, {
  215. label: "报备审核人",
  216. value: data.reportcheckby
  217. }, {
  218. label: "报备审核时间",
  219. value: data.reportcheckdate
  220. }, {
  221. label: "结案原因",
  222. value: data.endreason
  223. }, {
  224. label: "失败原因",
  225. value: data.defeattype + (data.defeatreason ? "," + data.defeatreason : data.defeatreason)
  226. }, {
  227. label: "转手次数",
  228. value: data.changecount
  229. }]
  230. })
  231. },
  232. /* 设置tabbar */
  233. async setTabbar(status, Leader) {
  234. let isLeader = Leader,
  235. isAdmin = this.data.isAdmin,
  236. editdataleader = true,
  237. tabbarList = [{
  238. icon: "icon-genjin",
  239. label: "跟进"
  240. }];
  241. if (!isLeader) {
  242. let s = await getApp().agentOrNot("sa_project", this.data.sa_projectid);
  243. isLeader = s.data.editable == 1;
  244. editdataleader = s.data.editdataleader == 1;
  245. }
  246. if (isAdmin) tabbarList = [{
  247. icon: "icon-genjin",
  248. label: "报备审核"
  249. }].concat(tabbarList);
  250. if (isLeader || isAdmin) {
  251. if (status != '已失败' && status != '已结案') {
  252. _Http.basic({
  253. "classname": "sysmanage.develop.datafunction.datafunction",
  254. "method": "execute",
  255. "content": {
  256. functionname: "bpmswitch"
  257. }
  258. }).then(res => {
  259. console.log("查询是否启用BPM流程", res)
  260. if (res.msg != '失败') paramvalue = res.data[0].paramvalue == "true";
  261. })
  262. tabbarList = tabbarList.concat([{
  263. icon: "icon-bianji",
  264. label: "编辑"
  265. }, {
  266. icon: "icon-genjin",
  267. label: "提交报备"
  268. }])
  269. if (editdataleader) tabbarList.push({
  270. icon: "icon-zhuanyi",
  271. label: "更换负责人"
  272. })
  273. }
  274. if (isLeader) {
  275. if (status == '已成交') tabbarList.push({
  276. icon: "icon-dibu-jieshu",
  277. label: "结案"
  278. })
  279. if (status == '跟进中') tabbarList.push({
  280. icon: "icon-dibu-wuxiao",
  281. label: "失败"
  282. })
  283. if (status == '已失败' || status == '已结案') tabbarList = [{
  284. icon: "icon-dibu-chehui",
  285. label: "恢复"
  286. }]
  287. }
  288. tabbarList.push({
  289. icon: "icon-shanchu",
  290. label: "作废"
  291. })
  292. }
  293. if (this.data.options.find(v => v == 'viewRepetition')) tabbarList.push({
  294. icon: "icon-a-shouyejingangquhehuoren",
  295. label: "查看重复"
  296. });
  297. this.setData({
  298. isLeader,
  299. tabbarList,
  300. editdataleader,
  301. disabled: status != '已失败' && status != '已结案'
  302. });
  303. },
  304. //详情按钮回调
  305. tabbarOnClick({
  306. detail
  307. }) {
  308. let data = this.data.detail,
  309. that = this;
  310. switch (detail.label) {
  311. case "失败":
  312. wx.navigateTo({
  313. url: '/packageA/project/modules/fail/index?id=' + this.data.sa_projectid
  314. })
  315. break;
  316. case "结案":
  317. this.selectComponent("#Dialog").onClick(this.data.sa_projectid)
  318. break;
  319. case "恢复":
  320. _Http.basic({
  321. "id": 20221208184202,
  322. "content": {
  323. ...data,
  324. pageSize: 999
  325. }
  326. }).then(res => {
  327. console.log("查看重复", res)
  328. if (res.msg != '成功') return wx.showToast({
  329. title: res.msg,
  330. icon: "none"
  331. });
  332. if (res.data.length == 0) {
  333. wx.showModal({
  334. title: '提示',
  335. content: '是否确认恢复项目',
  336. complete: ({
  337. confirm
  338. }) => {
  339. if (confirm) that.onRecover()
  340. }
  341. })
  342. } else {
  343. wx.showToast({
  344. title: '查询到有疑似重复项目',
  345. icon: "none"
  346. })
  347. this.setData({
  348. repetitionList: res.data,
  349. repetitionShow: true,
  350. isRecover: true
  351. });
  352. }
  353. })
  354. break;
  355. case "提交报备":
  356. wx.showModal({
  357. title: '提示',
  358. content: '是否确认提交项目审核',
  359. complete: ({
  360. confirm
  361. }) => {
  362. if (confirm) that.handleReport(1)
  363. }
  364. })
  365. break;
  366. case "报备审核":
  367. if (paramvalue) {
  368. wx.showToast({
  369. title: '请前往WEB端操作',
  370. icon: "none"
  371. })
  372. } else {
  373. wx.showModal({
  374. title: '提示',
  375. content: '是否确认审核项目',
  376. complete: ({
  377. confirm
  378. }) => {
  379. if (confirm) that.handleReport(2)
  380. }
  381. })
  382. }
  383. /* _Http.basic({
  384. "id": 20230628155602,
  385. "content": {
  386. "sa_projectid": that.data.sa_projectid,
  387. "type": "mobile"
  388. }
  389. }).then(res => {
  390. console.log("获取报备地址", res)
  391. if (res.msg != '成功') return wx.showToast({
  392. title: res.msg,
  393. icon: "none"
  394. });
  395. if (res.data === '') return wx.showToast({
  396. title: '暂无审核权限',
  397. icon: "none"
  398. });
  399. getApp().globalData.webviewurl = res.data;
  400. wx.navigateTo({
  401. url: './webview',
  402. })
  403. }) */
  404. break;
  405. case "报备驳回(退回)":
  406. if (paramvalue) {
  407. wx.showToast({
  408. title: '请前往WEB端操作',
  409. icon: "none"
  410. })
  411. } else {
  412. wx.showModal({
  413. title: '提示',
  414. content: '是否确认报备驳回(退回)项目',
  415. complete: ({
  416. confirm
  417. }) => {
  418. if (confirm) that.handleReport(3)
  419. }
  420. })
  421. }
  422. break;
  423. case "跟进":
  424. wx.navigateTo({
  425. url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_project&ownerid=${data.sa_projectid}`,
  426. })
  427. break;
  428. case "编辑":
  429. let tags = that.selectComponent("#Tags").data.systemtag;
  430. wx.navigateTo({
  431. url: `/packageA/project/addAndEdit?data=${JSON.stringify(data)}&disabled=${tags.includes("报备中")||tags.includes("已报备")}`,
  432. })
  433. break;
  434. case "作废":
  435. _Http.basic({
  436. "id": "20221223102102",
  437. "content": {
  438. "nocache": true,
  439. "sa_projectid": that.data.sa_projectid,
  440. pageNumbe: 1,
  441. pageSize: 9999,
  442. "where": {
  443. "conditino": ""
  444. }
  445. }
  446. }).then(res => {
  447. console.log("查询合同列表", res)
  448. if (res.msg != '成功') return wx.showToast({
  449. title: res.data,
  450. icon: "none"
  451. })
  452. if (res.data.some(v => v.status == '审核')) {
  453. wx.showToast({
  454. title: '当前项目中存在审核状态合同,不可作废!',
  455. icon: "none",
  456. mask: true
  457. })
  458. } else {
  459. wx.navigateTo({
  460. url: `/packageA/project/delete?id=${this.data.detail.sa_projectid}`,
  461. })
  462. }
  463. })
  464. break;
  465. case "更换负责人":
  466. wx.navigateTo({
  467. url: `/pages/group/select?data=${JSON.stringify({
  468. ownertable:"sa_project",
  469. ownerid:data.sa_projectid,
  470. })}&radio=true&principal=true`,
  471. })
  472. break;
  473. case "查看重复":
  474. _Http.basic({
  475. "id": 20221208184202,
  476. "content": {
  477. ...data,
  478. pageSize: 999
  479. }
  480. }).then(res => {
  481. console.log("查看重复", res)
  482. if (res.msg != '成功') return wx.showToast({
  483. title: res.msg,
  484. icon: "none"
  485. });
  486. if (res.data.length == 0) {
  487. wx.showToast({
  488. title: '未查询到重复数据',
  489. icon: "none"
  490. });
  491. this.getTags()
  492. } else {
  493. this.setTags();
  494. }
  495. this.setData({
  496. repetitionList: res.data,
  497. repetitionShow: true
  498. })
  499. })
  500. break;
  501. default:
  502. console.log(detail)
  503. break;
  504. }
  505. },
  506. /* 恢复项目 */
  507. onRecover() {
  508. _Http.basic({
  509. "id": 20221215164002,
  510. "content": {
  511. "sa_projectid": this.data.sa_projectid
  512. }
  513. }).then(res => {
  514. console.log('恢复', res)
  515. wx.showToast({
  516. title: res.msg == '成功' ? '已恢复' : res.msg,
  517. icon: "none",
  518. mask: true
  519. });
  520. if (res.msg == '成功') setTimeout(this.getDetail, 300);
  521. })
  522. },
  523. /* 关闭查重弹窗 */
  524. repClose() {
  525. let that = this;
  526. if (this.data.isRecover) wx.showModal({
  527. title: '提示',
  528. content: '存在重复项目,是否确认恢复',
  529. complete: ({
  530. confirm
  531. }) => {
  532. if (confirm) {
  533. that.onRecover(true)
  534. that.setTags();
  535. }
  536. }
  537. });
  538. this.setData({
  539. repetitionShow: false,
  540. isRecover: false
  541. })
  542. },
  543. /* setTags */
  544. setTags() {
  545. let {
  546. datatag,
  547. systemtag
  548. } = this.selectComponent("#Tags").returnTags();
  549. if (!systemtag.some(v => v == '疑似重复')) {
  550. systemtag.push("疑似重复")
  551. _Http.basic({
  552. "id": 20220929090901,
  553. "content": {
  554. "ownertable": "sa_project",
  555. "ownerid": this.data.sa_projectid,
  556. datatag,
  557. systemtag
  558. }
  559. }).then(res => {
  560. console.log("绑定疑似重复标签", res)
  561. if (res.msg == '成功') this.getTags();
  562. })
  563. } else {
  564. this.getTags();
  565. }
  566. },
  567. /* 1提交报备,2报备审核,3报备驳回(退回) */
  568. handleReport(type) {
  569. _Http.basic({
  570. "id": 20221114163402,
  571. "content": {
  572. "sa_projectid": this.data.sa_projectid,
  573. type
  574. }
  575. }).then(res => {
  576. console.log("报备", type, res)
  577. wx.showToast({
  578. title: res.data == '失败' ? res.msg : "操作成功",
  579. icon: "none",
  580. mask: true
  581. })
  582. if (res.data != '失败') {
  583. this.getDetail();
  584. this.getTags();
  585. }
  586. })
  587. },
  588. //局部数据更新 tabs
  589. partialRenewal(init = false) {
  590. let model = this.data.tabsList[this.data.tabsActive].model;
  591. if (model) {
  592. let Component = this.selectComponent(model),
  593. {
  594. total,
  595. pageNumber,
  596. pageTotal
  597. } = Component.data.content,
  598. id = this.data.sa_projectid;
  599. if (total == null || init) {
  600. Component.getList(id, init);
  601. } else if (pageNumber <= pageTotal) {
  602. Component.getList(id, false);
  603. }
  604. }
  605. },
  606. onReachBottom() {
  607. this.partialRenewal();
  608. },
  609. /* 项目评估切换 */
  610. taskTabsChange({
  611. detail
  612. }) {
  613. if (detail.change) {
  614. this.setData({
  615. tabsActive: this.data.tabsList.findIndex(v => v.label == '项目评估')
  616. });
  617. this.selectComponent("#Task").getList(this.data.sa_projectid, true)
  618. }
  619. },
  620. //tabs 切换
  621. tabsChange({
  622. detail
  623. }) {
  624. this.setData({
  625. tabsActive: detail
  626. });
  627. this.partialRenewal();
  628. },
  629. /* 更换负责人 */
  630. handelSubmit(arr) {
  631. const that = this;
  632. wx.showModal({
  633. title: '提示',
  634. content: '是否确认更换负责人',
  635. complete: ({
  636. confirm
  637. }) => {
  638. if (confirm) _Http.basic({
  639. "id": 20220930103701,
  640. "content": {
  641. ownertable: "sa_project",
  642. ownerid: that.data.detail.sa_projectid,
  643. userid: arr[0]
  644. }
  645. }).then(res => {
  646. wx.showToast({
  647. title: res.msg != '成功' ? res.data : '更换成功',
  648. icon: "none",
  649. mask: true
  650. });
  651. if (res.msg == '成功') setTimeout(() => {
  652. that.getDetail(true);
  653. wx.navigateBack();
  654. }, 300)
  655. })
  656. }
  657. })
  658. },
  659. //更新标签
  660. getTags() {
  661. this.selectComponent("#Tags").getTags();
  662. },
  663. //更新团队成员
  664. getGroup() {
  665. this.selectComponent("#Group").getList();
  666. },
  667. /* tag更新列表 */
  668. onGetList({
  669. detail
  670. }) {
  671. if (detail.data.systemtag.includes('报备中')) {
  672. let tabbarList = this.data.tabbarList.filter(v => v.label != '提交报备')
  673. let index = tabbarList.findIndex(v => v.label == '报备审核');
  674. if (index != -1) tabbarList.splice(index, 0, {
  675. icon: "icon-genjin",
  676. label: "报备驳回(退回)"
  677. })
  678. this.setData({
  679. tabbarList
  680. })
  681. }
  682. this.setData({
  683. isInsert: detail.data.systemtag.includes('已报备')
  684. })
  685. console.log(123123, this.data.isInsert)
  686. },
  687. onUnload() {
  688. const page = getCurrentPages().find(v => v.__route__ == 'packageA/project/index');
  689. if (!page) return;
  690. let content = JSON.parse(JSON.stringify(page.data.content));
  691. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  692. content.pageNumber = 1;
  693. _Http.basic({
  694. id: 20221020143502,
  695. content
  696. }).then(res => {
  697. console.log("更新项目商机列表", res);
  698. if (res.msg == '成功') {
  699. page.data.list = res.data.map(v => {
  700. v.progress = v.stage / v.totalstage * 100;
  701. return v
  702. });
  703. page.data.content.total = res.total;
  704. page.setListHeight();
  705. page.getTags();
  706. }
  707. })
  708. }
  709. })