detail.js 5.7 KB

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