detail.js 19 KB

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