detail.js 20 KB

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