detail.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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.code != '1') 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: getApp().globalData.Language.getMapText(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: getApp().globalData.Language.getMapText(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: getApp().globalData.Language.getMapText('提示'),
  154. content: getApp().globalData.Language.joint([{
  155. t: 1,
  156. v: '是否确认添加',
  157. r: " "
  158. }, {
  159. v: list.length,
  160. r: " "
  161. }, {
  162. t: 1,
  163. v: '个项目',
  164. r: "?"
  165. }]),
  166. cancelText: getApp().globalData.Language.getMapText('取消'),
  167. confirmText: getApp().globalData.Language.getMapText('确定'),
  168. complete: ({
  169. confirm
  170. }) => {
  171. if (confirm) _Http.basic({
  172. id: 20220913154403,
  173. version: 1,
  174. content: {
  175. nocache: true,
  176. sa_salesforecastmodelid: that.data.detail.sa_salesforecastmodelid,
  177. sa_salesforecastbillid: that.data.sa_salesforecastbillid,
  178. sa_projectids: list.map(v => {
  179. return {
  180. sa_projectid: v.sa_projectid,
  181. discountrate: v.discountrate
  182. }
  183. })
  184. }
  185. }).then(res => {
  186. console.log("添加项目", res)
  187. wx.showToast({
  188. title: res.code == '1' ? getApp().globalData.Language.getMapText('添加成功') : res.msg,
  189. icon: "none"
  190. });
  191. if (res.code == '1') {
  192. that.setData({
  193. tabsActive: that.data.tabsList.findIndex(v => v.label == '项目产品清单')
  194. });
  195. setTimeout(() => {
  196. wx.navigateBack();
  197. setTimeout(() => {
  198. that.selectComponent('#Project').getList(that.data.sa_salesforecastbillid, false, true);
  199. }, 300)
  200. }, 300)
  201. }
  202. })
  203. }
  204. })
  205. },
  206. /* 删除项目 */
  207. deteleProject({
  208. item
  209. }) {
  210. let that = this;
  211. wx.showModal({
  212. title: getApp().globalData.Language.getMapText('提示'),
  213. content: getApp().globalData.Language.getMapText('是否确认移除') + `“${item.projectname}”`,
  214. cancelText: getApp().globalData.Language.getMapText('取消'),
  215. confirmText: getApp().globalData.Language.getMapText('确定'),
  216. complete: ({
  217. confirm
  218. }) => {
  219. if (confirm) _Http.basic({
  220. "id": 20220906155103,
  221. "version": 1,
  222. "content": {
  223. "sa_salesforecastid": 0,
  224. "sa_projectid": item.sa_projectid,
  225. "sa_salesforecastbillid": item.sa_salesforecastbillid
  226. }
  227. }).then(res => {
  228. console.log("移除项目", res)
  229. if (res.code != '1') return wx.showToast({
  230. title: res.msg,
  231. icon: "none"
  232. });
  233. that.selectComponent("#Project").getList(that.data.sa_salesforecastbillid);
  234. setTimeout(() => {
  235. wx.showToast({
  236. title: getApp().globalData.Language.getMapText('已移除') + `“${item.projectname}”`,
  237. icon: "none"
  238. })
  239. let page = getCurrentPages().find(v => v.__route__ == 'packageA/select/project/select');
  240. if (page) page.deteleItem(item.sa_projectid);
  241. that.getDetail();
  242. }, 500)
  243. })
  244. }
  245. })
  246. },
  247. //详情按钮回调
  248. tabbarOnClick({
  249. detail
  250. }) {
  251. switch (detail.label) {
  252. case "跟进":
  253. wx.navigateTo({
  254. url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_salesforecastbill&ownerid=${this.data.sa_salesforecastbillid}`,
  255. })
  256. break;
  257. case "添加项目":
  258. wx.navigateTo({
  259. url: `/packageA/select/project/select?params=${JSON.stringify({
  260. "id": 20220906154803,
  261. "version":1,
  262. "content": {
  263. nocache:true,
  264. sa_salesforecastbillid:this.data.sa_salesforecastbillid,
  265. "where":{
  266. "condition":""
  267. }
  268. }
  269. })}`,
  270. });
  271. getApp().globalData.handleSelect = this.addProject.bind(this);
  272. break;
  273. case "移除项目":
  274. wx.navigateTo({
  275. url: `/packageA/select/project/select?params=${JSON.stringify({
  276. "id": "20220916115203",
  277. "version": 1,
  278. "content": {
  279. nocache: true,
  280. sa_salesforecastbillid:this.data.sa_salesforecastbillid,
  281. pageSize: 999,
  282. "where":{
  283. "condition":""
  284. }
  285. }
  286. })}&radio=true`,
  287. })
  288. getApp().globalData.handleSelect = this.deteleProject.bind(this);
  289. break;
  290. }
  291. },
  292. //更新标签
  293. getTags() {
  294. this.selectComponent("#Tags").getTags();
  295. },
  296. //局部数据更新 tabs
  297. partialRenewal(init = false) {
  298. let model = this.data.tabsList[this.data.tabsActive].model;
  299. if (model) {
  300. let Component = this.selectComponent(model),
  301. {
  302. total,
  303. pageNumber,
  304. pageTotal
  305. } = Component.data.content,
  306. id = this.data.sa_salesforecastbillid;
  307. if (total == null || init) {
  308. Component.getList(id, init);
  309. } else if (pageNumber <= pageTotal) {
  310. Component.getList(id, false);
  311. }
  312. }
  313. },
  314. onReachBottom() {
  315. this.partialRenewal();
  316. }
  317. })