detail.js 11 KB

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