detail.js 6.2 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}年`;
  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. /* {
  61. label: "审核",
  62. icon: "icon-shenhe"
  63. }, */
  64. if (res.data.status == '提交') tabbarsList = [ {
  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: 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. console.log(res);
  144. if (res.msg == '成功') {
  145. this.setData({
  146. show: false
  147. })
  148. this.getDetail(true)
  149. }
  150. },
  151. tabbarOnClick({
  152. detail
  153. }) {
  154. switch (detail.label) {
  155. case "编辑":
  156. wx.navigateTo({
  157. url: `/packageA/remitVoucher/update?rowData=${JSON.stringify(this.data.detail)}`,
  158. })
  159. break;
  160. case "提交":
  161. wx.showModal({
  162. title: '提示',
  163. content: `是否确认提交该打款凭证?`,
  164. complete: ({
  165. confirm
  166. }) => {
  167. if (confirm) _Http.basic({
  168. "id": "20221226153204",
  169. "content": {
  170. "sa_paybillid": this.data.sa_paybillid
  171. }
  172. }).then(res => {
  173. wx.showToast({
  174. title: res.msg == '成功' ? `已提交改打款凭证` : res.msg,
  175. icon: "none"
  176. });
  177. if (res.msg == '成功') {
  178. this.getDetail()
  179. let pages = getCurrentPages(),
  180. page = pages[pages.length - 2]
  181. page.getList(true)
  182. }
  183. })
  184. }
  185. })
  186. break;
  187. case "审核":
  188. wx.showToast({
  189. title: '请选择回款日期',
  190. icon: 'none'
  191. })
  192. this.setData({
  193. show: true
  194. })
  195. break;
  196. case "撤回":
  197. wx.showModal({
  198. title: '提示',
  199. content: `是否确认撤回该打款凭证?`,
  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.msg == '成功' ? `已撤回该凭证` : res.msg,
  211. icon: "none"
  212. });
  213. if (res.msg == '成功') {
  214. this.getDetail()
  215. }
  216. })
  217. }
  218. })
  219. break;
  220. case "删除":
  221. wx.showModal({
  222. title: '提示',
  223. content: `是否删除该凭证?`,
  224. complete: ({
  225. confirm
  226. }) => {
  227. if (confirm) _Http.basic({
  228. "id": 20221226153104,
  229. "content": {
  230. sa_paybillids: [this.data.sa_paybillid]
  231. }
  232. }).then(res => {
  233. wx.showToast({
  234. title: res.msg == '成功' ? `已删除该凭证` : res.msg,
  235. icon: "none"
  236. });
  237. if (res.msg == '成功') {
  238. setTimeout(() => {
  239. wx.navigateBack()
  240. getCurrentPages()[getCurrentPages().length - 2].getList(true)
  241. }, 300)
  242. }
  243. })
  244. }
  245. })
  246. break;
  247. }
  248. },
  249. onInput(detail) {
  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.msg == '成功') page.setData({
  293. list: res.data
  294. })
  295. })
  296. },
  297. })