detail.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. const _Http = getApp().globalData.http,
  2. getTime = require("../../utils/getTime")
  3. Page({
  4. data: {
  5. loading: true,
  6. sa_paybillid: null,
  7. tabsActive: 1,
  8. currentDate: new Date().getTime(),
  9. formatter(type, value) {
  10. if (type === 'year') {
  11. return value + getApp().globalData.Language.getMapText('年');
  12. }
  13. if (type === 'month') {
  14. return value + getApp().globalData.Language.getMapText('月');
  15. }
  16. return value;
  17. },
  18. show: false,
  19. tabsList: [{
  20. label: "详细信息",
  21. icon: "icon-tabchanpin"
  22. }, {
  23. label: "打款明细",
  24. icon: "icon-tabcaozuojilu1",
  25. model: "#remitVoucher"
  26. }],
  27. tabbarsList: [],
  28. sColors: getApp().globalData.sColors,
  29. },
  30. onLoad(options) {
  31. this.setData({
  32. sa_paybillid: options.id
  33. });
  34. this.getDetail(true);
  35. getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
  36. },
  37. /* 获取详情 */
  38. getDetail(init = false, show = true) {
  39. _Http.basic({
  40. "id": 20221226153404,
  41. "content": {
  42. nocache: true,
  43. "sa_paybillid": this.data.sa_paybillid
  44. }
  45. }, show).then(res => {
  46. console.log("出货详情", res)
  47. if (res.code != '1') return wx.showToast({
  48. title: res.msg,
  49. icon: "none"
  50. });
  51. let tabbarsList = []
  52. if (res.data.status == '新建') tabbarsList = [{
  53. label: "编辑",
  54. icon: "icon-dibu-bianji"
  55. }, {
  56. label: "提交",
  57. icon: "icon-tijiao",
  58. }, {
  59. label: "删除",
  60. icon: "icon-guanlian-shanchu"
  61. }]
  62. if (res.data.status == '提交') tabbarsList = [{
  63. label: "审核",
  64. icon: "icon-shenhe"
  65. }, {
  66. label: "退回",
  67. icon: "icon-a-fanshenhetuihui"
  68. }]
  69. if (res.data.status == '审核') tabbarsList = [{
  70. label: "退回",
  71. icon: "icon-a-fanshenhetuihui"
  72. }]
  73. this.setPreview(res.data);
  74. this.setData({
  75. detail: res.data,
  76. tabbarsList,
  77. loading: false
  78. });
  79. if (init) this.partialRenewal(true)
  80. })
  81. },
  82. /* 设置详情信息 */
  83. setPreview(data) {
  84. let list1 = [{
  85. label: "凭证单号",
  86. value: data.billno
  87. }, {
  88. label: "状态",
  89. value: getApp().globalData.Language.getMapText(data.status),
  90. style: `color:${this.data.sColors[data.status]}`
  91. }, {
  92. label: "经销商编号",
  93. value: data.agentnum
  94. }, {
  95. label: "经销商简称",
  96. value: data.enterprisename
  97. }, {
  98. label: "回款归属月份",
  99. value: data.period
  100. }, {
  101. label: "打款金额",
  102. value: data.amount
  103. }],
  104. list2 = [{
  105. label: "创建人",
  106. value: data.createby
  107. }, {
  108. label: "创建时间",
  109. value: data.createdate
  110. }, {
  111. label: "审核人",
  112. value: data.checkby
  113. }, {
  114. label: "审核时间",
  115. value: data.checkdate
  116. }, {
  117. label: "付款人",
  118. value: data.payer
  119. }, {
  120. label: "付款时间",
  121. value: data.paydate
  122. }];
  123. this.setData({
  124. list1,
  125. list2
  126. })
  127. },
  128. /* 审核选择弹出框关闭 */
  129. onClose() {
  130. this.setData({
  131. show: false
  132. })
  133. },
  134. /* 审核提交 */
  135. async checkSubmit({
  136. detail
  137. }) {
  138. let res = await _Http.basic({
  139. "id": "20221226153304",
  140. "content": {
  141. "sa_paybillid": this.data.sa_paybillid,
  142. "period": getTime.formatTime(new Date(detail), '-').split(' ')[0]
  143. }
  144. })
  145. if (res.code == '1') {
  146. this.setData({
  147. show: false
  148. })
  149. this.getDetail(true)
  150. }
  151. },
  152. tabbarOnClick({
  153. detail
  154. }) {
  155. switch (detail.label) {
  156. case "编辑":
  157. wx.navigateTo({
  158. url: `/packageA/remitVoucher/update?rowData=${JSON.stringify(this.data.detail)}`,
  159. })
  160. break;
  161. case "提交":
  162. wx.showModal({
  163. cancelText: getApp().globalData.Language.getMapText('取消'),
  164. confirmText: getApp().globalData.Language.getMapText('确定'),
  165. title: getApp().globalData.Language.getMapText('提示'),
  166. content: getApp().globalData.Language.getMapText('是否确认提交该打款凭证') + `?`,
  167. complete: ({
  168. confirm
  169. }) => {
  170. if (confirm) _Http.basic({
  171. "id": "20221226153204",
  172. "content": {
  173. "sa_paybillid": this.data.sa_paybillid
  174. }
  175. }).then(res => {
  176. wx.showToast({
  177. title: res.code == '1' ? getApp().globalData.Language.getMapText('已提交改打款凭证') : res.msg,
  178. icon: "none"
  179. });
  180. if (res.code == '1') {
  181. this.getDetail()
  182. let pages = getCurrentPages(),
  183. page = pages[pages.length - 2]
  184. page.getList(true)
  185. }
  186. })
  187. }
  188. })
  189. break;
  190. case "审核":
  191. getApp().globalData.Language.showToast('请选择回款日期')
  192. this.setData({
  193. show: true
  194. })
  195. break;
  196. case "退回":
  197. wx.showModal({
  198. cancelText: getApp().globalData.Language.getMapText('取消'),
  199. confirmText: getApp().globalData.Language.getMapText('确定'),
  200. title: getApp().globalData.Language.getMapText('提示'),
  201. content: getApp().globalData.Language.getMapText('是否确认退回该打款凭证') + `?`,
  202. complete: ({
  203. confirm
  204. }) => {
  205. if (confirm) _Http.basic({
  206. "id": 20221227110104,
  207. "content": {
  208. sa_paybillid: this.data.sa_paybillid
  209. }
  210. }).then(res => {
  211. wx.showToast({
  212. title: res.code == '1' ? getApp().globalData.Language.getMapText('已退回该凭证') : res.msg,
  213. icon: "none"
  214. });
  215. if (res.code == '1') {
  216. this.getDetail()
  217. }
  218. })
  219. }
  220. })
  221. break;
  222. case "删除":
  223. wx.showModal({
  224. cancelText: getApp().globalData.Language.getMapText('取消'),
  225. confirmText: getApp().globalData.Language.getMapText('确定'),
  226. title: getApp().globalData.Language.getMapText('提示'),
  227. content: getApp().globalData.Language.getMapText('是否删除该凭证') + `?`,
  228. complete: ({
  229. confirm
  230. }) => {
  231. if (confirm) _Http.basic({
  232. "id": 20221226153104,
  233. "content": {
  234. sa_paybillids: [this.data.sa_paybillid]
  235. }
  236. }).then(res => {
  237. wx.showToast({
  238. title: res.code == '1' ? getApp().globalData.Language.getMapText('删除成功') : res.msg,
  239. icon: "none"
  240. });
  241. if (res.code == '1') {
  242. setTimeout(() => {
  243. wx.navigateBack()
  244. getCurrentPages()[getCurrentPages().length - 2].getList(true)
  245. }, 300)
  246. }
  247. })
  248. }
  249. })
  250. break;
  251. }
  252. },
  253. //tabs 切换
  254. tabsChange({
  255. detail
  256. }) {
  257. this.setData({
  258. tabsActive: detail
  259. });
  260. console.log(this.data.tabsActive);
  261. this.partialRenewal();
  262. },
  263. //局部数据更新 tabs
  264. partialRenewal(init = false) {
  265. let model = this.data.tabsList[this.data.tabsActive].model;
  266. if (model) {
  267. let Component = this.selectComponent(model),
  268. {
  269. total,
  270. pageNumber,
  271. pageTotal
  272. } = Component.data.content,
  273. id = this.data.detail.sa_paybillid;
  274. if (total == null || init) {
  275. Component.getList(id, init);
  276. } else if (pageNumber <= pageTotal) {
  277. Component.getList(id, false);
  278. }
  279. }
  280. },
  281. onReachBottom() {
  282. this.partialRenewal();
  283. },
  284. onUnload() {
  285. let page = getCurrentPages().find(v => v.__route__ == 'packageA/remitVoucher/index');
  286. let content = JSON.parse(JSON.stringify(page.data.content));
  287. content.pageSize = (page.data.content.pageNumber - 1) * page.data.content.pageSize;
  288. content.pageNumber = 1;
  289. _Http.basic({
  290. "id": 20221226152904,
  291. content
  292. }).then(res => {
  293. console.log("更新订单列表", res)
  294. if (res.code == '1') page.setData({
  295. list: res.data
  296. })
  297. })
  298. },
  299. })