detail.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. tabsActive: 1, //tabs 选中项
  5. sa_salesforecastbillid: "",
  6. tabsList: [{
  7. label: "详细信息",
  8. icon: "icon-tabxiangxixinxi1"
  9. }, {
  10. label: "项目产品清单",
  11. icon: "icon-tabchanpin",
  12. model: "#Project"
  13. }, {
  14. label: "跟进动态",
  15. icon: "icon-tabgenjinjilu",
  16. model: "#Trace"
  17. }, {
  18. label: "操作记录",
  19. icon: "icon-tabcaozuojilu1",
  20. model: "#Record"
  21. }, {
  22. label: "附件",
  23. icon: "icon-tabfujian1",
  24. model: "#Files"
  25. }, {
  26. label: "任务",
  27. icon: "icon-tabrenwu",
  28. model: "#Work"
  29. }],
  30. tabbarList: [{
  31. icon: "icon-genjin",
  32. label: "跟进"
  33. }, {
  34. icon: "icon-guanlian-bianji",
  35. label: "添加项目"
  36. }, {
  37. icon: "icon-guanlian-fuzhi",
  38. label: "移除项目"
  39. }],
  40. },
  41. onLoad(options) {
  42. this.setData({
  43. sa_salesforecastbillid: options.sa_salesforecastbillid
  44. });
  45. this.getDetail(true);
  46. },
  47. getDetail(init = false) {
  48. _Http.basic({
  49. "id": 20220914104603,
  50. "version": 1,
  51. "content": {
  52. nocache: true,
  53. "sa_salesforecastbillid": this.data.sa_salesforecastbillid
  54. },
  55. }).then(res => {
  56. console.log("预测详情", res)
  57. if (res.msg != '成功') return wx.showToast({
  58. title: res.msg,
  59. icon: "none"
  60. });
  61. this.setPreview(res.data[0])
  62. if (init) this.getTags()
  63. this.partialRenewal(init);
  64. })
  65. },
  66. /* 设置显示项 */
  67. setPreview(data) {
  68. this.setData({
  69. detail: data,
  70. briefs: [{
  71. label: "提报类型",
  72. value: data.isrepeat == 1 ? '月度提报' : '单次提报'
  73. }, {
  74. label: "提报要求",
  75. value: data.remarks
  76. }, {
  77. label: "提报开始时间",
  78. value: data.periodstart
  79. }, {
  80. label: "提报截止时间",
  81. value: data.periodend
  82. }, {
  83. label: "预测金额",
  84. value: data.sumamount
  85. }, {
  86. label: "提报人",
  87. value: data.createby
  88. }, {
  89. label: "状态",
  90. value: data.status
  91. }],
  92. list1: [{
  93. label: "提报类型",
  94. value: data.isrepeat == 1 ? '月度提报' : '单次提报'
  95. }, {
  96. label: "提报要求",
  97. value: data.remarks
  98. }, {
  99. label: "提报开始时间",
  100. value: data.periodstart
  101. }, {
  102. label: "提报截止时间",
  103. value: data.periodend
  104. }, {
  105. label: "预测金额(元)",
  106. value: data.sumamount
  107. }, {
  108. label: "状态",
  109. value: data.status
  110. }],
  111. list2: [{
  112. label: "提报人",
  113. value: data.createby
  114. }, {
  115. label: "提报时间",
  116. value: data.createdate
  117. }, {
  118. label: "最近编辑人",
  119. value: data.changeby
  120. }, {
  121. label: "最近编辑时间",
  122. value: data.changedate
  123. }]
  124. });
  125. /* 更新列表数据 */
  126. let page = getCurrentPages().find(v => v.__route__ == 'packageA/salesForecasting/index');
  127. if (page) {
  128. let i = page.data.list.findIndex(v => v.sa_salesforecastbillid == this.data.sa_salesforecastbillid);
  129. if (i != -1) {
  130. page.data.list[i].status = data.status;
  131. page.data.list[i].amount = data.sumamount;
  132. page.setData({
  133. [`list[${i}]`]: page.data.list[i]
  134. })
  135. }
  136. }
  137. },
  138. //tabs 切换
  139. tabsChange({
  140. detail
  141. }) {
  142. this.setData({
  143. tabsActive: detail
  144. });
  145. this.partialRenewal();
  146. },
  147. /* 添加项目 */
  148. addProject({
  149. list
  150. }) {
  151. let that = this;
  152. wx.showModal({
  153. title: '提示',
  154. content: `是否确认添加${list.length}个项目`,
  155. complete: ({
  156. confirm
  157. }) => {
  158. if (confirm) _Http.basic({
  159. id: 20220913154403,
  160. version: 1,
  161. content: {
  162. nocache: true,
  163. sa_salesforecastmodelid: that.data.detail.sa_salesforecastmodelid,
  164. sa_salesforecastbillid: that.data.sa_salesforecastbillid,
  165. sa_projectids: list.map(v => {
  166. return {
  167. sa_projectid: v.sa_projectid,
  168. discountrate: v.discountrate
  169. }
  170. })
  171. }
  172. }).then(res => {
  173. console.log("添加项目", res)
  174. wx.showToast({
  175. title: res.msg == '成功' ? '添加成功' : res.msg,
  176. icon: "none"
  177. });
  178. if (res.msg == '成功') {
  179. that.setData({
  180. tabsActive: that.data.tabsList.findIndex(v => v.label == '项目产品清单')
  181. });
  182. setTimeout(() => {
  183. wx.navigateBack();
  184. setTimeout(() => {
  185. that.selectComponent('#Project').getList(that.data.sa_salesforecastbillid, false, true);
  186. }, 300)
  187. }, 300)
  188. }
  189. })
  190. }
  191. })
  192. },
  193. /* 删除项目 */
  194. deteleProject({
  195. item
  196. }) {
  197. let that = this;
  198. wx.showModal({
  199. title: '提示',
  200. content: `是否确认移除“${item.projectname}”`,
  201. complete: ({
  202. confirm
  203. }) => {
  204. if (confirm) _Http.basic({
  205. "id": 20220906155103,
  206. "version": 1,
  207. "content": {
  208. "sa_salesforecastid": 0,
  209. "sa_projectid": item.sa_projectid,
  210. "sa_salesforecastbillid": item.sa_salesforecastbillid
  211. }
  212. }).then(res => {
  213. console.log("移除项目", res)
  214. if (res.msg != '成功') return wx.showToast({
  215. title: res.msg,
  216. icon: "none"
  217. });
  218. that.selectComponent("#Project").getList(that.data.sa_salesforecastbillid);
  219. setTimeout(() => {
  220. wx.showToast({
  221. title: `已移除“${item.projectname}”`,
  222. icon: "none"
  223. })
  224. let page = getCurrentPages().find(v => v.__route__ == 'packageA/select/project/select');
  225. if (page) page.deteleItem(item.sa_projectid);
  226. that.getDetail();
  227. }, 500)
  228. })
  229. }
  230. })
  231. },
  232. //详情按钮回调
  233. tabbarOnClick({
  234. detail
  235. }) {
  236. switch (detail.label) {
  237. case "跟进":
  238. wx.navigateTo({
  239. url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_salesforecastbill&ownerid=${this.data.sa_salesforecastbillid}`,
  240. })
  241. break;
  242. case "添加项目":
  243. wx.navigateTo({
  244. url: `/packageA/select/project/select?params=${JSON.stringify({
  245. "id": 20220906154803,
  246. "version":1,
  247. "content": {
  248. nocache:true,
  249. sa_salesforecastbillid:this.data.sa_salesforecastbillid,
  250. "where":{
  251. "condition":""
  252. }
  253. }
  254. })}`,
  255. });
  256. getApp().globalData.handleSelect = this.addProject.bind(this);
  257. break;
  258. case "移除项目":
  259. wx.navigateTo({
  260. url: `/packageA/select/project/select?params=${JSON.stringify({
  261. "id": "20220916115203",
  262. "version": 1,
  263. "content": {
  264. nocache: true,
  265. sa_salesforecastbillid:this.data.sa_salesforecastbillid,
  266. pageSize: 999,
  267. "where":{
  268. "condition":""
  269. }
  270. }
  271. })}&radio=true`,
  272. })
  273. getApp().globalData.handleSelect = this.deteleProject.bind(this);
  274. break;
  275. }
  276. },
  277. //更新标签
  278. getTags() {
  279. this.selectComponent("#Tags").getTags();
  280. },
  281. //局部数据更新 tabs
  282. partialRenewal(init = false) {
  283. let model = this.data.tabsList[this.data.tabsActive].model;
  284. if (model) {
  285. let Component = this.selectComponent(model),
  286. {
  287. total,
  288. pageNumber,
  289. pageTotal
  290. } = Component.data.content,
  291. id = this.data.sa_salesforecastbillid;
  292. if (total == null || init) {
  293. Component.getList(id, init);
  294. } else if (pageNumber < pageTotal) {
  295. Component.getList(id, false);
  296. }
  297. }
  298. },
  299. onReachBottom() {
  300. this.partialRenewal();
  301. }
  302. })