detail.js 6.0 KB

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