detail.js 25 KB

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