detail.js 19 KB

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