detail.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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. getApp().globalData.Language.getLanguagePackage(this, '报价单详情');
  17. const appAuth = wx.getStorageSync('auth').woffer;
  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.code != '1') 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: getApp().globalData.Language.getMapText(res.data.status),
  115. style:`color:${this.data.sColors[res.data.status]}`
  116. }];
  117. //客户报价移除项目字段
  118. if (res.data.quotedpricetype == '客户报价') briefs.splice(1, 1);
  119. let list1 = [{
  120. label: "报价单号",
  121. value: res.data.billno
  122. }, {
  123. label: "报价类型",
  124. value: res.data.quotedpricetype
  125. }, {
  126. label: "产品系列",
  127. value: res.data.itemtype
  128. }, {
  129. label: "领域",
  130. value: res.data.tradefields
  131. }, {
  132. label: "品牌",
  133. value: res.data.brandname
  134. }, {
  135. label: "项目名称",
  136. value: res.data.projectname
  137. }, {
  138. label: "项目阶段",
  139. value: res.data.stagename
  140. }, {
  141. label: "客户",
  142. value: res.data.enterprisename
  143. }, {
  144. label: "电话",
  145. value: res.data.telephone
  146. }, {
  147. label: "客户联系人",
  148. value: res.data.contactsname
  149. }, {
  150. label: "联系人手机号",
  151. value: res.data.contactsphonenumber
  152. }, {
  153. label: "报价日期",
  154. value: res.data.billdate
  155. }, {
  156. label: "有效期",
  157. value: res.data.begdate + ' - ' + res.data.enddate
  158. }, {
  159. label: "整单折扣(%)",
  160. value: (res.data.discountrate * 100).toFixed(2) + '%'
  161. }, {
  162. label: "总金额",
  163. value: CNY(res.data.quotedpriceamount)
  164. }, {
  165. label: "是否特价",
  166. value: res.data.specialoffer == 1 ? '是' : '否'
  167. }, {
  168. label: "状态",
  169. value: getApp().globalData.Language.getMapText(res.data.status),
  170. style:`color:${this.data.sColors[res.data.status]}`
  171. }, {
  172. label: "负责人",
  173. value: res.data.leader.length ? res.data.leader[0].name : ""
  174. }, {
  175. label: "备注",
  176. value: res.data.remarks
  177. }];
  178. //客户报价移除项目字段
  179. if (res.data.quotedpricetype == '客户报价') list1.splice(4, 2);
  180. this.setData({
  181. briefs,
  182. list1,
  183. list2: [{
  184. label: "创建人",
  185. value: res.data.createby
  186. }, {
  187. label: "创建时间",
  188. value: res.data.createdate
  189. }, {
  190. label: "最近编辑人",
  191. value: res.data.changeby
  192. }, {
  193. label: "最近编辑时间",
  194. value: res.data.changedate
  195. }, {
  196. label: "提交人",
  197. value: res.data.submitby
  198. }, {
  199. label: "提交时间",
  200. value: res.data.submitdate
  201. }, {
  202. label: "审核人",
  203. value: res.data.checkby
  204. }, {
  205. label: "审核时间",
  206. value: res.data.checkdate
  207. }, {
  208. label: "复核人",
  209. value: res.data.checkby
  210. }, {
  211. label: "复核时间",
  212. value: res.data.checkdate
  213. }, {
  214. label: "作废原因",
  215. value: res.data.deletereason
  216. }, {
  217. label: "转手次数",
  218. value: res.data.leader.length ? res.data.leader[0].leadernum : ""
  219. }],
  220. })
  221. },
  222. /* 设置底部功能 */
  223. async setTabbarList() {
  224. let detail = this.data.detail,
  225. status = detail.status,
  226. isLeader = detail.leader.length ? detail.leader.some(v => v.userid == wx.getStorageSync('userMsg').userid) : false,
  227. isAdmin = this.data.isAdmin,
  228. specialoffer = detail.specialoffer == 1,
  229. editdataleader = isLeader,
  230. tabbarList = [];
  231. if (this.data.appAuth.isdatafollowup) tabbarList.push({
  232. icon: "icon-genjin",
  233. label: "跟进"
  234. })
  235. if (!isLeader) {
  236. let res = await getApp().agentOrNot("sa_quotedprice", this.data.sa_quotedpriceid),
  237. data = res.code == '1' ? res.data : {
  238. editable: 0,
  239. editdataleader: 0
  240. }
  241. if (this.data.appAuth.isdatateam) isLeader = this.selectComponent("#Group").data.editable == 1;
  242. if (!isLeader) isLeader = data.editable == 1;
  243. editdataleader = data.editdataleader;
  244. }
  245. if (isLeader || isAdmin) {
  246. //负责人/管理员默认权限功能
  247. tabbarList.push({
  248. icon: "icon-guanlian-fuzhi",
  249. label: "复制"
  250. });
  251. if (status == '新建') {
  252. if (editdataleader) tabbarList.unshift({
  253. icon: "icon-zhuanyi",
  254. label: "更换负责人"
  255. })
  256. tabbarList = [{
  257. icon: "icon-shanchu",
  258. label: "作废"
  259. }, {
  260. icon: "icon-dibu-bianji",
  261. label: "编辑"
  262. }].concat(tabbarList);
  263. }
  264. //负责人 新建状态可以提交 提交状态可以撤回 负责人可以打印
  265. if (isLeader) {
  266. if (status == '新建') tabbarList.unshift({
  267. icon: "icon-genjin",
  268. label: '提交'
  269. })
  270. if (status == '提交') tabbarList.unshift({
  271. icon: "icon-genjin",
  272. label: '撤回'
  273. });
  274. }
  275. }
  276. if (specialoffer) {
  277. //开启特价
  278. switch (status) {
  279. case "提交":
  280. if (this.data.options.some(v => v == 'isrecheck')) tabbarList.unshift({
  281. icon: "icon-fuhe",
  282. label: "复核"
  283. })
  284. break;
  285. case "复核":
  286. if (this.data.options.some(v => v == 'isrecheck')) tabbarList.unshift({
  287. icon: "icon-fanfuhe",
  288. label: "反复核"
  289. })
  290. if (this.data.isAdmin) tabbarList.unshift({
  291. icon: "icon-guanlian-fuzhi",
  292. label: "审核"
  293. })
  294. break;
  295. case "审核":
  296. if (this.data.isAdmin) tabbarList.unshift({
  297. icon: "icon-guanlian-fuzhi",
  298. label: "反审核"
  299. })
  300. break;
  301. }
  302. } else {
  303. //未开启特价
  304. //拥有管理权限 提交状态可以审核 审核状态可以反审核
  305. if (this.data.isAdmin && (status == '审核' || status == '提交')) tabbarList.unshift(status == '审核' ? {
  306. icon: "icon-guanlian-fuzhi",
  307. label: "反审核"
  308. } : {
  309. icon: "icon-guanlian-fuzhi",
  310. label: "审核"
  311. });
  312. }
  313. this.setData({
  314. tabbarList,
  315. isLeader,
  316. editdataleader
  317. });
  318. },
  319. //tabs 切换
  320. tabsChange({
  321. detail
  322. }) {
  323. this.setData({
  324. tabsActive: detail
  325. });
  326. this.partialRenewal();
  327. },
  328. //更新标签
  329. getTags() {
  330. this.selectComponent("#Tags").getTags();
  331. },
  332. //更新团队成员
  333. getGroup() {
  334. this.selectComponent("#Group").getList().then(this.setTabbarList)
  335. },
  336. //局部数据更新 tabs
  337. partialRenewal(init = false) {
  338. let model = this.data.tabsList[this.data.tabsActive].model;
  339. if (model) {
  340. let Component = this.selectComponent(model),
  341. {
  342. total,
  343. pageNumber,
  344. pageTotal
  345. } = Component.data.content,
  346. id = this.data.sa_quotedpriceid;
  347. if (total == null || init) {
  348. Component.getList(id, init);
  349. } else if (pageNumber <= pageTotal) {
  350. Component.getList(id, false);
  351. }
  352. }
  353. },
  354. onReachBottom() {
  355. this.partialRenewal();
  356. },
  357. //详情按钮回调
  358. tabbarOnClick({
  359. detail
  360. }) {
  361. let data = this.data.detail,
  362. that = this;
  363. switch (detail.label) {
  364. case "编辑":
  365. wx.navigateTo({
  366. url: `/packageA/offers/${data.quotedpricetype=='项目报价'?'addProjectOffer':'addSetclientOffer'}?data=${JSON.stringify(data)}`,
  367. })
  368. break;
  369. case "提交":
  370. wx.showModal({
  371. title: getApp().globalData.Language.getMapText('提示'),
  372. content: getApp().globalData.Language.getMapText(`是否确定提交当前报价,提交后禁止使用部分功能`),
  373. complete: ({
  374. confirm
  375. }) => {
  376. if (confirm) _Http.basic({
  377. "id": "2024091910001802",
  378. "content": {
  379. "ownertable": "sa_quotedprice", //sa_project,sa_contract,sa_quotedprice
  380. "ownerid": that.data.sa_quotedpriceid
  381. }
  382. }).then(s => {
  383. console.log("报价单是否可以提交", s)
  384. if (s.code == 1) {
  385. _Http.basic({
  386. "id": 20221020165303,
  387. "version": 1,
  388. "content": {
  389. "sa_quotedpriceid": that.data.sa_quotedpriceid
  390. }
  391. }).then(res => {
  392. console.log("提交报价单", res)
  393. getApp().globalData.Language.showToast(res.code == '1' ? "提交成功" : res.msg)
  394. if (res.code == '1') setTimeout(() => {
  395. that.getDetail();
  396. }, 300)
  397. })
  398. } else {
  399. _Http.basic({
  400. "id": 2024091910214302,
  401. "version": 1,
  402. "content": {
  403. "ownertable": "sa_quotedprice", //sa_project,sa_contract,sa_quotedprice
  404. "ownerid": that.data.sa_quotedpriceid
  405. }
  406. }).then(v => {
  407. console.log("发送提醒", v)
  408. getApp().globalData.Language.showToast(v.code == '1' ? "已发送提醒" : res.msg)
  409. })
  410. }
  411. })
  412. }
  413. })
  414. break;
  415. case "审核":
  416. wx.showModal({
  417. title: getApp().globalData.Language.getMapText('提示'),
  418. content: getApp().globalData.Language.getMapText('是否通过当前报价'),
  419. cancelText: getApp().globalData.Language.getMapText('取消'),
  420. confirmText: getApp().globalData.Language.getMapText('确定'),
  421. complete: (res) => {
  422. if (res.confirm) _Http.basic({
  423. "id": 20221020165403,
  424. "version": 1,
  425. "content": {
  426. "sa_quotedpriceid": that.data.sa_quotedpriceid,
  427. ischeck: true
  428. }
  429. }).then(res => {
  430. console.log("审核报价单", res)
  431. wx.showToast({
  432. title: res.code == '1' ? getApp().globalData.Language.getMapText('审核成功') : res.msg,
  433. icon: "none"
  434. })
  435. if (res.code == '1') setTimeout(() => {
  436. that.getDetail();
  437. }, 300)
  438. })
  439. }
  440. })
  441. break;
  442. case "反审核":
  443. wx.showModal({
  444. title: getApp().globalData.Language.getMapText('提示'),
  445. content: getApp().globalData.Language.getMapText('是否退回当前报价'),
  446. cancelText: getApp().globalData.Language.getMapText('取消'),
  447. confirmText: getApp().globalData.Language.getMapText('确定'),
  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.code == '1' ? getApp().globalData.Language.getMapText('反审核成功') : res.msg,
  460. icon: "none"
  461. })
  462. if (res.code == '1') setTimeout(() => {
  463. that.getDetail();
  464. }, 300)
  465. })
  466. }
  467. })
  468. break;
  469. case "撤回":
  470. wx.showModal({
  471. title: getApp().globalData.Language.getMapText('提示'),
  472. content: getApp().globalData.Language.getMapText('是否撤回审核当前报价'),
  473. cancelText: getApp().globalData.Language.getMapText('取消'),
  474. confirmText: getApp().globalData.Language.getMapText('确定'),
  475. complete: (res) => {
  476. if (res.confirm) _Http.basic({
  477. "id": 20221125162803,
  478. "version": 1,
  479. "content": {
  480. "sa_quotedpriceid": that.data.sa_quotedpriceid
  481. }
  482. }).then(res => {
  483. console.log("撤回报价单", res)
  484. wx.showToast({
  485. title: res.code == '1' ? getApp().globalData.Language.getMapText('撤回审核成功') : res.msg,
  486. icon: "none"
  487. })
  488. if (res.code == '1') setTimeout(that.getDetail, 300)
  489. })
  490. }
  491. })
  492. break;
  493. case "跟进":
  494. wx.navigateTo({
  495. url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_quotedprice&ownerid=${data.sa_quotedpriceid}`,
  496. })
  497. break;
  498. case "复制":
  499. const {
  500. billno,
  501. sa_quotedpriceid
  502. } = data;
  503. wx.showModal({
  504. title: getApp().globalData.Language.getMapText('提示'),
  505. content: getApp().globalData.Language.getMapText('是否确认复制') + `“${billno}”`,
  506. cancelText: getApp().globalData.Language.getMapText('取消'),
  507. confirmText: getApp().globalData.Language.getMapText('确定'),
  508. complete: ({
  509. confirm
  510. }) => {
  511. if (confirm) _Http.basic({
  512. "id": 20221209094103,
  513. "content": {
  514. sa_quotedpriceid
  515. },
  516. }).then(res => {
  517. console.log("复制报价单", res)
  518. wx.showToast({
  519. title: res.code == '1' ? getApp().globalData.Language.getMapText('复制成功') : res.msg,
  520. icon: "none",
  521. mask: true
  522. });
  523. if (res.code == '1') setTimeout(() => {
  524. wx.redirectTo({
  525. url: `/packageA/offers/detail?sa_quotedpriceid=${res.data.sa_quotedpriceid}`,
  526. })
  527. let page = getCurrentPages().find(v => v.__route__ == 'packageA/offers/index');
  528. if (page) page.getList(true);
  529. }, 300)
  530. })
  531. }
  532. })
  533. break;
  534. case "作废":
  535. wx.navigateTo({
  536. url: `/packageA/offers/delete?id=${this.data.detail.sa_quotedpriceid}`,
  537. })
  538. break;
  539. case "更换负责人":
  540. wx.navigateTo({
  541. url: `/pages/group/select?data=${JSON.stringify({
  542. ownertable:"sa_quotedprice",
  543. ownerid:data.sa_quotedpriceid,
  544. })}&radio=true&principal=true`,
  545. })
  546. break;
  547. case "复核":
  548. isrecheck(1)
  549. break;
  550. case "反复核":
  551. isrecheck(0)
  552. break;
  553. }
  554. function isrecheck(isrecheck) {
  555. wx.showModal({
  556. title: getApp().globalData.Language.getMapText('提示'),
  557. content: getApp().globalData.Language.joint([{
  558. v: '是否确定',
  559. t: 1,
  560. }, {
  561. v: isrecheck ? '复核' : '反复核',
  562. t: 1,
  563. r: ' ',
  564. f: " "
  565. }, {
  566. v: '报价单',
  567. t: 1,
  568. }]),
  569. cancelText: getApp().globalData.Language.getMapText('取消'),
  570. confirmText: getApp().globalData.Language.getMapText('确定'),
  571. complete: (res) => {
  572. if (res.confirm) _Http.basic({
  573. "id": 20231206102404,
  574. "content": {
  575. "sa_quotedpriceid": data.sa_quotedpriceid,
  576. isrecheck
  577. }
  578. }).then(res => {
  579. wx.showToast({
  580. title: res.code == '1' ? getApp().globalData.Language.joint([{
  581. v: isrecheck ? '复核' : '反复核',
  582. t: 1,
  583. r: ' ',
  584. }, {
  585. v: '成功',
  586. t: 1,
  587. }]) : res.msg,
  588. icon: "none"
  589. })
  590. if (res.code == '1') that.getDetail(true)
  591. })
  592. }
  593. })
  594. }
  595. },
  596. /* 更换负责人 */
  597. handelSubmit(arr) {
  598. const that = this;
  599. wx.showModal({
  600. title: getApp().globalData.Language.getMapText('提示'),
  601. content: getApp().globalData.Language.getMapText('是否确认更换负责人'),
  602. cancelText: getApp().globalData.Language.getMapText('取消'),
  603. confirmText: getApp().globalData.Language.getMapText('确定'),
  604. complete: ({
  605. confirm
  606. }) => {
  607. if (confirm) wx.showModal({
  608. title: getApp().globalData.Language.getMapText('提示'),
  609. content: getApp().globalData.Language.getMapText('是否参与该数据的后续工作'),
  610. cancelText: getApp().globalData.Language.getMapText('不参与'),
  611. confirmText: getApp().globalData.Language.getMapText('参与'),
  612. complete: (s) => {
  613. _Http.basic({
  614. "id": 20220930103701,
  615. "content": {
  616. ownertable: "sa_quotedprice",
  617. ownerid: that.data.detail.sa_quotedpriceid,
  618. userid: arr[0],
  619. isaddoldleader: s.confirm ? 1 : 0
  620. }
  621. }).then(res => {
  622. console.log("更换负责人", res)
  623. if (res.code != '1') return wx.showToast({
  624. title: res.data,
  625. icon: "none"
  626. });
  627. wx.showToast({
  628. title: getApp().globalData.Language.getMapText('更换成功'),
  629. icon: "none",
  630. mask: true
  631. });
  632. setTimeout(() => {
  633. wx.navigateBack({
  634. delta: 2
  635. });
  636. /* getCurrentPages().forEach(v => {
  637. if (['packageA/project/index'].includes(v.__route__)) v.getList(true)
  638. }) */
  639. }, 300)
  640. })
  641. }
  642. })
  643. }
  644. })
  645. },
  646. onUnload() {
  647. const page = getCurrentPages().find(v => v.__route__ == 'packageA/offers/index');
  648. if (!page) return;
  649. let content = JSON.parse(JSON.stringify(page.data.content));
  650. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  651. content.pageNumber = 1;
  652. _Http.basic({
  653. id: '20221020165103',
  654. content
  655. }).then(res => {
  656. console.log("更新报价单", res);
  657. if (res.code == '1') page.setData({
  658. list: res.data.map(v => {
  659. v.progress = v.stage / v.totalstage * 100;
  660. return v
  661. }),
  662. "content.total": res.total
  663. })
  664. })
  665. }
  666. })