detail.js 6.2 KB

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