detail.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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. loading: true,
  10. isLeader: false, //是否为负责人
  11. tabsActive: 1, //tabs 选中项
  12. sa_quotedpriceid: "",
  13. tabbarList: [],
  14. },
  15. onLoad(options) {
  16. const appAuth = wx.getStorageSync('auth').woffer;
  17. console.log("appAuth", appAuth)
  18. let tabsList = [{
  19. label: "详细信息",
  20. icon: "icon-tabxiangxixinxi1"
  21. }, {
  22. label: "产品明细折扣",
  23. icon: "icon-tabchanpin",
  24. model: "#Product"
  25. }, {
  26. label: "产品类别折扣",
  27. icon: "icon-tabchanpinleibie",
  28. model: "#PiscountType"
  29. }, {
  30. label: "其他费用",
  31. icon: "icon-tabkaipiaoxinxi",
  32. model: "#PettyExpense"
  33. }, {
  34. label: "历史报价",
  35. icon: "icon-tabbaojiadan",
  36. model: "#History"
  37. }, {
  38. label: "操作记录",
  39. icon: "icon-tabcaozuojilu1",
  40. model: "#Record"
  41. }, {
  42. label: "附件",
  43. icon: "icon-tabfujian1",
  44. model: "#Files"
  45. }];
  46. if (appAuth.isdatafollowup) tabsList.splice(5, 0, {
  47. label: "跟进动态",
  48. icon: "icon-tabgenjinjilu",
  49. model: "#Trace"
  50. })
  51. if (appAuth.istask) tabsList.push({
  52. label: "任务",
  53. icon: "icon-tabrenwu",
  54. model: "#Work"
  55. })
  56. this.setData({
  57. sa_quotedpriceid: options.sa_quotedpriceid,
  58. isAdmin: appAuth.options.some(v => v == "admin"), //是否具有管理权限
  59. options: appAuth.options, //权限列表
  60. tabsList,
  61. appAuth
  62. })
  63. this.getDetail(true);
  64. },
  65. getDetail(init = false) {
  66. _Http.basic({
  67. "id": 20221020165203,
  68. "version": 1,
  69. "content": {
  70. nocache: true,
  71. "sa_quotedpriceid": this.data.sa_quotedpriceid
  72. },
  73. }).then(res => {
  74. console.log("报价单详情", res)
  75. if (res.msg != '成功') return wx.showToast({
  76. title: res.msg,
  77. icon: "none"
  78. });
  79. this.setPreview(res);
  80. this.setData({
  81. loading: false,
  82. detail: res.data,
  83. })
  84. this.setTabbarList();
  85. /* 更新列表数据 */
  86. let page = getCurrentPages().find(v => v.__route__ == 'packageA/offers/index');
  87. if (page) {
  88. let i = page.data.list.findIndex(v => v.sa_quotedpriceid == this.data.sa_quotedpriceid);
  89. if (i != -1 && page.data.list[i].status != res.data.status) page.setData({
  90. [`list[${i}].status`]: res.data.status
  91. })
  92. }
  93. if (this.data.appAuth.isdatatag) this.getTags();
  94. if (this.data.appAuth.isdatateam) this.getGroup();
  95. this.partialRenewal();
  96. })
  97. },
  98. /* 设置显示字段 */
  99. setPreview(res) {
  100. let briefs = [{
  101. label: "报价类型",
  102. value: res.data.quotedpricetype
  103. }, {
  104. label: "项目",
  105. value: res.data.projectname
  106. }, {
  107. label: "客户",
  108. value: res.data.enterprisename
  109. }, {
  110. label: "是否特价",
  111. value: res.data.specialoffer == 1 ? '是' : '否'
  112. }, {
  113. label: "状态",
  114. value: res.data.status
  115. }];
  116. //客户报价移除项目字段
  117. if (res.data.quotedpricetype == '客户报价') briefs.splice(1, 1);
  118. let list1 = [{
  119. label: "报价单号",
  120. value: res.data.billno
  121. }, {
  122. label: "报价类型",
  123. value: res.data.quotedpricetype
  124. }, {
  125. label: "产品系列",
  126. value: res.data.itemtype
  127. }, {
  128. label: "领域",
  129. value: res.data.tradefields
  130. }, {
  131. label: "品牌",
  132. value: res.data.brandname
  133. }, {
  134. label: "项目名称",
  135. value: res.data.projectname
  136. }, {
  137. label: "项目阶段",
  138. value: res.data.stagename
  139. }, {
  140. label: "客户",
  141. value: res.data.enterprisename
  142. }, {
  143. label: "电话",
  144. value: res.data.telephone
  145. }, {
  146. label: "客户联系人",
  147. value: res.data.contactsname
  148. }, {
  149. label: "联系人手机号",
  150. value: res.data.contactsphonenumber
  151. }, {
  152. label: "报价日期",
  153. value: res.data.billdate
  154. }, {
  155. label: "有效期",
  156. value: res.data.begdate + ' - ' + res.data.enddate
  157. }, {
  158. label: "整单折扣(%)",
  159. value: (res.data.discountrate * 100).toFixed(2) + '%'
  160. }, {
  161. label: "总金额",
  162. value: CNY(res.data.quotedpriceamount)
  163. }, {
  164. label: "是否特价",
  165. value: res.data.specialoffer == 1 ? '是' : '否'
  166. }, {
  167. label: "状态",
  168. value: res.data.status
  169. }, {
  170. label: "负责人",
  171. value: res.data.leader.length ? res.data.leader[0].name : ""
  172. }, {
  173. label: "备注",
  174. value: res.data.remarks
  175. }];
  176. //客户报价移除项目字段
  177. if (res.data.quotedpricetype == '客户报价') list1.splice(4, 2);
  178. this.setData({
  179. briefs,
  180. list1,
  181. list2: [{
  182. label: "创建人",
  183. value: res.data.createby
  184. }, {
  185. label: "创建时间",
  186. value: res.data.createdate
  187. }, {
  188. label: "最近编辑人",
  189. value: res.data.changeby
  190. }, {
  191. label: "最近编辑时间",
  192. value: res.data.changedate
  193. }, {
  194. label: "提交人",
  195. value: res.data.submitby
  196. }, {
  197. label: "提交时间",
  198. value: res.data.submitdate
  199. }, {
  200. label: "审核人",
  201. value: res.data.checkby
  202. }, {
  203. label: "审核时间",
  204. value: res.data.checkdate
  205. }, {
  206. label: "复核人",
  207. value: res.data.checkby
  208. }, {
  209. label: "复核时间",
  210. value: res.data.checkdate
  211. }, {
  212. label: "作废原因",
  213. value: res.data.deletereason
  214. }, {
  215. label: "转手次数",
  216. value: res.data.leader.length ? res.data.leader[0].leadernum : ""
  217. }],
  218. })
  219. },
  220. /* 设置底部功能 */
  221. async setTabbarList() {
  222. let detail = this.data.detail,
  223. status = detail.status,
  224. isLeader = detail.leader.length ? detail.leader.some(v => v.userid == wx.getStorageSync('userMsg').userid) : false,
  225. isAdmin = this.data.isAdmin,
  226. specialoffer = detail.specialoffer == 1,
  227. editdataleader = isLeader,
  228. tabbarList = [];
  229. if (this.data.appAuth.isdatafollowup) tabbarList.push({
  230. icon: "icon-genjin",
  231. label: "跟进"
  232. })
  233. if (!isLeader) {
  234. let res = await getApp().agentOrNot("sa_quotedprice", this.data.sa_quotedpriceid),
  235. data = res.msg == '成功' ? res.data : {
  236. editable: 0,
  237. editdataleader: 0
  238. }
  239. if (this.data.appAuth.isdatateam) isLeader = this.selectComponent("#Group").data.editable == 1;
  240. if (!isLeader) isLeader = data.editable == 1;
  241. editdataleader = data.editdataleader;
  242. }
  243. if (isLeader || isAdmin) {
  244. //负责人/管理员默认权限功能
  245. tabbarList.push({
  246. icon: "icon-guanlian-fuzhi",
  247. label: "复制"
  248. });
  249. if (status == '新建') {
  250. if (editdataleader) tabbarList.unshift({
  251. icon: "icon-zhuanyi",
  252. label: "更换负责人"
  253. })
  254. tabbarList = [{
  255. icon: "icon-shanchu",
  256. label: "作废"
  257. }, {
  258. icon: "icon-dibu-bianji",
  259. label: "编辑"
  260. }].concat(tabbarList);
  261. }
  262. //负责人 新建状态可以提交 提交状态可以撤回 负责人可以打印
  263. if (isLeader) {
  264. if (status == '新建') tabbarList.unshift({
  265. icon: "icon-genjin",
  266. label: '提交'
  267. })
  268. if (status == '提交') tabbarList.unshift({
  269. icon: "icon-genjin",
  270. label: '撤回'
  271. });
  272. }
  273. }
  274. if (specialoffer) {
  275. //开启特价
  276. switch (status) {
  277. case "提交":
  278. if (this.data.options.some(v => v == 'isrecheck')) tabbarList.unshift({
  279. icon: "icon-fuhe",
  280. label: "复核"
  281. })
  282. break;
  283. case "复核":
  284. if (this.data.options.some(v => v == 'isrecheck')) tabbarList.unshift({
  285. icon: "icon-fanfuhe",
  286. label: "反复核"
  287. })
  288. if (this.data.isAdmin) tabbarList.unshift({
  289. icon: "icon-guanlian-fuzhi",
  290. label: "审核"
  291. })
  292. break;
  293. case "审核":
  294. if (this.data.isAdmin) tabbarList.unshift({
  295. icon: "icon-guanlian-fuzhi",
  296. label: "反审核"
  297. })
  298. break;
  299. }
  300. } else {
  301. //未开启特价
  302. //拥有管理权限 提交状态可以审核 审核状态可以反审核
  303. if (this.data.isAdmin && (status == '审核' || status == '提交')) tabbarList.unshift(status == '审核' ? {
  304. icon: "icon-guanlian-fuzhi",
  305. label: "反审核"
  306. } : {
  307. icon: "icon-guanlian-fuzhi",
  308. label: "审核"
  309. });
  310. }
  311. this.setData({
  312. tabbarList,
  313. isLeader,
  314. editdataleader
  315. });
  316. },
  317. //tabs 切换
  318. tabsChange({
  319. detail
  320. }) {
  321. this.setData({
  322. tabsActive: detail
  323. });
  324. this.partialRenewal();
  325. },
  326. //更新标签
  327. getTags() {
  328. this.selectComponent("#Tags").getTags();
  329. },
  330. //更新团队成员
  331. getGroup() {
  332. this.selectComponent("#Group").getList().then(this.setTabbarList)
  333. },
  334. //局部数据更新 tabs
  335. partialRenewal(init = false) {
  336. let model = this.data.tabsList[this.data.tabsActive].model;
  337. if (model) {
  338. let Component = this.selectComponent(model),
  339. {
  340. total,
  341. pageNumber,
  342. pageTotal
  343. } = Component.data.content,
  344. id = this.data.sa_quotedpriceid;
  345. if (total == null || init) {
  346. Component.getList(id, init);
  347. } else if (pageNumber <= pageTotal) {
  348. Component.getList(id, false);
  349. }
  350. }
  351. },
  352. onReachBottom() {
  353. this.partialRenewal();
  354. },
  355. //详情按钮回调
  356. tabbarOnClick({
  357. detail
  358. }) {
  359. let data = this.data.detail,
  360. that = this;
  361. switch (detail.label) {
  362. case "编辑":
  363. wx.navigateTo({
  364. url: `/packageA/offers/${data.quotedpricetype=='项目报价'?'addProjectOffer':'addSetclientOffer'}?data=${JSON.stringify(data)}`,
  365. })
  366. break;
  367. case "提交":
  368. wx.showModal({
  369. title: '提示',
  370. content: `是否确定提交当前报价,提交后禁止使用部分功能`,
  371. complete: ({
  372. confirm
  373. }) => {
  374. if (confirm) _Http.basic({
  375. "id": "2024091910001802",
  376. "content": {
  377. "ownertable": "sa_quotedprice", //sa_project,sa_contract,sa_quotedprice
  378. "ownerid": that.data.sa_quotedpriceid
  379. }
  380. }).then(s => {
  381. console.log("报价单是否可以提交", s)
  382. if (s.code == 1) {
  383. _Http.basic({
  384. "id": 20221020165303,
  385. "version": 1,
  386. "content": {
  387. "sa_quotedpriceid": that.data.sa_quotedpriceid
  388. }
  389. }).then(res => {
  390. console.log("提交报价单", res)
  391. wx.showToast({
  392. title: res.msg == '成功' ? "提交成功" : res.msg,
  393. icon: "none"
  394. })
  395. if (res.msg == '成功') setTimeout(() => {
  396. that.getDetail();
  397. }, 300)
  398. })
  399. } else {
  400. _Http.basic({
  401. "id": 2024091910214302,
  402. "version": 1,
  403. "content": {
  404. "ownertable": "sa_quotedprice", //sa_project,sa_contract,sa_quotedprice
  405. "ownerid": that.data.sa_quotedpriceid
  406. }
  407. }).then(v => {
  408. console.log("发送提醒", v)
  409. wx.showToast({
  410. title: v.msg == '成功' ? "已发送提醒" : res.msg,
  411. icon: "none"
  412. })
  413. })
  414. }
  415. })
  416. }
  417. })
  418. break;
  419. case "审核":
  420. wx.showModal({
  421. title: '提示',
  422. content: `是否通过当前报价`,
  423. complete: (res) => {
  424. if (res.confirm) _Http.basic({
  425. "id": 20221020165403,
  426. "version": 1,
  427. "content": {
  428. "sa_quotedpriceid": that.data.sa_quotedpriceid,
  429. ischeck: true
  430. }
  431. }).then(res => {
  432. console.log("审核报价单", res)
  433. wx.showToast({
  434. title: res.msg == '成功' ? "审核成功" : res.msg,
  435. icon: "none"
  436. })
  437. if (res.msg == '成功') setTimeout(() => {
  438. that.getDetail();
  439. }, 300)
  440. })
  441. }
  442. })
  443. break;
  444. case "反审核":
  445. wx.showModal({
  446. title: '提示',
  447. content: `是否退回当前报价`,
  448. complete: (res) => {
  449. if (res.confirm) _Http.basic({
  450. "id": 20221020165403,
  451. "version": 1,
  452. "content": {
  453. "sa_quotedpriceid": that.data.sa_quotedpriceid,
  454. ischeck: false
  455. }
  456. }).then(res => {
  457. console.log("反审核报价单", res)
  458. wx.showToast({
  459. title: res.msg == '成功' ? "反审核成功" : res.msg,
  460. icon: "none"
  461. })
  462. if (res.msg == '成功') setTimeout(() => {
  463. that.getDetail();
  464. }, 300)
  465. })
  466. }
  467. })
  468. break;
  469. case "撤回":
  470. wx.showModal({
  471. title: '提示',
  472. content: `是否撤回审核当前报价`,
  473. complete: (res) => {
  474. if (res.confirm) _Http.basic({
  475. "id": 20221125162803,
  476. "version": 1,
  477. "content": {
  478. "sa_quotedpriceid": that.data.sa_quotedpriceid
  479. }
  480. }).then(res => {
  481. console.log("撤回报价单", res)
  482. wx.showToast({
  483. title: res.msg == '成功' ? "撤回审核成功" : res.msg,
  484. icon: "none"
  485. })
  486. if (res.msg == '成功') setTimeout(that.getDetail, 300)
  487. })
  488. }
  489. })
  490. break;
  491. case "跟进":
  492. wx.navigateTo({
  493. url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_quotedprice&ownerid=${data.sa_quotedpriceid}`,
  494. })
  495. break;
  496. case "复制":
  497. const {
  498. billno,
  499. sa_quotedpriceid
  500. } = data;
  501. wx.showModal({
  502. title: '提示',
  503. content: `是否确认复制“${billno}”`,
  504. complete: ({
  505. confirm
  506. }) => {
  507. if (confirm) _Http.basic({
  508. "id": 20221209094103,
  509. "content": {
  510. sa_quotedpriceid
  511. },
  512. }).then(res => {
  513. console.log("复制报价单", res)
  514. wx.showToast({
  515. title: res.msg == '成功' ? '复制成功' : res.msg,
  516. icon: "none",
  517. mask: true
  518. });
  519. if (res.msg == '成功') setTimeout(() => {
  520. wx.redirectTo({
  521. url: `/packageA/offers/detail?sa_quotedpriceid=${res.data.sa_quotedpriceid}`,
  522. })
  523. let page = getCurrentPages().find(v => v.__route__ == 'packageA/offers/index');
  524. if (page) page.getList(true);
  525. }, 300)
  526. })
  527. }
  528. })
  529. break;
  530. case "作废":
  531. wx.navigateTo({
  532. url: `/packageA/offers/delete?id=${this.data.detail.sa_quotedpriceid}`,
  533. })
  534. break;
  535. case "更换负责人":
  536. wx.navigateTo({
  537. url: `/pages/group/select?data=${JSON.stringify({
  538. ownertable:"sa_quotedprice",
  539. ownerid:data.sa_quotedpriceid,
  540. })}&radio=true&principal=true`,
  541. })
  542. break;
  543. case "复核":
  544. isrecheck(1)
  545. break;
  546. case "反复核":
  547. isrecheck(0)
  548. break;
  549. }
  550. function isrecheck(isrecheck) {
  551. wx.showModal({
  552. title: '提示',
  553. content: `是否确定${isrecheck?'复核':'反复核'}报价单`,
  554. complete: (res) => {
  555. if (res.confirm) _Http.basic({
  556. "id": 20231206102404,
  557. "content": {
  558. "sa_quotedpriceid": data.sa_quotedpriceid,
  559. isrecheck
  560. }
  561. }).then(res => {
  562. wx.showToast({
  563. title: res.msg == '成功' ? `${ isrecheck ? '复核' : '反复核'}成功` : res.msg,
  564. icon: "none"
  565. })
  566. if (res.msg == '成功') that.getDetail(true)
  567. })
  568. }
  569. })
  570. }
  571. },
  572. /* 更换负责人 */
  573. handelSubmit(arr) {
  574. const that = this;
  575. wx.showModal({
  576. title: '提示',
  577. content: '是否确认更换负责人',
  578. complete: ({
  579. confirm
  580. }) => {
  581. if (confirm) wx.showModal({
  582. title: '提示',
  583. content: '是否参与该数据的后续工作',
  584. confirmText: "参与",
  585. cancelText: "不参与",
  586. complete: (s) => {
  587. _Http.basic({
  588. "id": 20220930103701,
  589. "content": {
  590. ownertable: "sa_quotedprice",
  591. ownerid: that.data.detail.sa_quotedpriceid,
  592. userid: arr[0],
  593. isaddoldleader: s.confirm ? 1 : 0
  594. }
  595. }).then(res => {
  596. console.log("更换负责人", res)
  597. if (res.msg != '成功') return wx.showToast({
  598. title: res.data,
  599. icon: "none"
  600. });
  601. wx.showToast({
  602. title: '更换成功!',
  603. icon: "none",
  604. mask: true
  605. });
  606. setTimeout(() => {
  607. wx.navigateBack({
  608. delta: 2
  609. });
  610. /* getCurrentPages().forEach(v => {
  611. if (['packageA/project/index'].includes(v.__route__)) v.getList(true)
  612. }) */
  613. }, 300)
  614. })
  615. }
  616. })
  617. }
  618. })
  619. }
  620. })