detail.js 26 KB

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