detail.js 11 KB

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