detail.js 7.1 KB

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